//重置密码 var networkUtil = require('../../utils/network_util.js') var api = require('../../utils/apiFile.js') var timeCount = 60; var timer; Page({ /** * 页面的初始数据 */ data: { time: '获取验证码', areaName: getApp().globalData.openInfo.hospitalName || '' }, /** * 生命周期函数--监听页面加载 */ onLoad: function(options) { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function() { timeCount = 60 clearTimeout(timer) }, /*-------自定义--------*/ // 计时器 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) }, inputPhone(e) { this.data.phone = e.detail.value }, // 获取验证码 getVerifyCode: function(e) { if (timeCount < 60) { return } if (this.data.phone.length != 11 || this.data.phone[0] != '1') { networkUtil.showErrorToast('请填写正确的手机号') return } var that = this networkUtil._get(api.bindDoc, { phone: this.data.phone }, function (res) { }, function (res) { timeCount = 60 clearTimeout(timer); that.setData({ time: '0s' }) networkUtil.showErrorToast('获取验证码失败,请稍后再试') }) if (timeCount == 60) { this.keepTime() } }, submitData(e) { var str = '' if (!e.detail.value.phone) { str = '请填写您的手机号' } else if (e.detail.value.phone.length < 11) { str = '请填写正确的手机号' } else if (!e.detail.value.code) { str = '请填写验证码' } else if (!e.detail.value.newPwd) { str = '请输入密码' } else if (!e.detail.value.passwordS) { str = '请再次确认密码' } else if (e.detail.value.newPwd.length < 6) { str = '密码必须为6位以上' } else if (!str && e.detail.value.newPwd != e.detail.value.passwordS) { str = '两次密码输入不一致' } if (str) { networkUtil.showErrorToast(str) return } networkUtil.showLoading() var param = e.detail.value if (!getApp().globalData.openInfo.hospitalId) { networkUtil.showErrorToast('缺少医院iD') return } param.hospitalId = getApp().globalData.openInfo.hospitalId delete param.passwordS networkUtil._get(api.updatePwd, param, function(res) { console.log(res) wx.showToast({ title: '成功修改密码', icon: 'success', duration: 2000 }) setTimeout(function () { wx.navigateBack({}) }, 1000) }, function(res) { networkUtil.showErrorToast(res.errormsg) }) } })