调整全局支付收银class

This commit is contained in:
唐明明
2021-11-04 11:30:15 +08:00
parent cbe6cc912b
commit d9b4d459ae
13 changed files with 1841 additions and 1865 deletions

View File

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