init project
This commit is contained in:
63
utils/pay.js
Normal file
63
utils/pay.js
Normal file
@@ -0,0 +1,63 @@
|
||||
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)
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user