Quellcode durchsuchen

小程序增加退出登录按钮,屏蔽绑定入口

liaoanqi vor 2 Jahren
Ursprung
Commit
ce829538f6
4 geänderte Dateien mit 74 neuen und 3 gelöschten Zeilen
  1. 33 0
      mall4m/pages/user/user.js
  2. 8 2
      mall4m/pages/user/user.wxml
  3. 22 0
      mall4m/pages/user/user.wxss
  4. 11 1
      mall4m/utils/util.js

+ 33 - 0
mall4m/pages/user/user.js

@@ -1,6 +1,7 @@
 // pages/user/user.js
 
 var http = require("../../utils/http.js");
+var util = require("../../utils/util.js");
 Page({
 
   /**
@@ -119,6 +120,38 @@ Page({
     })
   },
 
+  /**
+ * 退出登录
+ */
+  logout: function() {
+    // 请求退出登陆接口
+    http.request({
+      url: '/logOut',
+      method: 'post',
+      callBack: res => {
+        util.removeTabBadge()
+
+        wx.removeStorageSync('loginResult');
+        wx.removeStorageSync('token');
+
+        // this.$Router.pushTab('/pages/index/index')
+        wx.showToast({
+          title: "退出成功",
+          icon: "none"
+        })
+        
+        this.setData({
+          orderAmount: ''
+        });
+        setTimeout(() => {
+          wx.switchTab({
+            url: "/pages/index/index"
+          })
+        }, 1000)
+      }
+    })
+  },
+
   toOrderListPage: function(e) {
     var sts = e.currentTarget.dataset.sts;
     wx.navigateTo({

+ 8 - 2
mall4m/pages/user/user.wxml

@@ -9,10 +9,10 @@
       <open-data type="userNickName"></open-data>
     </view>
   </view>
-  <view class='binding-phone'>
+  <!-- <view class='binding-phone'>
     <text class='show-tip'>绑定手机号后可查看订单和领取优惠券,</text>
     <text class='gotobinding' bindtap='toBindingPhone'>去绑定</text>
-  </view>
+  </view> -->
   <!-- end 用户信息 -->
 
   <view class='list-cont'>
@@ -98,4 +98,10 @@
     <!--end 列表项 -->
   </view>
 
+  <view class="log-out" bindtap="logout" wx:if="isAuthInfo">
+    <view class="log-out-n">
+      <text>退出登录</text>
+    </view>
+  </view>
+
 </view>

+ 22 - 0
mall4m/pages/user/user.wxss

@@ -200,3 +200,25 @@ page {
 .prod-col .col-item .tit{
   line-height: 34px;
 }
+
+/* 退出登录 */
+.log-out{
+	padding:20rpx;
+	text-align: center;
+	margin-top:20rpx;
+}
+.log-out-n{
+	font-size: 30rpx;
+	margin: auto;
+	width:200rpx;
+	padding:20rpx;
+	border-radius: 10rpx;
+	background: #e43130;
+	color:#ffffff;
+}
+button.memu-btn.memu-item {
+  background-color: #fff;
+} 
+button.memu-btn.memu-item:after {
+  border: 0;
+}

+ 11 - 1
mall4m/utils/util.js

@@ -23,7 +23,17 @@ const formatHtml = content => {
   return content;
 }
 
+/**
+ * 移除购物车Tabbar的数字
+ */
+const removeTabBadge = () => {
+	wx.removeTabBarBadge({
+		index: 2
+	})
+}
+
 module.exports = {
   formatTime: formatTime,
-  formatHtml: formatHtml
+  formatHtml: formatHtml,
+	removeTabBadge: removeTabBadge
 }