he 5 bulan lalu
induk
melakukan
f33ffff088

+ 1 - 1
common/config.js

@@ -3,7 +3,7 @@
  */
  */
 
 
 const config = {
 const config = {
-	DEVE_URL: "https://zhijidaouniapp.dianjingkeji.net/prod-api",
+	DEVE_URL: "http://cht320621.gnway.cc:22075",
 	// DEVE_URL: "http://192.168.16.9:9002",
 	// DEVE_URL: "http://192.168.16.9:9002",
 	// PRODUCT_URL: "http://localhost:8085",
 	// PRODUCT_URL: "http://localhost:8085",
 	PRODUCT_URL: "https://api.ndtk.site/api",
 	PRODUCT_URL: "https://api.ndtk.site/api",

+ 254 - 0
components/auth-login-popup/auth-login-popup.vue

@@ -0,0 +1,254 @@
+<template>
+	<uni-popup ref="authPopup" type="bottom" :mask-click="false">
+		<view class="auth-popup">
+			<view class="close-icon" @tap="closePopup">
+				<uni-icons type="close" size="24" color="#999"></uni-icons>
+			</view>
+			<view>
+				<button class="login-btn" @tap="handleLogin">授权登录</button>
+				<view class="agreement-text">
+					登录即代表您已同意
+					<text class="agreement-link" @tap="goToPrivacy">《隐私政策》</text>
+					和
+					<text class="agreement-link" @tap="goToService">《服务协议》</text>
+				</view>
+			</view>
+		</view>
+	</uni-popup>
+</template>
+
+<script>
+	import {
+		wxLogin
+	} from '@/config/api.js';
+
+	export default {
+		name: 'AuthLoginPopup',
+		data() {
+			return {
+				// 默认用户信息
+				defaultUser: {
+
+				}
+			};
+		},
+		methods: {
+			// 打开弹窗
+			open() {
+				this.$refs.authPopup.open();
+			},
+
+			// 关闭弹窗
+			close() {
+				this.$refs.authPopup.close();
+			},
+
+			// 关闭授权弹窗
+			closePopup() {
+				this.close();
+				this.$emit('close');
+			},
+
+			// 处理微信授权登录
+			async handleLogin() {
+				uni.showLoading({
+					title: '登录中...',
+					mask: true
+				});
+
+				try {
+					// 获取用户信息
+					const profileRes = await this.getUserProfilePromise();
+					console.log('用户信息:', profileRes);
+
+					// 获取登录凭证
+					const loginRes = await this.wxLoginPromise();
+					console.log('登录凭证code:', loginRes.code);
+
+					// 调用后端登录接口
+					const loginData = await wxLogin({
+						code: loginRes.code
+					});
+					console.log('登录响应:', loginData);
+
+					// 检查登录是否成功
+					if (loginData.openid || loginData.code === 200 || loginData.message === "登录成功") {
+						// 如果用户信息为空,使用默认用户信息
+						if (!loginData.user || loginData.user === null) {
+							console.log('用户信息为空,使用默认用户信息');
+							loginData.user = this.defaultUser;
+						}
+
+						// 保存 token
+						const token = loginData.token || loginData.access_token;
+						if (token) {
+							uni.setStorageSync('access_token', token);
+							uni.setStorageSync('token', token);
+						}
+
+						// 保存 refresh_token
+						if (loginData.refresh_token) {
+							uni.setStorageSync('refresh_token', loginData.refresh_token);
+						}
+
+						// 保存完整的登录数据
+						uni.setStorageSync('loginData', loginData);
+
+						// 保存用户信息
+						uni.setStorageSync('user', loginData.user);
+
+						// 保存 openid
+						if (loginData.openid) {
+							uni.setStorageSync('openid', loginData.openid);
+						}
+
+						// 更新 store 状态
+						this.$store.commit('isLogin', true);
+						if (loginData.refresh_token) {
+							this.$store.commit('refresh_token', loginData.refresh_token);
+						}
+
+						uni.hideLoading();
+
+						// 关闭授权弹窗
+						this.close();
+
+						// 显示登录成功提示
+						uni.showToast({
+							title: '登录成功',
+							icon: 'success',
+							duration: 1500
+						});
+
+						// 触发登录成功事件,传递用户信息
+						this.$emit('success', loginData.user);
+
+					} else {
+						uni.hideLoading();
+						uni.showToast({
+							title: loginData.msg || loginData.message || '登录失败',
+							icon: 'none'
+						});
+						this.$emit('fail', loginData);
+					}
+				} catch (error) {
+					console.error('登录错误:', error);
+					uni.hideLoading();
+					uni.showToast({
+						title: error.message || '登录失败,请重试',
+						icon: 'none'
+					});
+					this.$emit('error', error);
+				}
+			},
+
+			// 获取用户信息 Promise 封装
+			getUserProfilePromise() {
+				return new Promise((resolve, reject) => {
+					uni.getUserProfile({
+						desc: '用于完善会员资料',
+						success: (res) => resolve(res),
+						fail: (err) => {
+							if (err.errMsg.includes('cancel')) {
+								reject(new Error('用户取消授权'));
+							} else {
+								reject(new Error('获取用户信息失败'));
+							}
+						}
+					});
+				});
+			},
+
+			// 微信登录 Promise 封装
+			wxLoginPromise() {
+				return new Promise((resolve, reject) => {
+					uni.login({
+						provider: 'weixin',
+						success: (res) => resolve(res),
+						fail: (err) => reject(new Error('获取登录凭证失败'))
+					});
+				});
+			},
+
+			// 跳转到隐私政策
+			goToPrivacy() {
+				uni.navigateTo({
+					url: '/pagesA/public/richtext'
+				});
+			},
+
+			// 跳转到服务协议
+			goToService() {
+				uni.navigateTo({
+					url: '/pagesA/public/richtext'
+				});
+			}
+		}
+	};
+</script>
+
+<style lang="scss" scoped>
+	// 确保 uni-popup 组件的 z-index 足够高
+	::v-deep .uni-popup {
+		z-index: 9999 !important;
+	}
+
+	::v-deep .uni-popup__wrapper {
+		z-index: 9999 !important;
+	}
+
+	.auth-popup {
+		width: 100%;
+		background-color: #fff;
+		border-radius: 24rpx 24rpx 0 0;
+		padding: 60rpx 40rpx 50rpx;
+		box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.1);
+		position: relative;
+		z-index: 10000;
+	}
+
+	.close-icon {
+		position: absolute;
+		top: 20rpx;
+		right: 20rpx;
+		width: 50rpx;
+		height: 50rpx;
+		display: flex;
+		align-items: center;
+		justify-content: center;
+		cursor: pointer;
+		z-index: 10001;
+
+		&:active {
+			opacity: 0.6;
+		}
+	}
+
+	.login-btn {
+		width: 100%;
+		height: 88rpx;
+		background-color: #FF5B05;
+		color: white;
+		border: none;
+		border-radius: 44rpx;
+		font-size: 32rpx;
+		font-weight: 600;
+		margin-bottom: 40rpx;
+	}
+
+	.login-btn:after {
+		border: none;
+	}
+
+	.agreement-text {
+		font-size: 24rpx;
+		color: rgba(41, 44, 53, 0.6);
+		line-height: 36rpx;
+		text-align: center;
+	}
+
+	.agreement-link {
+		color: #FF5B05;
+		text-decoration: none;
+	}
+</style>

+ 3 - 1
config/api.js

@@ -41,6 +41,8 @@ prefix = ''
 export const getDept = (data) => http.get(prefix + '/system/info/deptList?parentId=' + data.parentId)
 export const getDept = (data) => http.get(prefix + '/system/info/deptList?parentId=' + data.parentId)
 export const selectUser = (data) => http.get(prefix + '/system/info/selectUser?deptId=' + data.deptId)
 export const selectUser = (data) => http.get(prefix + '/system/info/selectUser?deptId=' + data.deptId)
 export const addVisit = (data) => http.post(prefix + '/system/info/addVisit', data) // 提交访客申请
 export const addVisit = (data) => http.post(prefix + '/system/info/addVisit', data) // 提交访客申请
+export const getVisitList = (data) => http.get(prefix + '/system/info/list?visitStatus=' + data.visitStatus +
+	'&userId=' + data.userId) // 获取访客记录列表
 // export const getFeedback = (data) => http.get(prefix + '/blade-feedback/getFeedback')
 // export const getFeedback = (data) => http.get(prefix + '/blade-feedback/getFeedback')
 // export const feedbackSave = (params) => http.post(prefix + '//blade-feedback/save', params) // 意见反馈
 // export const feedbackSave = (params) => http.post(prefix + '//blade-feedback/save', params) // 意见反馈
 /**
 /**
@@ -208,7 +210,7 @@ export const updatePassword = (params) => http.post(prefix + '/blade-member/memb
 export const wxLogin = (data) => http.post(prefix + '/system/link/login', {
 export const wxLogin = (data) => http.post(prefix + '/system/link/login', {
 	...data
 	...data
 })
 })
-export const phoneLogin = (data) => http.post(prefix + '/login', {
+export const phoneLogin = (data) => http.post(prefix + '/system/info/login', {
 	...data
 	...data
 })
 })
 // 更新用户基本信息(昵称和头像)
 // 更新用户基本信息(昵称和头像)

+ 60 - 105
pages/index/index.vue

@@ -12,8 +12,8 @@
 					<image class="title-icon" src="/static/images/person.png" mode="aspectFit"></image>
 					<image class="title-icon" src="/static/images/person.png" mode="aspectFit"></image>
 					对接人信息
 					对接人信息
 				</view>
 				</view>
-				<view class="mar-b-16"  >
-					<text class="label" >所属部门:</text>
+				<view class="mar-b-16">
+					<text class="label">所属部门:</text>
 					<view class="select-wrapper">
 					<view class="select-wrapper">
 						<!-- 调试信息 -->
 						<!-- 调试信息 -->
 						<uni-data-select v-model="formData.departmentId" :localdata="departmentOptions"
 						<uni-data-select v-model="formData.departmentId" :localdata="departmentOptions"
@@ -135,64 +135,24 @@
 		</view>
 		</view>
 
 
 		<!-- 提交成功弹框 -->
 		<!-- 提交成功弹框 -->
-<!--		<uni-popup ref="successPopup" type="center" :mask-click="false">-->
-<!--			<view class="success-popup">-->
-<!--				<view class="popup-content">-->
-<!--					<view class="success-icon">-->
-<!--						<uni-icons type="checkmarkempty" size="60" color="#52c41a"></uni-icons>-->
-<!--					</view>-->
-<!--					<view class="popup-title">申请提交成功</view>-->
-<!--					<view class="popup-message">您的申请已成功提交,请关注公众号即时查询审核结果</view>-->
-<!--					<view class="popup-buttons">-->
-<!--						<button class="cancel-btn" @click="closeSuccessPopup">取消</button>-->
-<!--						<button class="follow-btn" @click="showQRCode">关注</button>-->
-<!--					</view>-->
-<!--				</view>-->
-<!--			</view>-->
-<!--		</uni-popup>-->
-
-		<!-- 二维码弹框 -->
-<!--		<uni-popup ref="qrcodePopup" type="center" :mask-click="false">-->
-<!--			<view class="qrcode-popup">-->
-<!--				<view class="qrcode-content">-->
-<!--					<view class="qrcode-title">扫描二维码关注公众号</view>-->
-<!--					<view class="qrcode-image" @click="previewQRCode">-->
-<!--						<image src="/static/images/qrcode.png" mode="aspectFit"></image>-->
-<!--						<view class="preview-tip">-->
-<!--							<uni-icons type="search" size="16" color="#fff"></uni-icons>-->
-<!--							<text>点击查看大图</text>-->
-<!--						</view>-->
-<!--					</view>-->
-<!--					<view class="qrcode-tip">扫描上方二维码,关注公众号获取审核结果</view>-->
-<!--					<button class="qrcode-close-btn" @click="closeQRCode">我知道了</button>-->
-<!--				</view>-->
-<!--			</view>-->
-<!--		</uni-popup>-->
-
-		<uni-popup ref="successPopup" type="bottom" :mask-click="false">
-<!--			<view style="height: 100%;width: 100%;background-color: #fff;">-->
-<!--				<button>授权登录</button>-->
-<!--				<text style="font-size: 24rpx;color: rgba(41,44,53,0.6);line-height: 1.5;">-->
-<!--					登录即代表您已同意-->
-<!--					<text style="color: #FF5B05;text-decoration: none;" @tap="goToPrivacy">《隐私政策》</text>-->
-<!--					和-->
-<!--					<text style="color: #FF5B05;text-decoration: none;" @tap="goToService">《服务协议》</text>-->
-<!--				</text>-->
-<!--			</view>-->
-			<view class="auth-popup">
-
-				<view >
-					<button class="login-btn" @tap="handleLogin">授权登录</button>
-					<view class="agreement-text">
-						登录即代表您已同意
-						<text class="agreement-link" @tap="goToPrivacy">《隐私政策》</text>
-						和
-						<text class="agreement-link" @tap="goToService">《服务协议》</text>
-					</view>
-				</view>
-			</view>
-
-		</uni-popup>
+		<!--		<uni-popup ref="successPopup" type="center" :mask-click="false">-->
+		<!--			<view class="success-popup">-->
+		<!--				<view class="popup-content">-->
+		<!--					<view class="success-icon">-->
+		<!--						<uni-icons type="checkmarkempty" size="60" color="#52c41a"></uni-icons>-->
+		<!--					</view>-->
+		<!--					<view class="popup-title">申请提交成功</view>-->
+		<!--					<view class="popup-message">您的申请已成功提交,请关注公众号即时查询审核结果</view>-->
+		<!--					<view class="popup-buttons">-->
+		<!--						<button class="cancel-btn" @click="closeSuccessPopup">取消</button>-->
+		<!--						<button class="follow-btn" @click="showQRCode">关注</button>-->
+		<!--					</view>-->
+		<!--				</view>-->
+		<!--			</view>-->
+		<!--		</uni-popup>-->
+
+		<!-- 授权登录组件 -->
+		<auth-login-popup ref="authLoginPopup" @success="onLoginSuccess" @close="onLoginClose"></auth-login-popup>
 
 
 
 
 
 
@@ -202,12 +162,16 @@
 <script>
 <script>
 	import user from '../../store/modules/user';
 	import user from '../../store/modules/user';
 	import {
 	import {
-
 		getDept,
 		getDept,
 		selectUser,
 		selectUser,
 		addVisit
 		addVisit
 	} from '@/config/api.js';
 	} from '@/config/api.js';
+	import AuthLoginPopup from '@/components/auth-login-popup/auth-login-popup.vue';
+	
 	export default {
 	export default {
+		components: {
+			AuthLoginPopup
+		},
 		data() {
 		data() {
 			return {
 			return {
 				type: '', // 从上一页传递过来的参数
 				type: '', // 从上一页传递过来的参数
@@ -236,7 +200,7 @@
 				// 部门选项(格式化为uni-data-select所需格式)
 				// 部门选项(格式化为uni-data-select所需格式)
 				departmentOptions: [],
 				departmentOptions: [],
 				// 员工选项
 				// 员工选项
-				employeeOptions: [],
+				employeeOptions: []
 			}
 			}
 		},
 		},
 		onLoad(options) {
 		onLoad(options) {
@@ -253,7 +217,8 @@
 		onReady() {
 		onReady() {
 			// 页面渲染完成后再次获取,确保准确
 			// 页面渲染完成后再次获取,确保准确
 			this.getTabbarHeight()
 			this.getTabbarHeight()
-		this.$refs.successPopup.open()
+			// 打开授权登录弹窗
+			this.$refs.authLoginPopup.open()
 		},
 		},
 		methods: {
 		methods: {
 			// 获取tabbar高度
 			// 获取tabbar高度
@@ -569,7 +534,7 @@
 				// 构建提交数据
 				// 构建提交数据
 				const submitData = {
 				const submitData = {
 					visitDate: this.formData.visitTime, // 访问时间
 					visitDate: this.formData.visitTime, // 访问时间
-					// userId: this.user?.id || '', // 员工id
+					userId: this.formData.employeeId, // 员工id(从选择的员工中获取user_id)
 					empName: this.formData.employeeName, // 访问部门人(员工姓名)
 					empName: this.formData.employeeName, // 访问部门人(员工姓名)
 					visDept: this.formData.visitorCompany, // 访客单位
 					visDept: this.formData.visitorCompany, // 访客单位
 					visitPerson: this.formData.visitorName, // 访客姓名
 					visitPerson: this.formData.visitorName, // 访客姓名
@@ -586,12 +551,27 @@
 					const response = await addVisit(submitData);
 					const response = await addVisit(submitData);
 					console.log('提交成功:', response);
 					console.log('提交成功:', response);
 
 
-					// 显示提交成功弹框
-					this.$refs.successPopup.open();
+					// 检查返回结果
+					if (response && response.code === 200) {
+						uni.showToast({
+							title: response.msg || '提交成功',
+							icon: 'success',
+							duration: 2000
+						});
+						// 延迟返回上一页
+						setTimeout(() => {
+							uni.navigateBack();
+						}, 2000);
+					} else {
+						uni.showToast({
+							title: response.msg || '提交失败,请重试',
+							icon: 'none'
+						});
+					}
 				} catch (error) {
 				} catch (error) {
 					console.error('提交失败:', error);
 					console.error('提交失败:', error);
 					uni.showToast({
 					uni.showToast({
-						title: '提交失败,请重试',
+						title: error.msg || '提交失败,请重试',
 						icon: 'none'
 						icon: 'none'
 					});
 					});
 				}
 				}
@@ -638,6 +618,18 @@
 				});
 				});
 			},
 			},
 
 
+			// 登录成功回调
+			onLoginSuccess(userInfo) {
+				console.log('登录成功,用户信息:', userInfo);
+				// 更新当前页面的用户信息
+				this.user = userInfo;
+			},
+
+			// 登录弹窗关闭回调
+			onLoginClose() {
+				console.log('用户关闭了登录弹窗');
+			},
+
 		}
 		}
 	}
 	}
 </script>
 </script>
@@ -788,7 +780,7 @@
 		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
 		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.1);
 		z-index: 10;
 		z-index: 10;
 		cursor: pointer;
 		cursor: pointer;
-		
+
 		&:active {
 		&:active {
 			opacity: 0.7;
 			opacity: 0.7;
 			transform: scale(0.95);
 			transform: scale(0.95);
@@ -1008,41 +1000,4 @@
 
 
 
 
 
 
-	.auth-popup {
-		width: 100%;
-		background-color: #fff;
-		border-radius: 24rpx;
-		padding: 60rpx 40rpx 50rpx;
-		box-shadow: 0 10rpx 30rpx rgba(0, 0, 0, 0.1);
-	}
-
-
-
-	.login-btn {
-		width: 100%;
-		height: 88rpx;
-		background-color: #FF5B05;
-		color: white;
-		border: none;
-		border-radius: 44rpx;
-		font-size: 32rpx;
-		font-weight: 600;
-		margin-bottom: 40rpx;
-	}
-
-	.login-btn:after {
-		border: none;
-	}
-
-	.agreement-text {
-		font-size: 24rpx;
-		color: rgba(41, 44, 53, 0.6);
-		line-height: 36rpx;
-		text-align: center;
-	}
-
-	.agreement-link {
-		color: #FF5B05;
-		text-decoration: none;
-	}
 </style>
 </style>

+ 53 - 17
pages/tabbar/my.vue

@@ -12,19 +12,19 @@
 				<view v-if="isLogin">
 				<view v-if="isLogin">
 					<view class="form-item">
 					<view class="form-item">
 						<text class="label">姓名</text>
 						<text class="label">姓名</text>
-						<text class="value">{{user.account || '-'}}</text>
+						<text class="value">{{user.nickName || '-'}}</text>
 					</view>
 					</view>
 					<view class="form-item">
 					<view class="form-item">
 						<text class="label">手机号</text>
 						<text class="label">手机号</text>
-						<text class="value">{{user.phone || '-'}}</text>
+						<text class="value">{{user.phonenumber || '-'}}</text>
 					</view>
 					</view>
 					<view class="form-item">
 					<view class="form-item">
 						<text class="label">公司名称</text>
 						<text class="label">公司名称</text>
-						<text class="value">{{user.company || '-'}}</text>
+						<text class="value">{{user.dept && user.dept.deptName || '-'}}</text>
 					</view>
 					</view>
 					<view class="form-item">
 					<view class="form-item">
 						<text class="label">部门</text>
 						<text class="label">部门</text>
-						<text class="value">{{user.department || '-'}}</text>
+						<text class="value">{{user.dept && user.dept.deptName || '-'}}</text>
 					</view>
 					</view>
 				</view>
 				</view>
 				<view v-else class="login-container">
 				<view v-else class="login-container">
@@ -42,6 +42,11 @@
 				<text class="edit-text">编辑</text>
 				<text class="edit-text">编辑</text>
 			</view>
 			</view>
 
 
+			<!-- 退出登录按钮 -->
+			<view v-if="isLogin" class="logout-button" @tap="handlerLogout">
+				<text class="logout-text">退出登录</text>
+			</view>
+
 			<!-- 功能菜单 -->
 			<!-- 功能菜单 -->
 
 
 		</view>
 		</view>
@@ -56,9 +61,6 @@
 <script>
 <script>
 	import {
 	import {
 		getUserInfo,
 		getUserInfo,
-		memberPetList,
-		carouselQueryAll,
-		getOrderStatusCounts,
 	} from '../../config/api';
 	} from '../../config/api';
 	import {
 	import {
 		mapActions,
 		mapActions,
@@ -82,7 +84,7 @@
 
 
 		},
 		},
 		onShow() {
 		onShow() {
-			this.detail()
+			this.getUserInfo()
 		},
 		},
 		// 微信小程序分享配置
 		// 微信小程序分享配置
 		onShareAppMessage() {
 		onShareAppMessage() {
@@ -133,12 +135,10 @@
 			// },
 			// },
 
 
 			async getUserInfo() {
 			async getUserInfo() {
-				// const user = uni.getStorageSync('user');
-				// if (user) {
-				// 	this.user = user;
-				// } else {
-				// 	await this.detail();
-				// }
+				const user = uni.getStorageSync('user');
+				if (user) {
+					this.user = user;
+				}
 			},
 			},
 
 
 
 
@@ -160,12 +160,33 @@
 				});
 				});
 			},
 			},
 
 
-			handlerLogout() {
-				this.logout()
-			},
 
 
 
 
 
 
+
+			// 退出登录
+			handlerLogout() {
+				uni.showModal({
+					title: '提示',
+					content: '确定要退出登录吗?',
+					success: (res) => {
+						if (res.confirm) {
+							// 清除缓存
+							uni.removeStorageSync('access_token');
+							uni.removeStorageSync('user');
+							// 调用vuex的logout方法
+							this.logout();
+							uni.showToast({
+								title: '退出成功',
+								icon: 'success'
+							});
+							// 刷新当前页面
+							this.user = {};
+						}
+					}
+				});
+			}
+
 		},
 		},
 	}
 	}
 </script>
 </script>
@@ -291,4 +312,19 @@
 		color: #FF5B05;
 		color: #FF5B05;
 		font-size: 32rpx;
 		font-size: 32rpx;
 	}
 	}
+
+	.logout-button {
+		margin: 30rpx 32rpx 0;
+		height: 88rpx;
+		display: flex;
+		align-items: center;
+		justify-content: center;
+		background: #FF4748;
+		border-radius: 44rpx;
+	}
+
+	.logout-text {
+		color: #FFFFFF;
+		font-size: 32rpx;
+	}
 </style>
 </style>

+ 72 - 43
pages/tabbar/visitor.vue

@@ -44,7 +44,6 @@
 					<view class="font28 font-gray flex-items-plus">
 					<view class="font28 font-gray flex-items-plus">
 						数据为空
 						数据为空
 					</view>
 					</view>
-					<no-data text="暂无访问记录" mode="list"></no-data>
 				</template>
 				</template>
 			</scroll-view>
 			</scroll-view>
 		</template>
 		</template>
@@ -55,10 +54,15 @@
 	import {
 	import {
 		mapGetters
 		mapGetters
 	} from 'vuex';
 	} from 'vuex';
+	import {
+		getVisitList
+	} from '@/config/api.js';
 
 
 	export default {
 	export default {
 		data() {
 		data() {
 			return {
 			return {
+				user: {},
+				visitStatus: '0',
 				visitList: [],
 				visitList: [],
 				loadMoreStatus: 'loadmore', // loadmore, loading, nomore
 				loadMoreStatus: 'loadmore', // loadmore, loading, nomore
 				params: {
 				params: {
@@ -72,7 +76,10 @@
 			...mapGetters(['isLogin'])
 			...mapGetters(['isLogin'])
 		},
 		},
 		onLoad() {
 		onLoad() {
+			this.user = uni.getStorageSync("user")
+			console.log(uni.getStorageSync("user"), "usususuus")
 			this.getList();
 			this.getList();
+
 		},
 		},
 		onShow() {
 		onShow() {
 
 
@@ -109,8 +116,8 @@
 				return statusMap[status] || 'status-default'
 				return statusMap[status] || 'status-default'
 			},
 			},
 
 
-			// Get visit list with mock data
-			getList(loadMore = false) {
+			// 获取访客列表
+			async getList(loadMore = false) {
 				if (!loadMore) {
 				if (!loadMore) {
 					uni.showLoading({
 					uni.showLoading({
 						title: '加载中...'
 						title: '加载中...'
@@ -119,54 +126,76 @@
 
 
 				this.loadMoreStatus = 'loading'
 				this.loadMoreStatus = 'loading'
 
 
-				// 模拟接口延迟
-				setTimeout(() => {
-					// 模拟数据
-					const mockData = Array(10).fill(0).map((_, index) => {
-						const currentIndex = (this.params.current - 1) * 10 + index;
-						const date = new Date();
-						date.setDate(date.getDate() - currentIndex); // 每条数据日期递减
-
-						const statusList = ['待访问', '待审核', '已拒绝'];
-						const contactPersons = ['范海洋', '张河嘉', '李明', '王芳'];
-						const descList = [
-							'我是访问事由我是访问事由我是访问事由...',
-							'需要进行业务对接商谈...',
-							'产品展示与技术交流...',
-							'项目合作洽谈...'
-						];
-
-						return {
-							id: currentIndex,
-							contactPerson: contactPersons[Math.floor(Math.random() * contactPersons
-								.length)],
-							createTime: date,
-							status: statusList[Math.floor(Math.random() * statusList.length)],
-							visitReason: descList[Math.floor(Math.random() * descList.length)]
-						};
+				try {
+					// 调用接口获取数据
+					const response = await getVisitList({
+						userId: 100,
+						visitStatus: this.visitStatus || '0' // 可以根据需要传递状态参数,空字符串表示获取所有状态
 					});
 					});
 
 
-					const list = mockData.map(item => ({
-						...item,
-						date: this.$u.timeFormat(item.createTime, 'DD'),
-						year: this.$u.timeFormat(item.createTime, 'YYYY/MM'),
-						time: this.$u.timeFormat(item.createTime, 'hh:mm')
-					}));
+					console.log('访客列表接口返回:', response);
+
+					if (response && response.code === 200) {
+						// 处理返回的数据
+						const statusMap = {
+							'0': '待访问',
+							'1': '已访问',
+							'2': '待审核',
+							'3': '已拒绝'
+						};
 
 
-					if (loadMore) {
-						this.visitList = [...this.visitList, ...list];
+						const list = response.rows.map(item => {
+							// 解析创建时间
+							const createTime = item.createTime || item.visitDate;
+
+							return {
+								id: item.id,
+								employeeName: item.empName, // 对接人(员工姓名)
+								visitReason: item.visitReson, // 访问事由
+								status: statusMap[item.visitStatus] || '未知', // 状态
+								visitDate: item.visitDate, // 访问时间
+								visitorName: item.visitPerson, // 访客姓名
+								visitorCompany: item.visDept, // 访客单位
+								visitorPhone: item.visitorTel, // 访客电话
+								visitorNum: item.visitorNum, // 访客人数
+								accPerson: item.accPerson, // 随行人员(JSON字符串)
+								createTime: createTime,
+								// 格式化显示用的字段
+								date: this.$u.timeFormat(createTime, 'dd'),
+								year: this.$u.timeFormat(createTime, 'yyyy/mm'),
+								time: this.$u.timeFormat(createTime, 'hh:MM')
+							};
+						});
+
+						if (loadMore) {
+							this.visitList = [...this.visitList, ...list];
+						} else {
+							this.visitList = list;
+						}
+
+						// 根据返回的数据判断是否还有更多数据
+						// 这里简单处理,如果返回的数据少于每页数量,说明没有更多了
+						this.hasMore = response.rows.length >= this.params.size;
+						this.loadMoreStatus = this.hasMore ? 'loadmore' : 'nomore';
 					} else {
 					} else {
-						this.visitList = list;
+						uni.showToast({
+							title: response.msg || '获取数据失败',
+							icon: 'none'
+						});
+						this.loadMoreStatus = 'nomore';
 					}
 					}
-
-					// 模拟总共有5页数据
-					this.hasMore = this.params.current < 5;
-					this.loadMoreStatus = this.hasMore ? 'loadmore' : 'nomore';
-
+				} catch (error) {
+					console.error('获取访客列表失败:', error);
+					uni.showToast({
+						title: '获取数据失败',
+						icon: 'none'
+					});
+					this.loadMoreStatus = 'nomore';
+				} finally {
 					if (!loadMore) {
 					if (!loadMore) {
 						uni.hideLoading();
 						uni.hideLoading();
 					}
 					}
-				}, 500); // 增加500ms延迟模拟网络请求
+				}
 			},
 			},
 
 
 			// 跳转到详情页面
 			// 跳转到详情页面

+ 4 - 1
pagesA/public/phone-login.vue

@@ -69,7 +69,10 @@
 					console.log(res, "登陆成功")
 					console.log(res, "登陆成功")
 
 
 					uni.setStorageSync('access_token', res.token);
 					uni.setStorageSync('access_token', res.token);
-
+					// 保存用户信息到缓存
+					if (res.user) {
+						uni.setStorageSync('user', res.user);
+					}
 
 
 					this.$store.commit('isLogin', true);
 					this.$store.commit('isLogin', true);
 
 

+ 1 - 1
vite.config.js

@@ -12,7 +12,7 @@ export default defineConfig({
 		port: 8080,
 		port: 8080,
 		proxy: {
 		proxy: {
 			'/api': {
 			'/api': {
-				target: 'https://zhijidaouniapp.dianjingkeji.net/prod-api',
+				target: 'http://cht320621.gnway.cc:22075',
 				changeOrigin: true,
 				changeOrigin: true,
 				rewrite: (path) => path.replace(/^\/api/, ''), // 此处进行路径重写
 				rewrite: (path) => path.replace(/^\/api/, ''), // 此处进行路径重写
 			}
 			}