var that = this
if (that.data.selectNmae.title == undefined) {
wx.showToast({
title: '请选择发货地址',
icon: 'none'
})
} else {
wx.requestSubscribeMessage({
tmplIds: [
'BrDCzBIK84NA1-FTQoBrB9Tv-oten1g3C2iU'
],
success(res) {
that.createorder();
},
fail(res) {
wx.showToast({
title: res,
icon: 'none'
})
that.createorder();
},
})
}
},
createorder() {
var that = this
wx.showLoading({
title: '请稍后',
});
api.post(createOrder, {
createName: that.data.contactname
}).then(res => {
wx.hideLoading();
wx.requestPayment({
timeStamp: res.data.timeStamp,
nonceStr: res.data.nonceStr,
package: res.data.packageVal,
signType: res.data.signType,
paySign: res.data.paySign,
appId: res.data.appId,
success: function (payres) {
api.get(driverEnough).then(res =>{
if(!res.data){
wx.showModal({
title: '系统提示',
content: '请稍后',
showCancel: false,
success(res){
if(res.confirm){
wx.switchTab({
url: '../order/order',
})
}
}
})
}
}).catch(err => {
console.log(err)
})
wx.switchTab({
url: '../order/order',
})
},
fail: function (res) {
console.log(res)
wx.hideLoading();
wx.showToast({
title: '取消支付',
icon: 'none'
})
}
})
}).catch(err => {
console.log(err)
wx.hideLoading();
})
},
检查你API接口返回值。为什么要在唤起支付调用接口,而不在支付后去处理?
createName: that.data.contactname
}).then(res => {
wx.hideLoading();
这里有返回的时候就已经隐藏,不过你说的这个也是需要优化的,感谢