扫码进入详情

This commit is contained in:
ws
2026-04-27 17:05:35 +08:00
parent 3eb2718559
commit eb5af3fa4a
7 changed files with 284 additions and 4 deletions
+2 -1
View File
@@ -2,7 +2,8 @@
"pages": [
"pages/index/index",
"pages/appointment/appointment",
"pages/records/records"
"pages/records/records",
"pages/scan/result/index"
],
"window": {
"navigationBarTextStyle": "black",
+56
View File
@@ -0,0 +1,56 @@
// pages/scan/result/index.js
const { appointmentDB, formatRecord } = require('../../../utils/api')
Page({
data: {
record: null,
loading: true,
error: ''
},
onLoad(options) {
const id = options.id
if (!id) {
this.setData({
loading: false,
error: '缺少预约记录ID'
})
return
}
this.loadRecordDetail(id)
},
async loadRecordDetail(id) {
try {
this.setData({ loading: true })
const result = await appointmentDB.getDetail(id)
if (!result) {
this.setData({
loading: false,
error: '预约记录不存在'
})
return
}
const formatted = formatRecord(result)
const statusMap = {
'pending': '待审核',
'approved': '已通过',
'rejected': '已拒绝',
'cancelled': '已取消'
}
this.setData({
record: {
...formatted,
statusText: statusMap[formatted.status] || formatted.status
},
loading: false
})
} catch (err) {
console.error('加载预约记录详情失败', err)
this.setData({
loading: false,
error: '加载失败,请稍后重试'
})
}
}
})
+3
View File
@@ -0,0 +1,3 @@
{
"navigationBarTitleText": "预约详情"
}
+69
View File
@@ -0,0 +1,69 @@
<view class="page">
<!-- 加载中 -->
<view class="loading" wx:if="{{loading}}">
<text class="loading-icon">⏳</text>
<text class="loading-text">加载中...</text>
</view>
<!-- 错误提示 -->
<view class="error" wx:if="{{error}}">
<text class="error-icon">❌</text>
<text class="error-text">{{error}}</text>
</view>
<!-- 预约记录详情 -->
<view class="record-detail" wx:if="{{!loading && !error && record}}">
<view class="detail-header">
<view class="title">预约详情</view>
<view class="status-tag status-{{record.status}}">{{record.statusText}}</view>
</view>
<view class="detail-section">
<view class="section-title">访客信息</view>
<view class="detail-row">
<text class="detail-label">姓名</text>
<text class="detail-value">{{record.name}}</text>
</view>
<view class="detail-row">
<text class="detail-label">手机号</text>
<text class="detail-value">{{record.phone}}</text>
</view>
<view class="detail-row">
<text class="detail-label">所属公司</text>
<text class="detail-value">{{record.company}}</text>
</view>
<view class="detail-row">
<text class="detail-label">来访事由</text>
<text class="detail-value">{{record.reason}}</text>
</view>
</view>
<view class="detail-section">
<view class="section-title">预约信息</view>
<view class="detail-row">
<text class="detail-label">来访日期</text>
<text class="detail-value">{{record.date}}</text>
</view>
<view class="detail-row">
<text class="detail-label">来访时间</text>
<text class="detail-value">{{record.time}}</text>
</view>
<view class="detail-row">
<text class="detail-label">创建时间</text>
<text class="detail-value">{{record.createTime}}</text>
</view>
</view>
<view class="detail-section">
<view class="section-title">被访人信息</view>
<view class="detail-row">
<text class="detail-label">被访人姓名</text>
<text class="detail-value">{{record.hostName}}</text>
</view>
<view class="detail-row">
<text class="detail-label">拜访区域</text>
<text class="detail-value">{{record.area}}</text>
</view>
</view>
</view>
</view>
+136
View File
@@ -0,0 +1,136 @@
/* pages/scan/result/index.wxss */
.page {
min-height: 100vh;
background-color: #f5f5f5;
padding: 20rpx;
}
/* 加载状态 */
.loading {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 200rpx 0;
}
.loading-icon {
font-size: 80rpx;
margin-bottom: 20rpx;
}
.loading-text {
font-size: 28rpx;
color: #999;
}
/* 错误状态 */
.error {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 200rpx 0;
}
.error-icon {
font-size: 80rpx;
margin-bottom: 20rpx;
}
.error-text {
font-size: 28rpx;
color: #ff4d4f;
}
/* 预约详情 */
.record-detail {
background-color: #fff;
border-radius: 16rpx;
overflow: hidden;
}
/* 头部 */
.detail-header {
display: flex;
align-items: center;
justify-content: space-between;
padding: 30rpx;
border-bottom: 1rpx solid #f0f0f0;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.detail-header .title {
font-size: 32rpx;
font-weight: bold;
color: #fff;
}
/* 状态标签 */
.status-tag {
padding: 8rpx 20rpx;
border-radius: 20rpx;
font-size: 24rpx;
color: #fff;
}
.status-pending {
background-color: #faad14;
}
.status-approved {
background-color: #52c41a;
}
.status-rejected {
background-color: #ff4d4f;
}
.status-cancelled {
background-color: #999;
}
/* 详情区块 */
.detail-section {
padding: 30rpx;
border-bottom: 1rpx solid #f0f0f0;
}
.detail-section:last-child {
border-bottom: none;
}
.section-title {
font-size: 28rpx;
font-weight: bold;
color: #333;
margin-bottom: 20rpx;
padding-left: 16rpx;
border-left: 4rpx solid #1890ff;
}
.detail-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20rpx 0;
border-bottom: 1rpx solid #f5f5f5;
}
.detail-row:last-child {
border-bottom: none;
}
.detail-label {
font-size: 28rpx;
color: #666;
min-width: 180rpx;
}
.detail-value {
flex: 1;
font-size: 28rpx;
color: #333;
text-align: right;
word-break: break-all;
}
+14
View File
@@ -127,6 +127,20 @@ const appointmentDB = {
method: 'PUT'
})
return result === true
},
/**
* 获取预约详情
* @param {string} id - 预约记录 id
* @returns {Promise<object|null>}
*/
async getDetail(id) {
const data = await request({
url: BASE_URL + API.APPOINTMENT_DETAIL,
method: 'GET',
data: { id }
})
return mapApiRecord(data) || null
}
}
+3 -2
View File
@@ -6,7 +6,7 @@ const ENV_CONFIG = {
// release: 'https://xcx.yun.588580.xyz',
trial: 'https://qywx.yun.588580.xyz',
// 开发版 & 体验版
develop: 'https://qywx.yun.588580.xyz'
develop: 'http://172.16.60.235:8080'
}
// 自动判断当前运行环境
@@ -25,7 +25,8 @@ const API = {
APPOINTMENT_LATEST: '/api/wx-mini/appointment/latest',
APPOINTMENT_LIST: '/api/wx-mini/appointment/list',
APPOINTMENT_CREATE: '/api/wx-mini/appointment/create',
APPOINTMENT_CANCEL: '/api/wx-mini/appointment/cancel'
APPOINTMENT_CANCEL: '/api/wx-mini/appointment/cancel',
APPOINTMENT_DETAIL: '/api/wx-mini/appointment/detail'
}
console.log('[config] 当前环境:', wx.getAccountInfoSync().miniProgram.envVersion, 'BASE_URL:', BASE_URL)