Files
venue_wx/utils/pay.js
2021-05-27 22:43:12 +08:00

63 lines
1.3 KiB
JavaScript

export function pay(body) {
return new Promise((resolve, reject) => {
console.log(body)
wx.requestPayment({
timeStamp: body.time_stamp,
nonceStr: body.nonce_str,
package: 'prepay_id=' + body.prepay_id,
signType: body.sign_type,
paySign: body.pay_sign,
success: function(res) {
wx.showToast({
title: '支付成功',
icon: 'success',
})
resolve(res);
},
fail: function(res) {
console.log(res);
reject(res);
},
})
})
}
export function payWxLoing(body) {
console.log(body.userInfo)
const app = getApp();
return new Promise((resolve, reject) => {
if (!body.userInfo) {
reject(body);
return;
}
wx.login({
success: function(res) {
wx.showLoading({
title: '加载中...',
mask: true,
})
app.$api.memberLoginCheckWx({
avatar: body.userInfo.avatarUrl,
code: res.code,
nickname: body.userInfo.nickName
}).then(obj => {
wx.setStorageSync('accessToken', obj.authorization.accessToken);
resolve(res);
})
},
fail: function(res) {
reject(res);
},
})
})
}
export default {
wxPay(body) {
return pay(body);
},
payWxLoing(body) {
return payWxLoing(body);
}
}