123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- 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 () {
- // 用户点击右上角转发
- }
- });
|