diff --git a/jsFile/requst.js b/jsFile/requst.js
index 2fa353d..240f831 100644
--- a/jsFile/requst.js
+++ b/jsFile/requst.js
@@ -72,22 +72,20 @@ const request = (method, url, options) => {
}
break;
}
+ let params = {};
+ if(options!=undefined) params = options;
+ params.token = uni.getStorageSync('token');
return new Promise((resolve, reject) => {
uni.request({
url: `${uni.getStorageSync('hostapi')}${url}`,
method: methods,
- data: options,
+ data: params,
header: headers,
success: res => {
console.log(`${url}返的结果===>`,res);
if (res.statusCode == 200) {
- if (res.data.code == 0) {
- // 接口调用成功
- resolve(res.data);
- } else {
- // 接口返回错误信息
- checkError(res);
- }
+ // 接口调用成功
+ resolve(res.data);
} else {
// 接口返回错误信息
checkError(res);
diff --git a/pages/forget/forget.vue b/pages/forget/forget.vue
index 7b4d203..9b28545 100644
--- a/pages/forget/forget.vue
+++ b/pages/forget/forget.vue
@@ -1,41 +1,46 @@
- 忘记密码?
-
- 手机号码
-
-
-
-
+
+
+
+ 忘记密码 ?
+
+ 手机号码
+
+
+
+
+
+ 手机验证码
+
+
+ {{codeText}}
+
+
+
+ 新密码
+
+
+
+
+
+ 确认密码
+
+
+
+
+
+ 单位名称
+
+
+
+
+
+
+
+ 立即修改
- 手机验证码
-
-
- {{codeText}}
-
-
-
- 新密码
-
-
-
-
-
- 确认密码
-
-
-
-
-
- 单位名称
-
-
-
-
-
-
-
- 立即修改
+
@@ -54,7 +59,8 @@
ifUnitname:false,
forget_unitname:'',
codeText:'获取验证码' ,// 获取验证码按钮文字
- flagCode:true // 允许点击获取验证码
+ flagCode:true ,// 允许点击获取验证码
+ countDown:null//验证码倒计时事件
}
},
methods: {
@@ -69,7 +75,12 @@
affiliation: this.forget_unitname ,//单位名称
}
this.$requst.post('/universal/api.login/password_find',params).then(res=>{
- this.$toolAll.tools.showToast('找回成功');
+ if(res.code==1) {
+ this.$toolAll.tools.showToast('找回成功');
+ setTimeout(()=>{uni.navigateBack({delta:1})},1000)
+ } else {
+ this.$toolAll.tools.showToast(res.msg);
+ }
})
}
},
@@ -82,12 +93,12 @@
this.flagCode = false;
let count = 60;
this.codeText = `${count}S重新获取`
- let countDown = setInterval(()=>{
+ this.countDown = setInterval(()=>{
count--;
count < 10 ? this.codeText = `0${count}S重新获取` : this.codeText = `${count}S重新获取`;
if(count==0) {
this.codeText = `重新获取`;
- clearInterval(countDown);
+ clearInterval(this.countDown);
this.flagCode = true;
}
},1000)
@@ -100,6 +111,10 @@
getMessage(phone){
this.$requst.post('/universal/api.login/send_sms',{phone}).then(res=>{
this.$toolAll.tools.showToast(res.msg);
+ if(res.code==0) {
+ clearInterval(this.countDown);
+ this.codeText = `获取验证码`
+ }
})
},
// 检测是否某个输入框为空
@@ -202,5 +217,5 @@
diff --git a/pages/login/login.vue b/pages/login/login.vue
index 6718b5c..d280a64 100644
--- a/pages/login/login.vue
+++ b/pages/login/login.vue
@@ -82,22 +82,32 @@
methods: {
// 提交事件
submitEv(){
- // if(this.checkEmpty()){
- // let params = {
- // login_type: this.login_type, // 登陆手机类型: mobile:手机登陆、account:账号密码登陆
- // phone: this.login_type == 'mobile' ? this.login_phone : '', // 手机号码,login_type 为 mobile 时必填
- // password: this.login_password, // 密码,login_type 为 account 时必填
- // sms_code: this.login_code, // 短信验证码,login_type 为 mobile 时必填
- // username: this.login_type == 'account' ? this.login_phone : '', //账号,login_type 为 account 时必填
- // affiliation: this.login_unitName // 单位名称
- // }
- // this.$requst.post('/universal/api.login/login',params).then(res=>{
- // this.$toolAll.tools.showToast('登录成功');
- // })
- // }
- uni.reLaunch({
- url:'/pages/tabbar/pagehome/pagehome'
- })
+ if(this.checkEmpty()){
+ let params = {
+ login_type: this.login_type, // 登陆手机类型: mobile:手机登陆、account:账号密码登陆
+ phone: this.login_type == 'mobile' ? this.login_phone : '', // 手机号码,login_type 为 mobile 时必填
+ password: this.login_password, // 密码,login_type 为 account 时必填
+ sms_code: this.login_code, // 短信验证码,login_type 为 mobile 时必填
+ username: this.login_type == 'account' ? this.login_phone : '', //账号,login_type 为 account 时必填
+ affiliation: this.login_unitName // 单位名称
+ }
+ this.$requst.post('/universal/api.login/login',params).then(res=>{
+ console.log(res,95);
+ if(res.code==1) {
+ this.$toolAll.tools.showToast('登录成功');
+ // 缓存token和角色类型
+ uni.setStorageSync('token',res.data.token);
+ uni.setStorageSync('type_id',res.data.type_id);
+ setTimeout(()=>{
+ uni.reLaunch({
+ url:'/pages/tabbar/pagehome/pagehome'
+ })
+ },2000)
+ } else {
+ this.$toolAll.tools.showToast(res.msg);
+ }
+ })
+ }
},
// 获取验证码
getCode(){
@@ -126,7 +136,7 @@
getMessage(phone){
this.$requst.post('/universal/api.login/send_sms',{phone}).then(res=>{
this.$toolAll.tools.showToast(res.msg);
- if(res.data.length==0) {
+ if(res.code==0) {
this.codeText = '获取验证码';
clearInterval(this.countDown);
}
diff --git a/pages/register/register.vue b/pages/register/register.vue
index 3584d09..e5453bf 100644
--- a/pages/register/register.vue
+++ b/pages/register/register.vue
@@ -93,7 +93,8 @@
register_unitName:'', // 注册时的单位名称
ifAgreen:false ,// 注册时是否勾选协议与政策
codeText:'获取验证码' ,// 获取验证码按钮文字
- flagCode:true // 允许点击获取验证码
+ flagCode:true ,// 允许点击获取验证码
+ countDown:null//验证码倒计时事件
}
},
methods: {
@@ -108,9 +109,15 @@
affiliation: this.register_unitName //单位名称
}
this.$requst.post('/universal/api.login/register',params).then(res=>{
- this.$toolAll.tools.showToast('注册成功');
- // 调用前往登录页
- this.goLogin();
+ if(res.code==1) {
+ this.$toolAll.tools.showToast('注册成功');
+ setTimeout(()=>{
+ // 调用前往登录页
+ this.goLogin();
+ },1000)
+ } else {
+ this.$toolAll.tools.showToast(res.msg);
+ }
})
}
},
@@ -123,12 +130,12 @@
this.flagCode = false;
let count = 60;
this.codeText = `${count}S重新获取`
- let countDown = setInterval(()=>{
+ this.countDown = setInterval(()=>{
count--;
count < 10 ? this.codeText = `0${count}S重新获取` : this.codeText = `${count}S重新获取`;
if(count==0) {
this.codeText = `重新获取`;
- clearInterval(countDown);
+ clearInterval(this.countDown);
this.flagCode = true;
}
},1000)
@@ -141,6 +148,11 @@
getMessage(phone){
this.$requst.post('/universal/api.login/send_sms',{phone}).then(res=>{
this.$toolAll.tools.showToast(res.msg);
+ if(res.code==0) {
+ clearInterval(this.countDown);
+ this.codeText = `获取验证码`
+ this.flagCode = true;
+ }
})
},
// 检测是否某个输入框为空
diff --git a/pages/tabbar/my/my.vue b/pages/tabbar/my/my.vue
index 7c90159..b216166 100644
--- a/pages/tabbar/my/my.vue
+++ b/pages/tabbar/my/my.vue
@@ -45,7 +45,7 @@
- 退出登录
+ 退出登录
@@ -103,6 +103,21 @@
this.$toolAll.tools.disableShareEv();
},
methods: {
+ // 退出登录
+ logOutEv(){
+ this.$requst.post('/universal/api.login/signout').then(res=>{
+ if(res.code==1) {
+ this.$toolAll.tools.showToast('退出成功');
+ // 清除所有缓存
+ uni.clearStorageSync();
+ setTimeout(()=>{
+ uni.reLaunch({
+ url:'/pages/login/login'
+ })
+ },1000)
+ }
+ })
+ },
checkInfo(){
this.$requst.post('/api/user/info').then(res=>{
// console.log('用户信息:',res);