var businessT = require('../../../../../tool/business-tool.js') var sysT = require('../../../../../tool/sys-tool.js') var url = require('../../../../../constant/url.js') import Net from '../../../../../tool/net.js' var net = new Net() var app = getApp() Page({ data: { time:60 }, inputAction(e){ if(e.currentTarget.dataset.type=='phone'){ this.setData({ newPhone:e.detail.value }) }else{ this.setData({ code:e.detail.value }) } if(this.data.newPhone&&this.data.code){ this.setData({ canSave:true }) }else{ this.setData({ canSave:false }) } }, getCode() { if(!this.data.newPhone||this.data.newPhone.length!=11){ swan.showToast({ title: '请输入正确的手机号', icon: 'none', mask: true }); }else { net.connect({ url: url.app_host + url.getVerifyCode, data: { phone: this.data.newPhone }, method: "POST", }) var time = 60 this.setData({ countDown: true }) var timer1 = setInterval(() => { time -= 1 this.setData({ time: time }) }, 1000) var timer2 = setTimeout(() => { this.setData({ countDown: false, time: '60' }) clearInterval(timer1) clearTimeout(timer2) }, 60000) } }, btnAction(){ if(this.data.newPhone.length!=11){ swan.showToast({ title: '请输入正确的手机号', icon: 'none', mask: true }); }else{ net.connectNeedLogin({ url:url.app_host+url.changePhone, data:{phone:this.data.newPhone,verify_code:this.data.code}, success:(err,res)=>{ app.globalData.userInfo.phone=this.data.newPhone swan.hideLoading(); swan.showToast({ title: '修改成功', icon: 'none', mask: true }); swan.navigateBack() }, fail:(err,res)=>{ swan.hideLoading(); businessT.showFailTips(err) } },true) } }, onLoad: function () { // 监听页面加载的生命周期函数 }, onReady: function() { // 监听页面初次渲染完成的生命周期函数 }, onShow: function() { // 监听页面显示的生命周期函数 }, onHide: function() { // 监听页面隐藏的生命周期函数 }, onUnload: function() { // 监听页面卸载的生命周期函数 }, onPullDownRefresh: function() { // 监听用户下拉动作 }, onReachBottom: function() { // 页面上拉触底事件的处理函数 }, onShareAppMessage: function () { // 用户点击右上角转发 } });