From b6ca59d259447d41b9ed8cef9636e4a4eb5eca63 Mon Sep 17 00:00:00 2001 From: Ctrlcvs <1509167646@qq.com> Date: Fri, 10 Mar 2023 22:51:45 +0800 Subject: [PATCH] =?UTF-8?q?`#=E5=95=86=E5=93=81=E5=88=97=E8=A1=A8`?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=9B=BE=E7=89=87=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/mhyTopUpLogin.js | 2 +- model/mhyTopUpLogin.js | 27 ++++++++++++------- model/mys/mihoyoApi.js | 6 ++--- resources/pay/goods.html | 58 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+), 13 deletions(-) create mode 100644 resources/pay/goods.html diff --git a/apps/mhyTopUpLogin.js b/apps/mhyTopUpLogin.js index cf81f02..30798a7 100644 --- a/apps/mhyTopUpLogin.js +++ b/apps/mhyTopUpLogin.js @@ -32,7 +32,7 @@ export const rule = { export async function payOrder(e, { render }) { let Mys = new mys(e) if (/商品列表/.test(e.msg)) { - return await Mys.showgoods() + return await Mys.showgoods( { render }) } else if (/订单查询/.test(e.msg)) { //容我摆烂会 e.reply('作者还在咕咕咕~~~~') diff --git a/model/mhyTopUpLogin.js b/model/mhyTopUpLogin.js index 0ea75d6..9070fb6 100644 --- a/model/mhyTopUpLogin.js +++ b/model/mhyTopUpLogin.js @@ -9,6 +9,7 @@ export default class mysTopLogin { //消息提示以及风险警告 this.sendMsgUser = `免责声明:您将通过扫码完成获取米游社sk以及ck。\n本Bot将不会保存您的登录状态。\n我方仅提供米游社查询及相关游戏内容服务,若您的账号封禁、被盗等处罚与我方无关。\n害怕风险请勿扫码~` this.sendMsgUserPassLogin = `免责声明:您将通过密码完成获取米游社sk以及ck。\n本Bot将不会保存您的账号和密码。\n我方仅提供米游社查询及相关游戏内容服务,若您的账号封禁、被盗等处罚与我方无关。\n害怕风险请勿发送账号密码~` + this.sendMagPay = `格式参考:#原神充值 6(商品ID)\n可通过【#商品列表】获取可操作商品` } async init() { this.user = new User(this.e) @@ -135,17 +136,24 @@ export default class mysTopLogin { return false; } - async showgoods() { + async showgoods({ render }) { let goodslist = await this.goodsList() if (!goodslist) return false; - let msg = ['当前支持的商品有:\n'] + // let msg = ['当前支持的商品有:\n'] for (const [i, goods] of Object.entries(goodslist)) { if (i == 'api') continue; - let num = `${goods['goods_name']}×${(goods['goods_unit'])}` + ((goods['goods_unit']) > 0 ? goods["goods_name"] : '') + goods.num = `${goods['goods_name']}×${(goods['goods_unit'])}` + ((goods['goods_unit']) < 0 ? goods["goods_name"] : '') // console.log(`ID:${i} ${num} 价格:${parseInt(goods['price']) / 100}元`) - msg.push(`ID:${i} ${num} 价格:${parseInt(goods['price']) / 100}元\n`) + goods.index = i + // goods.msg =`ID:${i} ${num} 价格:${parseInt(goods['price']) / 100}元\n` } - this.e.reply(msg) + let r = await Common.render(`pay/goods`, { + goodslist + }, { + e: this.e, + render, + scale: 1.2, retMsgId: true + }) return true; } @@ -153,12 +161,12 @@ export default class mysTopLogin { try { let msg = this.e.msg.replace(/,|,|\|/g, ' ').split(' ') if (msg.length != 2) { - this.e.reply(`格式参考:#原神充值 6(商品ID)\n 可通过【#商品列表】获取可操作商品`) + this.e.reply(this.sendMagPay) return true; } let iswx = msg[0].includes('微信') ? 'weixin' : 'alipay' if (msg[1].length != 1) { - his.e.reply(`格式参考:#原神充值 6(商品ID)\n 可通过【#商品列表】获取可操作商品`) + this.e.reply(this.sendMagPay) return true; } let goods = (await this.goodsList())[msg[1]] @@ -166,10 +174,10 @@ export default class mysTopLogin { this.e.reply('请先 #绑定cookie') return true; } - let ckData =await utils.getCookieMap(this.e.cookie) + let ckData = await utils.getCookieMap(this.e.cookie) let device_id = utils.randomString(4) let order = { - "account":ckData?.get('ltuid')||ckData.get('account_id'), + "account": ckData?.get('ltuid') || ckData.get('account_id'), "region": utils.getServer(this.e.uid), "uid": this.e.uid, "delivery_url": "", @@ -199,6 +207,7 @@ export default class mysTopLogin { //记录操作日志 logger.mark(`当前操作用户:${this.e.user_id},操作uid:${this.e.uid},操作商品id:${goods?.goods_id},操作商品:${goods?.goods_name + (Number(goods.goods_unit) > 0 ? "×" + goods.goods_unit : "")}`) logger.mark(`支付链接:${res['data']['encode_order']}\n订单号:${res['data']['order_no']}\n 价格:${(res['data']['amount']) / 100}元`) + //待定,等周末再咕 let r = await Common.render(`pay/index`, { url: res.data.encode_order, data: res.data, uid: this.e.uid, diff --git a/model/mys/mihoyoApi.js b/model/mys/mihoyoApi.js index 0e579e9..5814be0 100644 --- a/model/mys/mihoyoApi.js +++ b/model/mys/mihoyoApi.js @@ -299,7 +299,7 @@ export default class miHoYoApi { query: `account_id=${data.uid}&game_token=${data.token}` }, createOrder:{ - url:`https://hk4e-sdk.mihoyo.com/hk4e_cn/mdk/atropos/api/createOrder`, + url:`${mys.hk4_sdk}/hk4e_cn/mdk/atropos/api/createOrder`, body: { // "special_info": "topup_center", "order": data.order, @@ -308,7 +308,7 @@ export default class miHoYoApi { types:'web' }, goodsList:{ - url:`https://hk4e-sdk.mihoyo.com/hk4e_cn/mdk/shopwindow/shopwindow/fetchGoods`, + url:`${mys.hk4_sdk}/hk4e_cn/mdk/shopwindow/shopwindow/fetchGoods`, body:{ "released_flag": true, "game": "hk4e_cn", @@ -319,7 +319,7 @@ export default class miHoYoApi { types:'web' }, checkOrder:{ - url:`https://hk4e-sdk.mihoyo.com/hk4e_cn/mdk/atropos/api/checkOrder`, + url:`${mys.hk4_sdk}/hk4e_cn/mdk/atropos/api/checkOrder`, query:`game=hk4e_cn®ion=${utils.getServer(data.uid)}&order_no=${data.order_no}&uid=${data.uid}`, types:'web' } diff --git a/resources/pay/goods.html b/resources/pay/goods.html new file mode 100644 index 0000000..e042e4f --- /dev/null +++ b/resources/pay/goods.html @@ -0,0 +1,58 @@ +{{extend defaultLayout}} +{{block 'css'}} + +{{/block}} +{{block 'main'}} +
+ {{each goodslist}} +
+ + +
+
+ 商品ID:{{$value.index}}
{{$value.num}}
价格:{{$value.price / 100}}元 +
+ {{/each}} +
+ +
+ bot使用指令:#原神充值 0(商品Id)
ps来源:米游社>联系客服>米游社>原神网页充值 +
+{{/block}} \ No newline at end of file