tanyanfei 4 年之前
父节点
当前提交
c3cc0b07ae

+ 18 - 1
pages/conference/conference.js

@@ -8,6 +8,7 @@ Page({
    */
   data: {
     info:{},
+    text:'发送验证码',
     labels: {
       company: '单位', name: '姓名', tax_company: '发票单位', idcard: '身份证号',
       email: '邮箱', sex: '性别', age: '年龄', title: '职称',
@@ -95,11 +96,12 @@ Page({
       url: host + '/api/phcode',
       method: 'POST',
       data: { phone: this.data.phone },
-      success: function (res) {
+      success: res => {
         if (res.data.code == 0) {
           wx.showToast({
             title: '验证码已发送',
           })
+          this.countdown()
         } else {
           wx.showToast({
             title: '发送失败',
@@ -109,6 +111,21 @@ Page({
       },
     })
   },
+  countdown: function () {
+    var time = 60, text;
+    var timer = setInterval(() => {
+      if (time > 0) {
+        time--;
+        text = time + 's'
+      } else {
+        text = '发送验证码'
+        clearInterval(timer)
+      }
+      this.setData({
+        text: text
+      })
+    }, 1000)
+  },
   bindSexChange: function (e) {
     this.setData({
       sex: e.detail.value

+ 2 - 1
pages/conference/conference.wxml

@@ -32,7 +32,8 @@
             <label>手机号:</label>
             <input bindinput="phoneChange" name='phone' 
             placeholder-style='color:#999;' placeholder="请输入手机号"></input>
-            <text bindtap="sendcode" class="code">发送验证码</text>
+            <text wx:if='{{text=="发送验证码"}}' bindtap="sendcode" class="code">{{text}}</text>
+             <text wx:else  style="color:#999;" class="code">{{text}}</text>
         </view>
         <view class="item">
             <label>验证码:</label><input name='code' placeholder-style='color:#999;' placeholder="请输入验证码"></input>

+ 18 - 1
pages/eventDetail/eventDetail.js

@@ -7,6 +7,7 @@ Page({
    * 页面的初始数据
    */
   data: {
+    text:'发送验证码',
     info: {},
     uid: '',
     zk1: 0,
@@ -151,11 +152,12 @@ Page({
       url: host + '/api/phcode',
       method: 'POST',
       data: { phone: this.data.phone},
-      success: function (res) {
+      success: res=> {
           if(res.data.code == 0){
               wx.showToast({
                 title: '验证码已发送',
               })
+            this.countdown()
           }else{
             wx.showToast({
               title: '发送失败',
@@ -165,6 +167,21 @@ Page({
       },
     })
   },
+  countdown:function(){
+    var time=60,text;
+    var timer=setInterval(()=>{
+      if(time>0){
+        time--;
+        text = time+'s'
+      }else{
+        text='发送验证码'
+        clearInterval(timer)
+      }
+      this.setData({
+        text: text
+      })
+    },1000)
+  },
   bindMultiPickerColumnChange:function(e){
     console.log('修改的列为', e.detail.column, ',值为', e.detail.value);
     var list = this.data.list, i = e.detail.value, j = e.detail.column;

+ 3 - 1
pages/eventDetail/eventDetail.wxml

@@ -102,7 +102,9 @@
             </picker>
         </view>
         <view class="item">
-            <label>手机号:</label><input bindinput="phoneChange" name='phone' placeholder-style='color:#999;' placeholder="请输入手机号"></input><text bindtap="sendcode" class="code">发送验证码</text>
+            <label>手机号:</label><input bindinput="phoneChange" name='phone' placeholder-style='color:#999;' placeholder="请输入手机号"></input>
+            <text wx:if='{{text=="发送验证码"}}' bindtap="sendcode" class="code">{{text}}</text>
+             <text wx:else  style="color:#999;" class="code">{{text}}</text>
         </view>
         <view class="item">
             <label>验证码:</label><input name='code' placeholder-style='color:#999;' placeholder="请输入验证码"></input>