// 网络请求工具类 var networkUtil = require('../../utils/network_util.js') var numberUtil = require('../../utils/numberUtil.js') var api = require('../../utils/apiFile.js') var timeCount = 60; var timer; var phone; var name; var isFirst = true Page({ data: { inputFocus: { codeInput: false }, time: '60s', }, // 获取验证码 getVerifyCode: function (e) { if (timeCount < 60) { return } var that = this networkUtil._post(api.bindDoc, { username: name, phone: phone }, function (res) { }, function (res) { // timeCount = 60 // clearTimeout(timer); // that.setData({ // time: '0s' // }) // networkUtil.showErrorToast('获取验证码失败,请稍后再试') }) if (timeCount == 60) { this.keepTime() } // if (numberUtil.IsTelPhoneNumber(phone)) { // } else { // wx.showToast({ // title: '请输入正确手机号码', // }) // return // } }, // 计时器 keepTime: function () { var that = this timeCount-- that.setData({ time: timeCount + 's' }) if (timeCount == 0) { timeCount = 60 clearTimeout(timer); return } timer = setTimeout(function () { that.keepTime() }, 1000) }, blurInput: function (e) { console.log(e) phone = e.detail.value }, // 提交表单 formSubmit: function (e) { // wx.navigateTo({ // url: '../childcare_knowledge/childcare_knowledge' // }) var self = this if (e.detail.value.code == "") { wx.showModal({ title: '提示', content: '请输入验证码', showCancel: false, success: function (res) { } }) return } networkUtil.showLoading() var param = { code: e.detail.value.code, phone: phone } if (getApp().globalData.openInfo.mpid) { param.gzopenid = getApp().globalData.openInfo.mpid console.log('绑定mpid', param) } if (getApp().globalData.openInfo.code) { param.jscode = getApp().globalData.openInfo.code console.log('绑定code', param) } networkUtil._get(api.verifyCode, param, function (res) { console.log(res) self.loginSuccess(res.data) }, function (res) { networkUtil.showErrorToast(res.errormsg) }) }, loginSuccess(data) { console.log(data) wx.setStorageSync('userToken', data.token) getApp().globalData.token = data.token // wx.navigateTo({ // url: '../HasDocumentedVerifySuccess/HasDocumentedVerifySuccess?name=' + name // }) } } )