This commit is contained in:
zhangmanman
2021-06-30 09:52:55 +08:00
parent 34590d9f72
commit 7cb9e1e92e
6 changed files with 104 additions and 85 deletions

View File

@@ -24,6 +24,7 @@ Page({
remark : '', //使用须知
score : '', //应付总积分
freight : '', //运费
welfareType : '', //权益类型
noticeShow : false, //须知显示状态
addressShow : false, //收货地址显示
payWayIndex : 0,
@@ -84,6 +85,7 @@ Page({
amount : res.data.total,
moreAmount : res.data.amount,
score : res.data.score,
welfareType : res.data.type,
remark : res.data.detail.remark.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"'),
content : res.data.detail.content.replace(/\<img/gi, '<img style="max-width:100%;height:auto;display:block;"')
})
@@ -157,6 +159,13 @@ Page({
* 商品数量加减
*/
goodsNumber(e){
if(this.data.welfareType == 'welfare') {
wx.showToast({
title : '抱歉,只能购买一张',
icon : 'none'
})
return
}
let num = this.data.num
if (e.currentTarget.dataset.type == 'plus'){
num ++;
@@ -207,93 +216,86 @@ Page({
wx.$api.user.washcarCreate(welfare_id, right_id, qty, address_id, is_deliver).then(res=>{
let dataUrl = '', //定义接口来源名称
type = res.data.type //订单来源
Newtype = res.data.type //订单来源
// welfare为福利活动购买
if(type == 'welfare') dataUrl = wx.$api.index.fridayInfo(welfare_id, address_id, is_deliver)
if(Newtype == 'welfare') dataUrl = wx.$api.index.fridayPay(res.data.trade_no)
// right为权益购买
if(type == 'right') dataUrl = wx.$api.index.rightStore(right_id, address_id, is_deliver, qty)
if(Newtype == 'right') dataUrl = wx.$api.index.wechat(res.data.trade_no)
// 第一步接口调取
dataUrl.then(dataRes=>{
let payUrl = '', //定义接口来源名称
Newtype = dataRes.data.type //订单来源
// welfare为福利活动购买
if(Newtype == 'welfare') payUrl = wx.$api.index.fridayPay(dataRes.data.trade_no)
// right为权益购买
if(Newtype == 'right') payUrl = wx.$api.index.wechat(dataRes.data.trade_no)
// 第一步接口调取
payUrl.then(payEes=>{
let payInfo = JSON.parse(payEes.data)
wx.requestPayment({
timeStamp: payInfo.timeStamp,
nonceStr : payInfo.nonceStr,
package : payInfo.package,
paySign : payInfo.paySign,
signType : payInfo.signType,
success : res=>{
if(res.errMsg == "requestPayment:ok"){
wx.showToast({
title: '支付成功',
icon : 'success'
})
if(Newtype == 'welfare'){
setTimeout(()=>{
if(this.data.isdeliver == 1) {
wx.reLaunch({
url: '/pages/order/order?orderType=welfareGoods'
})
} else {
wx.reLaunch({
url: '/pages/order/order?orderType=welfare'
})
}
},3000)
}
if(Newtype == 'right'){
setTimeout(()=>{
if(this.data.isdeliver == 1) {
wx.reLaunch({
url: '/pages/order/order?orderType=rightsCoupons'
})
} else {
wx.reLaunch({
url: '/pages/order/order?orderType=rights'
})
}
},3000)
}
}
},
fail : res=>{
dataUrl.then(payEes=>{
let payInfo = JSON.parse(payEes.data)
wx.requestPayment({
timeStamp: payInfo.timeStamp,
nonceStr : payInfo.nonceStr,
package : payInfo.package,
paySign : payInfo.paySign,
signType : payInfo.signType,
success : res=>{
if(res.errMsg == "requestPayment:ok"){
wx.showToast({
title: '支付成功',
icon : 'success'
})
if(Newtype == 'welfare'){
if(this.data.isdeliver == 1) {
wx.reLaunch({
url: '/pages/order/order?orderType=welfareGoods&stateType=unpay'
})
} else {
wx.reLaunch({
url: '/pages/order/order?orderType=welfare&stateType=unpay'
})
}
setTimeout(()=>{
if(this.data.isdeliver == 1) {
wx.reLaunch({
url: '/pages/order/order?orderType=welfareGoods'
})
} else {
wx.reLaunch({
url: '/pages/order/order?orderType=welfare'
})
}
},3000)
}
if(Newtype == 'right'){
if(this.data.isdeliver == 1) {
wx.reLaunch({
url: '/pages/order/order?orderType=rightsCoupons&stateType=unpay'
})
} else {
wx.reLaunch({
url: '/pages/order/order?orderType=rights&stateType=unpay'
})
}
setTimeout(()=>{
if(this.data.isdeliver == 1) {
wx.reLaunch({
url: '/pages/order/order?orderType=rightsCoupons'
})
} else {
wx.reLaunch({
url: '/pages/order/order?orderType=rights'
})
}
},3000)
}
}
})
},
fail : res=>{
console.log(this.data.isdeliver)
console.log(Newtype)
if(Newtype == 'welfare'){
if(this.data.isdeliver == 1) {
wx.reLaunch({
url: '/pages/order/order?orderType=welfareGoods&stateType=unpay'
})
} else {
wx.reLaunch({
url: '/pages/order/order?orderType=welfare&stateType=unpay'
})
}
}
if(Newtype == 'right'){
if(this.data.isdeliver == 1) {
wx.reLaunch({
url: '/pages/order/order?orderType=rightsCoupons&stateType=unpay'
})
} else {
wx.reLaunch({
url: '/pages/order/order?orderType=rights&stateType=unpay'
})
}
}
}
})
})
})
}
})