diff --git a/app.json b/app.json index 07d6815..5411241 100644 --- a/app.json +++ b/app.json @@ -2,7 +2,8 @@ "pages": [ "pages/index/index", "pages/appointment/appointment", - "pages/records/records" + "pages/records/records", + "pages/scan/result/index" ], "window": { "navigationBarTextStyle": "black", @@ -13,4 +14,4 @@ "componentFramework": "glass-easel", "sitemapLocation": "sitemap.json", "lazyCodeLoading": "requiredComponents" -} +} \ No newline at end of file diff --git a/pages/scan/result/index.js b/pages/scan/result/index.js new file mode 100644 index 0000000..6ee9a0c --- /dev/null +++ b/pages/scan/result/index.js @@ -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: '加载失败,请稍后重试' + }) + } + } +}) \ No newline at end of file diff --git a/pages/scan/result/index.json b/pages/scan/result/index.json new file mode 100644 index 0000000..dd9566f --- /dev/null +++ b/pages/scan/result/index.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "预约详情" +} \ No newline at end of file diff --git a/pages/scan/result/index.wxml b/pages/scan/result/index.wxml new file mode 100644 index 0000000..eac3626 --- /dev/null +++ b/pages/scan/result/index.wxml @@ -0,0 +1,69 @@ + + + + + 加载中... + + + + + + {{error}} + + + + + + 预约详情 + {{record.statusText}} + + + + 访客信息 + + 姓名 + {{record.name}} + + + 手机号 + {{record.phone}} + + + 所属公司 + {{record.company}} + + + 来访事由 + {{record.reason}} + + + + + 预约信息 + + 来访日期 + {{record.date}} + + + 来访时间 + {{record.time}} + + + 创建时间 + {{record.createTime}} + + + + + 被访人信息 + + 被访人姓名 + {{record.hostName}} + + + 拜访区域 + {{record.area}} + + + + \ No newline at end of file diff --git a/pages/scan/result/index.wxss b/pages/scan/result/index.wxss new file mode 100644 index 0000000..32a91ae --- /dev/null +++ b/pages/scan/result/index.wxss @@ -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; +} \ No newline at end of file diff --git a/utils/api.js b/utils/api.js index 53b5663..30b4163 100644 --- a/utils/api.js +++ b/utils/api.js @@ -127,6 +127,20 @@ const appointmentDB = { method: 'PUT' }) return result === true + }, + + /** + * 获取预约详情 + * @param {string} id - 预约记录 id + * @returns {Promise} + */ + async getDetail(id) { + const data = await request({ + url: BASE_URL + API.APPOINTMENT_DETAIL, + method: 'GET', + data: { id } + }) + return mapApiRecord(data) || null } } diff --git a/utils/config.js b/utils/config.js index 169fcd7..a3e1e20 100644 --- a/utils/config.js +++ b/utils/config.js @@ -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)