初始化移动端提交
This commit is contained in:
36
sheep/platform/provider/apple/app.js
Normal file
36
sheep/platform/provider/apple/app.js
Normal file
@@ -0,0 +1,36 @@
|
||||
// import third from '@/sheep/api/third';
|
||||
// TODO 芋艿:等后面搞 App 再弄
|
||||
|
||||
const login = () => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const loginRes = await uni.login({
|
||||
provider: 'apple',
|
||||
success: () => {
|
||||
uni.getUserInfo({
|
||||
provider: 'apple',
|
||||
success: async (res) => {
|
||||
if (res.errMsg === 'getUserInfo:ok') {
|
||||
const payload = res.userInfo;
|
||||
const { error } = await third.apple.login({
|
||||
payload,
|
||||
shareInfo: uni.getStorageSync('shareLog') || {},
|
||||
});
|
||||
if (error === 0) {
|
||||
resolve(true);
|
||||
} else {
|
||||
resolve(false);
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
},
|
||||
fail: (err) => {
|
||||
resolve(false);
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export default {
|
||||
login,
|
||||
};
|
||||
9
sheep/platform/provider/apple/index.js
Normal file
9
sheep/platform/provider/apple/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
// #ifdef APP-PLUS
|
||||
import service from './app';
|
||||
// #endif
|
||||
|
||||
let apple = {};
|
||||
if (typeof service !== 'undefined') {
|
||||
apple = service;
|
||||
}
|
||||
export default apple;
|
||||
15
sheep/platform/provider/wechat/index.js
Normal file
15
sheep/platform/provider/wechat/index.js
Normal file
@@ -0,0 +1,15 @@
|
||||
// #ifdef H5
|
||||
import service from './officialAccount';
|
||||
// #endif
|
||||
|
||||
// #ifdef MP-WEIXIN
|
||||
import service from './miniProgram';
|
||||
// #endif
|
||||
|
||||
// #ifdef APP-PLUS
|
||||
import service from './openPlatform';
|
||||
// #endif
|
||||
|
||||
const wechat = service;
|
||||
|
||||
export default wechat;
|
||||
241
sheep/platform/provider/wechat/miniProgram.js
Normal file
241
sheep/platform/provider/wechat/miniProgram.js
Normal file
File diff suppressed because it is too large
Load Diff
105
sheep/platform/provider/wechat/officialAccount.js
Normal file
105
sheep/platform/provider/wechat/officialAccount.js
Normal file
File diff suppressed because it is too large
Load Diff
64
sheep/platform/provider/wechat/openPlatform.js
Normal file
64
sheep/platform/provider/wechat/openPlatform.js
Normal file
@@ -0,0 +1,64 @@
|
||||
// 登录
|
||||
import third from '@/sheep/api/migration/third';
|
||||
import SocialApi from '@/sheep/api/system/social';
|
||||
import $share from '@/sheep/platform/share';
|
||||
|
||||
// TODO 芋艿:等后面搞 App 再弄
|
||||
const socialType = 32; // 社交类型 - 微信开放平台
|
||||
|
||||
const load = async () => {};
|
||||
|
||||
// 微信开放平台移动应用授权登陆
|
||||
const login = () => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
const loginRes = await uni.login({
|
||||
provider: 'weixin',
|
||||
onlyAuthorize: true,
|
||||
});
|
||||
debugger
|
||||
if (loginRes.errMsg == 'login:ok') {
|
||||
// TODO third.wechat.login 函数未实现
|
||||
const res = await third.wechat.login({
|
||||
platform: 'openPlatform',
|
||||
shareInfo: uni.getStorageSync('shareLog') || {},
|
||||
payload: encodeURIComponent(
|
||||
JSON.stringify({
|
||||
code: loginRes.code,
|
||||
}),
|
||||
),
|
||||
});
|
||||
|
||||
if (res.error === 0) {
|
||||
$share.bindBrokerageUser()
|
||||
resolve(true);
|
||||
}
|
||||
} else {
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: loginRes.errMsg,
|
||||
});
|
||||
}
|
||||
resolve(false);
|
||||
});
|
||||
};
|
||||
|
||||
// 微信 App 解除绑定
|
||||
const unbind = async (openid) => {
|
||||
const { code } = await SocialApi.socialUnbind(socialType, openid);
|
||||
return code === 0;
|
||||
};
|
||||
|
||||
// 获得社交信息
|
||||
async function getInfo() {
|
||||
const { code, data } = await SocialApi.getSocialUser(socialType);
|
||||
if (code !== 0) {
|
||||
return undefined;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
export default {
|
||||
load,
|
||||
login,
|
||||
getInfo
|
||||
};
|
||||
Reference in New Issue
Block a user