Browse Source

优化注册提示跳转

liaoanqi 3 năm trước cách đây
mục cha
commit
6dc9eaf66c
2 tập tin đã thay đổi với 19 bổ sung5 xóa
  1. 17 3
      mall4m/pages/login/login.js
  2. 2 2
      mall4m/pages/login/login.wxml

+ 17 - 3
mall4m/pages/login/login.js

@@ -109,6 +109,7 @@ Page({
    * 注册/登录按钮
    */
   handleLoginOrRegister() {
+    const that = this
     if (!this.data.userName.trim()) {
       wx.showToast({
         title: '请输入用户名',
@@ -132,9 +133,22 @@ Page({
       },
       callBack: (res) => {
         wx.setStorageSync('token', res.accessToken)
-        wx.switchTab({
-          url: '/pages/index/index',
-        })
+        if(this.data.isRegister) {
+          that.setData({
+            userName: '',
+            password: '',
+            isRegister: !that.data.isRegister
+          })
+          wx.showToast({
+            title: '注册成功,请登录',
+            icon: 'none'
+          })
+        }else {
+          wx.switchTab({
+            url: '/pages/index/index',
+          })          
+        }
+
       }
     };
     http.request(params);

+ 2 - 2
mall4m/pages/login/login.wxml

@@ -5,13 +5,13 @@
     <view class="item">
         <view class="account">
             <text class="input-item">用户名</text>
-            <input type="text" data-type="account" placeholder-class="inp-palcehoder" placeholder="请输入用户名" bindinput="getInputVal"></input>
+            <input type="text" data-type="account" placeholder-class="inp-palcehoder" value="{{userName}}" placeholder="请输入用户名" bindinput="getInputVal"></input>
         </view>
     </view>
     <view class="item">
         <view class="account">
             <text class="input-item">密码</text>
-            <input type="password" data-type="password" placeholder-class="inp-palcehoder" placeholder="请输入密码" bindinput="getInputVal"></input>
+            <input type="password" data-type="password" placeholder-class="inp-palcehoder" value="{{password}}" placeholder="请输入密码" bindinput="getInputVal"></input>
         </view>
     </view>
     <view>