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 ca4e5e3..255684a 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 }, @@ -244,6 +245,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 9fb895c..c1c2f48 100644 --- a/pages/orders/index.vue +++ b/pages/orders/index.vue @@ -1,34 +1,130 @@