65316219 by 杨炀

Merge commit '6f413499'

2 parents 27be1048 6f413499
......@@ -2,129 +2,136 @@ import request from './request'
import * as api from '@/common/api.js'
function pcLogin(data) {
return request({
url: '/login',
method: 'post',
params: data
}).then((res) => {
uni.setStorageSync('token', 'Bearer ' + res.data.token)
}).then(getInfo)
return request({
url: '/login',
method: 'post',
params: data
}).then((res) => {
uni.setStorageSync('token', 'Bearer ' + res.data.token)
}).then(getInfo)
}
function h5Login(userName) {
return request({
url: `/h5Login`,
method: 'post',
params: {
username: userName
}
}).then((res) => {
uni.setStorageSync('token', 'Bearer ' + res.data.token)
}).then(getInfo)
return request({
url: `/h5Login`,
method: 'post',
params: {
username: userName
}
}).then((res) => {
uni.setStorageSync('token', 'Bearer ' + res.data.token)
}).then(getInfo)
}
function h5LoginAuto() {
const userName = uni.getStorageSync('userName')
if (userName) {
return h5Login(userName)
} else {
uni.redirectTo({
url: '/pages/index/login'
})
}
const userName = uni.getStorageSync('userName')
if (userName) {
return h5Login(userName)
} else {
uni.redirectTo({
url: '/pages/index/login'
})
}
}
function logout() {
return request({
url: '/logout',
method: 'post'
}).then(() => {
uni.removeStorageSync('token')
uni.removeStorageSync('userName')
})
}
function getCodeImg() {
return request({
url: '/captchaImage',
method: 'get'
})
return request({
url: '/captchaImage',
method: 'get'
})
}
// 代退图形认证的获取手机验证码
function getSmsCode(data) {
return request({
url: '/captchaSmsWithCaptchaImage',
method: 'post',
params: data
})
return request({
url: '/captchaSmsWithCaptchaImage',
method: 'post',
params: data
})
}
function loginByPhone(phonenumber, code) {
const data = {
phonenumber,
code
}
return request({
url: '/userLoginByPhone',
method: 'post',
params: data
}).then((res) => {
uni.setStorageSync('token', 'Bearer ' + res.data.token)
}).then(getInfo)
const data = {
phonenumber,
code
}
return request({
url: '/userLoginByPhone',
method: 'post',
params: data
}).then((res) => {
uni.setStorageSync('token', 'Bearer ' + res.data.token)
}).then(getInfo)
}
// 获取用户详细信息
function getInfo() {
return request({
url: '/getInfo',
method: 'get'
}).then(res => {
const app = getApp()
const user = res.data.user
uni.setStorageSync('userName', user.userName)
app.globalData.deptType = user.dept.deptType
switch (user.dept.deptType) {
case '1': // 中跆协
app.globalData.userType = '1'
break
case '2': // 省
case '3':
app.globalData.userType = '2'
break
case '6': // 道馆
app.globalData.userType = '4'
break
default: // 市、区
app.globalData.userType = '3'
break
}
return request({
url: '/getInfo',
method: 'get'
}).then(res => {
const app = getApp()
const user = res.data.user
uni.setStorageSync('userName', user.userName)
app.globalData.deptType = user.dept.deptType
switch (user.dept.deptType) {
case '1': // 中跆协
app.globalData.userType = '1'
break
case '2': // 省
case '3':
app.globalData.userType = '2'
break
case '6': // 道馆
app.globalData.userType = '4'
break
default: // 市、区
app.globalData.userType = '3'
break
}
app.globalData.userInfo = user
})
app.globalData.userInfo = user
})
}
// 团队会员用户注册接口
function groupMemberRegister(data) {
return request({
url: '/groupMemberRegister',
method: 'post',
params: data
})
return request({
url: '/groupMemberRegister',
method: 'post',
params: data
})
}
// 获取道馆信息
function getMyOwnMemberInfo() {
return request({
url: '/member/info/getMyOwnMemberInfo',
method: 'get'
}).then(res => {
const app = getApp()
app.globalData.authenticationStatus = res.data.authenticationStatus
app.globalData.memberInfo = res.data.memberInfo
app.globalData.isExam = res.data?.dept?.isExam
})
return request({
url: '/member/info/getMyOwnMemberInfo',
method: 'get'
}).then(res => {
const app = getApp()
app.globalData.authenticationStatus = res.data.authenticationStatus
app.globalData.memberInfo = res.data.memberInfo
app.globalData.isExam = res.data?.dept?.isExam
})
}
export {
pcLogin,
getCodeImg,
getSmsCode,
h5Login,
h5LoginAuto,
loginByPhone,
groupMemberRegister,
getMyOwnMemberInfo
}
\ No newline at end of file
pcLogin,
getCodeImg,
getSmsCode,
h5Login,
h5LoginAuto,
loginByPhone,
groupMemberRegister,
getMyOwnMemberInfo,
logout
}
......
......@@ -5,7 +5,8 @@
// staging
// const baseUrl_api = "http://22yidpjzjifv.ngrok.xiaomiqiu123.top/stage-api/";
const baseUrl_api = "http://182.92.233.247/stage-api/";
// const baseUrl_api = 'http://192.168.1.97:8787'
export default {
baseUrl_api
}
\ No newline at end of file
baseUrl_api
}
......
......@@ -176,16 +176,16 @@
uni.showModal({
content: `确认退出吗?`,
success: function(res) {
if (res.confirm) {
let path = '/pages/index/login';
uni.reLaunch({
url: path
});
if (res.confirm) {
loginServer.logout().then(()=>{
let path = '/pages/index/login';
uni.reLaunch({
url: path
});
})
}
}
})
}
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!