|
@@ -2,9 +2,11 @@ const app = require('../../utils/util.js');
|
|
|
import WxValidate from '../../utils/WxValidate';
|
|
|
Page({
|
|
|
data: {
|
|
|
+ isRz: 0,
|
|
|
userName: "",
|
|
|
phone: "",
|
|
|
- card: ""
|
|
|
+ card: "",
|
|
|
+ isInput: false
|
|
|
},
|
|
|
showModal(error) {
|
|
|
wx.showModal({
|
|
@@ -48,13 +50,104 @@ Page({
|
|
|
})
|
|
|
},
|
|
|
formSubmit: function (e) {
|
|
|
- const params = e.detail.value
|
|
|
let _this = this;
|
|
|
- if (!this.WxValidate.checkForm(params)) {
|
|
|
- const error = this.WxValidate.errorList[0]
|
|
|
- this.showModal(error)
|
|
|
- return false
|
|
|
+ if (_this.data.isRz == 0) {
|
|
|
+ const params = e.detail.value
|
|
|
+ let _this = this;
|
|
|
+ if (!this.WxValidate.checkForm(params)) {
|
|
|
+ const error = this.WxValidate.errorList[0]
|
|
|
+ this.showModal(error)
|
|
|
+ return false
|
|
|
+ }
|
|
|
+ wx.checkSession({
|
|
|
+ success: () => {
|
|
|
+ console.log("我有缓存")
|
|
|
+ var sessionKey = wx.getStorageSync('sessionKey');
|
|
|
+ if (sessionKey == "") {
|
|
|
+ wx.login({
|
|
|
+ success(res) {
|
|
|
+ console.log(res);
|
|
|
+ var code = res.code
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
|
|
|
+ method: "get",
|
|
|
+ data: {
|
|
|
+ code
|
|
|
+ },
|
|
|
+ success: function (res) {
|
|
|
+ sessionKey = res.data.sessionKey;
|
|
|
+ wx.setStorageSync('sessionKey', res.data.sessionKey);
|
|
|
+ _this.tj(sessionKey, params);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ _this.tj(sessionKey, params);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail() {
|
|
|
+ console.log("我没有缓存并去登录请求")
|
|
|
+ wx.login({
|
|
|
+ success(res) {
|
|
|
+ console.log(res);
|
|
|
+ var code = res.code
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
|
|
|
+ method: "get",
|
|
|
+ data: {
|
|
|
+ code
|
|
|
+ },
|
|
|
+ success: function (res) {
|
|
|
+ wx.setStorageSync('sessionKey', res.data.sessionKey);
|
|
|
+ var sessionKey = res.data.sessionKey;
|
|
|
+ _this.tj(sessionKey, params);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showModal({
|
|
|
+ showCancel: false,
|
|
|
+ content: "您已经认证过了"
|
|
|
+ })
|
|
|
}
|
|
|
+ },
|
|
|
+ getXx(sessionKey) {
|
|
|
+ let _this = this;
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.publicUrl2 + '/wx/student/selStudentSessionKeyEcho',
|
|
|
+ method: "post",
|
|
|
+ data: {
|
|
|
+ sessionKey: sessionKey
|
|
|
+ },
|
|
|
+ success: function (res) {
|
|
|
+ if (res.data.code == 0) {
|
|
|
+ if (res.data.data !== null || res.data.data !== "") {
|
|
|
+ _this.setData({
|
|
|
+ isRz: 1,
|
|
|
+ userName: res.data.data.miniName,
|
|
|
+ phone: res.data.data.miniPhone,
|
|
|
+ card: res.data.data.studentCard,
|
|
|
+ isInput: true
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ console.log("我没认证,需要认证")
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log("报错额")
|
|
|
+ }
|
|
|
+ console.log(res)
|
|
|
+ // sessionKey = res.data.sessionKey;
|
|
|
+ // wx.setStorageSync('sessionKey', res.data.sessionKey);
|
|
|
+ // _this.getXx(sessionKey);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onLoad: function () {
|
|
|
+ var _this = this;
|
|
|
wx.checkSession({
|
|
|
success: () => {
|
|
|
console.log("我有缓存")
|
|
@@ -73,14 +166,17 @@ Page({
|
|
|
success: function (res) {
|
|
|
sessionKey = res.data.sessionKey;
|
|
|
wx.setStorageSync('sessionKey', res.data.sessionKey);
|
|
|
- _this.tj(sessionKey, params);
|
|
|
+ _this.getXx(sessionKey);
|
|
|
+ _this.initValidate();
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
- _this.tj(sessionKey, params);
|
|
|
+ _this.getXx(sessionKey);
|
|
|
+ _this.initValidate();
|
|
|
}
|
|
|
+
|
|
|
},
|
|
|
fail() {
|
|
|
console.log("我没有缓存并去登录请求")
|
|
@@ -96,8 +192,9 @@ Page({
|
|
|
},
|
|
|
success: function (res) {
|
|
|
wx.setStorageSync('sessionKey', res.data.sessionKey);
|
|
|
- var sessionKey = res.data.sessionKey;
|
|
|
- _this.tj(sessionKey, params);
|
|
|
+ var sessionKey = res.data.sessionKey
|
|
|
+ _this.getXx(sessionKey);
|
|
|
+ _this.initValidate();
|
|
|
}
|
|
|
})
|
|
|
}
|
|
@@ -105,28 +202,28 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- onLoad: function () {
|
|
|
- this.initValidate();
|
|
|
- // wx.login({
|
|
|
- // success(res) {
|
|
|
- // console.log(res);
|
|
|
- // var code = res.code
|
|
|
- // wx.request({
|
|
|
- // url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
|
|
|
- // method: "get",
|
|
|
- // data: {
|
|
|
- // code
|
|
|
- // },
|
|
|
- // success: function (res) {
|
|
|
- // console.log(res,"我是测试")
|
|
|
- // // wx.setStorageSync('sessionKey', res.data.sessionKey);
|
|
|
- // // var sessionKey = res.data.sessionKey;
|
|
|
- // // _this.tj(sessionKey, params);
|
|
|
- // }
|
|
|
- // })
|
|
|
- // }
|
|
|
- // })
|
|
|
- },
|
|
|
+ // onLoad: function () {
|
|
|
+ // this.initValidate();
|
|
|
+ // wx.login({
|
|
|
+ // success(res) {
|
|
|
+ // console.log(res);
|
|
|
+ // var code = res.code
|
|
|
+ // wx.request({
|
|
|
+ // url: app.globalData.publicUrl2 + '/wx/user/wx7e7a46e129d6cd0f/login',
|
|
|
+ // method: "get",
|
|
|
+ // data: {
|
|
|
+ // code
|
|
|
+ // },
|
|
|
+ // success: function (res) {
|
|
|
+ // console.log(res,"我是测试")
|
|
|
+ // // wx.setStorageSync('sessionKey', res.data.sessionKey);
|
|
|
+ // // var sessionKey = res.data.sessionKey;
|
|
|
+ // // _this.tj(sessionKey, params);
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ // },
|
|
|
initValidate() {
|
|
|
// 验证字段的规则
|
|
|
const rules = {
|