From 98f5c7bc49299575d3e20c055c15f735803fe522 Mon Sep 17 00:00:00 2001 From: ws Date: Wed, 29 Apr 2026 18:24:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E6=A0=B8=E9=94=80=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/scan/result/index.js | 64 ++++++++++++++++++++---------------- pages/scan/result/index.wxml | 19 +++++++---- pages/scan/result/index.wxss | 51 +++++++++++++++++----------- prompt/增加预约记录核验.md | 38 +++++++++++++++++++++ todo.md | 14 -------- utils/api.js | 12 +++---- utils/config.js | 4 +-- 7 files changed, 125 insertions(+), 77 deletions(-) create mode 100644 prompt/增加预约记录核验.md delete mode 100644 todo.md diff --git a/pages/scan/result/index.js b/pages/scan/result/index.js index ca22d46..03a91f4 100644 --- a/pages/scan/result/index.js +++ b/pages/scan/result/index.js @@ -42,16 +42,17 @@ Page({ 'cancelled': '已取消' } - // checkStatus 为字符串:'0' 未核销,'1' 已核销 - const checkStatus = String(result.checkStatus) - const checkStatusText = checkStatus === '1' ? '已核销' : '未核销' + const checkStatusMap = { + '1': '已核销', + '0': '未核销' + } this.setData({ record: { ...formatRecord(result), statusText: statusMap[result.status] || result.status, - checkStatus: checkStatus, - checkStatusText: checkStatusText + checkStatusText: checkStatusMap[result.checkStatus] || '未核销', + isChecked: result.checkStatus === '1' }, loading: false }) @@ -61,30 +62,37 @@ Page({ } }, - async onVerify() { - const { record, verifying } = this.data - if (verifying || !record || !record.id) return + async handleVerify() { + const { record } = this.data + if (!record || record.isChecked || this.data.verifying) return - wx.showModal({ - title: '确认核销', - content: '确定要核销该预约记录吗?', - confirmColor: '#1890ff', - success: async (res) => { - if (!res.confirm) return - - this.setData({ verifying: true }) - try { - await appointmentDB.notifyHost(record.id) - wx.showToast({ title: '核销成功', icon: 'success' }) - // 刷新详情页 - this.loadRecordDetail(record.id) - } catch (err) { - console.error('核销失败', err) - wx.showToast({ title: '核销失败,请重试', icon: 'none' }) - } finally { - this.setData({ verifying: false }) - } - } + const confirmed = await new Promise((resolve) => { + wx.showModal({ + title: '确认核销', + content: '确认通知被访人访客已到达并核销此预约记录?', + confirmText: '确认核销', + confirmColor: '#1890ff', + success: (res) => resolve(res.confirm) + }) }) + + if (!confirmed) return + + try { + this.setData({ verifying: true }) + await appointmentDB.notifyHostArrival(record._id) + + this.setData({ + 'record.isChecked': true, + 'record.checkStatusText': '已核销', + verifying: false + }) + + wx.showToast({ title: '核销成功,已通知被访人', icon: 'success' }) + } catch (err) { + console.error('核销失败', err) + this.setData({ verifying: false }) + wx.showToast({ title: err.message || '核销失败,请稍后重试', icon: 'none' }) + } } }) \ No newline at end of file diff --git a/pages/scan/result/index.wxml b/pages/scan/result/index.wxml index e82be45..1d4c36a 100644 --- a/pages/scan/result/index.wxml +++ b/pages/scan/result/index.wxml @@ -66,16 +66,21 @@ - - + + 核销状态 - {{record.checkStatusText}} + {{record.checkStatusText}} - - - {{verifying ? '核销中...' : '确认核销'}} - + + + 该预约记录已核销 diff --git a/pages/scan/result/index.wxss b/pages/scan/result/index.wxss index 8a33141..c5e81dd 100644 --- a/pages/scan/result/index.wxss +++ b/pages/scan/result/index.wxss @@ -57,7 +57,7 @@ justify-content: space-between; padding: 30rpx; border-bottom: 1rpx solid #f0f0f0; - background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + background: #5b9bd5; } .detail-header .title { @@ -135,34 +135,47 @@ word-break: break-all; } -/* 核销状态文字 */ -.text-warning { - color: #faad14; - font-weight: bold; +/* 核销区块 */ +.check-section { + padding: 30rpx; + border-top: 1rpx solid #f0f0f0; } -.text-success { +.check-status { + font-size: 28rpx; + font-weight: bold; + padding: 6rpx 16rpx; + border-radius: 8rpx; +} + +.check-status.checked { color: #52c41a; - font-weight: bold; + background-color: #f6ffed; } -/* 核销按钮 */ -.verify-btn-wrap { - padding-top: 20rpx; +.check-status.unchecked { + color: #faad14; + background-color: #fffbe6; } .verify-btn { - width: 100%; - height: 80rpx; - line-height: 80rpx; - text-align: center; - background: linear-gradient(135deg, #1890ff 0%, #096dd9 100%); + margin-top: 30rpx; + background: #5b9bd5; color: #fff; - font-size: 30rpx; - font-weight: bold; border-radius: 12rpx; + font-size: 30rpx; + height: 88rpx; + line-height: 88rpx; } -.verify-btn-disabled { - opacity: 0.6; +.verify-btn::after { + border: none; +} + +.verified-tip { + margin-top: 24rpx; + text-align: center; + font-size: 24rpx; + color: #999; + padding: 16rpx 0; } \ No newline at end of file diff --git a/prompt/增加预约记录核验.md b/prompt/增加预约记录核验.md new file mode 100644 index 0000000..f0c622a --- /dev/null +++ b/prompt/增加预约记录核验.md @@ -0,0 +1,38 @@ +### 任务目标 +pages/scan/result/index 页面增加核销功能和显示核销状态功能 + +### 详细要求 +pages/scan/result/index 最下面增加一个核销按钮,显示check_status,未核销时候可以点击按钮 +调用/visitor/notify-host 进行通知被访人和核销预约记录。分析项目信息,编码必须符合项目架构和风格。 +同时考虑用户体验与交互优化。 +### api数据 +后端接口文件 +I:\code\xxc\minispringboot\src\main\java\com\example\mini_program\controller\AppointmentController.java +I:\code\xxc\minispringboot\src\main\java\com\example\mini_program\controller\VisitorApprovalController.java +参考两个文件中的接口信息和项目中的数据结构 +``` +@GetMapping("/detail") +public Result getDetail(@RequestParam String id) { +if (id == null || id.trim().isEmpty()) { +return Result.error("id不能为空"); +} +return Result.success(appointmentService.getDetail(id)); +} +``` +和 +``` + @GetMapping("/notify-host") + public Result notifyHostArrival(@RequestParam String id) { + log.info("通知受访者访客已到达, id={}", id); + if (id == null || id.trim().isEmpty()) { + return Result.error("预约记录ID不能为空"); + } + try { + visitorApprovalService.notifyHostArrival(id); + return Result.success("通知发送成功"); + } catch (Exception e) { + log.error("通知发送失败, id={}", id, e); + return Result.error("通知发送失败: " + e.getMessage()); + } + } +`` diff --git a/todo.md b/todo.md deleted file mode 100644 index 0f643bd..0000000 --- a/todo.md +++ /dev/null @@ -1,14 +0,0 @@ -# 项目目标 -开发微信小程序,实现一个简单的访客预约系统,用于协能工厂区域的访问管理。 -预约功能页面可以选择预约时间和预约人,并提交预约信息。 -预约记录页面可以查看预约记录,和预约进度结果和取消预约。 -目前不需要进行登录和注册功能,可以直接使用微信小程序的登录和注册功能。 -# 系统功能需求 -### 主要页面 -1. 访客预约操作页面,小程序的首页可以选择跳转预约功能页面和选择跳转进入预约记录页面。 -2. 预约功能页面,选择预约时间和预约人,并提交预约信息。 - -3. 预约记录页面,可以查看预约记录,和预约进度结果和取消预约。 - -### 编码原则 -目前不需要后端信息,使用硬编码模拟数据 \ No newline at end of file diff --git a/utils/api.js b/utils/api.js index 743eff4..79e766e 100644 --- a/utils/api.js +++ b/utils/api.js @@ -200,18 +200,16 @@ const appointmentDB = { }, /** - * 核销通知被访人 + * 核销预约记录(通知被访人访客已到达) * @param {string} id - 预约记录 id - * @returns {Promise} + * @returns {Promise} 操作结果 */ - async notifyHost(id) { - await request({ + async notifyHostArrival(id) { + return await request({ url: BASE_URL + API.NOTIFY_HOST, - method: 'POST', - header: { 'content-type': 'application/json' }, + method: 'GET', data: { id } }) - return true } } diff --git a/utils/config.js b/utils/config.js index d6469ed..b299803 100644 --- a/utils/config.js +++ b/utils/config.js @@ -6,8 +6,8 @@ const ENV_CONFIG = { // release: 'https://xcx.yun.588580.xyz', trial: 'https://qywx.yun.588580.xyz', // 开发版 & 体验版 - // develop: 'http://172.16.60.235:8080' - develop: 'http://10.50.13.191:8080' + develop: 'http://172.16.60.235:8080' + // develop: 'http://10.50.13.191:8080' } // 自动判断当前运行环境