orderManage.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. <template>
  2. <view class="container">
  3. <!-- 每一个订单区域 -->
  4. <uni-swipe-action>
  5. <uni-swipe-action-item v-for="item in orderList" :key="item.id">
  6. <!-- 右侧选项内容区域 -->
  7. <template v-slot:right>
  8. <view class="order_right" @click="handleDelete(item)">
  9. <img class="img" src="../../static/my/delete.png" />
  10. </view>
  11. </template>
  12. <view class="order_box" @click="goPageOrderDetail(item.type)">
  13. <!-- 标题区域 -->
  14. <view class="box_header">
  15. <img class="img" src="../../static/my/hotel.png" />
  16. <view class="title">{{ item.hotelName }}</view>
  17. <view class="type type2" v-if="item.type === 1">
  18. 待付款,剩余
  19. <uv-count-down :time="countDownTime" format="mm:ss" @change="change" @finish="finish"></uv-count-down>
  20. </view>
  21. <view class="type" v-if="item.type === 2">支付超时</view>
  22. <view class="type" v-if="item.type === 3">已支付</view>
  23. <view class="type" v-if="item.type === 4">已取消</view>
  24. <view class="type" v-if="item.type === 5">已退单</view>
  25. <view class="type" v-if="item.type === 6">待入住</view>
  26. <view class="type" v-if="item.type === 7">已入住</view>
  27. <view class="type" v-if="item.type === 8">已退款</view>
  28. <view class="type" v-if="item.type === 9">已消费</view>
  29. </view>
  30. <!-- 酒店信息区域 -->
  31. <view class="box_info">
  32. <img class="img" :src="item.imgUrl" />
  33. <view class="info_right">
  34. <view class="info_right_item">1间,大床房</view>
  35. <view class="info_right_item">2023-07-26 - 2023-07-27</view>
  36. <view class="info_right_item">总价:¥229.00</view>
  37. </view>
  38. </view>
  39. <!-- 按钮区域 -->
  40. <view class="box_btn" v-if="item.type === 1 || item.type === 2">
  41. <view class="btn_item" v-if="item.type === 1" @click="goPagePay">预定</view>
  42. <view class="btn_item" v-if="item.type === 2" @click="goPageDetail">再次预定</view>
  43. </view>
  44. </view>
  45. </uni-swipe-action-item>
  46. </uni-swipe-action>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. /* type
  54. 1 为待付款 2 为支付超时,
  55. 3 为已支付 4 为已取消,
  56. 5 为已退单 6 为待入住,
  57. 7 为已入住 8 为已退款,
  58. 9 为已消费 */
  59. orderList: [
  60. {
  61. id: 1,
  62. hotelName: '靖安乡宿',
  63. type: 1,
  64. imgUrl: '../../static/my/test.png'
  65. },
  66. {
  67. id: 2,
  68. hotelName: '开心乡宿',
  69. type: 2,
  70. imgUrl: '../../static/my/test.png'
  71. },
  72. {
  73. id: 3,
  74. hotelName: '健康乡宿',
  75. type: 3,
  76. imgUrl: '../../static/my/test.png'
  77. },
  78. {
  79. id: 4,
  80. hotelName: '幸福乡宿',
  81. type: 4,
  82. imgUrl: '../../static/my/test.png'
  83. },
  84. {
  85. id: 5,
  86. hotelName: '靖安乡宿',
  87. type: 5,
  88. imgUrl: '../../static/my/test.png'
  89. },
  90. {
  91. id: 6,
  92. hotelName: '开心乡宿',
  93. type: 6,
  94. imgUrl: '../../static/my/test.png'
  95. },
  96. {
  97. id: 7,
  98. hotelName: '健康乡宿',
  99. type: 7,
  100. imgUrl: '../../static/my/test.png'
  101. },
  102. {
  103. id: 8,
  104. hotelName: '幸福乡宿',
  105. type: 8,
  106. imgUrl: '../../static/my/test.png'
  107. },
  108. {
  109. id: 9,
  110. hotelName: '幸福乡宿',
  111. type: 9,
  112. imgUrl: '../../static/my/test.png'
  113. }
  114. ],
  115. // 倒计时时间(毫秒)
  116. countDownTime: 1000 * 60 * 15
  117. }
  118. },
  119. methods: {
  120. // 倒计时变化时触发
  121. change(e) {
  122. // console.log(e)
  123. },
  124. // 倒计时结束回调
  125. finish() {
  126. uni.showModal({
  127. title: '提示',
  128. content: '订单已超过可支付时间,请重新下单',
  129. showCancel: false,
  130. success: (res) => {
  131. if (res.confirm) {
  132. uni.switchTab({
  133. url: '/pages/home/home'
  134. })
  135. }
  136. }
  137. })
  138. },
  139. // 点击预定按钮回调
  140. goPagePay() {
  141. uni.navigateTo({
  142. url: '/pages/pay/pay'
  143. })
  144. },
  145. // 点击再次预定按钮回调
  146. goPageDetail() {
  147. uni.navigateTo({
  148. url: '/pages/detail/detail'
  149. })
  150. },
  151. // 点击每一个订单回调
  152. goPageOrderDetail(type) {
  153. uni.navigateTo({
  154. url: `/pages/orderDetail/orderDetail?type=${type}`
  155. })
  156. },
  157. // 右侧选项内容删除按钮回调
  158. handleDelete(item) {
  159. console.log(item.name)
  160. uni.showModal({
  161. title: '提示',
  162. content: '确定删除吗?删除后不可恢复',
  163. success: (res) => {
  164. if (res.confirm) {
  165. uni.showToast({
  166. title: '删除成功',
  167. icon: 'success'
  168. })
  169. }
  170. }
  171. })
  172. }
  173. }
  174. }
  175. </script>
  176. <style lang="scss" scoped>
  177. .container {
  178. box-sizing: border-box;
  179. padding: 0 20rpx 40rpx;
  180. min-height: 100vh;
  181. background-color: #f2f3f5;
  182. overflow-y: auto;
  183. .order_right {
  184. display: flex;
  185. justify-content: center;
  186. align-items: center;
  187. margin-top: 20rpx;
  188. width: 126rpx;
  189. background-color: #d43030;
  190. .img {
  191. width: 50rpx;
  192. height: 50rpx;
  193. }
  194. }
  195. .order_box {
  196. margin-top: 20rpx;
  197. box-sizing: border-box;
  198. padding: 0 22rpx;
  199. width: 710rpx;
  200. border-radius: 15rpx;
  201. background-color: #fff;
  202. .box_header {
  203. display: flex;
  204. align-items: center;
  205. height: 94rpx;
  206. .img {
  207. width: 47rpx;
  208. height: 47rpx;
  209. }
  210. .title {
  211. margin-left: 16rpx;
  212. font-size: 32rpx;
  213. font-weight: bold;
  214. }
  215. .type {
  216. display: flex;
  217. align-items: center;
  218. margin-left: auto;
  219. color: #808080;
  220. font-size: 28rpx;
  221. }
  222. .type2 {
  223. color: #ff5733;
  224. }
  225. }
  226. .box_info {
  227. display: flex;
  228. height: 140rpx;
  229. .img {
  230. width: 100rpx;
  231. height: 100rpx;
  232. border-radius: 9rpx;
  233. }
  234. .info_right {
  235. display: flex;
  236. flex-direction: column;
  237. justify-content: space-around;
  238. margin-top: -5rpx;
  239. margin-left: 18rpx;
  240. height: 120rpx;
  241. color: #808080;
  242. font-size: 28rpx;
  243. .info_right_item {
  244. flex: 1;
  245. }
  246. }
  247. }
  248. .box_btn {
  249. display: flex;
  250. justify-content: flex-end;
  251. margin-top: -10rpx;
  252. height: 100rpx;
  253. .btn_item {
  254. display: flex;
  255. justify-content: center;
  256. align-items: center;
  257. margin-left: 20rpx;
  258. width: 178rpx;
  259. height: 68rpx;
  260. border-radius: 64rpx;
  261. color: #808080;
  262. font-size: 28rpx;
  263. border: 1rpx solid #808080;
  264. }
  265. }
  266. }
  267. }
  268. // 修改倒计时字体颜色
  269. ::v-deep .uv-count-down .uv-count-down__text {
  270. color: #ff5733;
  271. }
  272. </style>