fix(核销结果): 修复核销结果页面显示问题并优化代码
重构核销结果页面,将result_content重命名为verify_result_text以更准确表达用途 添加对核销结果数据的格式化显示支持 优化按钮字体大小和代码结构 更新页面标题为'义工核销' 添加TODO注释说明登录功能需要联调
Showing
3 changed files
with
48 additions
and
14 deletions
| 1 | +/* | ||
| 2 | + * @Date: 2026-01-07 17:41:38 | ||
| 3 | + * @LastEditors: hookehuyr hookehuyr@gmail.com | ||
| 4 | + * @LastEditTime: 2026-01-14 10:16:08 | ||
| 5 | + * @FilePath: /xyxBooking-weapp/src/pages/verificationResult/index.config.js | ||
| 6 | + * @Description: 核销结果配置 | ||
| 7 | + */ | ||
| 1 | export default { | 8 | export default { |
| 2 | - navigationBarTitleText: '核销' | 9 | + navigationBarTitleText: '义工核销' |
| 3 | } | 10 | } | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2026-01-08 13:01:20 | 2 | * @Date: 2026-01-08 13:01:20 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2026-01-14 10:07:56 | 4 | + * @LastEditTime: 2026-01-14 10:14:28 |
| 5 | * @FilePath: /xyxBooking-weapp/src/pages/verificationResult/index.vue | 5 | * @FilePath: /xyxBooking-weapp/src/pages/verificationResult/index.vue |
| 6 | * @Description: 核销结果页面 | 6 | * @Description: 核销结果页面 |
| 7 | --> | 7 | --> |
| ... | @@ -19,15 +19,24 @@ | ... | @@ -19,15 +19,24 @@ |
| 19 | </view> | 19 | </view> |
| 20 | </view> | 20 | </view> |
| 21 | 21 | ||
| 22 | - <view v-if="result_content" class="mt-4 rounded-2xl bg-white p-5 shadow-sm"> | 22 | + <view v-if="verify_result_text" class="mt-4 rounded-2xl bg-white p-5 shadow-sm"> |
| 23 | <view class="text-xs text-gray-500">核销结果</view> | 23 | <view class="text-xs text-gray-500">核销结果</view> |
| 24 | - <view class="mt-2 break-all text-sm font-medium text-gray-900">{{ result_content }}</view> | 24 | + <view class="mt-2 break-all whitespace-pre-wrap text-sm font-medium text-gray-900">{{ verify_result_text }}</view> |
| 25 | </view> | 25 | </view> |
| 26 | <view v-else class="mt-4 rounded-2xl bg-white p-5 shadow-sm"> | 26 | <view v-else class="mt-4 rounded-2xl bg-white p-5 shadow-sm"> |
| 27 | <view class="text-xs text-gray-500">核销结果</view> | 27 | <view class="text-xs text-gray-500">核销结果</view> |
| 28 | <view class="mt-2 text-sm text-gray-400">暂无核销结果,点击下方核销按钮开始扫码</view> | 28 | <view class="mt-2 text-sm text-gray-400">暂无核销结果,点击下方核销按钮开始扫码</view> |
| 29 | </view> | 29 | </view> |
| 30 | 30 | ||
| 31 | + <!-- <view v-if="verify_code" class="mt-4 rounded-2xl bg-white p-5 shadow-sm"> | ||
| 32 | + <view class="text-xs text-gray-500">预约码</view> | ||
| 33 | + <view class="mt-2 break-all text-sm font-medium text-gray-900">{{ verify_code }}</view> | ||
| 34 | + </view> | ||
| 35 | + <view v-else class="mt-4 rounded-2xl bg-white p-5 shadow-sm"> | ||
| 36 | + <view class="text-xs text-gray-500">预约码</view> | ||
| 37 | + <view class="mt-2 text-sm text-gray-400">暂无预约码</view> | ||
| 38 | + </view> --> | ||
| 39 | + | ||
| 31 | <view class="verify-footer"> | 40 | <view class="verify-footer"> |
| 32 | <nut-button | 41 | <nut-button |
| 33 | block | 42 | block |
| ... | @@ -51,7 +60,8 @@ import { verifyTicketAPI } from '@/api/index' | ... | @@ -51,7 +60,8 @@ import { verifyTicketAPI } from '@/api/index' |
| 51 | import Taro, { useDidShow } from '@tarojs/taro' | 60 | import Taro, { useDidShow } from '@tarojs/taro' |
| 52 | 61 | ||
| 53 | const router = useRouter() | 62 | const router = useRouter() |
| 54 | -const result_content = ref('') | 63 | +const verify_code = ref('') |
| 64 | +const verify_result = ref(null) | ||
| 55 | const verify_status = ref('idle') | 65 | const verify_status = ref('idle') |
| 56 | const msg = ref('请点击下方按钮进行核销') | 66 | const msg = ref('请点击下方按钮进行核销') |
| 57 | 67 | ||
| ... | @@ -74,26 +84,44 @@ const status_icon_color = computed(() => { | ... | @@ -74,26 +84,44 @@ const status_icon_color = computed(() => { |
| 74 | if (verify_status.value === 'fail') return '#E24A4A' | 84 | if (verify_status.value === 'fail') return '#E24A4A' |
| 75 | return '#A67939' | 85 | return '#A67939' |
| 76 | }) | 86 | }) |
| 77 | -/******************* END **********************/ | 87 | + |
| 88 | +const verify_result_text = computed(() => { | ||
| 89 | + const data = verify_result.value | ||
| 90 | + if (data === null || data === undefined) return '' | ||
| 91 | + if (typeof data === 'string') return data | ||
| 92 | + if (typeof data === 'number' || typeof data === 'boolean') return String(data) | ||
| 93 | + try { | ||
| 94 | + return JSON.stringify(data, null, 2) | ||
| 95 | + } catch (e) { | ||
| 96 | + return '' | ||
| 97 | + } | ||
| 98 | +}) | ||
| 78 | 99 | ||
| 79 | const verify_ticket = async (code) => { | 100 | const verify_ticket = async (code) => { |
| 80 | if (!code) return | 101 | if (!code) return |
| 81 | if (verify_status.value === 'verifying') return | 102 | if (verify_status.value === 'verifying') return |
| 82 | 103 | ||
| 83 | - result_content.value = code | 104 | + verify_code.value = code |
| 105 | + verify_result.value = null | ||
| 84 | verify_status.value = 'verifying' | 106 | verify_status.value = 'verifying' |
| 85 | msg.value = '核销中...' | 107 | msg.value = '核销中...' |
| 86 | 108 | ||
| 87 | Taro.showLoading({ title: '核销中...' }) | 109 | Taro.showLoading({ title: '核销中...' }) |
| 88 | try { | 110 | try { |
| 89 | const res = await verifyTicketAPI({ code }) | 111 | const res = await verifyTicketAPI({ code }) |
| 90 | - if (res?.code) { | 112 | + if (res?.code === 1) { |
| 91 | verify_status.value = 'success' | 113 | verify_status.value = 'success' |
| 92 | msg.value = res?.msg || '核销成功' | 114 | msg.value = res?.msg || '核销成功' |
| 115 | + if (res?.data !== undefined && res?.data !== null && res?.data !== '') { | ||
| 116 | + verify_result.value = res.data | ||
| 117 | + } | ||
| 93 | return | 118 | return |
| 94 | } | 119 | } |
| 95 | verify_status.value = 'fail' | 120 | verify_status.value = 'fail' |
| 96 | msg.value = res?.msg || '核销失败' | 121 | msg.value = res?.msg || '核销失败' |
| 122 | + if (res?.data !== undefined && res?.data !== null && res?.data !== '') { | ||
| 123 | + verify_result.value = res.data | ||
| 124 | + } | ||
| 97 | Taro.showToast({ title: msg.value, icon: 'none' }) | 125 | Taro.showToast({ title: msg.value, icon: 'none' }) |
| 98 | } catch (e) { | 126 | } catch (e) { |
| 99 | verify_status.value = 'fail' | 127 | verify_status.value = 'fail' |
| ... | @@ -105,12 +133,10 @@ const verify_ticket = async (code) => { | ... | @@ -105,12 +133,10 @@ const verify_ticket = async (code) => { |
| 105 | } | 133 | } |
| 106 | 134 | ||
| 107 | useDidShow(async () => { | 135 | useDidShow(async () => { |
| 108 | - /** | ||
| 109 | - * 现在主要用于:外部渠道如果手动带参进入则自动核销;正常业务流程(从义工登录进入)是不会带参的,会走缺省态 + 点击“核销”扫码。 | ||
| 110 | - */ | ||
| 111 | const code = router?.params?.result || '' | 136 | const code = router?.params?.result || '' |
| 112 | if (!code) { | 137 | if (!code) { |
| 113 | - result_content.value = '' | 138 | + verify_code.value = '' |
| 139 | + verify_result.value = null | ||
| 114 | verify_status.value = 'idle' | 140 | verify_status.value = 'idle' |
| 115 | msg.value = '请点击下方按钮进行核销' | 141 | msg.value = '请点击下方按钮进行核销' |
| 116 | return | 142 | return |
| ... | @@ -147,7 +173,7 @@ const start_scan_and_verify = () => { | ... | @@ -147,7 +173,7 @@ const start_scan_and_verify = () => { |
| 147 | } | 173 | } |
| 148 | 174 | ||
| 149 | .verify-btn { | 175 | .verify-btn { |
| 150 | - font-size: 36rpx; | 176 | + font-size: 32rpx; |
| 151 | height: 104rpx; | 177 | height: 104rpx; |
| 152 | line-height: 104rpx; | 178 | line-height: 104rpx; |
| 153 | border-radius: 16rpx; | 179 | border-radius: 16rpx; | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2026-01-08 13:01:56 | 2 | * @Date: 2026-01-08 13:01:56 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2026-01-14 09:59:46 | 4 | + * @LastEditTime: 2026-01-14 10:18:59 |
| 5 | * @FilePath: /xyxBooking-weapp/src/pages/volunteerLogin/index.vue | 5 | * @FilePath: /xyxBooking-weapp/src/pages/volunteerLogin/index.vue |
| 6 | * @Description: 义工登录页面 | 6 | * @Description: 义工登录页面 |
| 7 | --> | 7 | --> |
| ... | @@ -74,6 +74,7 @@ useDidShow(() => { | ... | @@ -74,6 +74,7 @@ useDidShow(() => { |
| 74 | check_permission_and_redirect() | 74 | check_permission_and_redirect() |
| 75 | }) | 75 | }) |
| 76 | 76 | ||
| 77 | +// TODO: 功能需要联调, 登录功能都是模拟, 实际登录需要后端接口支持 | ||
| 77 | const handleLogin = async () => { | 78 | const handleLogin = async () => { |
| 78 | if (!username.value || !password.value) { | 79 | if (!username.value || !password.value) { |
| 79 | Taro.showToast({ title: '请输入账号密码', icon: 'none' }) | 80 | Taro.showToast({ title: '请输入账号密码', icon: 'none' }) | ... | ... |
-
Please register or login to post a comment