From bed414251c59095a2c6921ad74032b5bed82d072 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=96=B9=E6=88=90?= Date: Thu, 18 Dec 2025 14:39:37 +0800 Subject: [PATCH] feat: merge pending stash changes (orders, activity, api) and update docs --- api/appUser.js | 11 + components/YifanSelector.vue | 4 + pages/activity/duiduipeng/index.vue | 14 +- pages/orders/index.vue | 774 ++++++++++++++++++++++------ utils/subscribe.js | 90 ++++ 说明文档.md | 1 + 6 files changed, 731 insertions(+), 163 deletions(-) create mode 100644 utils/subscribe.js diff --git a/api/appUser.js b/api/appUser.js index 82ed485..0c30ab2 100644 --- a/api/appUser.js +++ b/api/appUser.js @@ -31,6 +31,17 @@ export function getOrders(user_id, status, page = 1, page_size = 20) { return authRequest({ url: `/api/app/users/${user_id}/orders`, method: 'GET', data }) } +// 获取订单详情 +export function getOrderDetail(order_id) { + return authRequest({ url: `/api/app/orders/${order_id}`, method: 'GET' }) +} + +// 取消订单 +export function cancelOrder(order_id, reason = '') { + const data = reason ? { reason } : {} + return authRequest({ url: `/api/app/orders/${order_id}/cancel`, method: 'POST', data }) +} + export function listAddresses(user_id) { return authRequest({ url: `/api/app/users/${user_id}/addresses`, method: 'GET' }) } diff --git a/components/YifanSelector.vue b/components/YifanSelector.vue index b6caf74..7e4fd81 100644 --- a/components/YifanSelector.vue +++ b/components/YifanSelector.vue @@ -55,6 +55,7 @@ import { ref, computed, onMounted, watch } from 'vue' import { getIssueChoices, getUserCoupons, joinLottery, createWechatOrder, getLotteryResult } from '@/api/appUser' import PaymentPopup from '@/components/PaymentPopup.vue' +import { requestLotterySubscription } from '@/utils/subscribe' const props = defineProps({ activityId: { type: [String, Number], required: true }, @@ -216,6 +217,9 @@ async function onPaymentConfirm(paymentData) { return } + // 请求用户订阅开奖通知 + await requestLotterySubscription() + uni.showLoading({ title: '处理中...' }) try { diff --git a/pages/activity/duiduipeng/index.vue b/pages/activity/duiduipeng/index.vue index 08ef370..1294afc 100644 --- a/pages/activity/duiduipeng/index.vue +++ b/pages/activity/duiduipeng/index.vue @@ -255,23 +255,25 @@ function onPreviewBanner() { if (url) uni.previewImage({ urls: [url], current: url }) } -function onParticipate() { +async function onParticipate() { const aid = activityId.value || '' const iid = currentIssueId.value || '' if (!aid || !iid) { uni.showToast({ title: '期数未选择', icon: 'none' }); return } + uni.showLoading({ title: '抽选中...' }) - drawActivityIssue(aid, iid).then(res => { - try { uni.hideLoading() } catch (_) {} + try { + const res = await drawActivityIssue(aid, iid) + uni.hideLoading() const obj = res || {} const data = obj.data || obj.result || obj.reward || obj.item || obj const name = String((data && (data.title || data.name || data.product_name)) || '未知奖励') const img = String((data && (data.image || data.img || data.pic || data.product_image)) || '') uni.showModal({ title: '抽选结果', content: '恭喜获得:' + name, showCancel: false, success: () => { if (img) uni.previewImage({ urls: [img], current: img }) } }) - }).catch(err => { - try { uni.hideLoading() } catch (_) {} + } catch (err) { + uni.hideLoading() const msg = String((err && (err.message || err.msg)) || '抽选失败') uni.showToast({ title: msg, icon: 'none' }) - }) + } } onLoad((opts) => { diff --git a/pages/orders/index.vue b/pages/orders/index.vue index 5d8f847..d46a364 100644 --- a/pages/orders/index.vue +++ b/pages/orders/index.vue @@ -1,34 +1,130 @@