Showing
4 changed files
with
145 additions
and
44 deletions
| ... | @@ -42,7 +42,7 @@ | ... | @@ -42,7 +42,7 @@ |
| 42 | </nut-col> | 42 | </nut-col> |
| 43 | </nut-row> | 43 | </nut-row> |
| 44 | </view> | 44 | </view> |
| 45 | - <view style="padding: 0.5rem;"> | 45 | + <view style="padding: 0.5rem; padding-bottom: 0;"> |
| 46 | <nut-row> | 46 | <nut-row> |
| 47 | <nut-col span="6"> | 47 | <nut-col span="6"> |
| 48 | <view @tap="showOrderInfo('id')" style="display: flex; align-items: center; margin: 20rpx 0;height: 60rpx;"> | 48 | <view @tap="showOrderInfo('id')" style="display: flex; align-items: center; margin: 20rpx 0;height: 60rpx;"> |
| ... | @@ -59,13 +59,9 @@ | ... | @@ -59,13 +59,9 @@ |
| 59 | </nut-col> | 59 | </nut-col> |
| 60 | </nut-row> | 60 | </nut-row> |
| 61 | </view> | 61 | </view> |
| 62 | - <!-- <view v-if="flag" style="display: flex; justify-content: flex-end; font-size: 20rpx; margin-bottom: 1rem;"> --> | 62 | + <view style="display: flex; justify-content: flex-end; font-size: 23rpx; margin-bottom: 1rem; margin-right: 1rem;"> |
| 63 | - <view style="display: flex; justify-content: flex-end; font-size: 20rpx; margin-bottom: 1rem;"> | ||
| 64 | <text>支付剩余时间</text> | 63 | <text>支付剩余时间</text> |
| 65 | - <!-- <nut-countdown v-model="resetTime" :end-time="end" @end="onEnd('id')"> | 64 | + <text style="font-size: 23rpx; color: red;">{{ formatTime(remain_time) }}</text> |
| 66 | - <text style="font-size: 20rpx; color: red;">{{ resetTime.m }}:{{ resetTime.s }}</text> | ||
| 67 | - </nut-countdown> --> | ||
| 68 | - <text style="font-size: 20rpx; color: red;">30:00</text> | ||
| 69 | </view> | 65 | </view> |
| 70 | <view v-if="show_info"> | 66 | <view v-if="show_info"> |
| 71 | <view style="border-bottom: 1px dashed #979797; padding: 0.5rem;"> | 67 | <view style="border-bottom: 1px dashed #979797; padding: 0.5rem;"> |
| ... | @@ -124,24 +120,44 @@ | ... | @@ -124,24 +120,44 @@ |
| 124 | </template> | 120 | </template> |
| 125 | 121 | ||
| 126 | <script setup> | 122 | <script setup> |
| 127 | -import { ref } from 'vue' | 123 | +import { ref, onMounted, onUnmounted } from 'vue' |
| 128 | import Taro from '@tarojs/taro' | 124 | import Taro from '@tarojs/taro' |
| 129 | import { IconFont } from '@nutui/icons-vue-taro'; | 125 | import { IconFont } from '@nutui/icons-vue-taro'; |
| 130 | 126 | ||
| 131 | -const emit = defineEmits(["onPay"]); | 127 | +/** |
| 128 | + * 格式化时间 | ||
| 129 | + * @param {*} seconds | ||
| 130 | + */ | ||
| 131 | +function formatTime(seconds) { | ||
| 132 | + const hours = Math.floor(seconds / 3600); | ||
| 133 | + const minutes = Math.floor((seconds % 3600) / 60); | ||
| 134 | + const remainingSeconds = seconds % 60; | ||
| 132 | 135 | ||
| 133 | -const end = ref(Date.now() + 60 * 1000); | 136 | + let formattedTime = ""; |
| 134 | -const resetTime = ref({ | 137 | + |
| 135 | - m: '00', | 138 | + if (hours > 0) { |
| 136 | - s: '00' | 139 | + formattedTime += hours.toString().padStart(2, "0") + ":"; |
| 137 | -}); | 140 | + } |
| 138 | 141 | ||
| 139 | -const flag = ref(false); | 142 | + if (minutes > 0 || hours > 0) { |
| 140 | -const onEnd = (id) => { | 143 | + formattedTime += minutes.toString().padStart(2, "0") + ":"; |
| 141 | - console.warn(id); | 144 | + } |
| 142 | - flag.value = false; | 145 | + |
| 146 | + formattedTime += remainingSeconds.toString().padStart(2, "0"); | ||
| 147 | + | ||
| 148 | + return formattedTime; | ||
| 143 | } | 149 | } |
| 144 | 150 | ||
| 151 | +const props = defineProps({ | ||
| 152 | + data: { | ||
| 153 | + type: Object, | ||
| 154 | + default: {} | ||
| 155 | + } | ||
| 156 | +}); | ||
| 157 | +const emit = defineEmits(["onPay"]); | ||
| 158 | + | ||
| 159 | +const remain_time = ref(0); // 剩余时间秒数 | ||
| 160 | + | ||
| 145 | const show_info = ref(false); | 161 | const show_info = ref(false); |
| 146 | const showOrderInfo = (id) => { | 162 | const showOrderInfo = (id) => { |
| 147 | show_info.value = !show_info.value; | 163 | show_info.value = !show_info.value; |
| ... | @@ -160,9 +176,10 @@ const cancelOrder = (id) => { | ... | @@ -160,9 +176,10 @@ const cancelOrder = (id) => { |
| 160 | } | 176 | } |
| 161 | }) | 177 | }) |
| 162 | } | 178 | } |
| 163 | -const visible = ref(false); | 179 | + |
| 164 | const payOrder = (id) => { | 180 | const payOrder = (id) => { |
| 165 | - emit("onPay", id); | 181 | + // TODO: 把剩余支付时间发到支付组件上显示 |
| 182 | + emit("onPay", { id, remain_time: remain_time.value }); | ||
| 166 | // visible.value = !visible.value; | 183 | // visible.value = !visible.value; |
| 167 | // Taro.showToast({ | 184 | // Taro.showToast({ |
| 168 | // title: '支付已超时', | 185 | // title: '支付已超时', |
| ... | @@ -170,6 +187,21 @@ const payOrder = (id) => { | ... | @@ -170,6 +187,21 @@ const payOrder = (id) => { |
| 170 | // duration: 2000 | 187 | // duration: 2000 |
| 171 | // }); | 188 | // }); |
| 172 | } | 189 | } |
| 190 | + | ||
| 191 | +let timeId = null; | ||
| 192 | + | ||
| 193 | +onMounted(() => { | ||
| 194 | + console.warn(props.data) | ||
| 195 | + remain_time.value = props.data.remain_time; | ||
| 196 | + // 进入页面后,开始倒计时 | ||
| 197 | + timeId = setInterval(() => { | ||
| 198 | + remain_time.value ? remain_time.value -= 1 : 0; | ||
| 199 | + }, 1000); | ||
| 200 | +}); | ||
| 201 | + | ||
| 202 | +onUnmounted(() => { | ||
| 203 | + timeId && clearInterval(timeId); | ||
| 204 | +}) | ||
| 173 | </script> | 205 | </script> |
| 174 | 206 | ||
| 175 | <style lang="less"> | 207 | <style lang="less"> | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2023-12-20 14:11:11 | 2 | * @Date: 2023-12-20 14:11:11 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-12-20 14:56:37 | 4 | + * @LastEditTime: 2023-12-20 16:25:26 |
| 5 | * @FilePath: /meihuaApp/src/components/payCard.vue | 5 | * @FilePath: /meihuaApp/src/components/payCard.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -11,7 +11,7 @@ | ... | @@ -11,7 +11,7 @@ |
| 11 | <view style="padding: 2rem 1rem; text-align: center;"> | 11 | <view style="padding: 2rem 1rem; text-align: center;"> |
| 12 | <view style="font-size: 32rpx;">实付金额</view> | 12 | <view style="font-size: 32rpx;">实付金额</view> |
| 13 | <view style="color: red; margin: 10rpx 0;"><text style="font-size: 50rpx;">¥</text><text style="font-size: 80rpx;">{{ price }}</text></view> | 13 | <view style="color: red; margin: 10rpx 0;"><text style="font-size: 50rpx;">¥</text><text style="font-size: 80rpx;">{{ price }}</text></view> |
| 14 | - <view style="font-size: 28rpx; margin-bottom: 20rpx;">支付剩余时间 <text style="color: red;">{{ remain_time }}</text></view> | 14 | + <view style="font-size: 28rpx; margin-bottom: 20rpx;">支付剩余时间 <text style="color: red;">{{ formatTime(remain_time) }}</text></view> |
| 15 | <nut-button block color="#6A4925" @tap="goToPay">立即支付</nut-button> | 15 | <nut-button block color="#6A4925" @tap="goToPay">立即支付</nut-button> |
| 16 | </view> | 16 | </view> |
| 17 | </nut-action-sheet> | 17 | </nut-action-sheet> |
| ... | @@ -20,7 +20,31 @@ | ... | @@ -20,7 +20,31 @@ |
| 20 | 20 | ||
| 21 | <script setup> | 21 | <script setup> |
| 22 | import Taro from '@tarojs/taro' | 22 | import Taro from '@tarojs/taro' |
| 23 | -import { ref, watch, onMounted } from 'vue' | 23 | +import { ref, watch, onMounted, onUnmounted } from 'vue' |
| 24 | + | ||
| 25 | +/** | ||
| 26 | + * 格式化时间 | ||
| 27 | + * @param {*} seconds | ||
| 28 | + */ | ||
| 29 | + function formatTime(seconds) { | ||
| 30 | + const hours = Math.floor(seconds / 3600); | ||
| 31 | + const minutes = Math.floor((seconds % 3600) / 60); | ||
| 32 | + const remainingSeconds = seconds % 60; | ||
| 33 | + | ||
| 34 | + let formattedTime = ""; | ||
| 35 | + | ||
| 36 | + if (hours > 0) { | ||
| 37 | + formattedTime += hours.toString().padStart(2, "0") + ":"; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + if (minutes > 0 || hours > 0) { | ||
| 41 | + formattedTime += minutes.toString().padStart(2, "0") + ":"; | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + formattedTime += remainingSeconds.toString().padStart(2, "0"); | ||
| 45 | + | ||
| 46 | + return formattedTime; | ||
| 47 | +} | ||
| 24 | 48 | ||
| 25 | const props = defineProps({ | 49 | const props = defineProps({ |
| 26 | visible: { | 50 | visible: { |
| ... | @@ -43,6 +67,8 @@ const id = ref(''); | ... | @@ -43,6 +67,8 @@ const id = ref(''); |
| 43 | const price = ref(''); | 67 | const price = ref(''); |
| 44 | const remain_time = ref(''); | 68 | const remain_time = ref(''); |
| 45 | 69 | ||
| 70 | +let timeId = null; | ||
| 71 | + | ||
| 46 | watch( | 72 | watch( |
| 47 | () => props.visible, | 73 | () => props.visible, |
| 48 | (val) => { | 74 | (val) => { |
| ... | @@ -57,6 +83,14 @@ watch( | ... | @@ -57,6 +83,14 @@ watch( |
| 57 | ) | 83 | ) |
| 58 | 84 | ||
| 59 | onMounted(() => { | 85 | onMounted(() => { |
| 86 | + // 进入页面后,开始倒计时 | ||
| 87 | + timeId = setInterval(() => { | ||
| 88 | + remain_time.value ? remain_time.value -= 1 : 0; | ||
| 89 | + }, 1000); | ||
| 90 | +}) | ||
| 91 | + | ||
| 92 | +onUnmounted(() => { | ||
| 93 | + timeId && clearInterval(timeId); | ||
| 60 | }) | 94 | }) |
| 61 | 95 | ||
| 62 | const goToPay = () => { | 96 | const goToPay = () => { | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2022-09-19 14:11:06 | 2 | * @Date: 2022-09-19 14:11:06 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-12-19 15:01:47 | 4 | + * @LastEditTime: 2023-12-20 16:31:30 |
| 5 | * @FilePath: /meihuaApp/src/pages/book/index.vue | 5 | * @FilePath: /meihuaApp/src/pages/book/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -14,16 +14,16 @@ | ... | @@ -14,16 +14,16 @@ |
| 14 | <view class="book-type"> | 14 | <view class="book-type"> |
| 15 | <nut-tabs v-model="value" @click="onTabClick" title-scroll title-gutter="10" name="tabName" background="#FFF" color="#4C2E08" animated-time="0"> | 15 | <nut-tabs v-model="value" @click="onTabClick" title-scroll title-gutter="10" name="tabName" background="#FFF" color="#4C2E08" animated-time="0"> |
| 16 | <nut-tab-pane v-for="item in tabList" :title="item.title" :pane-key="item.key"> | 16 | <nut-tab-pane v-for="item in tabList" :title="item.title" :pane-key="item.key"> |
| 17 | - <view v-if="showContent" class="book-list"> | ||
| 18 | - <scroll-view ref="refScrollView" :style="scrollStyle" :scroll-y="true" :scroll-with-animation="true" @scrolltolower="onScrollToLower"> | ||
| 19 | - <view v-for="(item, index) in bookList" :key="index"> | ||
| 20 | - <room-card :key="index" :status="item.status"></room-card> | ||
| 21 | - <view v-if="index === bookList.length - 1" style="height: 2rem;"></view> | ||
| 22 | - </view> | ||
| 23 | - </scroll-view> | ||
| 24 | - </view> | ||
| 25 | </nut-tab-pane> | 17 | </nut-tab-pane> |
| 26 | </nut-tabs> | 18 | </nut-tabs> |
| 19 | + <view v-if="showContent" class="book-list"> | ||
| 20 | + <scroll-view ref="refScrollView" :style="scrollStyle" :scroll-y="true" :scroll-with-animation="true" @scrolltolower="onScrollToLower"> | ||
| 21 | + <view v-for="(item, index) in bookList" :key="index"> | ||
| 22 | + <room-card :key="index" :status="item.status"></room-card> | ||
| 23 | + <view v-if="index === bookList.length - 1" style="height: 2rem;"></view> | ||
| 24 | + </view> | ||
| 25 | + </scroll-view> | ||
| 26 | + </view> | ||
| 27 | </view> | 27 | </view> |
| 28 | </view> | 28 | </view> |
| 29 | <nav-bar activated="book" /> | 29 | <nav-bar activated="book" /> | ... | ... |
| 1 | <!-- | 1 | <!-- |
| 2 | * @Date: 2023-12-13 11:13:13 | 2 | * @Date: 2023-12-13 11:13:13 |
| 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com | 3 | * @LastEditors: hookehuyr hookehuyr@gmail.com |
| 4 | - * @LastEditTime: 2023-12-20 15:12:46 | 4 | + * @LastEditTime: 2023-12-20 16:16:11 |
| 5 | * @FilePath: /meihuaApp/src/pages/my/index.vue | 5 | * @FilePath: /meihuaApp/src/pages/my/index.vue |
| 6 | * @Description: 文件描述 | 6 | * @Description: 文件描述 |
| 7 | --> | 7 | --> |
| ... | @@ -15,7 +15,7 @@ | ... | @@ -15,7 +15,7 @@ |
| 15 | <text style="margin-left: 30rpx;">阿忆妞妞</text> | 15 | <text style="margin-left: 30rpx;">阿忆妞妞</text> |
| 16 | </view> | 16 | </view> |
| 17 | <view style="flex: 1;"> | 17 | <view style="flex: 1;"> |
| 18 | - <IconFont name="edit"></IconFont> | 18 | + <IconFont name="edit" @tap="goToEdit"></IconFont> |
| 19 | </view> | 19 | </view> |
| 20 | <view style="position: absolute; left: 0%; right: 0%; bottom: 0%; height: 20rpx; width: 100%; background-color: #FFF; border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;"></view> | 20 | <view style="position: absolute; left: 0%; right: 0%; bottom: 0%; height: 20rpx; width: 100%; background-color: #FFF; border-top-left-radius: 20rpx;border-top-right-radius: 20rpx;"></view> |
| 21 | </view> | 21 | </view> |
| ... | @@ -24,16 +24,16 @@ | ... | @@ -24,16 +24,16 @@ |
| 24 | <view> | 24 | <view> |
| 25 | <nut-tabs v-model="value" title-scroll title-gutter="0" name="tabName" background="#FFF" color="#6A4925" animated-time="0"> | 25 | <nut-tabs v-model="value" title-scroll title-gutter="0" name="tabName" background="#FFF" color="#6A4925" animated-time="0"> |
| 26 | <nut-tab-pane v-for="item in tabList" :title="item.title" :pane-key="item.key"> | 26 | <nut-tab-pane v-for="item in tabList" :title="item.title" :pane-key="item.key"> |
| 27 | - <view v-if="showContent" class="book-list"> | ||
| 28 | - <scroll-view ref="refScrollView" :style="scrollStyle" :scroll-y="true" :scroll-with-animation="true" @scrolltolower="onScrollToLower"> | ||
| 29 | - <view v-for="(item, index) in 5" :key="index"> | ||
| 30 | - <order-card :key="index" @onPay="onPay"></order-card> | ||
| 31 | - <view v-if="index === 4" style="height: 2rem;"></view> | ||
| 32 | - </view> | ||
| 33 | - </scroll-view> | ||
| 34 | - </view> | ||
| 35 | </nut-tab-pane> | 27 | </nut-tab-pane> |
| 36 | </nut-tabs> | 28 | </nut-tabs> |
| 29 | + <view v-if="showContent" class="book-list"> | ||
| 30 | + <scroll-view ref="refScrollView" :style="scrollStyle" :scroll-y="true" :scroll-with-animation="true" @scrolltolower="onScrollToLower"> | ||
| 31 | + <view v-for="(item, index) in orderList" :key="index"> | ||
| 32 | + <order-card :key="index" :data="item" @onPay="onPay"></order-card> | ||
| 33 | + <view v-if="index === orderList.length-1" style="height: 2rem;"></view> | ||
| 34 | + </view> | ||
| 35 | + </scroll-view> | ||
| 36 | + </view> | ||
| 37 | </view> | 37 | </view> |
| 38 | </view> | 38 | </view> |
| 39 | 39 | ||
| ... | @@ -68,10 +68,39 @@ const tabList = ref([{ | ... | @@ -68,10 +68,39 @@ const tabList = ref([{ |
| 68 | key: '3', | 68 | key: '3', |
| 69 | }]); | 69 | }]); |
| 70 | 70 | ||
| 71 | +const orderList = ref([ | ||
| 72 | + { | ||
| 73 | + id: 1, | ||
| 74 | + name: '阿忆妞妞1', | ||
| 75 | + phone: '138****8888', | ||
| 76 | + address: '北京市朝阳区', | ||
| 77 | + time: '2023-12-13 11:13:13', | ||
| 78 | + price: 1200, | ||
| 79 | + remain_time: 10, | ||
| 80 | + }, | ||
| 81 | + { | ||
| 82 | + id: 2, | ||
| 83 | + name: '阿忆妞妞2', | ||
| 84 | + phone: '138****8888', | ||
| 85 | + address: '北京市朝阳区', | ||
| 86 | + time: '2023-12-13 11:13:13', | ||
| 87 | + price: 1200, | ||
| 88 | + remain_time: 100, | ||
| 89 | + }, | ||
| 90 | + { | ||
| 91 | + id: 3, | ||
| 92 | + name: '阿忆妞妞3', | ||
| 93 | + phone: '138****8888', | ||
| 94 | + address: '北京市朝阳区', | ||
| 95 | + time: '2023-12-13 11:13:13', | ||
| 96 | + price: 1200, | ||
| 97 | + remain_time: 100, | ||
| 98 | + }, | ||
| 99 | +]) | ||
| 71 | 100 | ||
| 72 | const show_pay = ref(false); | 101 | const show_pay = ref(false); |
| 73 | const payData = ref({}); | 102 | const payData = ref({}); |
| 74 | -const onPay = (id) => { | 103 | +const onPay = ({ id, remain_time }) => { |
| 75 | console.warn(id); | 104 | console.warn(id); |
| 76 | // Taro.showToast({ | 105 | // Taro.showToast({ |
| 77 | // title: '支付已超时', | 106 | // title: '支付已超时', |
| ... | @@ -81,12 +110,18 @@ const onPay = (id) => { | ... | @@ -81,12 +110,18 @@ const onPay = (id) => { |
| 81 | show_pay.value = true; | 110 | show_pay.value = true; |
| 82 | payData.value.id = '123'; | 111 | payData.value.id = '123'; |
| 83 | payData.value.price = 1200; | 112 | payData.value.price = 1200; |
| 84 | - payData.value.remain_time = '30:00'; | 113 | + payData.value.remain_time = remain_time; |
| 85 | } | 114 | } |
| 86 | 115 | ||
| 87 | const onPayClose = () => { | 116 | const onPayClose = () => { |
| 88 | show_pay.value = false; | 117 | show_pay.value = false; |
| 89 | } | 118 | } |
| 119 | + | ||
| 120 | +const goToEdit = () => { | ||
| 121 | + Taro.navigateTo({ | ||
| 122 | + url: '/pages/myInfo/index', | ||
| 123 | + }); | ||
| 124 | +} | ||
| 90 | </script> | 125 | </script> |
| 91 | 126 | ||
| 92 | <script> | 127 | <script> | ... | ... |
-
Please register or login to post a comment