|
|
const BASE_URL = 'http://xide.shs.broing.cn';
|
|
|
// const BASE_URL = 'http://www.xide.com';
|
|
|
// 调用接口封装
|
|
|
const BASE_URL = 'http://www.xide.com';
|
|
|
export const rqs = (url, data, method) => {
|
|
|
return new Promise((resolve, reject) => {
|
|
|
uni.request({
|
...
|
...
|
@@ -8,8 +6,8 @@ export const rqs = (url, data, method) => { |
|
|
data: data || {},
|
|
|
method: method || 'POST',
|
|
|
header: {
|
|
|
token: uni.getStorageSync('token')
|
|
|
},
|
|
|
token: uni.getStorageSync('token'),
|
|
|
// token: '2a6395f8-390e-4893-b4af-a5f63e75bdd8',
|
|
|
success: (res) => {
|
|
|
console.log('调用成功');
|
|
|
resolve(res)
|
...
|
...
|
@@ -18,34 +16,9 @@ export const rqs = (url, data, method) => { |
|
|
console.log('调用失败');
|
|
|
reject(err)
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
import Login from '../login.js'
|
|
|
// 登录封装
|
|
|
export const loginCustom = (e) => {
|
|
|
let point = e || 0;//声明变量获取是否点击 e=1=>点击
|
|
|
let code = Login.getUrlCode('code'); // 截取code
|
|
|
if (code && !uni.getStorageSync('token')) {
|
|
|
let data = {
|
|
|
code,
|
|
|
platform: 'wechat'
|
|
|
}
|
|
|
// 调用登录接口获取用户信息
|
|
|
rqs('/api/common/third', data, "GET").then(res => {
|
|
|
if (res.data.code == 1) {
|
|
|
// 缓存个人信息
|
|
|
uni.setStorageSync("token", res.data.data.userinfo.token); // token
|
|
|
uni.setStorageSync("nickName", res.data.data.userinfo.nickname); // 昵称
|
|
|
uni.setStorageSync("avatar", res.data.data.userinfo.avatar); // 头像
|
|
|
uni.setStorageSync("is_focus", res.data.data.userinfo.is_focus); // 是否关注
|
|
|
uni.setStorageSync("is_members", res.data.data.userinfo.is_members); //是否入会
|
|
|
// 缓存支付
|
|
|
uni.setStorageSync("openid", res.data.data.thirdinfo.openid); //openid
|
|
|
uni.setStorageSync("access_token", res.data.data.thirdinfo.access_token); //access_token
|
|
|
}
|
|
|
})
|
|
|
} else if (!uni.getStorageSync('token') && point) {
|
|
|
Login.GetLoginCode(); // 调起登录中间页
|
|
|
}
|
|
|
})
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|