|
@@ -1,5 +1,6 @@
|
|
|
// pages/login/phone_login/phone_login.js
|
|
|
let log = require('../../../utils/log.js');
|
|
|
+let Util = require("../../../utils/util");
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
@@ -10,15 +11,18 @@ Page({
|
|
|
vcode: null,
|
|
|
checkCode: false,
|
|
|
checkPhone: false,
|
|
|
- vcodeFlag: true,
|
|
|
+ vcodeFlag: false,
|
|
|
errorMsg: '',
|
|
|
varificatCodeFocus:false,
|
|
|
vcode_button_text: '获取验证码',
|
|
|
scene: "LOGIN",
|
|
|
vcodeTimeOut: 0,
|
|
|
vcodeTimeOutDefault: 0,
|
|
|
- vcodeLen: 2,
|
|
|
- servicetel: getApp().globalData.helpPhoneNum
|
|
|
+ vcodeLen:6,
|
|
|
+ servicetel: getApp().globalData.helpPhoneNum,
|
|
|
+ queryip: '',
|
|
|
+ showMsg: false,
|
|
|
+ timeing: true,
|
|
|
},
|
|
|
onError(e) {
|
|
|
wx.showModal({
|
|
@@ -30,47 +34,62 @@ Page({
|
|
|
},
|
|
|
inputPhone(e) {
|
|
|
this.setData({
|
|
|
- phone: e.detail.value
|
|
|
+ phone: e.detail.value,
|
|
|
+ showMsg: false
|
|
|
});
|
|
|
this.checkAll();
|
|
|
},
|
|
|
|
|
|
inputVerificatrCode(e) {
|
|
|
this.setData({
|
|
|
- vcode: e.detail.value
|
|
|
+ vcode: e.detail.value,
|
|
|
+ showMsg: false
|
|
|
});
|
|
|
+ if(!this.msgVcode()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
this.checkAll();
|
|
|
},
|
|
|
|
|
|
- checkAll() {
|
|
|
- if (!this.checkPhoneNumber()) {
|
|
|
+ msgVcode(){
|
|
|
+ if (!this.checkVcode()) {
|
|
|
+ this.setData({
|
|
|
+ // errorMsg: '验证码格式不正确'
|
|
|
+ errorMsg: '验证码格式不正确'
|
|
|
+ });
|
|
|
this.setData({
|
|
|
- errorMsg: '手机号输入有误,请重新输入',
|
|
|
- checkPhone: false,
|
|
|
checkCode: false
|
|
|
});
|
|
|
- return;
|
|
|
+ return false;
|
|
|
} else {
|
|
|
this.setData({
|
|
|
- checkPhone: true,
|
|
|
errorMsg: ''
|
|
|
});
|
|
|
}
|
|
|
+ return true;
|
|
|
+ },
|
|
|
|
|
|
- if (!this.checkVcode()) {
|
|
|
- this.setData({
|
|
|
- errorMsg: '验证码格式不正确'
|
|
|
- });
|
|
|
+ checkAll() {
|
|
|
+ if (!this.checkPhoneNumber()) {
|
|
|
this.setData({
|
|
|
- checkCode: false
|
|
|
+ errorMsg: '手机号输入有误,请重新输入',
|
|
|
+ checkPhone: false,
|
|
|
+ checkCode: false,
|
|
|
+ vcodeFlag: false
|
|
|
});
|
|
|
return;
|
|
|
} else {
|
|
|
this.setData({
|
|
|
- errorMsg: ''
|
|
|
+ checkPhone: true,
|
|
|
+ errorMsg: '',
|
|
|
+ vcodeFlag: true
|
|
|
});
|
|
|
}
|
|
|
|
|
|
+ if(!this.msgVcode()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
if (this.data.phone && this.data.vcode) {
|
|
|
this.setData({
|
|
|
checkCode: true
|
|
@@ -134,14 +153,18 @@ Page({
|
|
|
method: 'POST',
|
|
|
success(res) {
|
|
|
console.info(res.data.code);
|
|
|
- if (res.data.code == 1) {
|
|
|
+ if (res.data.code == 2) {
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
|
content:res.data.msg,
|
|
|
showCancel:false,
|
|
|
confirmColor:'#00AADD',
|
|
|
});
|
|
|
- }else if (res.data.code == 2) {
|
|
|
+ }else if (res.data.code == 1) {
|
|
|
+ if(res.data.msg!=null && res.data.msg.startsWith("503")){
|
|
|
+ getApp().showNetworkError();
|
|
|
+ return;
|
|
|
+ }
|
|
|
// 跳转
|
|
|
wx.showModal({
|
|
|
title: '提示',
|
|
@@ -169,7 +192,8 @@ Page({
|
|
|
if (that.data.vcodeTimeOut <= 0) {
|
|
|
that.setData({
|
|
|
vcodeFlag: true,
|
|
|
- vcode_button_text: '获取验证码'
|
|
|
+ vcode_button_text: '获取验证码',
|
|
|
+ timeing:true
|
|
|
})
|
|
|
clearInterval(vcodeInterval);
|
|
|
}else{
|
|
@@ -177,7 +201,8 @@ Page({
|
|
|
that.setData({
|
|
|
vcodeTimeOut:that.data.vcodeTimeOut-1,
|
|
|
vcodeFlag: false,
|
|
|
- vcode_button_text: str
|
|
|
+ vcode_button_text: str,
|
|
|
+ timeing:false
|
|
|
})
|
|
|
}
|
|
|
}, 1000);
|
|
@@ -189,12 +214,24 @@ Page({
|
|
|
|
|
|
loginUser(e) {
|
|
|
let that = this;
|
|
|
- let { phone, vcode } = this.data;
|
|
|
+ that.loginUserInner(e,that,that.data.queryip)
|
|
|
+ },
|
|
|
+
|
|
|
+ loginUserInner(e,that,ip) {
|
|
|
+ let { phone, vcode } = that.data;
|
|
|
+ that.checkAll();
|
|
|
+ that.setData({
|
|
|
+ showMsg:true
|
|
|
+ })
|
|
|
+ if(!that.data.checkCode){
|
|
|
+ return;
|
|
|
+ }
|
|
|
log.info('[登录]', '[登录]', '[请求]', { phone, vcode });
|
|
|
wx.request({
|
|
|
url: getApp().globalData.postHeadAgreement +'/restapi/wechat/phoneLogin',
|
|
|
data: {
|
|
|
phonenumber: phone,
|
|
|
+ // ip:ip,
|
|
|
vcode
|
|
|
},
|
|
|
method: 'POST',
|
|
@@ -202,6 +239,10 @@ Page({
|
|
|
console.log(res);
|
|
|
log.info('[登录]', '[登录]', '[响应]', res.data);
|
|
|
if (res.data.code == 1) {
|
|
|
+ if(res.data.msg!=null && res.data.msg.startsWith("503")){
|
|
|
+ getApp().showNetworkError();
|
|
|
+ return;
|
|
|
+ }
|
|
|
that.setData({
|
|
|
vcode: null,
|
|
|
passwordFocus:true//,
|
|
@@ -232,6 +273,7 @@ Page({
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+
|
|
|
|
|
|
phoneCall(){
|
|
|
wx.makePhoneCall({
|
|
@@ -261,9 +303,10 @@ Page({
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
- onLoad: function (options) {
|
|
|
+ async onLoad(options) {
|
|
|
let scene = this.data.scene;
|
|
|
let that = this
|
|
|
+
|
|
|
wx.request({
|
|
|
url: getApp().globalData.postHeadAgreement + '/restapi/wechat/vcodeInfo',
|
|
|
data: {
|
|
@@ -277,6 +320,23 @@ Page({
|
|
|
vcodeTimeOutDefault:res.data.result.expire,
|
|
|
vcodeLen:res.data.result.len
|
|
|
})
|
|
|
+ wx.request({
|
|
|
+ url: 'https://ipv4.icanhazip.com/',
|
|
|
+ method: 'POST',
|
|
|
+ success(rrr){
|
|
|
+ console.info(rrr);
|
|
|
+ var query = (rrr == null?'':rrr==null?'':rrr);
|
|
|
+ let queryip = query.data==null? '':query.data.replace("\n","");
|
|
|
+ that.setData({
|
|
|
+ queryip
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail(rrr){
|
|
|
+ that.setData({
|
|
|
+ queryip: ''
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
}
|
|
|
});
|
|
|
},
|