diff --git a/src/packages/user/api/douyin.ts b/src/packages/user/api/douyin.ts new file mode 100644 index 0000000..98a519b --- /dev/null +++ b/src/packages/user/api/douyin.ts @@ -0,0 +1,98 @@ +// xuchao: 抖音核销接口层。接口契约依赖后端 /mp-api/douyin/*;后端尚未提供时由 DOUYIN_BACKEND_READY 控制直接返回模拟数据以便测试。 +// xuchao: 后端就绪后只需将 DOUYIN_BACKEND_READY 置为 true,即可走真实请求(无需改其它代码)。 +import { post } from '../../../api/request' + +// xuchao: 后端 /mp-api/douyin/* 是否已就绪。false=用模拟数据测试;true=走真实后端。 +const DOUYIN_BACKEND_READY = false + +/** 券码实名信息(用于回填绑卡表单) */ +export interface VoucherRealnameInfo { + voucher_id: string + realname: string + card_id: string + /** 证件类型文案,如「身份证」 */ + card_type: string + mobile: string +} + +/** 单张券码(对齐小泥人 voucher-list 的 ret 元素) */ +export interface VoucherItem { + id: string + order_id: string + /** 券码,列表展示与提交均使用此值 */ + code: string + /** 1=未使用 3=已使用 5=已取消 */ + status: number + mobile: string + product_name: string + merchant_name: string + voucherRealnameInfo?: VoucherRealnameInfo[] +} + +export interface QueryVoucherListParams { + mobile: string + /** 1=未使用,默认查未使用 */ + status?: number +} + +export interface ActivateAndBindParams { + voucherId: string + voucherCode: string + quantity: number + mobile: string + userName: string + idType: string + idNo: string + faceImg: string +} + +const delay = (ms: number) => new Promise((r) => setTimeout(r, ms)) + +// xuchao: 模拟券码数据(后端未就绪时使用),含一条带实名信息用于验证回填。 +const MOCK_VOUCHERS: VoucherItem[] = [ + { + id: '1001', + order_id: 'DY202607280001', + code: '20260728192093019', + status: 1, + mobile: '', + product_name: '赣湘全域旅游年卡', + merchant_name: '爱上萍乡', + voucherRealnameInfo: [ + { voucher_id: '1001', realname: '张三', card_id: '360302199001011234', card_type: '身份证', mobile: '' }, + ], + }, + { + id: '1002', + order_id: 'DY202607280002', + code: '20260728192093011', + status: 1, + mobile: '', + product_name: '赣湘全域旅游年卡', + merchant_name: '爱上萍乡', + }, +] + +/** + * xuchao: 查询当前手机号可核销的券码列表。 + * 后端接口:POST /mp-api/douyin/voucherList,入参 { mobile, status }。 + */ +export async function queryVoucherList(params: QueryVoucherListParams): Promise { + if (!DOUYIN_BACKEND_READY) { + await delay(300) + return MOCK_VOUCHERS.map((v) => ({ ...v, mobile: params.mobile })) + } + return post('/mp-api/douyin/voucherList', params) +} + +/** + * xuchao: 激活且绑定(核销)。 + * 后端接口:POST /mp-api/douyin/activateAndBind,入参见 ActivateAndBindParams。 + */ +export async function activateAndBind(params: ActivateAndBindParams): Promise { + if (!DOUYIN_BACKEND_READY) { + await delay(800) + return + } + await post('/mp-api/douyin/activateAndBind', params) +} diff --git a/src/packages/user/pages/douyin-verify.vue b/src/packages/user/pages/douyin-verify.vue new file mode 100644 index 0000000..b17f965 --- /dev/null +++ b/src/packages/user/pages/douyin-verify.vue @@ -0,0 +1,863 @@ + + + + + diff --git a/src/pages.json b/src/pages.json index f73d441..9df75bd 100644 --- a/src/pages.json +++ b/src/pages.json @@ -136,6 +136,15 @@ "style": { "navigationBarTitleText": "预约/使用记录" } + }, + { + "path": "pages/douyin-verify", + "style": { + "navigationBarTitleText": "抖音核销", + "backgroundColor": "#FFFFFF", + "backgroundColorTop": "#FFFFFF", + "backgroundColorBottom": "#FFFFFF" + } } ] }, diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 5682e6f..3ffd275 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -200,10 +200,11 @@ function onBannerClick(banner: BannerItem) { /** 金刚区操作项 */ const quickActions = [ - { label: '我要绑卡', icon: 'https://aliyunoss.hntgov.net/pxmall/card.png' }, - { label: '我要预约', icon: 'https://aliyunoss.hntgov.net/pxmall/reserve.png' }, - { label: '我要入园', icon: 'https://aliyunoss.hntgov.net/pxmall/check.png' }, - { label: '常见问题', icon: 'https://aliyunoss.hntgov.net/pxmall/faq.png' }, + { label: '我要绑卡', icon: 'https://aliyunoss.hn12301.net/pxmall/card.png' }, + { label: '我要预约', icon: 'https://aliyunoss.hn12301.net/pxmall/reserve.png' }, + { label: '我要入园', icon: 'https://aliyunoss.hn12301.net/pxmall/check.png' }, + { label: '常见问题', icon: 'https://aliyunoss.hn12301.net/pxmall/faq.png' }, + { label: '抖音核销', icon: 'https://aliyunoss.hn12301.net/pxmall/douyin.png' }, ] /** 处理金刚区点击 */ @@ -228,6 +229,14 @@ function onQuickAction(item: { label: string }) { uni.navigateTo({ url: '/packages/content/pages/faq' }) return } + if (item.label === '抖音核销') { + if (!userStore.isLogin) { + uni.navigateTo({ url: '/pages/login/login' }) + return + } + uni.navigateTo({ url: '/packages/user/pages/douyin-verify' }) + return + } uni.showToast({ title: `${item.label}功能开发中`, icon: 'none' }) }