|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163 |
- const config = require('../../config/config.js')
- const Common = require('../../common/common.js')
- const app = getApp()
- var interval = null //倒计时函数
- Page({
- data: {
- phone: '',
- yzm: '',
- flag: true,
- retry: false,
- time: 60,
- phones: "",
- date: '请选择日期',
- fun_id: 2,
- time: '获取验证码', //倒计时
- currentTime: 61,
- disabled:false,
- setInter:''
- },
- getCode: function (options) {
- var that = this;
- var currentTime = that.data.currentTime
- that.data.setInter = setInterval(function () {
- currentTime--;
- that.setData({
- time: currentTime + '秒'
- })
- if (currentTime <= 0) {
- clearInterval(that.data.setInter)
- that.setData({
- time: '获取验证码',
- currentTime: 61,
- disabled: false
- })
- }
- console.log(that.data.time)
- }, 1000)
- },
- onHide:function(){
- let that = this;
- clearInterval(that.data.setInter);
- that.setData({
- time: '获取验证码',
- currentTime: 61,
- disabled: false
- })
- },
- onUnload:function(){
- let that = this;
- clearInterval(that.data.setInter)
- that.setData({
- time: '获取验证码',
- currentTime: 61,
- disabled: false
- })
- },
- onLoad:function(options){
- console.log(options);
- if(tt.getStorageSync("phone")){
- this.setData({
- phone: tt.getStorageSync("phone"),
- })
- }
- if(options.flags=='reset'){
- tt.setNavigationBarTitle({
- title: '修改密码'
- })
- this.setData({
- flags: options.flags
- })
- }else{
- tt.setNavigationBarTitle({
- title: '忘记密码'
- })
- }
-
- },
- onShow: function () {
- let that = this;
- that.setData({
- phones: tt.getStorageSync("phone"),
- disabled:false
- });
- console.log(that.data.phones)
- },
- getYZM(e) {
- console.log(e);
- if (e.detail.value.phone) {
- this.setData({
- phone: e.detail.value.phone,
- yzm: e.detail.value.yzm
- })
- }else{
- this.setData({
- phone: tt.getStorageSync("phone"),
- yzm: e.detail.value.yzm
- })
- }
- },
- next() {
- setTimeout(() => {
- console.log(this.data)
- Common.hasValidationCode(this.data.phone, this.data.yzm)
- .then(res => {
- console.log(res)
- setTimeout(() => {
- console.log(res)
- if (res.code == 200) {
- tt.navigateTo({
- url: `/pages/setpwd/setpwd?phone=${this.data.phone}&code=${this.data.yzm}`
- })
- } else {
- tt.showToast({
- title: "验证码错误",
- icon: "none",
- duration: 2000
- })
- }
- }, 500)
- })
- }, 1000)
- },
- send(e) {
- console.log(this.data.phone);
- var phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
- let that = this;
- // setTimeout(() => {
- let tel = that.data.phone;
- console.log(tel)
- if (phoneReg.test(tel)) {
- Common.sendValidationCode(tel)
- .then(res => {
- console.log(res);
- if (res.code == 200) {
- that.getCode();
- that.setData({
- disabled: true
- })
- tt.showToast({
- title: res.message,
- image: '../../static/images/success.png'
- })
- } else if (res.code == 12061){
- tt.showToast({
- title: "短息已发送,稍后重试",
- icon: "none",
- })
- } else {
- tt.showToast({
- title: res.message,
- icon: "none",
- })
- }
- })
- } else {
- tt.showToast({
- title: '手机号有误',
- icon: "none",
- })
- }
- // }, 500)
- }
- })
|