|
|
@@ -87,37 +87,61 @@ function next() {
|
|
|
showProtocol.value = false
|
|
|
}
|
|
|
|
|
|
+async function handleH5PayResult(orderNumber: string) {
|
|
|
+ const isPaySuccess = await useUserStore().pollOrderPaySuccess(orderNumber)
|
|
|
+ if (isPaySuccess) {
|
|
|
+ await useUserStore().paySuccess('film-order', 'subPack-film/index/index')
|
|
|
+ return
|
|
|
+ }
|
|
|
+ useGlobalToast().show({ msg: '暂未查询到支付成功,请稍后在订单列表查看' })
|
|
|
+}
|
|
|
+
|
|
|
async function pay() {
|
|
|
loading.value = true
|
|
|
- console.log(info.value.chooseSeatList)
|
|
|
- query.value.fastTicket = isWithin45Minutes(new Date(), info.value.showTime)
|
|
|
- query.value.movieOrderItems = info.value.chooseSeatList.map((item: any) => {
|
|
|
- if (isWithin45Minutes(new Date(), info.value.showTime)) { // 如果在45分钟内,快速出票
|
|
|
- return {
|
|
|
- name: item.seatName,
|
|
|
- price: item.fastPrice,
|
|
|
+ try {
|
|
|
+ query.value.fastTicket = isWithin45Minutes(new Date(), info.value.showTime)
|
|
|
+ query.value.movieOrderItems = info.value.chooseSeatList.map((item: any) => {
|
|
|
+ if (isWithin45Minutes(new Date(), info.value.showTime)) { // 如果在45分钟内,快速出票
|
|
|
+ return {
|
|
|
+ name: item.seatName,
|
|
|
+ price: item.fastPrice,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ return {
|
|
|
+ name: item.seatName,
|
|
|
+ price: item.ticketPrice,
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const { data: orderNumber } = await Apis.film.addFilmOrder({ data: query.value })
|
|
|
+ const payMent = await useUserStore().getPayMent(orderNumber)
|
|
|
+ if (payMent.payType !== 'point') {
|
|
|
+ try {
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
+ const res = await useUserStore().handleCommonPayMent(orderNumber)
|
|
|
+ await useUserStore().getWxCommonPayment(res)
|
|
|
+ await useUserStore().paySuccess('film-order', 'subPack-film/index/index')
|
|
|
+ // #endif
|
|
|
+ // #ifdef H5
|
|
|
+ useUserStore().handleCommonWechatPay(orderNumber)
|
|
|
+ await handleH5PayResult(orderNumber)
|
|
|
+ // #endif
|
|
|
+ }
|
|
|
+ catch {
|
|
|
+ await useUserStore().payError('film-order', 'subPack-film/index/index')
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- return {
|
|
|
- name: item.seatName,
|
|
|
- price: item.ticketPrice,
|
|
|
- }
|
|
|
+ await useUserStore().handleCommonPayMent(orderNumber)
|
|
|
+ await useUserStore().paySuccess('film-order', 'subPack-film/index/index')
|
|
|
}
|
|
|
- })
|
|
|
- const { data: orderNumber } = await Apis.film.addFilmOrder({ data: query.value })
|
|
|
- const res = await useUserStore().handleCommonPayMent(orderNumber)
|
|
|
- loading.value = false
|
|
|
- if (res.payType !== 1) {
|
|
|
- // await getWxCommonPayment(res)
|
|
|
- uni.showToast({
|
|
|
- title: '当前只支持积分支付',
|
|
|
- icon: 'none',
|
|
|
- duration: 2000,
|
|
|
- })
|
|
|
}
|
|
|
- else {
|
|
|
- await useUserStore().paySuccess('film-order', 'subPack-film/index/index')
|
|
|
+ catch (error) {
|
|
|
+ console.error('支付失败:', error)
|
|
|
+ }
|
|
|
+ finally {
|
|
|
+ loading.value = false
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -139,9 +163,14 @@ async function getPoints() {
|
|
|
getPoints()
|
|
|
|
|
|
function usePoints() {
|
|
|
- return (totalPrice.value * 100) >= info.value.points ? info.value.points : ((totalPrice.value * 10000) / 100)
|
|
|
+ return Math.round(totalPrice.value * 100) >= info.value.points ? info.value.points : Math.round(totalPrice.value * 100)
|
|
|
}
|
|
|
|
|
|
+const actualPayPrice = computed(() => {
|
|
|
+ const result = (Math.round(totalPrice.value * 100) - usePoints()) / 100
|
|
|
+ return Math.max(0, Number(result.toFixed(2)))
|
|
|
+})
|
|
|
+
|
|
|
onLoad((options) => {
|
|
|
query.value = JSON.parse(options?.query)
|
|
|
info.value = uni.getStorageSync('film-info')
|
|
|
@@ -255,7 +284,7 @@ onLoad((options) => {
|
|
|
总计
|
|
|
</view>
|
|
|
<view class="total">
|
|
|
- ¥{{ (totalPrice * 100 - usePoints()) / 100 }}
|
|
|
+ ¥{{ actualPayPrice }}
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -294,7 +323,7 @@ onLoad((options) => {
|
|
|
<view class="footer-box">
|
|
|
<view class="price-box">
|
|
|
<view class="total">
|
|
|
- ¥{{ (totalPrice * 100 - usePoints()) / 100 }}
|
|
|
+ ¥{{ actualPayPrice }}
|
|
|
</view>
|
|
|
<view class="reduce">
|
|
|
共减¥{{ usePoints() / 100 }}
|