|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- const config = require("../../config/config");
- const Http = require("../../utils/HttpBasics");
- // d:\fumaolianke\ttFmC\tt富茂C\components\getPhoen\getPhoen.js
- Component({
- data: {
- phone: "",
- auth: "",
- time: "获取验证码",
- verFlag: true,
- currentTime: 61,
- setInter: ''
- },
- properties: {
- type: Boolean,
- showBox: false
- },
-
- methods: {
- getCode() {
- 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,
- verFlag: true
- })
- }
- }, 1000)
- },
- setPhone(e) {
- this.setData({
- phone: e.detail.value
- })
- },
- setAuth(e) {
- this.setData({
- auth: e.detail.value
- })
- },
- verify() {
- let phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
- if (!this.data.verFlag) {
- return
- }
- if (phoneReg.test(this.data.phone)) {
- Http.get({
- url: config.api.sendValidationCode,
- data: {
- phone: this.data.phone,
- type:6
- }
- }).then(res => {
- console.log(res, "res");
- this.setData({
- verFlag: false
- })
- this.getCode()
- }).catch(err => {
- tt.showToast({
- title: err.message ? err.message : err.data, // 内容
- icon: "none"
- });
- })
- } else {
- tt.showToast({
- title: '手机号有误',
- icon: "none",
- })
- }
-
- },
- hieBox(){
- this.triggerEvent("heiBox" ,false)
- },
- hiePhoen(){
- this.triggerEvent("hiePhoen" ,false)
- },
- send() {
- let phoneReg = /(^1[3|4|5|7|8]\d{9}$)|(^09\d{8}$)/;
- if (phoneReg.test(this.data.phone)) {
- console.log(this.data.auth);
- if(this.data.auth!=""){
- Http.get({
- url: config.api.validationCode,
- data: {
- phone: this.data.phone,
- code: this.data.auth,
- type:6
- }
- }).then(res => {
- this.hiePhoen()
- }).catch(err => {
- tt.showToast({
- title: err.message ? err.message : err.data, // 内容
- icon: "none"
- });
- })
- }else{
- tt.showToast({
- title: '请输入验证码',
- icon: "none",
- })
- }
-
- } else {
- tt.showToast({
- title: '手机号有误',
- icon: "none",
- })
- }
-
- }
- }
- })
|