|
|
|
@ -40,15 +40,10 @@ |
|
|
|
<view class="card-header">订单详情</view> |
|
|
|
<view style="margin-top: 16rpx;"> |
|
|
|
<uv-form-item prop="members" :customStyle="formItemStyle"> |
|
|
|
<!-- style="width: calc(100vw - 40rpx*2);" --> |
|
|
|
<view> |
|
|
|
<peopleNumberInput |
|
|
|
:adults.sync="form.adults" |
|
|
|
:teenager.sync="form.teenager" |
|
|
|
:child.sync="form.child" |
|
|
|
:adultsPrice="productPackage.adultsPrice" |
|
|
|
:teenagerPrice="productPackage.teenagerPrice" |
|
|
|
:childPrice="productPackage.childPrice" |
|
|
|
<peopleNumberInput style="width: calc(100vw - 40rpx*2);" |
|
|
|
v-model="form.prices" |
|
|
|
:options="orderInfo.priceList" |
|
|
|
></peopleNumberInput> |
|
|
|
|
|
|
|
<memberChooseView |
|
|
|
@ -65,7 +60,7 @@ |
|
|
|
<view class="form-item-label">选择优惠券</view> |
|
|
|
<view class="form-item-content"> |
|
|
|
<view class="flex row" @click="jumpToSelectCoupon"> |
|
|
|
<view v-if="form.couponId" class="text">{{ couponInfo.label }}</view> |
|
|
|
<view v-if="form.couponId" class="text">{{ couponInfo.title }}</view> |
|
|
|
<view v-else class="text placeholder">请选择</view> |
|
|
|
<uv-icon name="arrow-right" color="#C6C6C6" size="32rpx"></uv-icon> |
|
|
|
</view> |
|
|
|
@ -161,14 +156,41 @@ |
|
|
|
data() { |
|
|
|
return { |
|
|
|
form: { |
|
|
|
name: null, |
|
|
|
phone: null, |
|
|
|
adults: 0, |
|
|
|
teenager: 0, |
|
|
|
child: 0, |
|
|
|
name: '', |
|
|
|
phone: '', |
|
|
|
prices: [], |
|
|
|
members: [], |
|
|
|
couponId: null, |
|
|
|
receiptId: null, |
|
|
|
couponId: '', |
|
|
|
receiptId: '', |
|
|
|
}, |
|
|
|
rules: { |
|
|
|
'name': { |
|
|
|
type: 'string', |
|
|
|
required: true, |
|
|
|
message: '请输入真实姓名', |
|
|
|
}, |
|
|
|
'phone': { |
|
|
|
type: 'string', |
|
|
|
required: true, |
|
|
|
message: '请输入手机号码', |
|
|
|
}, |
|
|
|
'prices': { |
|
|
|
type: 'array', |
|
|
|
message: '请选择人数', |
|
|
|
validator: (rule, value, callback) => { |
|
|
|
|
|
|
|
if (value.some(num => num > 0)) { |
|
|
|
return true |
|
|
|
} |
|
|
|
|
|
|
|
return false |
|
|
|
}, |
|
|
|
}, |
|
|
|
'members': { |
|
|
|
type: 'array', |
|
|
|
required: true, |
|
|
|
message: '请选择出行人', |
|
|
|
}, |
|
|
|
}, |
|
|
|
checkboxValue: [], |
|
|
|
formItemStyle: { padding: 0 }, |
|
|
|
@ -178,39 +200,31 @@ |
|
|
|
...mapState(['configList', 'userInfo', 'orderInfo', 'couponInfo']), |
|
|
|
productPackage() { |
|
|
|
const { time, product } = this.orderInfo |
|
|
|
const { timeOptions } = product || {} |
|
|
|
const { dateList } = product || {} |
|
|
|
|
|
|
|
return timeOptions?.find?.(item => item.id === time) || {} |
|
|
|
return dateList?.find?.(item => item.id === time) || {} |
|
|
|
}, |
|
|
|
totolPeople() { |
|
|
|
const { adults, teenager, child } = this.form |
|
|
|
const { prices } = this.orderInfo |
|
|
|
|
|
|
|
return (adults || 0) + (teenager || 0) + (child || 0) |
|
|
|
return prices.reduce((total, num) => { |
|
|
|
return total + num |
|
|
|
}, 0) |
|
|
|
}, |
|
|
|
totalPrice() { |
|
|
|
const { adults, teenager, child, couponId } = this.form |
|
|
|
|
|
|
|
const { adultsPrice, teenagerPrice, childPrice } = this.productPackage |
|
|
|
priceOrigin() { |
|
|
|
const { prices, priceList } = this.orderInfo |
|
|
|
|
|
|
|
let total = 0 |
|
|
|
|
|
|
|
adults && (total += adults * (adultsPrice || 0)) |
|
|
|
teenager && (total += teenager * (teenagerPrice || 0)) |
|
|
|
child && (total += child * (childPrice || 0)) |
|
|
|
|
|
|
|
couponId && (total -= (this.couponInfo?.price || 0)) |
|
|
|
|
|
|
|
return total |
|
|
|
return prices.reduce((total, num, index) => { |
|
|
|
return total + priceList[index].price * (num || 0) |
|
|
|
}, 0) |
|
|
|
}, |
|
|
|
discount() { |
|
|
|
return this.couponInfo?.discountAmount || 0 |
|
|
|
}, |
|
|
|
totalPrice() { |
|
|
|
return this.priceOrigin - this.discount |
|
|
|
}, |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
form: { |
|
|
|
handler(val) { |
|
|
|
this.$refs.form.setRules(this.getRules()) |
|
|
|
}, |
|
|
|
deep: true |
|
|
|
} |
|
|
|
}, |
|
|
|
onShow() { |
|
|
|
if (this.couponInfo) { |
|
|
|
this.form.couponId = this.couponInfo.id |
|
|
|
@ -221,65 +235,27 @@ |
|
|
|
console.log('orderInfo', this.orderInfo) |
|
|
|
this.initData() |
|
|
|
}, |
|
|
|
onReady() { |
|
|
|
this.$refs.form.setRules(this.getRules()) |
|
|
|
}, |
|
|
|
onReady() { |
|
|
|
this.$refs.form.setRules(this.rules); |
|
|
|
}, |
|
|
|
onUnload() { |
|
|
|
this.$store.commit('setCouponInfo', null) |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
getRules() { |
|
|
|
const { adults, teenager, child } = this.form |
|
|
|
|
|
|
|
return { |
|
|
|
'name': { |
|
|
|
type: 'string', |
|
|
|
required: true, |
|
|
|
message: '请输入真实姓名', |
|
|
|
}, |
|
|
|
'phone': { |
|
|
|
type: 'string', |
|
|
|
required: true, |
|
|
|
message: '请输入手机号码', |
|
|
|
}, |
|
|
|
'adults': { |
|
|
|
type: 'number', |
|
|
|
required: true, |
|
|
|
message: '请选择人数', |
|
|
|
validator: (rule, value, callback) => { |
|
|
|
|
|
|
|
if (adults || teenager || child) { |
|
|
|
return true |
|
|
|
} |
|
|
|
|
|
|
|
return false |
|
|
|
}, |
|
|
|
}, |
|
|
|
'members': { |
|
|
|
type: 'array', |
|
|
|
required: true, |
|
|
|
message: '请选择出行人', |
|
|
|
}, |
|
|
|
} |
|
|
|
}, |
|
|
|
initData() { |
|
|
|
const { |
|
|
|
time, |
|
|
|
adults, |
|
|
|
teenager, |
|
|
|
child, |
|
|
|
prices, |
|
|
|
members, |
|
|
|
} = this.orderInfo |
|
|
|
|
|
|
|
this.form = { |
|
|
|
name: null, |
|
|
|
phone: null, |
|
|
|
adults, |
|
|
|
teenager, |
|
|
|
child, |
|
|
|
name: '', |
|
|
|
phone: '', |
|
|
|
prices, |
|
|
|
members: members.map(item => ({ ...item, isSelected: true })), |
|
|
|
couponId: null, |
|
|
|
receiptId: null, |
|
|
|
couponId: '', |
|
|
|
receiptId: '', |
|
|
|
} |
|
|
|
}, |
|
|
|
jumpToSelectCoupon() { |
|
|
|
@ -323,52 +299,37 @@ |
|
|
|
const { |
|
|
|
name, |
|
|
|
phone, |
|
|
|
adults, |
|
|
|
teenager, |
|
|
|
child, |
|
|
|
prices, |
|
|
|
members, |
|
|
|
couponId, |
|
|
|
receiptId, |
|
|
|
} = this.form |
|
|
|
|
|
|
|
const { startDate, endDate } = time |
|
|
|
const { startDate, endDate } = this.productPackage |
|
|
|
let params = { |
|
|
|
activityId: product.id, |
|
|
|
startDate, |
|
|
|
endDate, |
|
|
|
dayNum: this.$dayjs(endDate).diff(this.$dayjs(startDate), 'day'), |
|
|
|
couponId, |
|
|
|
receiptId, |
|
|
|
name, |
|
|
|
phone, |
|
|
|
priceOrigin: this.priceOrigin, |
|
|
|
discount: this.discount, |
|
|
|
priceDiscount: this.totalPrice, |
|
|
|
payAmount: this.totalPrice, |
|
|
|
tourisIds: members.map(touris => touris.id).join(',') |
|
|
|
} |
|
|
|
|
|
|
|
const result = await this.$fetch('createOrder', params) |
|
|
|
|
|
|
|
// todo: check result includes order id? |
|
|
|
const orderId = await this.$fetch('createOrder', params) |
|
|
|
|
|
|
|
const orderInfo = { |
|
|
|
product, |
|
|
|
couponInfo: this.couponInfo, |
|
|
|
time, |
|
|
|
adults, |
|
|
|
teenager, |
|
|
|
child, |
|
|
|
members, |
|
|
|
couponId, |
|
|
|
receiptId, |
|
|
|
name, |
|
|
|
phone, |
|
|
|
} |
|
|
|
|
|
|
|
this.$store.commit('setOrderInfo', orderInfo) |
|
|
|
|
|
|
|
// todo: get id? |
|
|
|
uni.navigateTo({ |
|
|
|
url: `/pages_order/order/orderPay/index?id=${result.id}` |
|
|
|
url: `/pages_order/order/orderPay/index?id=${orderId}` |
|
|
|
}) |
|
|
|
|
|
|
|
} catch (err) { |
|
|
|
|
|
|
|
console.log('createOrder', err) |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|