登录对接
This commit is contained in:
@@ -41,7 +41,7 @@ export function queryFeedBackPage(params) {
|
||||
url: '/feedback/queryFeedBackPage',
|
||||
method: 'post',
|
||||
data: {
|
||||
currentPage: 1,
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
status: '',
|
||||
type: '',
|
||||
|
||||
@@ -31,7 +31,7 @@ export function queryTopologyDiagramPage(params) {
|
||||
method: 'post',
|
||||
data: Object.assign(
|
||||
{
|
||||
currentPage: 1,
|
||||
pageNum: 1,
|
||||
pageSize: 999,
|
||||
projectId: '',
|
||||
searchValue: '',
|
||||
|
||||
@@ -1,70 +1,105 @@
|
||||
import request from '../js/request'
|
||||
|
||||
|
||||
/**
|
||||
* 发送验证码
|
||||
* @param {*} params.type 0:登录 1:注册 3:忘记密码 4:更换手机号第二步获取验证码 5:更换手机号第一步获取验证码
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export function apiGetYms (params) {
|
||||
export function apiGetYms(params) {
|
||||
return request({
|
||||
url: '/shiningCloud/user/authCode',
|
||||
url: '/user-boot/appUser/authCode',
|
||||
data: {
|
||||
phone: params.phone,
|
||||
devCode: uni.getStorageSync('cidAES'),
|
||||
type: params.type
|
||||
type: params.type,
|
||||
},
|
||||
method: 'POST'
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 登录
|
||||
* @param {*} params.type 0:ysm 1:pwd
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
export function apiLogin (params) {
|
||||
console.log(uni.getStorageSync('cidAES'));
|
||||
export function apiLogin(params) {
|
||||
console.log(uni.getStorageSync('cidAES'))
|
||||
return request({
|
||||
url: '/shiningCloud/user/login',
|
||||
data: {
|
||||
phone: params.phone,
|
||||
devCode: uni.getStorageSync('cidAES'),
|
||||
key: params.key.trim(),
|
||||
type: params.type
|
||||
type: params.type,
|
||||
},
|
||||
method: 'POST'
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证码登录
|
||||
* @param {*} params.type 0:ysm 1:pwd
|
||||
* @returns
|
||||
*/
|
||||
export function apiYsmLogin(params) {
|
||||
uni.setStorageSync('token', 'Basic bmpjbmFwcDpuamNucHFz')
|
||||
return request({
|
||||
url: '/pas-auth/oauth/token',
|
||||
data: {
|
||||
grant_type: 'sms_code',
|
||||
phone: params.phone,
|
||||
smsCode: params.smsCode.trim(),
|
||||
},
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册
|
||||
* @param {*} params
|
||||
* @returns
|
||||
* @param {*} params
|
||||
* @returns
|
||||
*/
|
||||
export function apiRegister (params) {
|
||||
export function apiRegister(params) {
|
||||
return request({
|
||||
url: '/shiningCloud/user/register',
|
||||
url: '/user-boot/appUser/register',
|
||||
data: {
|
||||
phone: params.phone,
|
||||
devCode: uni.getStorageSync('cidAES'),
|
||||
code: params.code.trim(),
|
||||
},
|
||||
method: 'POST'
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* app用户注册完自动登录
|
||||
* @param params
|
||||
* @returns {*}
|
||||
*/
|
||||
export function autoLogin(phone) {
|
||||
return request({
|
||||
url: '/user-boot/appUser/autoLogin',
|
||||
data: {
|
||||
phone: phone,
|
||||
devCode: uni.getStorageSync('cidAES'),
|
||||
},
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
|
||||
// 第一次登录设置密码
|
||||
export function apiSetPsd (params) {
|
||||
export function apiSetPsd(params) {
|
||||
return request({
|
||||
url: '/shiningCloud/user/setPsd',
|
||||
data: {
|
||||
userId: uni.getStorageSync('userInfo').userId,
|
||||
devCode: uni.getStorageSync('cidAES'),
|
||||
password: params.password.trim()
|
||||
password: params.password.trim(),
|
||||
},
|
||||
method: 'POST'
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
|
||||
// 重置密码
|
||||
export function apiReSetPsd(params) {
|
||||
return request({
|
||||
@@ -73,34 +108,35 @@ export function apiReSetPsd(params) {
|
||||
phone: params.phone,
|
||||
code: params.code.trim(),
|
||||
devCode: uni.getStorageSync('cidAES'),
|
||||
password: params.password.trim()
|
||||
password: params.password.trim(),
|
||||
},
|
||||
method: 'POST'
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
|
||||
// 更换手机号第一步
|
||||
export function apiComfirmCode (params) {
|
||||
export function apiComfirmCode(params) {
|
||||
return request({
|
||||
url: '/shiningCloud/user/comfirmCode',
|
||||
data: {
|
||||
devCode: uni.getStorageSync('cidAES'),
|
||||
phone: params.phone,
|
||||
code: params.code.trim()
|
||||
code: params.code.trim(),
|
||||
},
|
||||
method: 'POST'
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
|
||||
// 重新绑定手机号
|
||||
export function apiRebindPhone (params) {
|
||||
export function apiRebindPhone(params) {
|
||||
return request({
|
||||
url: '/shiningCloud/user/rebindPhone',
|
||||
data: {
|
||||
devCode: uni.getStorageSync('cidAES'),
|
||||
userId: uni.getStorageSync('userInfo').userId,
|
||||
phoneNew: params.phone,
|
||||
code: params.code.trim()
|
||||
code: params.code.trim(),
|
||||
},
|
||||
method: 'POST'
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,14 +27,14 @@ export default {
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
},
|
||||
params: {
|
||||
currentPage: 1,
|
||||
pageNum: 1,
|
||||
pageSize: 20,
|
||||
},
|
||||
reload() {
|
||||
this.data = [];
|
||||
this.status = 'loading';
|
||||
this.empty = false;
|
||||
this.params.currentPage = 1;
|
||||
this.params.pageNum = 1;
|
||||
this.next();
|
||||
},
|
||||
callBack: null,
|
||||
@@ -50,7 +50,7 @@ export default {
|
||||
console.warn(res);
|
||||
let resultData =
|
||||
res.data?.list || res.data?.records || [];
|
||||
if (this.params.currentPage == 1) {
|
||||
if (this.params.pageNum == 1) {
|
||||
this.data = resultData;
|
||||
if (resultData.length == 0 || resultData == 0) {
|
||||
this.empty = true;
|
||||
@@ -68,11 +68,11 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
if (this.params.currentPage == 1) {
|
||||
if (this.params.pageNum == 1) {
|
||||
this.firstCallBack && this.firstCallBack();
|
||||
}
|
||||
this.loadedCallback && this.loadedCallback();
|
||||
this.params.currentPage++;
|
||||
this.params.pageNum++;
|
||||
this.total = res.total;
|
||||
this.loading = false;
|
||||
});
|
||||
|
||||
@@ -1,68 +1,62 @@
|
||||
import config from './config';
|
||||
let arr = [];
|
||||
import config from './config'
|
||||
|
||||
let arr = []
|
||||
export default (options = {}) => {
|
||||
if (options.data == undefined) {
|
||||
options.data = {};
|
||||
options.data = {}
|
||||
}
|
||||
// 防止接口重复点击
|
||||
if (arr.indexOf(options.url) === -1) {
|
||||
arr.push(options.url);
|
||||
arr.push(options.url)
|
||||
} else {
|
||||
return new Promise((resolve, reject) => {
|
||||
reject({
|
||||
code: -1,
|
||||
msg: '请勿重复提交',
|
||||
});
|
||||
});
|
||||
})
|
||||
})
|
||||
}
|
||||
return new Promise((reslove, reject) => {
|
||||
uni.request({
|
||||
url:
|
||||
options.url.indexOf('http') === -1
|
||||
? config.domain + options.url
|
||||
: options.url,
|
||||
url: options.url.indexOf('http') === -1 ? config.domain + options.url : options.url,
|
||||
data: {
|
||||
...options.data,
|
||||
userId: uni.getStorageSync('userInfo').id,
|
||||
},
|
||||
header: {
|
||||
// 'Content-Type': 'application/json;charset=UTF-8',
|
||||
"Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
|
||||
Authorization: '12',
|
||||
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
||||
Authorization: uni.getStorageSync('token'),
|
||||
...options.header,
|
||||
},
|
||||
method: options.method || 'GET',
|
||||
success: async (res) => {
|
||||
console.log(res);
|
||||
console.log(res)
|
||||
if (arr.indexOf(options.url) > -1) {
|
||||
arr.splice(arr.indexOf(options.url), 1);
|
||||
arr.splice(arr.indexOf(options.url), 1)
|
||||
}
|
||||
if (
|
||||
res.data.resultCode !== 10000 &&
|
||||
res.data.code !== 'A0000'
|
||||
) {
|
||||
errHandler(res.data);
|
||||
reject(res.data);
|
||||
if (res.data.resultCode !== 10000 && res.data.code !== 'A0000') {
|
||||
errHandler(res.data)
|
||||
reject(res.data)
|
||||
} else {
|
||||
reslove(res.data);
|
||||
reslove(res.data)
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
if (arr.indexOf(options.url) > -1) {
|
||||
arr.splice(arr.indexOf(options.url), 1);
|
||||
arr.splice(arr.indexOf(options.url), 1)
|
||||
}
|
||||
reject(err);
|
||||
reject(err)
|
||||
uni.showToast({
|
||||
icon: 'none',
|
||||
title: '网络异常,请稍后再试',
|
||||
});
|
||||
})
|
||||
uni.reLaunch({
|
||||
url: '/pages/user/login',
|
||||
});
|
||||
})
|
||||
},
|
||||
});
|
||||
});
|
||||
};
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* 错误处理
|
||||
@@ -72,17 +66,17 @@ function errHandler(res) {
|
||||
switch (res.resultCode) {
|
||||
case '401':
|
||||
// #ifdef MP
|
||||
uni.removeStorageSync('Cookie');
|
||||
uni.clearStorageSync();
|
||||
uni.removeStorageSync('Cookie')
|
||||
uni.clearStorageSync()
|
||||
// #endif
|
||||
uni.reLaunch({ url: '/pages/user/login' });
|
||||
break;
|
||||
uni.reLaunch({ url: '/pages/user/login' })
|
||||
break
|
||||
default:
|
||||
uni.showToast({
|
||||
title: res.msg || '服务端未知错误',
|
||||
title: res.message || res.msg || '服务端未知错误',
|
||||
duration: 2000,
|
||||
icon: 'none',
|
||||
});
|
||||
break;
|
||||
})
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,6 +197,14 @@ const prePage = () => {
|
||||
return prePage
|
||||
}
|
||||
|
||||
const loginSuccess = (data) => {
|
||||
uni.setStorageSync('userInfo', data)
|
||||
uni.setStorageSync('token', data.token_type + ' ' + data.access_token)
|
||||
uni.reLaunch({
|
||||
url: '/pages/user/login',
|
||||
})
|
||||
}
|
||||
|
||||
export default {
|
||||
validatePhoneNumber,
|
||||
toast,
|
||||
@@ -206,4 +214,5 @@ export default {
|
||||
getUserLocation,
|
||||
loadConfig,
|
||||
prePage,
|
||||
loginSuccess,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user