From a345e57300e7ea667da2ef7e837612c22d98bc3c Mon Sep 17 00:00:00 2001
From: quanwei <419654421@qq.com>
Date: Wed, 12 Nov 2025 18:29:44 +0800
Subject: [PATCH] 名片收银台

---
 mobile/pages/plus/business/visitors.vue |  125 +++++++++++++++--------------------------
 1 files changed, 47 insertions(+), 78 deletions(-)

diff --git a/mobile/pages/plus/business/visitors.vue b/mobile/pages/plus/business/visitors.vue
index c2aa653..1849583 100644
--- a/mobile/pages/plus/business/visitors.vue
+++ b/mobile/pages/plus/business/visitors.vue
@@ -9,49 +9,47 @@
 					<input type="text" v-model="search" placeholder="搜索访客姓名" @confirm="searchVisitor" />
 				</view>
 			</view>
-
-		<!-- 访客列表 -->
-		<scroll-view scroll-y="true" class="visitor-list" @scrolltolower="loadMore">
-			<view v-if="visitors.length > 0">
-				<view class="visitor-item" v-for="(visitor, index) in visitors" :key="index">
-					<image class="visitor-avatar" :src="visitor.avatar || '/static/default.png'" mode="aspectFill"></image>
-					<view class="visitor-info">
-						<view class="visitor-header">
-							<view class="visitor-name">{{visitor.user_name || '未知访客'}}</view>
-							<view class="visitor-time">{{formatTime(visitor.visit_time)}}</view>
-						</view>
-						<view v-if="visitor.company_name" class="visitor-company">{{visitor.company_name}}</view>
-						<view v-if="visitor.position" class="visitor-position">{{visitor.position}}</view>
-						<view class="visitor-action">
-							<view class="action-btn" @click="viewCard(visitor.business_card_id)">
-								<text class="icon iconfont icon-card"></text>
-								<text>查看名片</text>
+			<!-- 访客列表 -->
+			<scroll-view scroll-y="true" :width="screenWidth" class="visitor-list" @scrolltolower="loadMore">
+				<view v-if="visitors.length > 0">
+					<view class="visitor-item" v-for="(visitor, index) in visitors" :key="index">
+						<image class="visitor-avatar" :src="visitor.user.avatarUrl || '/static/default.png'"
+							mode="aspectFill">
+						</image>
+						<view class="visitor-info">
+							<view class="visitor-header">
+								<view class="visitor-name">{{visitor.user.nickName || '未知访客'}}</view>
+								<view class="visitor-time">{{visitor.update_time}}</view>
 							</view>
-							<view class="action-btn" @click="contactVisitor(visitor)">
-								<text class="icon iconfont icon-message"></text>
-								<text>联系访客</text>
+							<view v-if="visitor.company_name" class="visitor-company">{{visitor.company_name}}</view>
+							<view v-if="visitor.position" class="visitor-position">{{visitor.position}}</view>
+							<view class="visitor-action">
+								<view class="action-btn" @click="viewCard(visitor)">
+									<text class="icon iconfont icon-card"></text>
+									<text>查看名片</text>
+								</view>
 							</view>
 						</view>
 					</view>
 				</view>
-			</view>
 
-			<!-- 无数据提示 -->
-			<view v-else-if="!loading" class="no-data">
-				<text class="icon iconfont icon-wushuju"></text>
-				<text class="text">暂无访客记录</text>
-			</view>
+				<!-- 无数据提示 -->
+				<view v-else-if="!loading" class="no-data">
+					<text class="icon iconfont icon-wushuju"></text>
+					<text class="text">暂无访客记录</text>
+				</view>
 
-			<!-- 加载中 -->
-			<view v-if="loading && visitors.length > 0" class="loading-more">
-				<text>加载中...</text>
-			</view>
+				<!-- 加载中 -->
+				<view v-if="loading && visitors.length > 0" class="loading-more">
+					<text>加载中...</text>
+				</view>
 
-			<!-- 无更多数据 -->
-			<view v-if="!hasMore && visitors.length > 0" class="no-more">
-				<text>没有更多了</text>
-			</view>
-		</scroll-view>
+				<!-- 无更多数据 -->
+				<view v-if="!hasMore && visitors.length > 0" class="no-more">
+					<text>没有更多了</text>
+				</view>
+			</scroll-view>
+		</view>
 	</view>
 </template>
 
@@ -64,11 +62,14 @@
 				page: 1,
 				list_rows: 10,
 				hasMore: true,
-				search: ''
+				search: '',
+				screenWidth: 0, // 屏幕宽度
 			};
 		},
 		onLoad() {
 			this.getVisitors();
+			const systemInfo = uni.getSystemInfoSync()
+			this.screenWidth = systemInfo.screenWidth * 2 - 70;
 		},
 		methods: {
 			back() {
@@ -88,9 +89,10 @@
 				_this._post('plus.business.business/getVisitors', params, function(res) {
 					_this.loading = false;
 					if (_this.page === 1) {
-						_this.visitors = res.data.list;
+						_this.visitors = res.data.data;
+						console.log(_this.visitors.length);
 					} else {
-						_this.visitors = _this.visitors.concat(res.data.list);
+						_this.visitors = _this.visitors.concat(res.data.data);
 					}
 					// 判断是否还有更多数据
 					_this.hasMore = _this.visitors.length < res.data.total;
@@ -109,48 +111,15 @@
 				}
 			},
 			// 查看访客名片
-			viewCard(business_card_id) {
-				this.gotoPage(`/pages/plus/business/detail?business_card_id=${business_card_id}`);
-			},
-			// 联系访客
-			contactVisitor(visitor) {
-				// 这里可以根据系统功能扩展,比如发送消息、拨打电话等
-				uni.showActionSheet({
-					itemList: ['发送消息', '拨打电话'],
-					success: (res) => {
-						if (res.tapIndex === 0) {
-							// 发送消息
-							this.showError('消息功能暂未开放');
-						} else if (res.tapIndex === 1) {
-							// 拨打电话
-							if (visitor.phone) {
-								uni.makePhoneCall({
-									phoneNumber: visitor.phone
-								});
-							} else {
-								this.showError('暂无联系电话');
-							}
-						}
+			viewCard(visitor) {
+				this._get('plus.business.business/getDetail',{user_id:visitor.user_id},res=>{
+					if(res.data){
+						this.gotoPage(`/pages/plus/business/detail?business_card_id=${res.data.business_card_id}`);
+					}else{
+						this.showError('该用户暂无名片')
 					}
-				});
+				})
 			},
-			// 格式化时间
-			formatTime(time) {
-				if (!time) return '';
-				const date = new Date(time);
-				const now = new Date();
-				const diff = now - date;
-				const days = Math.floor(diff / (1000 * 60 * 60 * 24));
-				if (days === 0) {
-					return '今天 ' + date.getHours() + ':' + (date.getMinutes() < 10 ? '0' : '') + date.getMinutes();
-				} else if (days === 1) {
-					return '昨天 ' + date.getHours() + ':' + (date.getMinutes() < 10 ? '0' : '') + date.getMinutes();
-				} else if (days < 7) {
-					return days + '天前';
-				} else {
-					return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate();
-				}
-			}
 		}
 	};
 </script>

--
Gitblit v1.9.2