|
@@ -5,9 +5,12 @@
|
|
|
<view class="g-shoping-info" v-if="previewCourseInfo">
|
|
|
<image class="shoping-img" :src="previewCourseInfo.cover" mode=""></image>
|
|
|
<view class="shoping-info">
|
|
|
- <view class="name">{{ previewCourseInfo.placeName||previewCourseInfo.name }}</view>
|
|
|
+ <view class="name">{{ previewCourseInfo.placeName || previewCourseInfo.name }}</view>
|
|
|
<view class="price-info">
|
|
|
- <view class="price"><text class="mini-text">¥</text>{{ previewCourseInfo?.sellingPrice.toFixed(2) }}</view>
|
|
|
+ <!-- previewCourseInfo?.originalPrice字段用来判断是课程订单还是场地订单 -->
|
|
|
+ <view class="price"><text class="mini-text">¥</text>{{ previewCourseInfo?.originalPrice ?
|
|
|
+ previewCourseInfo?.originalPrice : previewCourseInfo?.sellingPrice.toFixed(2)
|
|
|
+ }}</view>
|
|
|
<view class="price-stepper">
|
|
|
<view class="minus" @click="minusNum">-</view>
|
|
|
<input v-model="countTotal" disabled type="number" />
|
|
@@ -18,8 +21,11 @@
|
|
|
</view>
|
|
|
<view class="g-shoping-total">
|
|
|
<view class="total-price">
|
|
|
- <view class="">商品总价(共1件)</view>
|
|
|
- <view class="">¥{{ previewCourseInfo?.sellingPrice.toFixed(2) }}</view>
|
|
|
+ <view class="">商品总价(共{{ countTotal }}件)</view>
|
|
|
+ <view class="">¥{{
|
|
|
+ previewCourseInfo?.originalPrice ? (previewCourseInfo?.originalPrice * countTotal).toFixed(2) :
|
|
|
+ previewCourseInfo?.sellingPrice.toFixed(2)
|
|
|
+ * countTotal }}</view>
|
|
|
</view>
|
|
|
<view class="total-price">
|
|
|
<view class="">
|
|
@@ -27,12 +33,23 @@
|
|
|
<text v-if="buyType == 0 || placeId">团购优惠</text>
|
|
|
</view>
|
|
|
<view class="">-¥
|
|
|
- <text v-if="buyType == 0 || !placeId">{{ previewCourseInfo?.discountPrice }}</text>
|
|
|
- <text v-else>{{ (previewCourseInfo?.originalPrice - previewCourseInfo?.sellingPrice).toFixed(2) }}</text>
|
|
|
+ <!-- <text v-if="buyType == 0 || !placeId">{{ previewCourseInfo?.discountPrice }}</text> -->
|
|
|
+ <text v-if="buyType == 1">{{ previewCourseInfo?.sellingPrice.toFixed(2) }}</text>
|
|
|
+ <text v-else>{{
|
|
|
+ previewCourseInfo?.originalPrice ? (previewCourseInfo?.originalPrice -
|
|
|
+ previewCourseInfo?.sellingPrice.toFixed(2)) * countTotal : ((previewCourseInfo?.sellingPrice
|
|
|
+ -
|
|
|
+ previewCourseInfo?.totalPrice.toFixed(2))) * countTotal }}</text>
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="subtotal">小计 ¥{{previewCourseInfo?.discountPrice?totalPriceDisplay-previewCourseInfo?.discountPrice:totalPriceDisplay }}</view>
|
|
|
+ <view class="subtotal">小计 ¥
|
|
|
+ <text v-if="buyType == 1">0.00</text>
|
|
|
+ <text v-else>{{ previewCourseInfo?.originalPrice ? (previewCourseInfo?.sellingPrice *
|
|
|
+ countTotal).toFixed(2) :
|
|
|
+ (previewCourseInfo?.sellingPrice.toFixed(2) - (previewCourseInfo?.sellingPrice -
|
|
|
+ previewCourseInfo?.totalPrice.toFixed(2))) * countTotal }}</text>
|
|
|
+ </view>
|
|
|
</view>
|
|
|
<!-- 课程进入 -->
|
|
|
<view class="r-insurance" v-for="item in insureIdList" :key="item.id">
|
|
@@ -58,8 +75,8 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="line" v-if="insureData.length > 0"></view>
|
|
|
- <blcok v-if="insureData.length > 0">
|
|
|
+ <view class="line" v-if="insureData.length > 0 && insureId == item.id"></view>
|
|
|
+ <blcok v-if="insureData.length > 0 && insureId == item.id">
|
|
|
<view class="r-insurance-adduser" v-for="(insureUser, index) in insureData" :key="index">
|
|
|
<view class="r-adduser-btn">
|
|
|
<view class="r-celar" @click="clearUser">清除</view>
|
|
@@ -76,7 +93,7 @@
|
|
|
</view>
|
|
|
<view class="r-userinfo-item">
|
|
|
<view class="r-item-title">生效时间</view>
|
|
|
- <view class="r-item-info">{{ insureUser.slectObj.day }}天({{ insureUser.startDate }}-{{
|
|
|
+ <view class="r-item-info">{{ insureUser.slectObj.insureDay }}天({{ insureUser.startDate }}-{{
|
|
|
insureUser.endDate }})
|
|
|
</view>
|
|
|
</view>
|
|
@@ -118,7 +135,8 @@
|
|
|
<rich-text :nodes="previewCourseInfo?.reminder"></rich-text>
|
|
|
</view>
|
|
|
</view>
|
|
|
- <view class="use-tips-more" @click="RouterUtils.to_page(`/pages/index/useNotice/index?reminder=${previewCourseInfo?.reminder}`)">
|
|
|
+ <view class="use-tips-more"
|
|
|
+ @click="RouterUtils.to_page(`/pages/index/useNotice/index?reminder=${previewCourseInfo?.reminder}`)">
|
|
|
<view class="more-text">查看更多</view>
|
|
|
<view class="use-line"></view>
|
|
|
</view>
|
|
@@ -139,15 +157,29 @@
|
|
|
<view class="footer footer-box">
|
|
|
<view class="footer-price">
|
|
|
<view class="total-price">合计:</view>
|
|
|
- <view class="price"><text class="mini-text">¥</text>
|
|
|
- <text>{{ previewCourseInfo?.discountPrice?totalPriceDisplay-previewCourseInfo?.discountPrice:totalPriceDisplay }}</text>
|
|
|
+ <view class="price">
|
|
|
+ <text class="mini-text">¥</text>
|
|
|
+ <text>{{
|
|
|
+ previewCourseInfo?.originalPrice ? (previewCourseInfo?.originalPrice * countTotal).toFixed(2) :
|
|
|
+ ((previewCourseInfo?.sellingPrice
|
|
|
+ || 0) * countTotal + totalInsurePrice).toFixed(2) }}</text>
|
|
|
+ </view>
|
|
|
+ <view class="discount">优惠¥
|
|
|
+ <text v-if="buyType == 1">{{ previewCourseInfo?.sellingPrice.toFixed(2) }}</text>
|
|
|
+ <text v-else>{{ previewCourseInfo?.originalPrice ? previewCourseInfo?.originalPrice :
|
|
|
+ ((previewCourseInfo?.sellingPrice - previewCourseInfo?.totalPrice.toFixed(2))) * countTotal
|
|
|
+ }}</text>
|
|
|
</view>
|
|
|
- <view class="discount">优惠¥{{ previewCourseInfo?.totalDiscount }}</view>
|
|
|
</view>
|
|
|
<view class="footer-btn" @click="submitOrder">
|
|
|
<button>
|
|
|
<view class="btn-price">
|
|
|
- <text> ¥{{ previewCourseInfo?.discountPrice?totalPriceDisplay-previewCourseInfo?.discountPrice:totalPriceDisplay }}</text>
|
|
|
+ <text v-if="buyType == 1">0.00</text>
|
|
|
+ <text v-else>
|
|
|
+ ¥{{ previewCourseInfo?.originalPrice ? (previewCourseInfo?.sellingPrice *
|
|
|
+ countTotal).toFixed(2) :
|
|
|
+ (((previewCourseInfo?.sellingPrice || 0) - ((previewCourseInfo?.sellingPrice || 0) -
|
|
|
+ (previewCourseInfo?.totalPrice || 0))) * countTotal + totalInsurePrice).toFixed(2) }}</text>
|
|
|
</view>
|
|
|
<view class="btn-price">立即支付</view>
|
|
|
</button>
|
|
@@ -174,9 +206,11 @@
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
import { ref, onMounted, computed } from 'vue';
|
|
|
-import { onLoad } from '@dcloudio/uni-app';
|
|
|
-import { RouterUtils, TipsUtils, idCardHide } from '@/utils/util';
|
|
|
+import { onLoad, onShareAppMessage } from '@dcloudio/uni-app';
|
|
|
+import { RouterUtils, TipsUtils, idCardHide,debounce } from '@/utils/util';
|
|
|
import { http } from '@/utils/http'
|
|
|
+import { useCacheStore } from '@/stores/cache'
|
|
|
+const cache = useCacheStore()
|
|
|
const insurePopup = ref()
|
|
|
const select_insurance = ref(false)
|
|
|
const loadType = ref(1)
|
|
@@ -192,29 +226,17 @@ onLoad((options) => {
|
|
|
orderFormData.value.orFreeOrder = options.buyType
|
|
|
orderFormData.value.amount = 1
|
|
|
})
|
|
|
-// 优化价格计算,合并保险价格
|
|
|
-const totalPrice = computed(() => {
|
|
|
- let basePrice = 0;
|
|
|
- if (previewCourseInfo.value) {
|
|
|
- if (previewCourseInfo.value.totalPrice) {
|
|
|
- basePrice = Number(previewCourseInfo.value.totalPrice) * Number(countTotal.value);
|
|
|
- } else if (previewCourseInfo.value.sellingPrice) {
|
|
|
- basePrice = Number(previewCourseInfo.value.sellingPrice) * Number(countTotal.value);
|
|
|
- }
|
|
|
- }
|
|
|
- let insureTotal = 0;
|
|
|
- if (Array.isArray(insureData.value) && insureData.value.length > 0) {
|
|
|
- insureTotal = insureData.value.reduce((sum, item) => {
|
|
|
- const price = Number(item.totalPrice) || 0;
|
|
|
- return sum + price;
|
|
|
- }, 0);
|
|
|
- }
|
|
|
- return basePrice + insureTotal;
|
|
|
-});
|
|
|
|
|
|
-const totalPriceDisplay = computed(() => {
|
|
|
- return totalPrice.value.toFixed(2);
|
|
|
-});
|
|
|
+onShareAppMessage((res) => {
|
|
|
+ if (res.from === 'button') {// 来自页面内分享按钮
|
|
|
+ console.log(res.target)
|
|
|
+ }
|
|
|
+ return {
|
|
|
+ title: '邀请您加入',
|
|
|
+ path: `pages/index/userList/index?userId=${cache.get('USER_INFO').id}`
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
if (placeId.value) {
|
|
|
getEventsDetail()
|
|
@@ -250,7 +272,9 @@ const deleteUser = async (e) => {
|
|
|
}
|
|
|
|
|
|
const priceDataListData = ref([])
|
|
|
+const insureId = ref()
|
|
|
const gotoInsuracePage = (e1: any, e2: any) => {
|
|
|
+ insureId.value = e1.id
|
|
|
getFindByType(e1.insuranceName)
|
|
|
priceDataListData.value = e2
|
|
|
orderFormData.value.insureOrderInfoForm.insureId = e1.id
|
|
@@ -310,6 +334,16 @@ const getInsureData = () => {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
+// 计算保费
|
|
|
+const totalInsurePrice = computed(() => {
|
|
|
+ if (!insureData.value || insureData.value.length === 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ if (insureData.value.length === 1) {
|
|
|
+ return parseFloat(insureData.value[0].totalPrice) || 0;
|
|
|
+ }
|
|
|
+ return insureData.value.reduce((total, insure) => total + (parseFloat(insure.totalPrice) || 0), 0);
|
|
|
+});
|
|
|
|
|
|
const clearUser = async () => {
|
|
|
let res: any = await TipsUtils.tips_alert('确定清除投保人信息吗?', true)
|
|
@@ -328,9 +362,9 @@ const minusNum = () => {
|
|
|
|
|
|
const addNum = () => {
|
|
|
if (buyType.value == 1) return TipsUtils.tips_toast('试听课程不支持多个购买')
|
|
|
- if(courseId.value){
|
|
|
- get_checkCourseLimitNum(countTotal.value + 1)
|
|
|
- }else{
|
|
|
+ if (courseId.value) {
|
|
|
+ get_checkCourseLimitNum(countTotal.value + 1)
|
|
|
+ } else {
|
|
|
countTotal.value++
|
|
|
}
|
|
|
}
|
|
@@ -368,7 +402,7 @@ const toRefuse = () => {
|
|
|
let orderFormData = ref({
|
|
|
type: null,
|
|
|
orderType: null,
|
|
|
- orFreeOrder: 1,
|
|
|
+ orFreeOrder: null, //0正常 1试听
|
|
|
productIds: null,
|
|
|
amount: null,
|
|
|
familyIds: '',
|
|
@@ -380,12 +414,12 @@ let orderFormData = ref({
|
|
|
familyMembersIds: '',
|
|
|
}
|
|
|
})
|
|
|
-const submitOrder = () => {
|
|
|
+const submitOrderImpl = () => {
|
|
|
orderFormData.value.amount = countTotal.value
|
|
|
if (!placeId.value) {
|
|
|
if (!userData.value) return TipsUtils.tips_toast('请添加用户信息')
|
|
|
if (userData.value.length < countTotal.value) return TipsUtils.tips_toast(`请至少选择${countTotal.value}人`)
|
|
|
- if(userData.value.length > countTotal.value) return TipsUtils.tips_toast(`最多选择${countTotal.value}人`)
|
|
|
+ if (userData.value.length > countTotal.value) return TipsUtils.tips_toast(`最多选择${countTotal.value}人`)
|
|
|
orderFormData.value.orderType = 5
|
|
|
orderFormData.value.type = 2
|
|
|
} else {
|
|
@@ -396,11 +430,54 @@ const submitOrder = () => {
|
|
|
if (!insureData.value || insureData.value.length === 0) {
|
|
|
delete data.insureOrderInfoForm;
|
|
|
}
|
|
|
- if(!userData||userData.value.length === 0){
|
|
|
+ if (!userData || userData.value.length === 0) {
|
|
|
delete data.familyIds
|
|
|
}
|
|
|
- http.post('/order/createOrder', data, { loading: true }).then((res) => {
|
|
|
- RouterUtils.to_page(`/pages/index/toBeUsed/index?orderId=${res.result.orderId}&orderType=${orderFormData.value.orderType}`)
|
|
|
+ uni.requestSubscribeMessage({
|
|
|
+ tmplIds: ['Yi1Z1IKRwgF6-mpiFcOUTvavc4TUAsfsLynK_3Yu350', 'NPlIBEwBDPX23J3Jip0CwYUU4vF9ZlcK8U1d6Gs4yrM'],
|
|
|
+ success(res) {
|
|
|
+ TipsUtils.tips_toast('订阅成功')
|
|
|
+ http.post('/order/createOrder', data, { loading: true }).then((res) => {
|
|
|
+ getOrderQuery(res.result.orderCode,res.result.orderId)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail(err) {
|
|
|
+ console.log(err, '订阅消息失败')
|
|
|
+ http.post('/order/createOrder', data, { loading: true }).then((res) => {
|
|
|
+ getOrderQuery(res.result.orderCode,res.result.orderId)
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
+const submitOrder = debounce(submitOrderImpl, 500)
|
|
|
+
|
|
|
+// code编码 "100001支付成功";"100002查询失败"; "100003查询中 "; "100004支付失败"
|
|
|
+const getOrderQuery = (orderCode: string,orderId:string, retryCount = 0) => {
|
|
|
+ http.get('/order/orderQuery', { data: { orderCode: orderCode }, loading: true }).then((res) => {
|
|
|
+ if (res.result == '100001') {
|
|
|
+ RouterUtils.to_page(`/pages/index/toBeUsed/index?orderId=${orderId}&orderType=${orderFormData.value.orderType}`)
|
|
|
+ } else if (retryCount <= 3) {
|
|
|
+ setTimeout(() => {
|
|
|
+ getOrderQuery(orderCode,orderId, retryCount + 1)
|
|
|
+ }, 1000)
|
|
|
+ } else {
|
|
|
+ if (res.result == '100003') {
|
|
|
+ console.log('查询中,但已达到最大查询次数')
|
|
|
+ } else if (res.result == '100002') {
|
|
|
+ console.log('查询失败')
|
|
|
+ } else if (res.result == '100004') {
|
|
|
+ console.log('支付失败')
|
|
|
+ TipsUtils.tips_toast('支付失败')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }).catch((error) => {
|
|
|
+ console.error('查询订单失败:', error)
|
|
|
+ if (retryCount < 2) {
|
|
|
+ setTimeout(() => {
|
|
|
+ getOrderQuery(orderCode,orderId, retryCount + 1)
|
|
|
+ }, 1000)
|
|
|
+ }
|
|
|
})
|
|
|
}
|
|
|
</script>
|