// 已有建档 var numberUtil = require('../../utils/numberUtil.js') // 网络请求工具类 var networkUtil = require('../../utils/network_util.js') var api = require('../../utils/apiFile.js') Page({ data: { inputFocus: {nameInput:false, phoneInput:false} }, formSubmit: function(e) { console.log('form发生了submit事件,携带数据为:', e.detail.value.name) // 校验 if(e.detail.value.name == '' || e.detail.value.phone == ''){ wx.showModal({ title: '提示', content: '请输入姓名与手机号', showCancel:false, success: function(res) { } }) return } if(!numberUtil.IsTelPhoneNumber(e.detail.value.phone)) { wx.showModal({ title: '提示', content: '请输入正确的手机号', showCancel:false, success: function(res) { } }) return } // 请求 networkUtil.showLoading() var username = e.detail.value.name var self = this var param = { username : e.detail.value.name, phone : e.detail.value.phone, } networkUtil._post(api.bindDoc,param,function(res){ console.log(res) wx.navigateTo({ url: '../HasDocumentedVerify/HasDocumentedVerify?name=' + e.detail.value.name + '&phone=' + e.detail.value.phone + '' }) },function(res){ if(res.errorcode == 4100){ networkUtil.showErrorToast('您的手机号获取验证码超过限制') } else if (res.errorcode == 404){ networkUtil.showErrorToast('暂未连接到服务器,请稍后再试') } else { networkUtil.showErrorToast('暂未查询到您的建档信息,请前往医院建档或稍后再试') } }) }, getFocus:function(e) { var that = this var focus = that.data.inputFocus if(e.target.id == 'name') { focus.nameInput = true focus.phoneInput = false } else { focus.phoneInput = true focus.nameInput = false } that.setData({ inputFocus:focus }) }, blurInput:function(e) { var that = this var focus = that.data.inputFocus if(e.target.id == 'name') { focus.nameInput = false } else { focus.phoneInput = false } that.setData({ inputFocus:focus }) } })