diff --git a/src/api/server.js b/src/api/server.js index 4e244e5..2e96cb9 100644 --- a/src/api/server.js +++ b/src/api/server.js @@ -35,7 +35,7 @@ server.interceptors.request.use( server.interceptors.response.use( response => { loading.hide(response.config.loading); - if(response?.data?.code === 0)return formatResponse(response); + if([0].includes(response?.data?.code))return formatResponse(response); // console.error(`get ${response?.config?.url} err -> `, response) return errorHandle({ Catch: response?.config?.catch || false, diff --git a/src/subpackage/groupon/api/index.js b/src/subpackage/groupon/api/index.js index 314130f..8015646 100644 --- a/src/subpackage/groupon/api/index.js +++ b/src/subpackage/groupon/api/index.js @@ -7,6 +7,7 @@ export const bookList = params => server.post({ url: '/stadium/book/list', ...pa export const userCertificates = params => server.post({ url: '/douyinMiniapp/202506/postv1-api-trade-v2-fulfillment-query_user_certificates', ...params }); // 抖音团购券列表 export const countCity = params => server.post({ url: '/stadium/count/city', ...params }); // A主页-选择门店-城市列表 export const stadiumFind = params => server.post({ url: '/stadium/find', ...params }); // 门店列表 +export const jsapiPreVerifyCertificates = params => server.post({ url: '/douyinMiniapp/202506/jsapiPreVerifyCertificates', ...params }); // 票券核销 diff --git a/src/subpackage/groupon/components/confirm_template.vue b/src/subpackage/groupon/components/confirm_template.vue index 856bac1..79a61f4 100644 --- a/src/subpackage/groupon/components/confirm_template.vue +++ b/src/subpackage/groupon/components/confirm_template.vue @@ -36,10 +36,11 @@ onLoad(() => { - + + @@ -77,28 +78,29 @@ onLoad(() => { padding: 10upx 24upx; @include isPd(10upx); background-color: #fff; - @include ctf; - .cf-btn{ - flex-shrink: 0; - flex-grow: 0; - margin-left: 12upx; - width: 240upx; - text-align: center; - border-radius: 20upx; - background-color: $redColor; - @include flcw(32upx, 88upx, #fff); - &.cf-full{ - flex-grow: 1; - width: auto; - } - } - .cf-price{ - flex-grow: 1; - @include flcw(40upx, 56upx, $redColor, 500); - .cp-txt{ - @include flcw(28upx, 56upx, #333); - } - } + // @include ctf; + // .cf-btn{ + // @include clearBtn; + // flex-shrink: 0; + // flex-grow: 0; + // margin-left: 12upx; + // width: 240upx; + // text-align: center; + // border-radius: 20upx; + // background-color: $redColor; + // @include flcw(32upx, 88upx, #fff); + // &.cf-full{ + // flex-grow: 1; + // width: auto; + // } + // } + // .cf-price{ + // flex-grow: 1; + // @include flcw(40upx, 56upx, $redColor, 500); + // .cp-txt{ + // @include flcw(28upx, 56upx, #333); + // } + // } } } diff --git a/src/subpackage/groupon/pages/confirm_order/ticket.vue b/src/subpackage/groupon/pages/confirm_order/ticket.vue index dc00216..2b92536 100644 --- a/src/subpackage/groupon/pages/confirm_order/ticket.vue +++ b/src/subpackage/groupon/pages/confirm_order/ticket.vue @@ -3,8 +3,11 @@ import { onLoad } from '@dcloudio/uni-app'; import { reactive, ref, onMounted, getCurrentInstance, computed } from "vue"; import confirmTemplate from "../../components/confirm_template.vue"; import ticketItem from "../../components/ticket_item.vue"; +import { jsapiPreVerifyCertificates } from "../../api"; +import { routeTo, showModal } from '@/utils/polish'; const stadiumInfo = ref({}); // 场馆信息 const ticketInfo = ref({}); // 票券信息 +const verify_token = ref(''); onLoad(() => { }); @@ -16,10 +19,79 @@ onMounted(() =>{ const instance = getCurrentInstance().proxy const eventChannel = instance.getOpenerEventChannel(); eventChannel.on('dataFromGrouponStadiums', function(data) { - ticketInfo.value = data?.ticket || {}; - stadiumInfo.value = data?.stadium || {}; + let { ticket, stadium } = data; + ticketInfo.value = ticket || {}; + stadiumInfo.value = stadium || {}; + pvc_func({ + encrypted_codes: ticket?.encrypted_codes ?? '', + stadium_id: stadium?.id ?? '', + douyin_merchant_pay_amount: ticket?.douyin_merchant_pay_amount ?? '', + certificate_id: ticket?.certificate_id ?? '', + }) }) }) +function pvc_func({ + encrypted_codes, stadium_id, douyin_merchant_pay_amount, certificate_id +}){ + jsapiPreVerifyCertificates({ + data: { + encrypted_codes, stadium_id, douyin_merchant_pay_amount, certificate_id + }, + }) + .then(res=>{ + // routeTo(`/subpackage/groupon/pages/exchange_success`); + console.log('jsapiPreVerifyCertificates', res); + verify_token.value = res?.data?.verify_token ?? ''; + }) +} +function confirmBtn(){ + let _tVal = ticketInfo.value; + + const _query = { + verifyToken: verify_token.value ?? '', + poiId: '7174984639059068985', + orderList: [{ + orderId: _tVal?.order_id ?? '', + certificateList: [{ + code: _tVal?.certificate_id ?? '', + times: 1 + }] + }], + orderEntrySchema: { + path: 'subpackage/order/pages/detail' + }, + success(res){ + console.warn('verifyCertificates success', res); + + }, + fail(err){ + console.warn('verifyCertificates fail', err); + showModal({ content: err?.errMsg ?? '兑换操作失败!' }) + }, + + } + console.log('tt.verifyCertificates data -->', _query) + return tt.verifyCertificates(_query); + jsapiPreVerifyCertificates({ + data: { + encrypted_codes: _tVal?.encrypted_codes ?? '', + verify_token: _tVal?.verify_token ?? '', + stadium_id: stadiumInfo.value?.id ?? '', + douyin_merchant_pay_amount: _tVal?.douyin_merchant_pay_amount ?? '', + certificate_id: _tVal?.certificate_id ?? '', + }, + Catch: true, + }) + .then(res=>{ + // routeTo(`/subpackage/groupon/pages/exchange_success`); + console.log('jsapiPreVerifyCertificates', res); + + console.log('verifyCertificates data -->', _query) + + }) + + +} @@ -128,5 +209,31 @@ onMounted(() =>{ } } } + +} +.ti-fixed{ + @include ctf; + .cf-btn{ + @include clearBtn; + flex-shrink: 0; + flex-grow: 0; + margin-left: 12upx; + width: 240upx; + text-align: center; + border-radius: 20upx; + background-color: $redColor; + @include flcw(32upx, 88upx, #fff); + &.cf-full{ + flex-grow: 1; + width: auto; + } + } + .cf-price{ + flex-grow: 1; + @include flcw(40upx, 56upx, $redColor, 500); + .cp-txt{ + @include flcw(28upx, 56upx, #333); + } + } } diff --git a/src/subpackage/groupon/pages/list.vue b/src/subpackage/groupon/pages/list.vue index 438fb6e..5293ec9 100644 --- a/src/subpackage/groupon/pages/list.vue +++ b/src/subpackage/groupon/pages/list.vue @@ -6,20 +6,20 @@ import { routeTo, showModal } from '@/utils/polish'; import { userCertificates } from "../api"; const ticketLs = ref([]); onLoad(() => { - tt.login({ - success() { - tt.showToast({ - title: '登录成功', - icon: 'success', - }); - }, - fail() { - tt.showToast({ - title: '登录失败', - icon: 'fail', - }); - }, - }); + // tt.login({ + // success() { + // tt.showToast({ + // title: '登录成功', + // icon: 'success', + // }); + // }, + // fail() { + // tt.showToast({ + // title: '登录失败', + // icon: 'fail', + // }); + // }, + // }); userCertificates({ data: { debug: 1, @@ -38,27 +38,47 @@ onLoad(() => { function ticketClick(e){ let [ certificates ] = e?.certificates || []; - + let _ouxuan_group_purchase_info = certificates?.sku_info?.ouxuan_group_purchase_info ?? {}; + let _merchandise_type = _ouxuan_group_purchase_info?.merchandise_type; + if(![0, 1].includes(_merchandise_type))return showModal({ content: '无效的商品类型' }); + // const _query = { + // verifyToken: new Date().getTime() + '', + // poiId: '7174984639059068985', + // orderList: [{ + // orderId: e.order_id, + // certificateList: [{ + // code: certificates.certificate_id, + // times: 1 + // }] + // }], + // orderEntrySchema: { + // path: 'subpackage/order/pages/detail' + // }, + // complete(res){ + // console.warn('verifyCertificates', res); + // } - tt.verifyCertificates({ - verifyToken: new Date().getTime() + '', - poiId: 7441486703712337958 +'', - orderList: [{ - orderId: e.order_id, - certificateList: [{ - code: certificates.certificate_id, - times: 1 - }] - }], - orderEntrySchema: { - path: 'subpackage/order/pages/detail' - }, - complete(res){ - console.warn('verifyCertificates', res); - } + // } + // console.log('tt.verifyCertificates -->', _query) + // tt.verifyCertificates(_query); - }) - return + // return + let _ticketInfo = { + expire_time: certificates?.expire_time ?? 0, + dy_title: certificates?.sku_info?.title ?? '', + merchandise_name: _ouxuan_group_purchase_info?.merchandise_name ?? '', + // merchandise_type 1-> 订场,0-> 次卡 + merchandise_type: _merchandise_type, + // tt.verifyCertificates 需要参数 + order_id: e?.order_id ?? '', + verify_token: `${new Date().getTime()}`, + poi_id: '7174984639059068985', + certificate_id: certificates?.certificate_id ?? '', + // 后端接口需要 + encrypted_codes: certificates?.encrypted_code ?? '', + douyin_merchant_pay_amount: certificates?.amount?.pay_amount ?? 0, + + } uni.navigateTo({ url: `/subpackage/groupon/pages/stadiums`, success: res => { @@ -73,7 +93,7 @@ function ticketClick(e){