my_orderlist.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <view class="content">
  3. <!-- 切换栏 -->
  4. <view class="inv-h-w">
  5. <view :class="['inv-h',Inv==0?'inv-h-se':'']" @click="changeTab(0)">全部</view>
  6. <view :class="['inv-h',Inv==1?'inv-h-se':'']" @click="changeTab(1)">待支付</view>
  7. <view :class="['inv-h',Inv==2?'inv-h-se':'']" @click="changeTab(2)">待入住</view>
  8. <view :class="['inv-h',Inv==3?'inv-h-se':'']" @click="changeTab(3)">已入住</view>
  9. <view :class="['inv-h',Inv==4?'inv-h-se':'']" @click="changeTab(4)">已取消</view>
  10. <view :class="['inv-h',Inv==5?'inv-h-se':'']" @click="changeTab(5)">待结账</view>
  11. <view :class="['inv-h',Inv==6?'inv-h-se':'']" @click="changeTab(6)">已完成</view>
  12. </view>
  13. <!-- 订单样式 -->
  14. <view class="room-kuang">
  15. <view class="room-xinxi" v-for="(item,index) in troom" :key="index">
  16. <view @click="navigateToOrderMark(item.id)">
  17. <image class="room-image" :src="item.srcUrl"></image>
  18. <view class="room-name">{{item.name}}</view>
  19. <view class="room-time">{{item.time}}</view>
  20. <view class="room-order">{{item.order_num}}</view>
  21. <view class="room-type">{{item.type}}</view>
  22. <view class="room-price">{{item.price}}</view>
  23. </view>
  24. <uni-countdown v-if="item.types === 1" class="room-count" color="#FF5733" :show-day="false" :second="timeupSecond" @timeup="timeup" />
  25. <text v-if="item.types === 1" class="room-count-txt">之后取消</text>
  26. <view class="room-button">
  27. <text v-if="item.type === '已取消'">删除</text>
  28. <text v-if="item.type === '待支付'">取消订单</text>
  29. <text v-if="item.type === '已完成'">删除</text>
  30. <text v-if="item.type === '待入住'">取消订单</text>
  31. <text v-if="item.type === '已入住'">删除</text>
  32. </view>
  33. <view class="room-button2" :class="{'room-button3': item.type == '待支付'}">
  34. <text v-if="item.type === '已取消'">再次预定</text>
  35. <text v-if="item.type === '待支付'">支付</text>
  36. <text v-if="item.type === '已完成'">再次预定</text>
  37. <text v-if="item.type === '待入住'">办理入住</text>
  38. <text v-if="item.type === '已入住'">退房</text>
  39. </view>
  40. <view class="room-line" v-if="index<(troom.length-1)"></view>
  41. </view>
  42. </view>
  43. </view>
  44. </template>
  45. <script>
  46. // 导入图片
  47. import room1 from '../../static/index/room_image.svg'
  48. import room2 from '../../static/index/room_image.svg'
  49. export default {
  50. data(){
  51. return {
  52. Inv: 0,
  53. tabList:[
  54. {id:1,name:'全部'},
  55. {id:2,name:'待支付'},
  56. {id:3,name:'待入住'},
  57. {id:4,name:'已入住'},
  58. {id:5,name:'已取消'},
  59. {id:6,name:'待结账'},
  60. {id:7,name:'已完成'},
  61. ],
  62. room:[],
  63. troom:[],
  64. timeupSecond: 1800
  65. }
  66. },
  67. onShow() {
  68. // 模拟从后台拿到的数据
  69. var room = [
  70. {id:1,srcUrl:room1,name:'01户型',order_num:'订单号:23021260',price:'¥0.00',time:'2022.07.21 - 2022.07.22',type:'待支付',types:1},
  71. {id:2,srcUrl:room2,name:'02户型',order_num:'订单号:23021261',price:'¥0.00',time:'2022.07.21 - 2022.07.22',type:'已取消',types:4},
  72. {id:3,srcUrl:room1,name:'01户型',order_num:'订单号:23021262',price:'¥0.00',time:'2022.07.21 - 2022.07.22',type:'已完成',types:6},
  73. {id:4,srcUrl:room2,name:'02户型',order_num:'订单号:23021263',price:'¥0.00',time:'2022.07.21 - 2022.07.22',type:'待入住',types:2},
  74. ]
  75. // list数组中为每一项添加双向绑定的属性---这个属性要在页面显示(onShow)添加
  76. room.forEach(el => el.isChecked = false);
  77. this.room = room;
  78. this.troom = room;//真实数据赋值给页面数据
  79. },
  80. onLoad(option) {
  81. this.Inv=option.Inv;
  82. // console.log(this.Inv)
  83. },
  84. mounted(){
  85. // location.reload()//自动刷新
  86. console.log(this.Inv)
  87. this.changeTab(this.Inv)
  88. },
  89. methods:{
  90. /**
  91. * @Explain:选项卡点击切换
  92. */
  93. changeTab(Inv) {
  94. var that = this;
  95. this.Inv =Inv
  96. var arr = [];
  97. that.room.map(item => {//遍历真实数据,拿到所需要的数据放在页面数据tlist中,展示在页面上
  98. if(item.types == this.Inv){
  99. arr.push(item);
  100. }
  101. })
  102. that.troom = arr;
  103. if(this.Inv == 0){//获取全部数据
  104. that.troom = that.room;
  105. }
  106. //滚动到顶部
  107. uni.pageScrollTo({
  108. duration: 0, //过渡时间必须为0,否则运行到手机会报错
  109. scrollTop: 0 //滚动到实际距离是元素距离顶部的距离减去最外层盒子的滚动距离(如res.top - data.top)
  110. })
  111. },
  112. // 倒计时
  113. timeup() {
  114. uni.showToast({
  115. title: '时间到'
  116. })
  117. this.timeupSecond = 1799
  118. },
  119. // 跳转到订单详情
  120. navigateToOrderMark(id) {
  121. // console.log(id)
  122. uni.navigateTo({
  123. url: "../order_mark/order_mark?ids="+id,
  124. complete: () => {console.log("调用完成,id:"+id)}
  125. })
  126. },
  127. },
  128. }
  129. </script>
  130. <style>
  131. @import url(./css/my_orderlist.css);
  132. </style>