|
@@ -4,9 +4,9 @@
|
|
|
<template v-if="!isEmployeeLogin">
|
|
<template v-if="!isEmployeeLogin">
|
|
|
<!-- 未登录状态 -->
|
|
<!-- 未登录状态 -->
|
|
|
<view class="no-login">
|
|
<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>
|
|
<text class="no-login-text">请使用员工账号登录</text>
|
|
|
- <button class="login-btn" @click="goToLogin">去登录</button>
|
|
|
|
|
|
|
+ <button class="login-btn" @click="goToLogin">授权登录</button>
|
|
|
</view>
|
|
</view>
|
|
|
</template>
|
|
</template>
|
|
|
<template v-else>
|
|
<template v-else>
|
|
@@ -55,7 +55,7 @@
|
|
|
mapGetters
|
|
mapGetters
|
|
|
} from 'vuex';
|
|
} from 'vuex';
|
|
|
import {
|
|
import {
|
|
|
- getVisitList
|
|
|
|
|
|
|
+ getVisitList, wxLogin
|
|
|
} from '@/config/api.js';
|
|
} from '@/config/api.js';
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
@@ -67,7 +67,7 @@
|
|
|
loadMoreStatus: 'loadmore', // loadmore, loading, nomore
|
|
loadMoreStatus: 'loadmore', // loadmore, loading, nomore
|
|
|
params: {
|
|
params: {
|
|
|
current: 1,
|
|
current: 1,
|
|
|
- size: 10,
|
|
|
|
|
|
|
+ size: 10000,
|
|
|
},
|
|
},
|
|
|
hasMore: true,
|
|
hasMore: true,
|
|
|
isEmployeeLogin: false // 是否是员工登录
|
|
isEmployeeLogin: false // 是否是员工登录
|
|
@@ -81,6 +81,7 @@
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
onShow() {
|
|
onShow() {
|
|
|
|
|
+ console.log('onShow-----',this.isEmployeeLogin);
|
|
|
// 每次显示页面时检查登录状态
|
|
// 每次显示页面时检查登录状态
|
|
|
this.checkEmployeeLogin();
|
|
this.checkEmployeeLogin();
|
|
|
if (this.isEmployeeLogin) {
|
|
if (this.isEmployeeLogin) {
|
|
@@ -158,10 +159,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
// 调用接口获取数据
|
|
// 调用接口获取数据
|
|
|
- const response = await getVisitList({
|
|
|
|
|
- userId: 100,
|
|
|
|
|
- // visitStatus: this.visitStatus || '0' // 可以根据需要传递状态参数,空字符串表示获取所有状态
|
|
|
|
|
- });
|
|
|
|
|
|
|
+ const user = uni.getStorageSync('user');
|
|
|
|
|
+
|
|
|
|
|
+ let data={}
|
|
|
|
|
+
|
|
|
|
|
+ // if (user.userId=='1') {
|
|
|
|
|
+ //
|
|
|
|
|
+ // }else{
|
|
|
|
|
+ // data.userId = user.userId
|
|
|
|
|
+ // }
|
|
|
|
|
+ // if (this.visitStatus) {
|
|
|
|
|
+ //
|
|
|
|
|
+ // }
|
|
|
|
|
+
|
|
|
|
|
+ const response = await getVisitList(
|
|
|
|
|
+
|
|
|
|
|
+ {
|
|
|
|
|
+ userId: user.userId, // 从缓存获取用户ID
|
|
|
|
|
+ // visitStatus: this.visitStatus // 传递状态参数
|
|
|
|
|
+ }
|
|
|
|
|
+ );
|
|
|
|
|
|
|
|
console.log('访客列表接口返回:', response);
|
|
console.log('访客列表接口返回:', response);
|
|
|
|
|
|
|
@@ -181,15 +198,16 @@
|
|
|
return {
|
|
return {
|
|
|
id: item.id,
|
|
id: item.id,
|
|
|
employeeName: item.empName, // 对接人(员工姓名)
|
|
employeeName: item.empName, // 对接人(员工姓名)
|
|
|
- visitReason: item.visitReson, // 访问事由
|
|
|
|
|
|
|
+ visitReason: item.visitReson || item.visitReason, // 兼容字段拼写问题
|
|
|
status: statusMap[item.visitStatus] || '未知', // 状态
|
|
status: statusMap[item.visitStatus] || '未知', // 状态
|
|
|
visitDate: item.visitDate, // 访问时间
|
|
visitDate: item.visitDate, // 访问时间
|
|
|
visitorName: item.visitPerson, // 访客姓名
|
|
visitorName: item.visitPerson, // 访客姓名
|
|
|
- visitorCompany: item.visDept, // 访客单位
|
|
|
|
|
|
|
+ visDept: item.visDept, // 部门
|
|
|
visitorPhone: item.visitorTel, // 访客电话
|
|
visitorPhone: item.visitorTel, // 访客电话
|
|
|
visitorNum: item.visitorNum, // 访客人数
|
|
visitorNum: item.visitorNum, // 访客人数
|
|
|
accPerson: item.accPerson, // 随行人员(JSON字符串)
|
|
accPerson: item.accPerson, // 随行人员(JSON字符串)
|
|
|
createTime: createTime,
|
|
createTime: createTime,
|
|
|
|
|
+ // visitorCompany: item.visDept, // 访客单位
|
|
|
// 格式化显示用的字段
|
|
// 格式化显示用的字段
|
|
|
date: this.$u.timeFormat(createTime, 'dd'),
|
|
date: this.$u.timeFormat(createTime, 'dd'),
|
|
|
year: this.$u.timeFormat(createTime, 'yyyy/mm'),
|
|
year: this.$u.timeFormat(createTime, 'yyyy/mm'),
|
|
@@ -238,11 +256,59 @@
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
// 跳转到登录页面
|
|
// 跳转到登录页面
|
|
|
- goToLogin() {
|
|
|
|
|
- uni.navigateTo({
|
|
|
|
|
- url: '/pagesA/public/phone-login'
|
|
|
|
|
- });
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ async goToLogin() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 1. 尝试微信授权登录
|
|
|
|
|
+ const loginRes = await new Promise((resolve, reject) => {
|
|
|
|
|
+ uni.login({
|
|
|
|
|
+ provider: 'weixin',
|
|
|
|
|
+ success: (res) => {
|
|
|
|
|
+ if (res.code) {
|
|
|
|
|
+ resolve(res); // 成功获取 code
|
|
|
|
|
+ } else {
|
|
|
|
|
+ reject(new Error('未获取到微信授权码'));
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ fail: (err) => {
|
|
|
|
|
+ reject(new Error('微信授权失败'));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 2. 调用微信登录接口
|
|
|
|
|
+ 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) {
|
|
|
|
|
+ uni.setStorageSync('user', wxRes.data);
|
|
|
|
|
+ if (wxRes.user) {
|
|
|
|
|
+ uni.setStorageSync('user', wxRes.user);
|
|
|
|
|
+ }
|
|
|
|
|
+ // 更新store状态
|
|
|
|
|
+ this.$store.commit('isLogin', true);
|
|
|
|
|
+ this.isEmployeeLogin = true
|
|
|
|
|
+ this.getList(true)
|
|
|
|
|
+ // uni.switchTab({
|
|
|
|
|
+ // url: '/pages/tabbar/home' // 替换为实际首页路径
|
|
|
|
|
+ // });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ throw new Error('微信登录接口返回异常');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (error) {
|
|
|
|
|
+ console.error('登录失败:', error);
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 微信授权或登录失败,跳转到手机号登录页
|
|
|
|
|
+ uni.navigateTo({
|
|
|
|
|
+ url: '/pagesA/public/phone-login'
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
};
|
|
};
|
|
|
</script>
|
|
</script>
|