|
@@ -45,6 +45,13 @@ import OrderDiscount from './order-discount'
|
|
|
import OrderVipCourse from './order-vip-course'
|
|
|
import AddDiscount from './add-discount'
|
|
|
|
|
|
+/** 保留两位小数向上取整 */
|
|
|
+export const numberToTwoUp = (num: number | string) => {
|
|
|
+ num = Number(num)
|
|
|
+
|
|
|
+ return Math.ceil(num * 100) / 100
|
|
|
+}
|
|
|
+
|
|
|
export default defineComponent({
|
|
|
name: 'order-detail',
|
|
|
data() {
|
|
@@ -110,11 +117,11 @@ export default defineComponent({
|
|
|
},
|
|
|
countDiscountPrice() {
|
|
|
const orderObject = orderStatus.orderObject
|
|
|
- return orderObject.couponAmount || (orderObject.couponDiscountPrice + orderObject.discountCardPrice + orderObject.discountCardPrice).toFixed(2)
|
|
|
+ return orderObject.couponAmount || numberToTwoUp(orderObject.couponDiscountPrice + orderObject.discountCardPrice + orderObject.discountCardPrice)
|
|
|
}
|
|
|
},
|
|
|
async mounted() {
|
|
|
- await this.getUserRegisterProtocol()
|
|
|
+ // await this.getUserRegisterProtocol()
|
|
|
// 判断是否是曲目购买(只有智能陪练才会有入口),其它地方不会有入口
|
|
|
this.dataLoading = true
|
|
|
if (this.orderType == 'MUSIC' && this.id) {
|
|
@@ -155,9 +162,6 @@ export default defineComponent({
|
|
|
})
|
|
|
this.orderGoodsType = tempGoodsType
|
|
|
|
|
|
- console.log(this.orderGoodsType, 'orderGoodsType')
|
|
|
-
|
|
|
-
|
|
|
await this.getOrderPayType()
|
|
|
|
|
|
this.orderAmount = orderStatus.orderObject.actualPrice || 0
|
|
@@ -278,10 +282,9 @@ export default defineComponent({
|
|
|
if (this.paymentVersion === 'V1') {
|
|
|
this.paymentStatus = true
|
|
|
} else {
|
|
|
- this.orderInfo = orderStatus.orderObject.paymentConfig || {}
|
|
|
+ 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 ||
|
|
@@ -357,7 +360,7 @@ export default defineComponent({
|
|
|
|
|
|
const res = await request.post(url, {
|
|
|
data: {
|
|
|
- activityId: orderObject.activityId || null,
|
|
|
+ activityId: orderObject.activityId > 0 ? orderObject.activityId : null,
|
|
|
couponIds: orderObject.couponId,
|
|
|
goodsInfos: goods,
|
|
|
orderDesc: orderObject.orderDesc,
|
|
@@ -437,11 +440,11 @@ export default defineComponent({
|
|
|
})
|
|
|
|
|
|
const lastAmount = Number(
|
|
|
- (
|
|
|
+ numberToTwoUp(
|
|
|
Number(this.orderAmount) -
|
|
|
orderStatus.orderObject.discountCardPrice -
|
|
|
Number(discountCount)
|
|
|
- ).toFixed(2)
|
|
|
+ )
|
|
|
)
|
|
|
this.orderPrice = lastAmount >= 0 ? lastAmount : 0
|
|
|
// 设置优惠券编号
|
|
@@ -452,34 +455,33 @@ export default defineComponent({
|
|
|
orderStatus.orderObject.couponDiscountPrice = discountCount
|
|
|
},
|
|
|
onConfirm(val: any) {
|
|
|
- const config: any = this.orderInfo.paymentConfig || {}
|
|
|
- orderStatus.orderObject.paymentConfig.paymentConfig.paymentChannel =
|
|
|
- val.pay_channel
|
|
|
- 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
|
|
|
- })
|
|
|
- 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() {
|
|
@@ -559,10 +561,10 @@ export default defineComponent({
|
|
|
// 重置金额
|
|
|
this.orderAmount = Number(price)
|
|
|
const lastAmount = Number(
|
|
|
- (
|
|
|
+ numberToTwoUp(
|
|
|
Number(this.orderAmount) -
|
|
|
Number(orderStatus.orderObject.couponDiscountPrice)
|
|
|
- ).toFixed(2)
|
|
|
+ )
|
|
|
)
|
|
|
this.orderPrice = lastAmount >= 0 ? lastAmount : 0
|
|
|
}}
|
|
@@ -587,10 +589,10 @@ export default defineComponent({
|
|
|
// 重置金额
|
|
|
this.orderAmount = Number(price)
|
|
|
const lastAmount = Number(
|
|
|
- (
|
|
|
+ numberToTwoUp(
|
|
|
Number(this.orderAmount) -
|
|
|
Number(orderStatus.orderObject.couponDiscountPrice)
|
|
|
- ).toFixed(2)
|
|
|
+ )
|
|
|
)
|
|
|
this.orderPrice = lastAmount >= 0 ? lastAmount : 0
|
|
|
}}
|
|
@@ -615,12 +617,15 @@ export default defineComponent({
|
|
|
discountPrice: number | string
|
|
|
vipType: string
|
|
|
}) => {
|
|
|
+ orderStatus.orderObject.discountCardPrice = Number(
|
|
|
+ item.discountPrice
|
|
|
+ )
|
|
|
this.orderPrice = Number(
|
|
|
- (
|
|
|
+ numberToTwoUp(
|
|
|
Number(this.orderAmount) -
|
|
|
Number(item.discountPrice) -
|
|
|
Number(orderStatus.orderObject.couponDiscountPrice)
|
|
|
- ).toFixed(2)
|
|
|
+ )
|
|
|
)
|
|
|
}}
|
|
|
onConfirm={(item: {
|
|
@@ -660,11 +665,11 @@ export default defineComponent({
|
|
|
}
|
|
|
|
|
|
this.orderPrice = Number(
|
|
|
- (
|
|
|
+ numberToTwoUp(
|
|
|
Number(this.orderAmount) -
|
|
|
Number(item.discountPrice) -
|
|
|
Number(orderStatus.orderObject.couponDiscountPrice)
|
|
|
- ).toFixed(2)
|
|
|
+ )
|
|
|
)
|
|
|
}}
|
|
|
/>
|
|
@@ -698,6 +703,7 @@ export default defineComponent({
|
|
|
couponId={orderStatus.orderObject.couponId}
|
|
|
discountPrice={orderStatus.orderObject.discountPrice}
|
|
|
orderType={this.orderType}
|
|
|
+ orderGoodsType={this.orderGoodsType}
|
|
|
orderAmount={
|
|
|
this.orderAmount - orderStatus.orderObject.discountCardPrice
|
|
|
}
|
|
@@ -718,6 +724,10 @@ export default defineComponent({
|
|
|
v-model={this.agreeStatus}
|
|
|
showHeader
|
|
|
style={{ paddingLeft: 0, paddingRight: 0 }}
|
|
|
+ onProtocolExists={(val: any) => {
|
|
|
+ console.log(val, 'al')
|
|
|
+ this.exists = val
|
|
|
+ }}
|
|
|
/>
|
|
|
</div>
|
|
|
)}
|