|
@@ -121,7 +121,14 @@ export default defineComponent({
|
|
|
},
|
|
|
countDiscountPrice() {
|
|
|
const orderObject = orderStatus.orderObject
|
|
|
- return orderObject.couponAmount || numberToTwoDown(orderObject.couponDiscountPrice + orderObject.discountPrice + orderObject.discountCardPrice)
|
|
|
+ return (
|
|
|
+ orderObject.couponAmount ||
|
|
|
+ numberToTwoDown(
|
|
|
+ orderObject.couponDiscountPrice +
|
|
|
+ orderObject.discountPrice +
|
|
|
+ orderObject.discountCardPrice
|
|
|
+ )
|
|
|
+ )
|
|
|
}
|
|
|
},
|
|
|
async mounted() {
|
|
@@ -161,7 +168,6 @@ export default defineComponent({
|
|
|
// 初始化所有商品的类型
|
|
|
const orderList = orderStatus.orderObject.orderList || []
|
|
|
const tempGoodsType: any = []
|
|
|
- console.log(orderList, 'orderList, ')
|
|
|
orderList.forEach((order: any) => {
|
|
|
tempGoodsType.push({
|
|
|
orderType: order.orderType,
|
|
@@ -220,48 +226,49 @@ export default defineComponent({
|
|
|
async getOrderPayType() {
|
|
|
try {
|
|
|
const orderObject = orderStatus.orderObject
|
|
|
- // 单独处理其它支付类型下面用的bizId
|
|
|
- let bizId =
|
|
|
- orderObject.orderList.length > 0 ? orderObject.orderList[0].id : ''
|
|
|
- if (orderObject.orderType === 'PRACTICE') {
|
|
|
- bizId =
|
|
|
- orderObject.orderList.length > 0
|
|
|
- ? orderObject.orderList[0].teacherId
|
|
|
- : ''
|
|
|
- }
|
|
|
- if (
|
|
|
- orderObject.orderType === 'LIVE' ||
|
|
|
- orderObject.orderType === 'VIDEO'
|
|
|
- ) {
|
|
|
- bizId =
|
|
|
- orderObject.orderList.length > 0
|
|
|
- ? orderObject.orderList[0].courseGroupId
|
|
|
- : ''
|
|
|
- }
|
|
|
- const { data } = await request.post(
|
|
|
- state.platformApi + '/userOrder/orderPayType',
|
|
|
- {
|
|
|
- data: {
|
|
|
- goodType: orderObject.orderType,
|
|
|
- bizId,
|
|
|
- recomUserId: orderObject.recomUserId
|
|
|
- ? orderObject.recomUserId
|
|
|
- : null
|
|
|
- }
|
|
|
- }
|
|
|
- )
|
|
|
-
|
|
|
// 判断是否已经有支付方式了
|
|
|
const paymentConfig = orderStatus.orderObject.paymentConfig || {}
|
|
|
if (paymentConfig.paymentVersion && orderStatus.orderObject.orderNo) {
|
|
|
this.paymentVersion = paymentConfig.paymentVersion || 'V1'
|
|
|
this.paymentVendor = paymentConfig.paymentVendor
|
|
|
} else {
|
|
|
+ // 单独处理其它支付类型下面用的bizId
|
|
|
+ const orderItem = orderObject.orderList.find(
|
|
|
+ (item: any) => item.orderType === this.orderType
|
|
|
+ )
|
|
|
+ let bizId = orderItem ? orderItem.id : ''
|
|
|
+ if (orderObject.orderType === 'PRACTICE') {
|
|
|
+ const orderItem = orderObject.orderList.find(
|
|
|
+ (item: any) => item.orderType === 'PRACTICE'
|
|
|
+ )
|
|
|
+ bizId = orderItem ? orderItem.teacherId : ''
|
|
|
+ }
|
|
|
+ if (
|
|
|
+ orderObject.orderType === 'LIVE' ||
|
|
|
+ orderObject.orderType === 'VIDEO'
|
|
|
+ ) {
|
|
|
+ const orderItem = orderObject.orderList.find(
|
|
|
+ (item: any) =>
|
|
|
+ item.orderType === 'VIDEO' || item.orderType === 'LIVE'
|
|
|
+ )
|
|
|
+ bizId = orderItem ? orderItem.courseGroupId : ''
|
|
|
+ }
|
|
|
+ const { data } = await request.post(
|
|
|
+ state.platformApi + '/userOrder/orderPayType',
|
|
|
+ {
|
|
|
+ data: {
|
|
|
+ goodType: orderObject.orderType,
|
|
|
+ bizId,
|
|
|
+ recomUserId: orderObject.recomUserId
|
|
|
+ ? orderObject.recomUserId
|
|
|
+ : null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ )
|
|
|
this.paymentVersion = data.paymentVersion || 'V1'
|
|
|
this.paymentVendor = data.paymentVendor
|
|
|
+ this.paymentChannels = data.paymentChannels // 可以选择的支付类型
|
|
|
}
|
|
|
-
|
|
|
- this.paymentChannels = data.paymentChannels // 可以选择的支付类型
|
|
|
} catch {
|
|
|
//
|
|
|
}
|
|
@@ -293,7 +300,7 @@ export default defineComponent({
|
|
|
} else {
|
|
|
this.orderInfo = orderStatus.orderObject || {}
|
|
|
this.orderNo = orderStatus.orderObject.orderNo
|
|
|
- const paymentChannel = this.orderInfo.paymentConfig.paymentChannel
|
|
|
+ const paymentChannel = this.orderInfo.paymentConfig.paymentChannel
|
|
|
// 判断是否为原生支付
|
|
|
if (
|
|
|
this.orderInfo.paymentVendor?.indexOf('wxpay') > -1 ||
|
|
@@ -363,13 +370,14 @@ export default defineComponent({
|
|
|
: '/api-student/userOrder/executeOrder/v2'
|
|
|
|
|
|
const goods: any = orderTenantInfos()
|
|
|
- if(this.selectGoods && this.selectGoods.length > 0) {
|
|
|
+ if (this.selectGoods && this.selectGoods.length > 0) {
|
|
|
goods.push(...orderTenantInfos(this.selectGoods))
|
|
|
}
|
|
|
|
|
|
const res = await request.post(url, {
|
|
|
data: {
|
|
|
- activityId: orderObject.activityId > 0 ? orderObject.activityId : null,
|
|
|
+ activityId:
|
|
|
+ orderObject.activityId > 0 ? orderObject.activityId : null,
|
|
|
couponIds: orderObject.couponId,
|
|
|
goodsInfos: goods,
|
|
|
orderDesc: orderObject.orderDesc,
|
|
@@ -450,8 +458,8 @@ export default defineComponent({
|
|
|
const lastAmount = Number(
|
|
|
numberToTwoUp(
|
|
|
Number(this.orderAmount) -
|
|
|
- orderStatus.orderObject.discountCardPrice -
|
|
|
- Number(discountCount)
|
|
|
+ orderStatus.orderObject.discountCardPrice -
|
|
|
+ Number(discountCount)
|
|
|
)
|
|
|
)
|
|
|
this.orderPrice = lastAmount >= 0 ? lastAmount : 0
|
|
@@ -463,33 +471,33 @@ export default defineComponent({
|
|
|
orderStatus.orderObject.couponDiscountPrice = discountCount
|
|
|
},
|
|
|
onConfirm(val: any) {
|
|
|
- // debugger
|
|
|
- const config: any = this.orderInfo.paymentConfig || {}
|
|
|
- this.pay_channel = val.pay_channel
|
|
|
- const params = qs.stringify({
|
|
|
- pay_channel: val.pay_channel,
|
|
|
- wxAppId: config.wxAppId,
|
|
|
- alipayAppId: config.alipayAppId,
|
|
|
- paymentType: this.orderInfo.paymentType,
|
|
|
- body: config.body,
|
|
|
- price: config.price,
|
|
|
- orderNo: config.merOrderNo,
|
|
|
- userId: config.userId
|
|
|
- })
|
|
|
- orderStatus.orderObject.paymentConfig.paymentChannel = val.pay_channel
|
|
|
- if (val.payCode === 'payResult') {
|
|
|
- window.location.href =
|
|
|
- window.location.origin + state.payBackPath + '#/payResult?' + params
|
|
|
- } else {
|
|
|
- this.qrCodeUrl =
|
|
|
- window.location.origin + state.payBackPath + '#/payDefine?' + params
|
|
|
- this.showQrcode = true
|
|
|
- this.paymentStatus = false
|
|
|
-
|
|
|
- setTimeout(() => {
|
|
|
- this.getPaymentOrderStatus()
|
|
|
- }, 300)
|
|
|
- }
|
|
|
+ // debugger
|
|
|
+ const config: any = this.orderInfo.paymentConfig || {}
|
|
|
+ this.pay_channel = val.pay_channel
|
|
|
+ const params = qs.stringify({
|
|
|
+ pay_channel: val.pay_channel,
|
|
|
+ wxAppId: config.wxAppId,
|
|
|
+ alipayAppId: config.alipayAppId,
|
|
|
+ paymentType: this.orderInfo.paymentType,
|
|
|
+ body: config.body,
|
|
|
+ price: config.price,
|
|
|
+ orderNo: config.merOrderNo,
|
|
|
+ userId: config.userId
|
|
|
+ })
|
|
|
+ orderStatus.orderObject.paymentConfig.paymentChannel = val.pay_channel
|
|
|
+ if (val.payCode === 'payResult') {
|
|
|
+ window.location.href =
|
|
|
+ window.location.origin + state.payBackPath + '#/payResult?' + params
|
|
|
+ } else {
|
|
|
+ this.qrCodeUrl =
|
|
|
+ window.location.origin + state.payBackPath + '#/payDefine?' + params
|
|
|
+ this.showQrcode = true
|
|
|
+ this.paymentStatus = false
|
|
|
+
|
|
|
+ setTimeout(() => {
|
|
|
+ this.getPaymentOrderStatus()
|
|
|
+ }, 300)
|
|
|
+ }
|
|
|
},
|
|
|
// 轮询查询订单状态
|
|
|
async getPaymentOrderStatus() {
|
|
@@ -566,27 +574,29 @@ export default defineComponent({
|
|
|
item={item}
|
|
|
disabled={this.disabledCoupon}
|
|
|
onPriceChange={(price: number) => {
|
|
|
+
|
|
|
+ // 畅学卡变更状态时需要重新选择优惠券
|
|
|
+ orderStatus.orderObject.couponId = ''
|
|
|
+ orderStatus.orderObject.couponDiscountPrice = 0
|
|
|
// 重置金额
|
|
|
this.orderAmount = Number(price)
|
|
|
const lastAmount = Number(
|
|
|
numberToTwoUp(
|
|
|
Number(this.orderAmount) -
|
|
|
- Number(orderStatus.orderObject.couponDiscountPrice)
|
|
|
+ Number(item.discountPrice) -
|
|
|
+ Number(orderStatus.orderObject.couponDiscountPrice)
|
|
|
)
|
|
|
)
|
|
|
this.orderPrice = lastAmount >= 0 ? lastAmount : 0
|
|
|
|
|
|
- this.orderGoodsType.forEach((child: any)=> {
|
|
|
- if(child.orderType === item.orderType) {
|
|
|
+ this.orderGoodsType.forEach((child: any) => {
|
|
|
+ if (child.orderType === item.orderType) {
|
|
|
child.price = Number(price)
|
|
|
}
|
|
|
})
|
|
|
- // 畅学卡变更状态时需要重新选择优惠券
|
|
|
- orderStatus.orderObject.couponId = ''
|
|
|
- orderStatus.orderObject.couponDiscountPrice = 0
|
|
|
// 更新优惠券列表
|
|
|
- const useCouponRef: any = this.$refs.useCouponRef
|
|
|
- if(useCouponRef) {
|
|
|
+ const useCouponRef: any = this.$refs.useCouponRef
|
|
|
+ if (useCouponRef) {
|
|
|
useCouponRef.resetCouponList()
|
|
|
}
|
|
|
}}
|
|
@@ -608,27 +618,27 @@ export default defineComponent({
|
|
|
disabled={this.disabledCoupon}
|
|
|
item={item}
|
|
|
onPriceChange={(price: number) => {
|
|
|
+ // 畅学卡变更状态时需要重新选择优惠券
|
|
|
+ orderStatus.orderObject.couponId = ''
|
|
|
+ orderStatus.orderObject.couponDiscountPrice = 0
|
|
|
// 重置金额
|
|
|
this.orderAmount = Number(price)
|
|
|
const lastAmount = Number(
|
|
|
numberToTwoUp(
|
|
|
Number(this.orderAmount) -
|
|
|
- Number(orderStatus.orderObject.couponDiscountPrice)
|
|
|
+ Number(orderStatus.orderObject.couponDiscountPrice)
|
|
|
)
|
|
|
)
|
|
|
this.orderPrice = lastAmount >= 0 ? lastAmount : 0
|
|
|
|
|
|
- this.orderGoodsType.forEach((child: any)=> {
|
|
|
- if(child.orderType === item.orderType) {
|
|
|
+ this.orderGoodsType.forEach((child: any) => {
|
|
|
+ if (child.orderType === item.orderType) {
|
|
|
child.price = Number(price)
|
|
|
}
|
|
|
})
|
|
|
- // 畅学卡变更状态时需要重新选择优惠券
|
|
|
- orderStatus.orderObject.couponId = ''
|
|
|
- orderStatus.orderObject.couponDiscountPrice = 0
|
|
|
// 更新优惠券列表
|
|
|
- const useCouponRef: any = this.$refs.useCouponRef
|
|
|
- if(useCouponRef) {
|
|
|
+ const useCouponRef: any = this.$refs.useCouponRef
|
|
|
+ if (useCouponRef) {
|
|
|
useCouponRef.resetCouponList()
|
|
|
}
|
|
|
}}
|
|
@@ -657,22 +667,24 @@ export default defineComponent({
|
|
|
item.discountPrice
|
|
|
)
|
|
|
|
|
|
- this.orderGoodsType.forEach((child: any)=> {
|
|
|
- if(child.orderType !== 'DISCOUNT') {
|
|
|
- child.price = numberToTwoUp(child.price - Number(item.discountPrice))
|
|
|
+ this.orderGoodsType.forEach((child: any) => {
|
|
|
+ if (child.orderType !== 'DISCOUNT') {
|
|
|
+ child.price = numberToTwoUp(
|
|
|
+ child.price - Number(item.discountPrice)
|
|
|
+ )
|
|
|
}
|
|
|
})
|
|
|
|
|
|
// 更新优惠券列表
|
|
|
- const useCouponRef: any = this.$refs.useCouponRef
|
|
|
- if(useCouponRef) {
|
|
|
+ const useCouponRef: any = this.$refs.useCouponRef
|
|
|
+ if (useCouponRef) {
|
|
|
useCouponRef.resetCouponList()
|
|
|
}
|
|
|
this.orderPrice = Number(
|
|
|
numberToTwoUp(
|
|
|
Number(this.orderAmount) -
|
|
|
- Number(item.discountPrice) -
|
|
|
- Number(orderStatus.orderObject.couponDiscountPrice)
|
|
|
+ Number(item.discountPrice) -
|
|
|
+ Number(orderStatus.orderObject.couponDiscountPrice)
|
|
|
)
|
|
|
)
|
|
|
}}
|
|
@@ -696,9 +708,11 @@ export default defineComponent({
|
|
|
orderStatus.orderObject.discountCardPrice = Number(
|
|
|
item.discountPrice
|
|
|
)
|
|
|
- this.orderGoodsType.forEach((child: any)=> {
|
|
|
- if(child.orderType !== 'DISCOUNT') {
|
|
|
- child.price = numberToTwoUp(child.price - Number(item.discountPrice))
|
|
|
+ this.orderGoodsType.forEach((child: any) => {
|
|
|
+ if (child.orderType !== 'DISCOUNT') {
|
|
|
+ child.price = numberToTwoUp(
|
|
|
+ child.price - Number(item.discountPrice)
|
|
|
+ )
|
|
|
}
|
|
|
})
|
|
|
if (index === -1) {
|
|
@@ -709,8 +723,10 @@ export default defineComponent({
|
|
|
num: 1,
|
|
|
id: item.id
|
|
|
})
|
|
|
- const typeIndex = tempType.findIndex((child: any) => child.orderType === item.vipType)
|
|
|
- if(typeIndex === -1) {
|
|
|
+ const typeIndex = tempType.findIndex(
|
|
|
+ (child: any) => child.orderType === item.vipType
|
|
|
+ )
|
|
|
+ if (typeIndex === -1) {
|
|
|
tempType.push({
|
|
|
orderType: item.vipType,
|
|
|
price: item.salePrice
|
|
@@ -722,13 +738,15 @@ export default defineComponent({
|
|
|
if (index !== -1) {
|
|
|
this.selectGoods.splice(index, 1)
|
|
|
this.orderAmount = this.orderAmount - item.salePrice
|
|
|
- this.orderGoodsType.forEach((child: any)=> {
|
|
|
- if(child.orderType !== 'DISCOUNT') {
|
|
|
+ this.orderGoodsType.forEach((child: any) => {
|
|
|
+ if (child.orderType !== 'DISCOUNT') {
|
|
|
child.price = child.basePrice
|
|
|
}
|
|
|
})
|
|
|
- const typeIndex = tempType.findIndex((child: any) => child.orderType === item.vipType)
|
|
|
- if(typeIndex !== -1) {
|
|
|
+ const typeIndex = tempType.findIndex(
|
|
|
+ (child: any) => child.orderType === item.vipType
|
|
|
+ )
|
|
|
+ if (typeIndex !== -1) {
|
|
|
tempType.splice(typeIndex, 1)
|
|
|
}
|
|
|
}
|
|
@@ -736,16 +754,16 @@ export default defineComponent({
|
|
|
this.orderGoodsType = tempType
|
|
|
|
|
|
// 更新优惠券列表
|
|
|
- const useCouponRef: any = this.$refs.useCouponRef
|
|
|
- if(useCouponRef) {
|
|
|
+ const useCouponRef: any = this.$refs.useCouponRef
|
|
|
+ if (useCouponRef) {
|
|
|
// console.log(useCouponRef, 'useCouponRef')
|
|
|
useCouponRef.resetCouponList()
|
|
|
}
|
|
|
this.orderPrice = Number(
|
|
|
numberToTwoUp(
|
|
|
Number(this.orderAmount) -
|
|
|
- Number(item.discountPrice) -
|
|
|
- Number(orderStatus.orderObject.couponDiscountPrice)
|
|
|
+ Number(item.discountPrice) -
|
|
|
+ Number(orderStatus.orderObject.couponDiscountPrice)
|
|
|
)
|
|
|
)
|
|
|
this.$forceUpdate()
|
|
@@ -757,23 +775,32 @@ export default defineComponent({
|
|
|
|
|
|
{/* 只做显示用 - 不参与逻辑 */}
|
|
|
{state.platformType === 'STUDENT' &&
|
|
|
- !this.dataLoading &&
|
|
|
- this.disabledCoupon && orderStatus.orderObject.discountCardPrice > 0 ? <CellGroup class={['mb12', styles.cellGroup]} border={false}>
|
|
|
- <Cell
|
|
|
- center
|
|
|
- v-slots={{
|
|
|
- title: () => (
|
|
|
- <div class={styles.timerCell}>
|
|
|
- <div class={styles.timerTitle}>
|
|
|
- <span>畅学卡优惠</span>
|
|
|
+ !this.dataLoading &&
|
|
|
+ this.disabledCoupon &&
|
|
|
+ orderStatus.orderObject.discountCardPrice > 0 ? (
|
|
|
+ <CellGroup class={['mb12', styles.cellGroup]} border={false}>
|
|
|
+ <Cell
|
|
|
+ center
|
|
|
+ v-slots={{
|
|
|
+ title: () => (
|
|
|
+ <div class={styles.timerCell}>
|
|
|
+ <div class={styles.timerTitle}>
|
|
|
+ <span>畅学卡优惠</span>
|
|
|
+ </div>
|
|
|
+ <div class={styles.timer}>
|
|
|
+ -¥
|
|
|
+ {(this as any).$filters.moneyFormat(
|
|
|
+ orderStatus.orderObject.discountCardPrice
|
|
|
+ )}
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <div class={styles.timer}>-¥{(this as any).$filters.moneyFormat(orderStatus.orderObject.discountCardPrice)}</div>
|
|
|
- </div>
|
|
|
- )
|
|
|
- }}
|
|
|
- />
|
|
|
- </CellGroup> : '' }
|
|
|
-
|
|
|
+ )
|
|
|
+ }}
|
|
|
+ />
|
|
|
+ </CellGroup>
|
|
|
+ ) : (
|
|
|
+ ''
|
|
|
+ )}
|
|
|
|
|
|
{/* 优惠券使用 */}
|
|
|
{!this.dataLoading && (
|
|
@@ -823,7 +850,13 @@ export default defineComponent({
|
|
|
</span>
|
|
|
</div>
|
|
|
</div>
|
|
|
- {this.countDiscountPrice > 0 ? <div class={styles.isDiscountPrice}>已优惠 ¥{moneyFormat(this.countDiscountPrice)}</div> : ''}
|
|
|
+ {this.countDiscountPrice > 0 ? (
|
|
|
+ <div class={styles.isDiscountPrice}>
|
|
|
+ 已优惠 ¥{moneyFormat(this.countDiscountPrice)}
|
|
|
+ </div>
|
|
|
+ ) : (
|
|
|
+ ''
|
|
|
+ )}
|
|
|
</div>
|
|
|
</div>
|
|
|
<Button
|
|
@@ -862,9 +895,6 @@ export default defineComponent({
|
|
|
onBackOut={this.onBackOut}
|
|
|
/>
|
|
|
) : (
|
|
|
- // this.paymentVersion = data.paymentVersion || 'V1'
|
|
|
- // this.paymentVendor = data.paymentVendor
|
|
|
- // this.paymentChannels = data.paymentChannels // 可以选择的支付类型
|
|
|
<UrlPayment
|
|
|
paymentConfig={{
|
|
|
...orderStatus.orderObject,
|