Переглянути джерело

登录、注册页添加取消登录/注册并退出操作

Xiao_123 16 годин тому
батько
коміт
bd7aa465dd
1 змінених файлів з 19 додано та 0 видалено
  1. 19 0
      layout/components/authModal/login/index.vue

+ 19 - 0
layout/components/authModal/login/index.vue

@@ -27,6 +27,7 @@
           <view class="register" @tap="handleChangeRegister">还没有登录账户?去注册</view>
         </view>
         <button class="send-button" @tap="handleLogin"> 登 录  </button>
+		    <view class="exit-mini-text MiSans-Normal color-error" @tap="handleExitMiniProgram">取消登录并退出</view>
         <view class="agreement-box ss-flex ss-row-center" style="margin-bottom: 30px;">
           <uni-icons size="20" :type="protocol ? 'checkbox-filled' : 'circle'" :color="protocol ? '#00B760' : '#ccc'" @tap="protocol = !protocol"></uni-icons>
           <view class="color-999 ss-flex ss-col-center ss-m-l-8 font-size-13">
@@ -66,6 +67,7 @@
       <view>
         <button class="send-button" @tap="handleRegister"> 注 册 </button>
       </view>
+	    <view class="exit-mini-text MiSans-Normal color-error" @tap="handleExitMiniProgram">取消注册并退出</view>
       <view class="color-999 ss-flex ss-col-center ss-row-center ss-m-l-8 font-size-13" style="margin-bottom: 30px;">
         点击注册即代表您同意
         <view class="color-primary" @tap.stop="handleToDetail('user')">
@@ -117,6 +119,17 @@ const state = ref({
   }
 })
 
+// 取消登录并退出小程序
+const handleExitMiniProgram = () => {
+  // #ifdef MP-WEIXIN
+  try {
+    wx.exitMiniProgram()
+  } catch (e) {
+    // 非微信环境忽略
+  }
+  // #endif
+}
+
 
 // 设置默认账号密码便于开发快捷登录
 if (window && window.location && window.location.hostname && window.location.hostname === 'localhost') {
@@ -209,6 +222,12 @@ const handleLogin = async () => {
 </script>
 
 <style scoped lang="scss">
+.exit-mini-text {
+	margin-bottom: 12px;
+	text-align: center;
+	font-size: 14px;
+	text-decoration: underline;
+}
 .login-code {
   width: 73px;
   min-width: 73px;