Showing
1 changed file
with
55 additions
and
42 deletions
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2024-01-24 16:38:13 | 2 | * @Date: 2024-01-24 16:38:13 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2024-01-25 16:08:56 | 4 | + * @LastEditTime: 2024-01-27 11:42:42 |
| 5 | * @FilePath: /xysBooking/src/components/reserveCard.vue | 5 | * @FilePath: /xysBooking/src/components/reserveCard.vue |
| 6 | * @Description: 预约记录卡组件 | 6 | * @Description: 预约记录卡组件 |
| 7 | --> | 7 | --> |
| 8 | <template> | 8 | <template> |
| 9 | - <div class="booking-list-item" @click="goToDetail(props.data)"> | 9 | + <div class="booking-list-item" @click="goToDetail(reserve_info)"> |
| 10 | <div class="booking-list-item-header"> | 10 | <div class="booking-list-item-header"> |
| 11 | - <div>{{ props.data.booking_time }}</div> | 11 | + <div>{{ reserve_info.booking_time }}</div> |
| 12 | - <div :class="[formatStatus(props.data.status)?.key, 'status']">{{ formatStatus(props.data.status)?.value }}</div> | 12 | + <div :class="[formatStatus(reserve_info.status)?.key, 'status']">{{ formatStatus(reserve_info.status)?.value }}</div> |
| 13 | </div> | 13 | </div> |
| 14 | <div class="booking-list-item-body"> | 14 | <div class="booking-list-item-body"> |
| 15 | <div class="booking-num"> | 15 | <div class="booking-num"> |
| 16 | - <div class="num-body van-ellipsis">预约人数:<span>{{ props.data.total_qty }} 人</span> <span>({{ props.data.person_name }})</span></div> | 16 | + <div class="num-body van-ellipsis">预约人数:<span>{{ reserve_info.total_qty }} 人</span> <span>({{ reserve_info.person_name }})</span></div> |
| 17 | - <div v-if="(props.data.status === CodeStatus.SUCCESS || props.data.status === CodeStatus.USED || props.data.status === CodeStatus.CANCEL)"> | 17 | + <div v-if="(reserve_info.status === CodeStatus.SUCCESS || reserve_info.status === CodeStatus.USED || reserve_info.status === CodeStatus.CANCEL)"> |
| 18 | <van-icon name="arrow" /> | 18 | <van-icon name="arrow" /> |
| 19 | </div> | 19 | </div> |
| 20 | </div> | 20 | </div> |
| 21 | - <div class="booking-price">支付金额:<span>¥ {{ props.data.total_amt }}</span></div> | 21 | + <div class="booking-price">支付金额:<span>¥ {{ reserve_info.total_amt }}</span></div> |
| 22 | - <div class="booking-time">下单时间:<span>{{ props.data.order_time }}</span></div> | 22 | + <div class="booking-time">下单时间:<span>{{ reserve_info.order_time }}</span></div> |
| 23 | </div> | 23 | </div> |
| 24 | <div class="booking-list-item-footer"> | 24 | <div class="booking-list-item-footer"> |
| 25 | <div v-if="pay_show" class="pay-time"> | 25 | <div v-if="pay_show" class="pay-time"> |
| 26 | <span>支付剩余时间 </span> | 26 | <span>支付剩余时间 </span> |
| 27 | <span>{{ formatTime(remain_time) }}</span> | 27 | <span>{{ formatTime(remain_time) }}</span> |
| 28 | </div> | 28 | </div> |
| 29 | - <div v-if="showBtn"> | 29 | + <div v-if="showPayControl"> |
| 30 | <van-button v-if="pay_show" @click="payOrder()" type="primary" color="#A67939" size="small">重新支付</van-button> | 30 | <van-button v-if="pay_show" @click="payOrder()" type="primary" color="#A67939" size="small">重新支付</van-button> |
| 31 | <div v-if="delay_pay_show" class="delay-pay">支付超时,请重新下单!</div> | 31 | <div v-if="delay_pay_show" class="delay-pay">支付超时,请重新下单!</div> |
| 32 | </div> | 32 | </div> |
| ... | @@ -114,13 +114,6 @@ const formatStatus = (status) => { | ... | @@ -114,13 +114,6 @@ const formatStatus = (status) => { |
| 114 | } | 114 | } |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | - | ||
| 118 | -const goToDetail = (item) => { | ||
| 119 | - if (item.status === CodeStatus.SUCCESS || item.status === CodeStatus.USED || item.status === CodeStatus.CANCEL) { | ||
| 120 | - go('/bookingDetail', { pay_id: item.pay_id }) | ||
| 121 | - } | ||
| 122 | -} | ||
| 123 | - | ||
| 124 | /** | 117 | /** |
| 125 | * 格式化时间 | 118 | * 格式化时间 |
| 126 | * @param {*} seconds | 119 | * @param {*} seconds |
| ... | @@ -137,24 +130,15 @@ function formatTime(seconds) { | ... | @@ -137,24 +130,15 @@ function formatTime(seconds) { |
| 137 | return `${formattedHours}:${formattedMinutes}:${formattedSeconds}`; | 130 | return `${formattedHours}:${formattedMinutes}:${formattedSeconds}`; |
| 138 | } | 131 | } |
| 139 | 132 | ||
| 140 | -// 显示操作按钮的条件判断 | 133 | +let timeId = null; |
| 141 | -const showBtn = computed(() => { | ||
| 142 | - return props.data.status === CodeStatus.APPLY; | ||
| 143 | -}); | ||
| 144 | - | ||
| 145 | const remain_time = ref(0); // 剩余时间秒数 | 134 | const remain_time = ref(0); // 剩余时间秒数 |
| 146 | - | 135 | +const reserve_info = ref({ |
| 147 | -// 控制待支付状态下的显示 | 136 | + booking_time: '', |
| 148 | -const pay_show = computed(() => { | 137 | + status: '', |
| 149 | - let flag = false; | 138 | + total_qty: '', |
| 150 | - if (props.data.status === CodeStatus.APPLY && remain_time.value) { | 139 | + total_amt: '', |
| 151 | - // 倒计时进行时 | 140 | + order_time: '', |
| 152 | - flag = true; | 141 | + rest_second: 0, |
| 153 | - } else if (props.data.status === CodeStatus.APPLY && !remain_time.value) { | ||
| 154 | - // 倒计时结束 | ||
| 155 | - flag = false; | ||
| 156 | - } | ||
| 157 | - return flag; | ||
| 158 | }); | 142 | }); |
| 159 | 143 | ||
| 160 | watch( | 144 | watch( |
| ... | @@ -162,6 +146,13 @@ watch( | ... | @@ -162,6 +146,13 @@ watch( |
| 162 | (val) => { | 146 | (val) => { |
| 163 | if (val) { | 147 | if (val) { |
| 164 | remain_time.value = val.rest_second > 0 ? val.rest_second : 0; | 148 | remain_time.value = val.rest_second > 0 ? val.rest_second : 0; |
| 149 | + reserve_info.value.booking_time = val.booking_time; | ||
| 150 | + reserve_info.value.rest_second = val.rest_second; | ||
| 151 | + reserve_info.value.status = val.status; | ||
| 152 | + reserve_info.value.person_name = val.person_name; | ||
| 153 | + reserve_info.value.total_qty = val.total_qty; | ||
| 154 | + reserve_info.value.total_amt = val.total_amt; | ||
| 155 | + reserve_info.value.order_time = val.order_time; | ||
| 165 | } | 156 | } |
| 166 | }, | 157 | }, |
| 167 | { | 158 | { |
| ... | @@ -170,15 +161,7 @@ watch( | ... | @@ -170,15 +161,7 @@ watch( |
| 170 | } | 161 | } |
| 171 | ); | 162 | ); |
| 172 | 163 | ||
| 173 | -// 支付超时显示 | ||
| 174 | -const delay_pay_show = computed(() => { | ||
| 175 | - return props.data.status === CodeStatus.APPLY && !remain_time.value; | ||
| 176 | -}); | ||
| 177 | - | ||
| 178 | -let timeId = null; | ||
| 179 | - | ||
| 180 | onMounted(() => { | 164 | onMounted(() => { |
| 181 | - remain_time.value = props.data.rest_second > 0 ? props.data.rest_second : 0; | ||
| 182 | // 进入页面后,开始倒计时 | 165 | // 进入页面后,开始倒计时 |
| 183 | timeId = setInterval(() => { | 166 | timeId = setInterval(() => { |
| 184 | remain_time.value ? (remain_time.value -= 1) : 0; | 167 | remain_time.value ? (remain_time.value -= 1) : 0; |
| ... | @@ -188,8 +171,38 @@ onMounted(() => { | ... | @@ -188,8 +171,38 @@ onMounted(() => { |
| 188 | }); | 171 | }); |
| 189 | }); | 172 | }); |
| 190 | 173 | ||
| 174 | +const goToDetail = (item) => { | ||
| 175 | + if (item.status === CodeStatus.SUCCESS || item.status === CodeStatus.USED || item.status === CodeStatus.CANCEL) { | ||
| 176 | + go('/bookingDetail', { pay_id: item.pay_id }) | ||
| 177 | + } | ||
| 178 | +} | ||
| 179 | + | ||
| 180 | +// 显示操作按钮 | ||
| 181 | +const showPayControl = computed(() => { | ||
| 182 | + return reserve_info.value.status === CodeStatus.APPLY; | ||
| 183 | +}); | ||
| 184 | + | ||
| 185 | +// 支付超时显示 | ||
| 186 | +const delay_pay_show = computed(() => { | ||
| 187 | + return showPayControl.value && !remain_time.value; | ||
| 188 | +}); | ||
| 189 | + | ||
| 190 | +// 控制待支付状态下的显示 | ||
| 191 | +const pay_show = computed(() => { | ||
| 192 | + let flag = false; | ||
| 193 | + if (showPayControl.value) { | ||
| 194 | + if (remain_time.value) { // 倒计时进行时 | ||
| 195 | + flag = true; | ||
| 196 | + } else if (!remain_time.value) { // 倒计时结束 | ||
| 197 | + flag = false; | ||
| 198 | + } | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + return flag; | ||
| 202 | +}); | ||
| 203 | + | ||
| 191 | const payOrder = () => { | 204 | const payOrder = () => { |
| 192 | - const pay_url = `/srv/?f=reserve&a=icbc_pay&pay_id=${props.data.pay_id}`; | 205 | + const pay_url = `/srv/?f=reserve&a=icbc_pay&pay_id=${reserve_info.value.pay_id}`; |
| 193 | location.href = pay_url; // 跳转支付页面 | 206 | location.href = pay_url; // 跳转支付页面 |
| 194 | } | 207 | } |
| 195 | </script> | 208 | </script> | ... | ... |
-
Please register or login to post a comment