Files
BlockChainH5/public/cashierPay.js
2021-11-04 11:30:15 +08:00

82 lines
1.5 KiB
JavaScript

/**
* Web唐明明
* 匆匆数载恍如梦,岁月迢迢华发增。
* 碌碌无为枉半生,一朝惊醒万事空。
* moduleName: 收银
*/
class cashierPay {
constructor() {
}
// 收银台
pay(platform, orderInfo, buyType) {
if (!platform) {
uni.showToast({
title: '缺少必要参数:支付平台类型',
icon: 'none'
})
return
}
if (!orderInfo) {
uni.showToast({
title: '缺少必要参数:支付参数不能为空',
icon: 'none'
})
return
}
if (!buyType) {
uni.showToast({
title: '缺少必要参数:缺少支付类型',
icon: 'none'
})
return
}
return new Promise((resolve, reject) => {
uni.requestPayment({
provider: platform,
orderInfo: orderInfo,
success: payRes => {
resolve(payRes)
this.showToast(buyType)
},
fail: payErr => {
reject(payErr)
uni.showToast({
title: '支付被取消',
icon: 'none'
})
}
})
})
}
// 成功提示信息
showToast(buyType){
switch(buyType){
case 'vip':
uni.showModal({
title: "开通提示",
content: "支付成功,已成功开通/升级节点身份",
showCancel: false,
})
break;
case 'goods':
uni.showToast({
title: '支付成功',
mask: true,
icon: 'none'
})
break;
case 'market':
uni.showToast({
title: '支付成功',
mask: true,
icon: 'none'
})
break;
}
}
}
export default new cashierPay();