This commit is contained in:
zhangmanman
2021-08-09 15:57:37 +08:00
parent c661dd0e16
commit 540d76bdb8
158 changed files with 4914 additions and 788 deletions

View File

@@ -28,16 +28,15 @@ Page({
noticeShow : false, //须知显示状态
addressShow : false, //收货地址显示
payWayIndex : 0,
payWay :[
{value: 0, name: "微信支付"}
// {value: 1, name: "沃钱包支付"}
]
unicomPay : getApp().globalData.unicomPay //是否有沃支付
},
/**
* 生命周期函数--监听页面加载
*/
onLoad (options) {
console.log(getApp().globalData.unicomPay)
this.setData({
rightId : options.right_id,
welfareId: options.welfare_id
@@ -89,22 +88,7 @@ Page({
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;"')
})
}).catch(err=>{
if(!err.login){
wx.showModal({
title : '用户登录已过期',
content : '请重新登录',
showCancel : false,
success : res => {
if (res.confirm) {
wx.redirectTo({
url: '/pages/login/login'
})
}
}
})
}
})
}).catch(err=>{})
},
/**
@@ -215,85 +199,96 @@ Page({
qty = this.data.num
wx.$api.user.washcarCreate(welfare_id, right_id, qty, address_id, is_deliver).then(res=>{
let dataUrl = '', //定义接口来源名称
// payWayIndex为1的时候为沃支付-直接跳转h5
if (this.data.payWayIndex == 1) {
const newUrl = "https://card.ysd-bs.com/unicom/payment?trade_no=" + res.data.trade_no
let url= encodeURIComponent(newUrl)
wx.redirectTo({
// 跳转到webview页面
url: `/pages/webView/webView?url=${url}`
});
}
// payWayIndex为0的时候为微信支付
if(this.data.payWayIndex == 0) {
let dataUrl = '', //定义接口来源名称
Newtype = res.data.type //订单来源
// welfare为福利活动购买
if(Newtype == 'welfare') dataUrl = wx.$api.index.fridayPay(res.data.trade_no)
// welfare为福利活动购买
if(Newtype == 'welfare') dataUrl = wx.$api.index.fridayPay(res.data.trade_no)
// right为权益购买
if(Newtype == 'right') dataUrl = wx.$api.index.wechat(res.data.trade_no)
// right为权益购买
if(Newtype == 'right') dataUrl = wx.$api.index.wechat(res.data.trade_no)
// 第一步接口调取
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'
})
// 第一步接口调取
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'){
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=>{
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(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'){
setTimeout(()=>{
if(this.data.isdeliver == 1) {
wx.reLaunch({
url: '/pages/order/order?orderType=rightsCoupons'
})
} else {
wx.reLaunch({
url: '/pages/order/order?orderType=rights'
})
}
},3000)
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'
})
}
}
}
},
fail : res=>{
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'
})
}
}
}
})
})
})
})
}).catch(err => {});
}
}).catch(err => {});
}
})