65316219 by 杨炀

Merge commit '6f413499'

2 parents 27be1048 6f413499
...@@ -2,129 +2,136 @@ import request from './request' ...@@ -2,129 +2,136 @@ import request from './request'
2 import * as api from '@/common/api.js' 2 import * as api from '@/common/api.js'
3 3
4 function pcLogin(data) { 4 function pcLogin(data) {
5 return request({ 5 return request({
6 url: '/login', 6 url: '/login',
7 method: 'post', 7 method: 'post',
8 params: data 8 params: data
9 }).then((res) => { 9 }).then((res) => {
10 uni.setStorageSync('token', 'Bearer ' + res.data.token) 10 uni.setStorageSync('token', 'Bearer ' + res.data.token)
11 }).then(getInfo) 11 }).then(getInfo)
12 } 12 }
13 13
14 function h5Login(userName) { 14 function h5Login(userName) {
15 return request({ 15 return request({
16 url: `/h5Login`, 16 url: `/h5Login`,
17 method: 'post', 17 method: 'post',
18 params: { 18 params: {
19 username: userName 19 username: userName
20 } 20 }
21 }).then((res) => { 21 }).then((res) => {
22 uni.setStorageSync('token', 'Bearer ' + res.data.token) 22 uni.setStorageSync('token', 'Bearer ' + res.data.token)
23 }).then(getInfo) 23 }).then(getInfo)
24 } 24 }
25 25
26 function h5LoginAuto() { 26 function h5LoginAuto() {
27 const userName = uni.getStorageSync('userName') 27 const userName = uni.getStorageSync('userName')
28 if (userName) { 28 if (userName) {
29 return h5Login(userName) 29 return h5Login(userName)
30 } else { 30 } else {
31 uni.redirectTo({ 31 uni.redirectTo({
32 url: '/pages/index/login' 32 url: '/pages/index/login'
33 }) 33 })
34 } 34 }
35 } 35 }
36 36
37 37 function logout() {
38 38 return request({
39 39 url: '/logout',
40 method: 'post'
41 }).then(() => {
42 uni.removeStorageSync('token')
43 uni.removeStorageSync('userName')
44 })
45 }
40 46
41 function getCodeImg() { 47 function getCodeImg() {
42 return request({ 48 return request({
43 url: '/captchaImage', 49 url: '/captchaImage',
44 method: 'get' 50 method: 'get'
45 }) 51 })
46 } 52 }
47 53
48 // 代退图形认证的获取手机验证码 54 // 代退图形认证的获取手机验证码
49 function getSmsCode(data) { 55 function getSmsCode(data) {
50 return request({ 56 return request({
51 url: '/captchaSmsWithCaptchaImage', 57 url: '/captchaSmsWithCaptchaImage',
52 method: 'post', 58 method: 'post',
53 params: data 59 params: data
54 }) 60 })
55 } 61 }
56 62
57 function loginByPhone(phonenumber, code) { 63 function loginByPhone(phonenumber, code) {
58 const data = { 64 const data = {
59 phonenumber, 65 phonenumber,
60 code 66 code
61 } 67 }
62 return request({ 68 return request({
63 url: '/userLoginByPhone', 69 url: '/userLoginByPhone',
64 method: 'post', 70 method: 'post',
65 params: data 71 params: data
66 }).then((res) => { 72 }).then((res) => {
67 uni.setStorageSync('token', 'Bearer ' + res.data.token) 73 uni.setStorageSync('token', 'Bearer ' + res.data.token)
68 }).then(getInfo) 74 }).then(getInfo)
69 } 75 }
70 76
71 // 获取用户详细信息 77 // 获取用户详细信息
72 function getInfo() { 78 function getInfo() {
73 return request({ 79 return request({
74 url: '/getInfo', 80 url: '/getInfo',
75 method: 'get' 81 method: 'get'
76 }).then(res => { 82 }).then(res => {
77 const app = getApp() 83 const app = getApp()
78 const user = res.data.user 84 const user = res.data.user
79 uni.setStorageSync('userName', user.userName) 85 uni.setStorageSync('userName', user.userName)
80 app.globalData.deptType = user.dept.deptType 86 app.globalData.deptType = user.dept.deptType
81 switch (user.dept.deptType) { 87 switch (user.dept.deptType) {
82 case '1': // 中跆协 88 case '1': // 中跆协
83 app.globalData.userType = '1' 89 app.globalData.userType = '1'
84 break 90 break
85 case '2': // 省 91 case '2': // 省
86 case '3': 92 case '3':
87 app.globalData.userType = '2' 93 app.globalData.userType = '2'
88 break 94 break
89 case '6': // 道馆 95 case '6': // 道馆
90 app.globalData.userType = '4' 96 app.globalData.userType = '4'
91 break 97 break
92 default: // 市、区 98 default: // 市、区
93 app.globalData.userType = '3' 99 app.globalData.userType = '3'
94 break 100 break
95 } 101 }
96 102
97 app.globalData.userInfo = user 103 app.globalData.userInfo = user
98 }) 104 })
99 } 105 }
100 106
101 // 团队会员用户注册接口 107 // 团队会员用户注册接口
102 function groupMemberRegister(data) { 108 function groupMemberRegister(data) {
103 return request({ 109 return request({
104 url: '/groupMemberRegister', 110 url: '/groupMemberRegister',
105 method: 'post', 111 method: 'post',
106 params: data 112 params: data
107 }) 113 })
108 } 114 }
109 // 获取道馆信息 115 // 获取道馆信息
110 function getMyOwnMemberInfo() { 116 function getMyOwnMemberInfo() {
111 return request({ 117 return request({
112 url: '/member/info/getMyOwnMemberInfo', 118 url: '/member/info/getMyOwnMemberInfo',
113 method: 'get' 119 method: 'get'
114 }).then(res => { 120 }).then(res => {
115 const app = getApp() 121 const app = getApp()
116 app.globalData.authenticationStatus = res.data.authenticationStatus 122 app.globalData.authenticationStatus = res.data.authenticationStatus
117 app.globalData.memberInfo = res.data.memberInfo 123 app.globalData.memberInfo = res.data.memberInfo
118 app.globalData.isExam = res.data?.dept?.isExam 124 app.globalData.isExam = res.data?.dept?.isExam
119 }) 125 })
120 } 126 }
121 export { 127 export {
122 pcLogin,
123 getCodeImg,
124 getSmsCode,
125 h5Login,
126 h5LoginAuto,
127 loginByPhone,
128 groupMemberRegister,
129 getMyOwnMemberInfo
130 }
...\ No newline at end of file ...\ No newline at end of file
128 pcLogin,
129 getCodeImg,
130 getSmsCode,
131 h5Login,
132 h5LoginAuto,
133 loginByPhone,
134 groupMemberRegister,
135 getMyOwnMemberInfo,
136 logout
137 }
......
...@@ -5,7 +5,8 @@ ...@@ -5,7 +5,8 @@
5 // staging 5 // staging
6 // const baseUrl_api = "http://22yidpjzjifv.ngrok.xiaomiqiu123.top/stage-api/"; 6 // const baseUrl_api = "http://22yidpjzjifv.ngrok.xiaomiqiu123.top/stage-api/";
7 const baseUrl_api = "http://182.92.233.247/stage-api/"; 7 const baseUrl_api = "http://182.92.233.247/stage-api/";
8 // const baseUrl_api = 'http://192.168.1.97:8787'
8 9
9 export default { 10 export default {
10 baseUrl_api
11 }
...\ No newline at end of file ...\ No newline at end of file
11 baseUrl_api
12 }
......
...@@ -176,16 +176,16 @@ ...@@ -176,16 +176,16 @@
176 uni.showModal({ 176 uni.showModal({
177 content: `确认退出吗?`, 177 content: `确认退出吗?`,
178 success: function(res) { 178 success: function(res) {
179 if (res.confirm) { 179 if (res.confirm) {
180 let path = '/pages/index/login'; 180 loginServer.logout().then(()=>{
181 uni.reLaunch({ 181 let path = '/pages/index/login';
182 url: path 182 uni.reLaunch({
183 }); 183 url: path
184 });
185 })
184 } 186 }
185 } 187 }
186 }) 188 })
187
188
189 } 189 }
190 190
191 function goPath(path) { 191 function goPath(path) {
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!