|
@@ -3,146 +3,7 @@ import WxValidate from '../../utils/WxValidate';
|
|
|
const tools = require('../../utils/tools.js');
|
|
|
Page({
|
|
|
data: {
|
|
|
- isRz: 0,
|
|
|
- userName: "",
|
|
|
- phone: "",
|
|
|
- card: "",
|
|
|
- isInput1: false,
|
|
|
- isInput2: false,
|
|
|
- isInput3: false
|
|
|
+ name:'',
|
|
|
},
|
|
|
- // 错误信息回显
|
|
|
- showModal(error) {
|
|
|
- wx.showModal({
|
|
|
- content: error.msg,
|
|
|
- showCancel: false,
|
|
|
- })
|
|
|
- },
|
|
|
- // 提交
|
|
|
- tj(sessionKey, params) {
|
|
|
- wx.request({
|
|
|
- url: app.globalData.publicUrl + '/wx/student/uthentication',
|
|
|
- method: "post",
|
|
|
- data: {
|
|
|
- studentName: params.userName,
|
|
|
- studentCard: params.card,
|
|
|
- phone: params.phone,
|
|
|
- sessionKey: sessionKey
|
|
|
- },
|
|
|
- success: function (res) {
|
|
|
- if (res.data.code == 0) {
|
|
|
- wx.showModal({
|
|
|
- showCancel: false,
|
|
|
- content: res.data.msg,
|
|
|
- success(res) {
|
|
|
- if (res.confirm) {
|
|
|
- wx.switchTab({
|
|
|
- url: '../index/index'
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- } else {
|
|
|
- wx.showModal({
|
|
|
- showCancel: false,
|
|
|
- content: res.data.msg
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- // 表单提交 跳转tj()
|
|
|
- async formSubmit(e) {
|
|
|
- wx.showLoading({
|
|
|
- mask: true,
|
|
|
- title: '加载中',
|
|
|
- })
|
|
|
- // let _this = this;
|
|
|
- if (this.data.isRz == 0) {
|
|
|
- wx.hideLoading()
|
|
|
- const params = e.detail.value
|
|
|
- if (!this.WxValidate.checkForm(params)) {
|
|
|
- const error = this.WxValidate.errorList[0]
|
|
|
- this.showModal(error)
|
|
|
- wx.hideLoading()
|
|
|
- return false
|
|
|
- }
|
|
|
- const sessionKey = await tools.checkSessionAndLogin();
|
|
|
- this.tj(sessionKey, params);
|
|
|
- } else {
|
|
|
- wx.hideLoading()
|
|
|
- wx.showModal({
|
|
|
- showCancel: false,
|
|
|
- content: "您已经认证过了"
|
|
|
- })
|
|
|
- }
|
|
|
- },
|
|
|
- // 如果有就把信息回显出来
|
|
|
- getXx(sessionKey) {
|
|
|
- // let _this = this;
|
|
|
- wx.request({
|
|
|
- url: app.globalData.publicUrl + '/wx/student/selStudentSessionKeyEcho',
|
|
|
- method: "post",
|
|
|
- data: {
|
|
|
- sessionKey: sessionKey
|
|
|
- },
|
|
|
- success: (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,
|
|
|
- isInput3: true
|
|
|
- })
|
|
|
- } else {
|
|
|
- console.log("我没认证,需要认证")
|
|
|
- }
|
|
|
- } else {
|
|
|
- console.log("报错额")
|
|
|
- }
|
|
|
- console.log(res)
|
|
|
- }
|
|
|
- })
|
|
|
- },
|
|
|
- async onLoad() {
|
|
|
- const sessionKey = await tools.checkSessionAndLogin();
|
|
|
- this.getXx(sessionKey);
|
|
|
- this.initValidate();
|
|
|
- },
|
|
|
- // 验证字段的规则
|
|
|
- initValidate() {
|
|
|
- const rules = {
|
|
|
- userName: {
|
|
|
- required: true
|
|
|
- },
|
|
|
- phone: {
|
|
|
- required: true,
|
|
|
- tel: true,
|
|
|
- },
|
|
|
- card: {
|
|
|
- required: true,
|
|
|
- idcard: true,
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 验证字段的提示信息,若不传则调用默认的信息
|
|
|
- const messages = {
|
|
|
- userName: {
|
|
|
- required: '请输入姓名'
|
|
|
- },
|
|
|
- phone: {
|
|
|
- required: '请输入手机号',
|
|
|
- tel: '请输入正确的手机号',
|
|
|
- },
|
|
|
- card: {
|
|
|
- required: '请输入身份证号码',
|
|
|
- idcard: '请输入正确的身份证号码',
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- // 创建实例对象
|
|
|
- this.WxValidate = new WxValidate(rules, messages)
|
|
|
- }
|
|
|
})
|