Bladeren bron

计件宝退出登录

zh 10 maanden geleden
bovenliggende
commit
8efc105436
2 gewijzigde bestanden met toevoegingen van 33 en 17 verwijderingen
  1. 10 0
      src/utils/androidPiece.ts
  2. 23 17
      src/views/piece/dashboard/index.vue

+ 10 - 0
src/utils/androidPiece.ts

@@ -50,6 +50,16 @@ export function saveUserId(userId : string) : boolean {
     return false
     return false
   }
   }
 }
 }
+/**
+ * 保存userId - piece
+ */
+export function removeUserId() {
+  try {
+    // @ts-ignore
+    return window.android.removeUserId()
+  }catch (e){
+  }
+}
 /**
 /**
  * 读取userId - piece
  * 读取userId - piece
  */
  */

+ 23 - 17
src/views/piece/dashboard/index.vue

@@ -52,10 +52,10 @@
       </div>
       </div>
 
 
       <div class="error-section">
       <div class="error-section">
-<!--        <div class="error-display">-->
-<!--          <div class="error-label">错误数量</div>-->
-<!--          <div class="error-count">{{ errNum }}</div>-->
-<!--        </div>-->
+        <div class="error-display">
+          <div class="error-label" @click="logout">退出登录</div>
+          <!--          <div class="error-count">{{ errNum }}</div>-->
+        </div>
       </div>
       </div>
 
 
     </van-col>
     </van-col>
@@ -147,7 +147,7 @@ import { onMounted, onUnmounted, ref, watch } from 'vue'
 import { closeListener, openListener, scanInit } from '@/utils/keydownListener'
 import { closeListener, openListener, scanInit } from '@/utils/keydownListener'
 import { scanSuccess, scanError } from '@/utils/android'
 import { scanSuccess, scanError } from '@/utils/android'
 import { getVersionName, checkUpdate, saveUserId, getUserId, scanRepeat, saveMacAddress, listErrRecords, reLoginTip,
 import { getVersionName, checkUpdate, saveUserId, getUserId, scanRepeat, saveMacAddress, listErrRecords, reLoginTip,
-   readMacAddress, pageDelivery, addDelivery, isDeliveryNoExists, markAsPushed, getErrRecordsCount } from '@/utils/androidPiece'
+   readMacAddress, pageDelivery, addDelivery, isDeliveryNoExists, markAsPushed, getErrRecordsCount, removeUserId } from '@/utils/androidPiece'
 import { showLoadingToast, showNotify } from 'vant'
 import { showLoadingToast, showNotify } from 'vant'
 import { getUserIdByCert, getUserNameById } from '@/api/login/index'
 import { getUserIdByCert, getUserNameById } from '@/api/login/index'
 import { receive, getScanDriverInfo } from '@/api/scan/index'
 import { receive, getScanDriverInfo } from '@/api/scan/index'
@@ -185,6 +185,18 @@ const updateNetworkStatus = () => {
   isOnline.value = navigator.onLine
   isOnline.value = navigator.onLine
 }
 }
 
 
+// 退出登录
+const logout = () => {
+  if (!userInfo.value.userId) {
+    scanError()
+    showNotify({ type: 'danger', style: 'font-size: 30px !important;height:50px', message: '请先登录!' });
+    return
+  }
+  userInfo.value = {}
+  removeUserId()
+  scanSuccess()
+  showNotify({ type: 'success', style: 'font-size: 30px !important;height:50px', message: '已退出登录!' });
+}
 
 
 // 网络提示
 // 网络提示
 const showReconnected = ref(false)
 const showReconnected = ref(false)
@@ -837,23 +849,17 @@ span
   padding-left: 8px
   padding-left: 8px
 
 
 .error-section
 .error-section
-  margin-top: auto
-  padding-top: 10px
-  padding-bottom: 30px
-  border-top: 1px dashed #e0e0e0
+  padding-bottom: 25px
 
 
 .error-display
 .error-display
-  display: flex
-  justify-content: space-between
-  align-items: center
   background: #fff5f5
   background: #fff5f5
-  padding: 12px 15px
-  border-radius: 8px
-  box-shadow: 0 2px 8px rgba(0,0,0,0.05)
+  padding: 3px 4px
+  border-radius: 3px
+  box-shadow: 0 2px 8px rgba(0,0,0,0.1)
 
 
 .error-label
 .error-label
-  font-size: 7px
-  color: #7f8c8d
+  font-size: 8px
+  color: #778181
 
 
 .error-count
 .error-count
   font-size: 10px
   font-size: 10px