Silent 7 lat temu
rodzic
commit
46dceea6ba

+ 1 - 1
routes/wechat.php

xqd
@@ -16,5 +16,5 @@ Route::get('remarkTeacher', 'ApiController@remarkTeacher');
 Route::get('getArticleContent', 'ApiController@getArticleContent');
 Route::get('getAnnounces', 'ApiController@getAnnounces');
 Route::post('updateUserInfo', 'ApiController@updateUserInfo');
-Route::post('bindPhone', 'ApiController@bindPhone');
+Route::get('bindPhone', 'ApiController@bindPhone');
 Route::post('getPhone', 'ApiController@getPhone');

+ 21 - 14
wechat/pages/bind-phone/index.js

xqd xqd
@@ -16,25 +16,33 @@ Page({
   onLoad: function (options) {
     
   },
-  handleFieldChange: function(e) {
-    console.log(this.data.phone)
-    console.log(e)
-  },
 
   formSubmit: e => {
     if(!e.detail.value.phone) {
       wx.showToast({
         title: '手机号不能为空',
       })
-
-      // wx.request({
-      //   url: api.bindPhoneUrl,
-      //   method: 'GET',
-      //   data: {
-      //     'id': wx.getStorageSync('we_chat_user_id'),
-      //     'phone': e.detail.value.phone
-      //   }
-      // })
+    } else {
+      wx.request({
+        url: api.bindPhoneUrl,
+        method: 'GET',
+        data: {
+          'id': wx.getStorageSync('we_chat_user_id'),
+          'phone': e.detail.value.phone
+        },
+        success: res => {
+          if (res.data.status == 'success') {
+            wx.setStorageSync('pt_student', res.data.data)
+            wx.switchTab({
+              url: '/pages/index/index',
+            })
+          } else if (res.data.status == 'fail') {
+            wx.showToast({
+              title: res.data.info,
+            })
+          }
+        }
+      })
     }
   },
 
@@ -50,7 +58,6 @@ Page({
           'encryptedData': e.detail.encryptedData,
         },
         success: res => {
-          console.log(res)
           if(res.data.status == 'success') {
             that.setData({
               phone: res.data.phone

+ 1 - 1
wechat/pages/bind-phone/index.wxml

xqd
@@ -13,7 +13,7 @@
     <zan-row>
       <view class='sg-row'>
         <zan-col col="16" col-class="custom-zan-col">
-          <zan-field placeholder="输入手机号" focus="true" name='phone' value='{{ phone }}' bind:change="handleFieldChange"></zan-field>
+          <zan-field placeholder="输入手机号" focus="true" name='phone' value='{{ phone }}'></zan-field>
         </zan-col>
         <zan-col col="8" col-class="custom-zan-col">
           <zan-button type='warn' openType="getPhoneNumber" class='get-phone-btn' bindgetphonenumber='getPhoneNumber'>获取</zan-button>