1
|
-const BASE_URL = 'http://xide.shs.broing.cn';
|
|
|
2
|
-// const BASE_URL = 'http://www.xide.com';
|
|
|
3
|
-// 调用接口封装
|
1
|
+const BASE_URL = 'http://www.xide.com';
|
4
|
export const rqs = (url, data, method) => {
|
2
|
export const rqs = (url, data, method) => {
|
5
|
return new Promise((resolve, reject) => {
|
3
|
return new Promise((resolve, reject) => {
|
6
|
uni.request({
|
4
|
uni.request({
|
|
@@ -8,8 +6,8 @@ export const rqs = (url, data, method) => { |
|
@@ -8,8 +6,8 @@ export const rqs = (url, data, method) => { |
8
|
data: data || {},
|
6
|
data: data || {},
|
9
|
method: method || 'POST',
|
7
|
method: method || 'POST',
|
10
|
header: {
|
8
|
header: {
|
11
|
- token: uni.getStorageSync('token')
|
|
|
12
|
- },
|
9
|
+ token: uni.getStorageSync('token'),
|
|
|
10
|
+ // token: '2a6395f8-390e-4893-b4af-a5f63e75bdd8',
|
13
|
success: (res) => {
|
11
|
success: (res) => {
|
14
|
console.log('调用成功');
|
12
|
console.log('调用成功');
|
15
|
resolve(res)
|
13
|
resolve(res)
|
|
@@ -18,34 +16,9 @@ export const rqs = (url, data, method) => { |
|
@@ -18,34 +16,9 @@ export const rqs = (url, data, method) => { |
18
|
console.log('调用失败');
|
16
|
console.log('调用失败');
|
19
|
reject(err)
|
17
|
reject(err)
|
20
|
}
|
18
|
}
|
21
|
- })
|
|
|
22
|
- })
|
|
|
23
|
-}
|
|
|
24
|
-import Login from '../login.js'
|
|
|
25
|
-// 登录封装
|
|
|
26
|
-export const loginCustom = (e) => {
|
|
|
27
|
- let point = e || 0;//声明变量获取是否点击 e=1=>点击
|
|
|
28
|
- let code = Login.getUrlCode('code'); // 截取code
|
|
|
29
|
- if (code && !uni.getStorageSync('token')) {
|
|
|
30
|
- let data = {
|
|
|
31
|
- code,
|
|
|
32
|
- platform: 'wechat'
|
|
|
33
|
- }
|
|
|
34
|
- // 调用登录接口获取用户信息
|
|
|
35
|
- rqs('/api/common/third', data, "GET").then(res => {
|
|
|
36
|
- if (res.data.code == 1) {
|
|
|
37
|
- // 缓存个人信息
|
|
|
38
|
- uni.setStorageSync("token", res.data.data.userinfo.token); // token
|
|
|
39
|
- uni.setStorageSync("nickName", res.data.data.userinfo.nickname); // 昵称
|
|
|
40
|
- uni.setStorageSync("avatar", res.data.data.userinfo.avatar); // 头像
|
|
|
41
|
- uni.setStorageSync("is_focus", res.data.data.userinfo.is_focus); // 是否关注
|
|
|
42
|
- uni.setStorageSync("is_members", res.data.data.userinfo.is_members); //是否入会
|
|
|
43
|
- // 缓存支付
|
|
|
44
|
- uni.setStorageSync("openid", res.data.data.thirdinfo.openid); //openid
|
|
|
45
|
- uni.setStorageSync("access_token", res.data.data.thirdinfo.access_token); //access_token
|
|
|
46
|
}
|
19
|
}
|
47
|
})
|
20
|
})
|
48
|
- } else if (!uni.getStorageSync('token') && point) {
|
|
|
49
|
- Login.GetLoginCode(); // 调起登录中间页
|
|
|
50
|
- }
|
21
|
+ })
|
|
|
22
|
+
|
|
|
23
|
+
|
51
|
} |
24
|
} |