2
0
mirror of https://github.com/ctrlcvs/xiaoyao-cvs-plugin.git synced 2024-12-22 19:10:53 +08:00

#商品列表改为图片显示

This commit is contained in:
Ctrlcvs 2023-03-10 22:51:45 +08:00
parent a2f76364ae
commit b6ca59d259
4 changed files with 80 additions and 13 deletions

View File

@ -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('作者还在咕咕咕~~~~')

View File

@ -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,

View File

@ -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&region=${utils.getServer(data.uid)}&order_no=${data.order_no}&uid=${data.uid}`,
types:'web'
}

58
resources/pay/goods.html Normal file
View File

@ -0,0 +1,58 @@
{{extend defaultLayout}}
{{block 'css'}}
<style>
.container {
width: 700px !important;
font-size: 1.125rem;
/* 背景色 渐变 */
background-image: linear-gradient( rgba(62, 214, 252),rgba(137, 240, 225 ),rgba(192, 240, 238));
padding: 20px 0 10px 0 !important;
}
.image {
margin-right: 20px;
margin-left: 20px;
}
.topTitle table {
margin: 0 auto;
}
.text{
line-height: 25px;
}
.bodys {
display: flex;
flex-wrap: wrap;
justify-content:left;
align-items: center;
padding: 10px;
}
.order div {
margin-top: 10px;
}
.txt {
text-align: center;
color: red;
margin-top: 10px;
padding: 0 10px;
}
</style>
{{/block}}
{{block 'main'}}
<div class="bodys">
{{each goodslist}}
<div class="image">
<img src="{{$value.goods_icon}}">
</div>
<div class="text">
商品ID{{$value.index}} <br/> {{$value.num}} <br/> 价格:{{$value.price / 100}}元
</div>
{{/each}}
</div>
<div class="txt">
bot使用指令#原神充值 0(商品Id) <br> ps来源:米游社>联系客服>米游社>原神网页充值
</div>
{{/block}}