|
|
@@ -4,7 +4,7 @@
|
|
|
<template v-if="!isEmployeeLogin">
|
|
|
<!-- 未登录状态 -->
|
|
|
<view class="no-login">
|
|
|
-<!-- <image src="/static/images/no-login.png" mode="aspectFit" class="no-login-image"></image>-->
|
|
|
+ <!-- <image src="/static/images/no-login.png" mode="aspectFit" class="no-login-image"></image>-->
|
|
|
<text class="no-login-text">请使用员工账号登录</text>
|
|
|
<button class="login-btn" @click="goToLogin">授权登录</button>
|
|
|
</view>
|
|
|
@@ -55,7 +55,8 @@
|
|
|
mapGetters
|
|
|
} from 'vuex';
|
|
|
import {
|
|
|
- getVisitList, wxLogin
|
|
|
+ getVisitList,
|
|
|
+ wxLogin
|
|
|
} from '@/config/api.js';
|
|
|
|
|
|
export default {
|
|
|
@@ -81,8 +82,9 @@
|
|
|
},
|
|
|
|
|
|
onShow() {
|
|
|
- console.log('onShow-----',this.isEmployeeLogin);
|
|
|
+ console.log('onShow-----', this.isEmployeeLogin);
|
|
|
// 每次显示页面时检查登录状态
|
|
|
+ this.visitList = []
|
|
|
this.checkEmployeeLogin();
|
|
|
if (this.isEmployeeLogin) {
|
|
|
this.getList();
|
|
|
@@ -106,7 +108,7 @@
|
|
|
checkEmployeeLogin() {
|
|
|
const user = uni.getStorageSync('user');
|
|
|
console.log('检查员工登录状态,user:', user);
|
|
|
-
|
|
|
+
|
|
|
if (user && Object.keys(user).length > 0) {
|
|
|
// user 缓存有值,已登录
|
|
|
this.isEmployeeLogin = true;
|
|
|
@@ -161,7 +163,7 @@
|
|
|
// 调用接口获取数据
|
|
|
const user = uni.getStorageSync('user');
|
|
|
|
|
|
- let data={}
|
|
|
+ let data = {}
|
|
|
|
|
|
// if (user.userId=='1') {
|
|
|
//
|
|
|
@@ -174,10 +176,10 @@
|
|
|
|
|
|
const response = await getVisitList(
|
|
|
|
|
|
- {
|
|
|
- userId: user.userId, // 从缓存获取用户ID
|
|
|
- // visitStatus: this.visitStatus // 传递状态参数
|
|
|
- }
|
|
|
+ {
|
|
|
+ userId: user.userId, // 从缓存获取用户ID
|
|
|
+ // visitStatus: this.visitStatus // 传递状态参数
|
|
|
+ }
|
|
|
);
|
|
|
|
|
|
console.log('访客列表接口返回:', response);
|
|
|
@@ -276,13 +278,15 @@
|
|
|
});
|
|
|
|
|
|
// 2. 调用微信登录接口
|
|
|
- const wxRes = await wxLogin({ code: loginRes.code });
|
|
|
+ const wxRes = await wxLogin({
|
|
|
+ code: loginRes.code
|
|
|
+ });
|
|
|
console.log('微信登录成功:', wxRes);
|
|
|
if (wxRes.openid) {
|
|
|
uni.setStorageSync('openid', wxRes.openid);
|
|
|
}
|
|
|
// 3. 登录成功后的逻辑(如存储用户信息、跳转首页等)
|
|
|
- if (wxRes && wxRes.message === "登录成功"&& wxRes.user) {
|
|
|
+ if (wxRes && wxRes.message === "登录成功" && wxRes.user) {
|
|
|
uni.setStorageSync('user', wxRes.data);
|
|
|
if (wxRes.user) {
|
|
|
uni.setStorageSync('user', wxRes.user);
|