|
|
@ -4,20 +4,107 @@ import { reactive, ref, onMounted, getCurrentInstance } from "vue"; |
|
|
|
import confirmTemplate from "../../components/confirm_template.vue"; |
|
|
|
import ticketItem from "../../components/ticket_item.vue"; |
|
|
|
import venueInfo from "../../components/venue_info.vue"; |
|
|
|
import { jsapiPreVerifyCertificates, orderAdd } from "../../api"; |
|
|
|
import { routeTo, showModal, showLoad, hideLoad } from '@/utils/polish'; |
|
|
|
const stadiumInfo = ref({}); |
|
|
|
const ticketInfo = ref({}); |
|
|
|
const venueData = ref({}); |
|
|
|
|
|
|
|
const verify_token = ref(''); |
|
|
|
const APPID = tt.getEnvInfoSync()?.microapp?.appId ?? ''; |
|
|
|
onMounted(() =>{ |
|
|
|
const instance = getCurrentInstance().proxy |
|
|
|
const eventChannel = instance.getOpenerEventChannel(); |
|
|
|
eventChannel.on('dataFromGrouponSiteSelect', data => { |
|
|
|
stadiumInfo.value = data?.stadium ?? {}; |
|
|
|
ticketInfo.value = data?.ticket ?? {}; |
|
|
|
venueData.value = data?.venueInfo ?? {}; |
|
|
|
let { stadium, ticket, venueInfo } = data; |
|
|
|
stadiumInfo.value = stadium ?? {}; |
|
|
|
ticketInfo.value = ticket ?? {}; |
|
|
|
venueData.value = venueInfo ?? {}; |
|
|
|
|
|
|
|
console.warn('dataFromGrouponSiteSelect data', data); |
|
|
|
let _classTags = (venueInfo?.venues ?? []).map(e=>e?._class_tag ?? ''); |
|
|
|
pvc_func({ |
|
|
|
appid: APPID, |
|
|
|
brand_id: stadium?.brand_id ?? '', |
|
|
|
stadium_id: stadium?.id ?? '', |
|
|
|
encrypted_codes: ticket?.encrypted_codes ?? '', |
|
|
|
douyin_merchant_pay_amount: ticket?.douyin_merchant_pay_amount ?? '', |
|
|
|
certificate_id: ticket?.certificate_id ?? '', |
|
|
|
certificate: ticket?.certificates ?? null, |
|
|
|
// 场地新增参数 |
|
|
|
classify: venueInfo?.classify ?? '', |
|
|
|
class_tags: _classTags.filter(e=>e!=='').join(','), |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
function pvc_func(data){ |
|
|
|
jsapiPreVerifyCertificates({ data }) |
|
|
|
.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: _tVal?.poi_id ?? '', |
|
|
|
orderList: [{ |
|
|
|
orderId: _tVal?.order_id ?? '', |
|
|
|
certificateList: [ _tVal?.certificate_id ?? '' ] |
|
|
|
}], |
|
|
|
orderEntrySchema: { |
|
|
|
// 后端: 把verify_token和c什么id那个作为参数, 到时候应该也用这两个反查 |
|
|
|
path: 'subpackage/order/pages/detail', |
|
|
|
params: JSON.stringify({ certificate_id: _tVal?.certificate_id ?? '' }), |
|
|
|
}, |
|
|
|
success(res){ |
|
|
|
hideLoad(); |
|
|
|
console.warn('verifyCertificates success', res); |
|
|
|
showModal({ content: '核销成功!' }); |
|
|
|
let _classTags = (venueData.value?.venues ?? []).map(e=>e?._class_tag ?? ''); |
|
|
|
createBookOrder({ |
|
|
|
appid: APPID, |
|
|
|
brand_id: stadiumInfo.value?.brand_id ?? '', |
|
|
|
stadium_id: stadiumInfo.value?.id ?? '', |
|
|
|
date: venueData.value?.date, |
|
|
|
sessions: (venueData.value?.venues || []).map(el=>({ |
|
|
|
venue_id: el?.venue_id ?? '', |
|
|
|
duration: el?.time ?? '', |
|
|
|
price: el?.price ?? 0, |
|
|
|
tag: el?._class_tag ?? '', |
|
|
|
})), |
|
|
|
type_key: venueData.value?.classify ?? '', |
|
|
|
class_tags_enable: _classTags.filter(e=>e!=='').join(','), |
|
|
|
verify_token: verify_token.value ?? '', |
|
|
|
douyin_merchant_pay_amount: _tVal?.douyin_merchant_pay_amount ?? 0, |
|
|
|
douyin_groupon_coupon_code: _tVal?.certificate_id ?? '' |
|
|
|
}) |
|
|
|
}, |
|
|
|
fail(err){ |
|
|
|
hideLoad(); |
|
|
|
console.warn('verifyCertificates fail', err); |
|
|
|
showModal({ content: err?.errMsg ?? '兑换操作失败!' }) |
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
console.log('tt.verifyCertificates data -->', _query) |
|
|
|
showLoad(); |
|
|
|
return tt.verifyCertificates(_query); |
|
|
|
} |
|
|
|
|
|
|
|
function createBookOrder(data){ |
|
|
|
orderAdd({ data }) |
|
|
|
.then(res=>{ |
|
|
|
console.log('createBookOrder', res); |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
<template> |
|
|
@ -43,7 +130,7 @@ onMounted(() =>{ |
|
|
|
<image class="tti-icon" mode="aspectFit" src="@/subpackage/groupon/static/images/ticket_icon.png"></image> |
|
|
|
<view class="tti-right"> |
|
|
|
<view class="tr-txt">团购券 <text class="tt-orange">(已选1张)</text> </view> |
|
|
|
<view class="tr-price">团购券抵扣6小时,-¥600.00</view> |
|
|
|
<view class="tr-price">{{ ticketInfo?.merchandise_name ?? '-' }}</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
<view class="vc-box vc-groupon"> |
|
|
@ -68,6 +155,15 @@ onMounted(() =>{ |
|
|
|
<view class="vc-txt">*同一订单不支持部分场次退款</view> |
|
|
|
</view> |
|
|
|
</view> |
|
|
|
|
|
|
|
<template #fixed> |
|
|
|
<view class="ti-fixed"> |
|
|
|
<view class="cf-price" v-if="0 >= 0"> |
|
|
|
<text class="cp-txt">应付金额:</text> ¥{{ 0 }} |
|
|
|
</view> |
|
|
|
<button v-if="verify_token" class="cf-btn" :class="{ 'cf-full': 0 < 0 }" @click="confirmBtn" data-eventsync>确认兑换</button> |
|
|
|
</view> |
|
|
|
</template> |
|
|
|
</confirm-template> |
|
|
|
</template> |
|
|
|
|
|
|
@ -151,4 +247,30 @@ 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); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
</style> |