| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- import {
- sendPhoneCode,
- usePhoneBound
- } from '../../services/index.js'
- import {
- imgServerUrl
- } from '../../config/config.js'
- import {
- showToast
- } from '../../utils/tips.js'
- import $wuxCountDown from '../../utils/coutdown.js'
- import {
- updataStorageData
- } from '../../utils/storage.js'
- const app = getApp();
- Page({
- data: {
- imgServerUrl: imgServerUrl,
- bornYear: '',
- gender: '',
- realName: '',
- zym: '',
- phone: '',
- isShowYzm: false,
- isShowCode: false,
- },
- onLoad: function() {
- this.setData({
- userInfo: app.globalData.userInfo,
- phone: updataStorageData("phone"),
- hpUser: wx.getStorageSync("hpuser")
- })
- },
- vcode() {
- if (this.djs && this.djs.interval) return !1
- this.djs = new $wuxCountDown({
- date: +(new Date) + 60000,
- onEnd() {
- this.setData({
- djs: '重新获取验证码',
- })
- },
- render(date) {
- const sec = this.leadingZeros(date.sec, 2) + ' 秒 '
- date.sec !== 0 && this.setData({
- djs: '重新发送(' + sec + ')',
- })
- },
- })
- },
- inputPhone(e) {
- this.setData({
- phone: e.detail.value
- })
- },
- inputYzm(e) {
- this.setData({
- zym: e.detail.value
- })
- },
- sendCode() {
- if (String(this.data.phone).length != 11) {
- showToast("请输入11位手机号")
- return false
- }
- if (this.data.djs && this.data.djs !== '重新获取验证码') {
- return false
- }
- this.setData({
- isShowYzm: true
- })
- this.vcode()
- sendPhoneCode({
- phoneNo: this.data.phone
- }).then(data => {
- showToast('短信已发送,请填写新手机号和验证码', 'none', 2500)
- })
- },
- showCode() {
- this.setData({
- isShowCode: true
- })
- },
- save() {
- if (!this.data.isShowCode) {
- wx.navigateBack()
- return
- }
- let {
- phone,
- zym
- } = this.data
- if (String(phone).length != 11) {
- showToast("请输入手机号")
- return false
- }
- if (!this.data.isShowYzm) {
- showToast("请先获取验证码")
- return false
- }
- if (String(zym).length != 4) {
- showToast("请输入验证码")
- return false
- }
- usePhoneBound({
- phoneNo: phone,
- msgCode: zym
- }).then(data => {
- wx.navigateBack()
- })
- }
- })
|