|
@ -4,26 +4,29 @@ import { reactive, ref, onMounted, getCurrentInstance } from "vue"; |
|
|
import confirmTemplate from "../../components/confirm_template.vue"; |
|
|
import confirmTemplate from "../../components/confirm_template.vue"; |
|
|
import ticketItem from "../../components/ticket_item.vue"; |
|
|
import ticketItem from "../../components/ticket_item.vue"; |
|
|
import venueInfo from "../../components/venue_info.vue"; |
|
|
import venueInfo from "../../components/venue_info.vue"; |
|
|
import { jsapiPreVerifyCertificates, orderAdd, orderPayMini, computedPayInfo } from "../../api"; |
|
|
|
|
|
|
|
|
import { jsapiPreVerifyCertificates, orderAdd, orderPayMini, computedPayInfo, userCurrent } from "../../api"; |
|
|
import { routeTo, showModal, showLoad, hideLoad } from '@/utils/polish'; |
|
|
import { routeTo, showModal, showLoad, hideLoad } from '@/utils/polish'; |
|
|
import { accAdd } from "@/utils/calculation"; |
|
|
import { accAdd } from "@/utils/calculation"; |
|
|
const stadiumInfo = ref({}); |
|
|
const stadiumInfo = ref({}); |
|
|
const ticketInfo = ref({}); |
|
|
const ticketInfo = ref({}); |
|
|
const venueData = ref({}); |
|
|
const venueData = ref({}); |
|
|
const verify_token = ref(''); |
|
|
const verify_token = ref(''); |
|
|
|
|
|
const POI_ID = ref(''); |
|
|
const APPID = tt.getEnvInfoSync()?.microapp?.appId ?? ''; |
|
|
const APPID = tt.getEnvInfoSync()?.microapp?.appId ?? ''; |
|
|
|
|
|
const computedPrice = ref(-1); |
|
|
|
|
|
const MobileNum = ref(''); // 手机号码 |
|
|
onMounted(() =>{ |
|
|
onMounted(() =>{ |
|
|
|
|
|
setDefaultMobileNum(); |
|
|
const instance = getCurrentInstance().proxy |
|
|
const instance = getCurrentInstance().proxy |
|
|
const eventChannel = instance.getOpenerEventChannel(); |
|
|
const eventChannel = instance.getOpenerEventChannel(); |
|
|
eventChannel.on('dataFromGrouponSiteSelect', data => { |
|
|
|
|
|
|
|
|
eventChannel.on('dataFromGrouponSiteSelect', async data => { |
|
|
let { stadium, ticket, venueInfo } = data; |
|
|
let { stadium, ticket, venueInfo } = data; |
|
|
stadiumInfo.value = stadium ?? {}; |
|
|
stadiumInfo.value = stadium ?? {}; |
|
|
ticketInfo.value = ticket ?? {}; |
|
|
ticketInfo.value = ticket ?? {}; |
|
|
venueData.value = venueInfo ?? {}; |
|
|
venueData.value = venueInfo ?? {}; |
|
|
|
|
|
|
|
|
console.warn('dataFromGrouponSiteSelect data', data); |
|
|
|
|
|
let _classTags = (venueInfo?.venues ?? []).map(e=>e?._class_tag ?? ''); |
|
|
let _classTags = (venueInfo?.venues ?? []).map(e=>e?._class_tag ?? ''); |
|
|
pvc_func({ |
|
|
|
|
|
|
|
|
let _token = await pvc_func({ |
|
|
appid: APPID, |
|
|
appid: APPID, |
|
|
brand_id: stadium?.brand_id ?? '', |
|
|
brand_id: stadium?.brand_id ?? '', |
|
|
stadium_id: stadium?.id ?? '', |
|
|
stadium_id: stadium?.id ?? '', |
|
@ -35,12 +38,15 @@ onMounted(() =>{ |
|
|
classify: venueInfo?.classify ?? '', |
|
|
classify: venueInfo?.classify ?? '', |
|
|
class_tags: _classTags.filter(e=>e!=='').join(','), |
|
|
class_tags: _classTags.filter(e=>e!=='').join(','), |
|
|
}) |
|
|
}) |
|
|
|
|
|
if(!_token)return; |
|
|
let _totalPrice = 0; |
|
|
let _totalPrice = 0; |
|
|
venueInfo.venues.forEach(e=>{ |
|
|
venueInfo.venues.forEach(e=>{ |
|
|
_totalPrice = accAdd(_totalPrice, e?.price ?? 0); |
|
|
_totalPrice = accAdd(_totalPrice, e?.price ?? 0); |
|
|
}); |
|
|
}); |
|
|
|
|
|
// 如果你从接口获取的金额如果超过0就不给下订单 |
|
|
computedPayInfo({ |
|
|
computedPayInfo({ |
|
|
data: { |
|
|
data: { |
|
|
|
|
|
appid: APPID, |
|
|
brand_id: stadium?.brand_id ?? '', |
|
|
brand_id: stadium?.brand_id ?? '', |
|
|
stadium_id: stadium?.id ?? '', |
|
|
stadium_id: stadium?.id ?? '', |
|
|
amount: _totalPrice, |
|
|
amount: _totalPrice, |
|
@ -55,32 +61,37 @@ onMounted(() =>{ |
|
|
start: `${_date} ${start}:00`, |
|
|
start: `${_date} ${start}:00`, |
|
|
end: `${_date} ${end}:00`, |
|
|
end: `${_date} ${end}:00`, |
|
|
tag: e?._class_tag ?? '', |
|
|
tag: e?._class_tag ?? '', |
|
|
price: e?.price ?? 0, |
|
|
|
|
|
|
|
|
price: +(e?.price ?? 0), |
|
|
} |
|
|
} |
|
|
}), |
|
|
}), |
|
|
douyin_groupon_coupon_code: ticket?.certificate_id ?? '' |
|
|
douyin_groupon_coupon_code: ticket?.certificate_id ?? '' |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
.then(res=>{ |
|
|
.then(res=>{ |
|
|
console.warn('computedPayInfo--->', res); |
|
|
|
|
|
|
|
|
computedPrice.value = res?.data?.pay_amount ?? -1; |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
function pvc_func(data){ |
|
|
function pvc_func(data){ |
|
|
jsapiPreVerifyCertificates({ data }) |
|
|
|
|
|
|
|
|
return jsapiPreVerifyCertificates({ data }) |
|
|
.then(res=>{ |
|
|
.then(res=>{ |
|
|
// routeTo(`/subpackage/groupon/pages/exchange_success`); |
|
|
// routeTo(`/subpackage/groupon/pages/exchange_success`); |
|
|
console.log('jsapiPreVerifyCertificates', res); |
|
|
console.log('jsapiPreVerifyCertificates', res); |
|
|
verify_token.value = res?.data?.verify_token ?? ''; |
|
|
|
|
|
|
|
|
let _token = res?.data?.verify_token ?? ''; |
|
|
|
|
|
verify_token.value = _token; |
|
|
|
|
|
POI_ID.value = res?.data?.poi_id ?? ''; |
|
|
|
|
|
return _token |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function confirmBtn(){ |
|
|
function confirmBtn(){ |
|
|
|
|
|
if(computedPrice.value !== 0)return; |
|
|
|
|
|
if(!isPhoneNumber(MobileNum.value))return showModal({ content: '请输入正确的手机号码' }); |
|
|
let _tVal = ticketInfo.value; |
|
|
let _tVal = ticketInfo.value; |
|
|
const _query = { |
|
|
const _query = { |
|
|
verifyToken: verify_token.value ?? '', |
|
|
verifyToken: verify_token.value ?? '', |
|
|
poiId: _tVal?.poi_id ?? '', |
|
|
|
|
|
|
|
|
poiId: POI_ID.value ?? '', |
|
|
orderList: [{ |
|
|
orderList: [{ |
|
|
orderId: _tVal?.order_id ?? '', |
|
|
orderId: _tVal?.order_id ?? '', |
|
|
certificateList: [ _tVal?.certificate_id ?? '' ] |
|
|
certificateList: [ _tVal?.certificate_id ?? '' ] |
|
@ -128,6 +139,7 @@ function createServerOrder(){ |
|
|
verify_token: verify_token.value ?? '', |
|
|
verify_token: verify_token.value ?? '', |
|
|
douyin_merchant_pay_amount: _tVal?.douyin_merchant_pay_amount ?? 0, |
|
|
douyin_merchant_pay_amount: _tVal?.douyin_merchant_pay_amount ?? 0, |
|
|
douyin_groupon_coupon_code: _tVal?.certificate_id ?? '', |
|
|
douyin_groupon_coupon_code: _tVal?.certificate_id ?? '', |
|
|
|
|
|
mobile: MobileNum.value ?? '', |
|
|
}) |
|
|
}) |
|
|
.then(cRes=>{ |
|
|
.then(cRes=>{ |
|
|
console.log('createBookOrder', cRes); |
|
|
console.log('createBookOrder', cRes); |
|
@ -157,6 +169,15 @@ function createBookOrder(data){ |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function setDefaultMobileNum(e){ |
|
|
|
|
|
let _user = uni.getStorageSync('userInfo') || {}; |
|
|
|
|
|
MobileNum.value = _user?.mobile ?? ''; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function isPhoneNumber(number) { |
|
|
|
|
|
return /^1[3-9]\d{9}$/.test(number); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
</script> |
|
|
</script> |
|
|
|
|
|
|
|
|
<template> |
|
|
<template> |
|
@ -194,12 +215,12 @@ function createBookOrder(data){ |
|
|
<view class="vc-txt">温馨提示:团购券需一次性使用完,一经使用不退不换</view> |
|
|
<view class="vc-txt">温馨提示:团购券需一次性使用完,一经使用不退不换</view> |
|
|
</view> |
|
|
</view> |
|
|
<!-- 没有这个字段 --> |
|
|
<!-- 没有这个字段 --> |
|
|
<view class="vc-box vc-contact" v-if="false"> |
|
|
|
|
|
|
|
|
<view class="vc-box vc-contact"> |
|
|
<view class="vc-title">*联系方式:</view> |
|
|
<view class="vc-title">*联系方式:</view> |
|
|
<view class="vc-txt">为了场馆更好地为您服务,请准确填写您的联系方式</view> |
|
|
<view class="vc-txt">为了场馆更好地为您服务,请准确填写您的联系方式</view> |
|
|
<view class="vc-phone"> |
|
|
<view class="vc-phone"> |
|
|
<view class="vp-name">手机号码</view> |
|
|
<view class="vp-name">手机号码</view> |
|
|
<input type="phone" class="vp-ipt" /> |
|
|
|
|
|
|
|
|
<input type="phone" class="vp-ipt" v-model="MobileNum" /> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
</view> |
|
|
<view class="vc-box vc-notice"> |
|
|
<view class="vc-box vc-notice"> |
|
@ -210,11 +231,12 @@ function createBookOrder(data){ |
|
|
</view> |
|
|
</view> |
|
|
|
|
|
|
|
|
<template #fixed> |
|
|
<template #fixed> |
|
|
<view class="ti-fixed"> |
|
|
|
|
|
<view class="cf-price" v-if="0 >= 0"> |
|
|
|
|
|
<text class="cp-txt">应付金额:</text> ¥{{ 0 }} |
|
|
|
|
|
|
|
|
<view class="ti-fixed" v-if="computedPrice >= 0"> |
|
|
|
|
|
<view class="cf-price"> |
|
|
|
|
|
<text class="cp-txt">应付金额:</text> ¥{{ computedPrice }} |
|
|
</view> |
|
|
</view> |
|
|
<button v-if="verify_token" class="cf-btn" :class="{ 'cf-full': 0 < 0 }" @click="confirmBtn" data-eventsync>确认兑换</button> |
|
|
|
|
|
|
|
|
<!-- 后台 如果你从接口获取的金额如果超过0就不给下订单 --> |
|
|
|
|
|
<button v-if="verify_token&&computedPrice === 0" class="cf-btn" :class="{ 'cf-full': 0 < 0 }" @click="confirmBtn" data-eventsync>确认兑换</button> |
|
|
</view> |
|
|
</view> |
|
|
</template> |
|
|
</template> |
|
|
</confirm-template> |
|
|
</confirm-template> |
|
|