|
|
|
@ -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) {
|
|
|
|
|