个人信息:增加读取社交信息的接口

This commit is contained in:
YunaiV
2023-12-23 22:04:11 +08:00
parent f968397ad8
commit 4d9343d2db
6 changed files with 121 additions and 49 deletions
+14 -7
View File
@@ -1,6 +1,6 @@
import third from '@/sheep/api/third';
import $store from '@/sheep/store';
import AuthUtil from '@/sheep/api/member/auth';
import SocialApi from '@/sheep/api/member/social';
const socialType = 34; // 社交类型 - 微信小程序
@@ -83,11 +83,9 @@ const bind = () => {
};
// 微信小程序解除绑定
const unbind = async () => {
const { error } = await third.wechat.unbind({
platform: 'miniProgram',
});
return !error;
const unbind = async (openid) => {
const { code } = await SocialApi.socialUnbind(socialType, openid);
return code === 0;
};
// 小程序更新
@@ -183,13 +181,22 @@ function setOpenid(openid) {
uni.setStorageSync('openid', openid);
}
// 获得社交信息
async function getInfo() {
const { code, data } = await SocialApi.getSocialUser(socialType);
if (code !== 0) {
return undefined;
}
return data;
}
export default {
load,
login,
bind,
unbind,
checkUpdate,
bindUserPhoneNumber,
mobileLogin,
getInfo,
subscribeMessage,
};
@@ -2,6 +2,7 @@ import third from '@/sheep/api/third';
import $wxsdk from '@/sheep/libs/sdk-h5-weixin';
import { getRootUrl } from '@/sheep/helper';
import AuthUtil from '@/sheep/api/member/auth';
import SocialApi from '@/sheep/api/member/social';
const socialType = 31; // 社交类型 - 微信公众号
@@ -51,13 +52,10 @@ async function bind(code = '') {
}
// 微信公众号解除绑定
async function unbind() {
debugger
const { error } = await third.wechat.unbind({
platform: 'officialAccount',
});
return Promise.resolve(!error);
}
const unbind = async (openid) => {
const { code } = await SocialApi.socialUnbind(socialType, openid);
return code === 0;
};
// 获取公众号登陆地址
async function getLoginUrl(event = 'login') {
@@ -104,10 +102,20 @@ function setOpenid(openid) {
uni.setStorageSync('openid', openid);
}
// 获得社交信息
async function getInfo() {
const { code, data } = await SocialApi.getSocialUser(socialType);
if (code !== 0) {
return undefined;
}
return data;
}
export default {
load,
login,
bind,
unbind,
getInfo,
jssdk: $wxsdk,
};
@@ -1,7 +1,9 @@
// 登录
import third from '@/sheep/api/third';
import SocialApi from '@/sheep/api/member/social';
// TODO 芋艿:等后面搞 App 再弄
const socialType = 32; // 社交类型 - 微信开放平台
const load = async () => {};
@@ -37,7 +39,23 @@ const login = () => {
});
};
// 微信 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
};