11.10 绑定微信提交

formal_basic
hejiangbo 2 weeks ago
parent 7513793b1d
commit 84465273f8

@ -3,7 +3,7 @@ const request = (options) => {
// 例如:
return new Promise((resolve, reject) => {
let token = uni.getStorageSync('token')
uni.request({
wx.request({
url: options.url || '',
method: options.method || 'GET',
data: options.data || {},

@ -7,6 +7,7 @@ import {
} from '@/sheep/helper';
import PayOrderApi from '@/sheep/api/pay/order';
import wechat from '@/sheep/platform/provider/wechat/index.js';
import SocialApi from '@/sheep/api/member/social';
/**
* 支付
*
@ -331,14 +332,58 @@ export default class SheepPay {
uni.showModal({
title: '微信支付',
content: '请先绑定微信再使用微信支付',
success: function(res) {
success: function (res) {
if (res.confirm) {
sheep.$platform.useProvider('wechat').bind();
// sheep.$platform.useProvider('wechat').bind();
return new Promise(async (resolve, reject) => {
// 1. 获得微信 code
const codeResult = await uni.login();
console.log(codeResult, 'codeResult')
if (codeResult.errMsg !== 'login:ok') {
return resolve(false);
} else {
// 2. 绑定账号
const bindResult = await SocialApi.socialBind(34,
codeResult.code, 'default');
console.log(bindResult, 'bindResult')
if (bindResult.code === 0) {
// setOpenid(bindResult.data);
uni.setStorageSync('openid', bindResult.data);
return resolve(true);
} else {
return resolve(false);
}
}
});
}
},
});
}
async bind() {
return new Promise(async (resolve, reject) => {
// 1. 获得微信 code
const codeResult = await uni.login();
console.log(codeResult, 'codeResult')
if (codeResult.errMsg !== 'login:ok') {
return resolve(false);
} else {
// 2. 绑定账号
const bindResult = await SocialApi.socialBind(socialType, codeResult.code, 'default');
console.log(bindResult, 'bindResult')
if (bindResult.code === 0) {
// setOpenid(bindResult.data);
uni.setStorageSync('openid', bindResult.data);
return resolve(true);
} else {
return resolve(false);
}
}
});
};
}
export function getPayMethods(channels) {

Loading…
Cancel
Save