my_orderlist.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312
  1. <template>
  2. <view class="content">
  3. <!-- 切换栏 -->
  4. <view class="inv-h-w">
  5. <view :class="['inv-h',Inv==6?'inv-h-se':'']" @click="changeTab(6)">全部</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==0?'inv-h-se':'']" @click="changeTab(0)">已取消</view>
  10. <view :class="['inv-h',Inv==4?'inv-h-se':'']" @click="changeTab(4)">待结账</view>
  11. <view :class="['inv-h',Inv==5?'inv-h-se':'']" @click="changeTab(5)">已完成</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.roomTypeMasterImg"></image>
  18. <view class="room-name">{{item.roomTypeName}}</view>
  19. <view class="room-time">{{item.enableStartTime|snippet}}-{{item.enableEndTime|snippet}}</view>
  20. <view class="room-order">订单号:{{item.id}}</view>
  21. <view class="room-type">
  22. <text v-if="item.orderStatu==0">已取消</text>
  23. <text v-if="item.orderStatu==1">待支付</text>
  24. <text v-if="item.orderStatu==2">待入住</text>
  25. <text v-if="item.orderStatu==3">已入住</text>
  26. <text v-if="item.orderStatu==4">待结账</text>
  27. <text v-if="item.orderStatu==5">已完成</text>
  28. </view>
  29. <view class="room-price">¥{{item.payAmount}}</view>
  30. </view>
  31. <uni-countdown v-if="item.orderStatu == 1" class="room-count" color="#FF5733" :show-day="false" :second="timeupSecond" @timeup="timeup" />
  32. <text v-if="item.orderStatu == 1" class="room-count-txt">之后取消</text>
  33. <view class="room-button">
  34. <text v-if="item.orderStatu == 0">删除</text>
  35. <text v-if="item.orderStatu == 1">取消订单</text>
  36. <text v-if="item.orderStatu == 5">删除</text>
  37. <text v-if="item.orderStatu == 2">取消订单</text>
  38. <text v-if="item.orderStatu == 3" @click="getOrderReturn(item.id)">退房</text>
  39. </view>
  40. <view class="room-button2" :class="{'room-button3': item.orderStatu == 1}">
  41. <text v-if="item.orderStatu == 0">再次预定</text>
  42. <text v-if="item.orderStatu == 1">支付</text>
  43. <text v-if="item.orderStatu == 5">再次预定</text>
  44. <text v-if="item.orderStatu == 2">办理入住</text>
  45. <text v-if="item.orderStatu == 3" @click="navigateToXuzhu">续住</text>
  46. </view>
  47. <view class="room-line" v-if="index<(troom.length-1)"></view>
  48. </view>
  49. </view>
  50. <!-- 办理续住弹窗 -->
  51. <uni-popup ref="popup_xuzhu" type="dialog" :mask-click="false">
  52. <view class="popup_bg_xu">
  53. <text class="popup_title">办理续住</text>
  54. <text class="popup_error" @click="popupXuzhuClose"></text>
  55. <text class="popup_xu_line"></text>
  56. <!-- 时间选择 -->
  57. <view class="select-time-xu" @click="openXuCalendar">
  58. <view class="select-time-one-xu">
  59. <text class="select-list">周四入住</text>
  60. <text class="select-list-time">07月21日</text>
  61. </view>
  62. <view class="select-center">
  63. <view class="select-line1"></view>
  64. <view class="select-circle">1晚</view>
  65. <view class="select-line2"></view>
  66. </view>
  67. <view class="select-time-one-xu">
  68. <text class="select-list">周五离店</text>
  69. <text class="select-list-time">07月22日</text>
  70. </view>
  71. </view>
  72. <text class="popup_xu_txt">注:办理续住最多7天,如超过7天需要重新预定</text>
  73. <!-- 支付框 -->
  74. <view class="fukuan">
  75. <view class="fu-price"><text style="font-size: 28rpx;">总计:</text>¥20.00</view>
  76. <view class="fu-zhifu">立即支付</view>
  77. </view>
  78. </view>
  79. </uni-popup>
  80. <uni-popup ref="popup_xu" :mask-click="true">
  81. <uni-calendar :selected="infoXu.selected" class="uni-calendar--hook" :clear-date="true" :date="infoXu.date" :insert="infoXu.insert" :lunar="infoXu.lunar" :startDate="infoXu.startDate"
  82. :endDate="infoXu.endDate" :range="infoXu.range" @change="changeXu"/>
  83. </uni-popup>
  84. </view>
  85. </template>
  86. <script>
  87. /**
  88. * 获取任意时间
  89. */
  90. function getDate(date, AddDayCount = 0) {
  91. if (!date) {
  92. date = new Date()
  93. }
  94. if (typeof date !== 'object') {
  95. date = date.replace(/-/g, '/')
  96. }
  97. const dd = new Date(date)
  98. dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
  99. var a = new Array("日", "一", "二", "三", "四", "五", "六");
  100. var week = new Date().getDay();
  101. var week2 = new Date().getDay()+1;
  102. const y = dd.getFullYear()
  103. const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
  104. const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
  105. const h = dd.getHours() < 10 ? '0' + dd.getHours() : dd.getHours()
  106. const f = dd.getMinutes() < 10 ? '0' + dd.getMinutes() : dd.getMinutes()
  107. const s = dd.getSeconds() < 10 ? '0' + dd.getSeconds() : dd.getSeconds()
  108. return {
  109. fullDate: y + '-' + m + '-' + d,
  110. fullDate2: y + '-' + m + '-' + d+' '+h+':'+f+':'+s,
  111. fullTime: m + '月' + d + '日',
  112. year: y,
  113. month: m,
  114. date: d,
  115. day: dd.getDay(),
  116. sWeek:"周"+ a[week],
  117. eWeek:"周"+ a[week2]
  118. }
  119. }
  120. // 导入图片
  121. import room1 from '../../static/index/room_image.svg'
  122. import room2 from '../../static/index/room_image.svg'
  123. export default {
  124. data(){
  125. return {
  126. Inv: 6,
  127. room:[],
  128. troom:[],
  129. timeupSecond: 1800,
  130. //续住里选择器
  131. infoXu: {
  132. lunar: true,
  133. range: true,
  134. insert: true,
  135. selected: [],
  136. startDate:'',
  137. date:'',
  138. endDate:''
  139. },
  140. }
  141. },
  142. filters:{
  143. //字过长变为...
  144. snippet: function(value) {
  145. if(value.length>=10) {
  146. return value.slice(0, 10);
  147. } else {
  148. return value
  149. }
  150. },
  151. },
  152. onShow() {
  153. // 模拟从后台拿到的数据
  154. var room = [
  155. // {id:1,srcUrl:room1,name:'01户型',order_num:'订单号:23021260',price:'¥0.00',time:'2022.07.21 - 2022.07.22',type:'待支付',types:1},
  156. // {id:2,srcUrl:room2,name:'02户型',order_num:'订单号:23021261',price:'¥0.00',time:'2022.07.21 - 2022.07.22',type:'已取消',types:4},
  157. // {id:3,srcUrl:room1,name:'01户型',order_num:'订单号:23021262',price:'¥0.00',time:'2022.07.21 - 2022.07.22',type:'已完成',types:6},
  158. // {id:4,srcUrl:room2,name:'02户型',order_num:'订单号:23021263',price:'¥0.00',time:'2022.07.21 - 2022.07.22',type:'待入住',types:2},
  159. ]
  160. // list数组中为每一项添加双向绑定的属性---这个属性要在页面显示(onShow)添加
  161. room.forEach(el => el.isChecked = false);
  162. this.room = room;
  163. this.troom = room;//真实数据赋值给页面数据
  164. this.changeTab(this.Inv)
  165. },
  166. onLoad(option) {
  167. this.Inv=option.Inv;
  168. },
  169. mounted(){
  170. },
  171. onReady() {
  172. this.$nextTick(() => {
  173. this.showCalendar = true
  174. })
  175. // TODO 模拟请求异步同步数据
  176. setTimeout(() => {
  177. // console.log('date:'+getDate(new Date()).fullDate)
  178. // console.log('startDate:'+getDate(new Date()).fullDate)
  179. // console.log('endDate:'+getDate(new Date(),6).fullDate)
  180. this.infoXu.date = getDate(new Date()).fullDate
  181. this.infoXu.startDate = getDate(new Date()).fullDate
  182. this.infoXu.endDate = getDate(new Date(),6).fullDate
  183. }, 2000)
  184. },
  185. methods:{
  186. // 订单列表
  187. getOrderPage() {
  188. let _self = this
  189. _self.troom = []
  190. _self.room = []
  191. this.$axios.get("/ihotel/hotelOrder/user/order/page?curPage=1&pageSize=100&statu="+this.Inv,
  192. {
  193. headers:{
  194. 'user_token':localStorage.getItem('user_token')
  195. }
  196. }).then(res => {
  197. res = res.data
  198. if (res.success) {
  199. // console.log(res)
  200. res.data.list.forEach(data => {
  201. if (data.flag !== '-1') {
  202. _self.troom.push(data)
  203. _self.room.push(data)
  204. }
  205. })
  206. } else {
  207. console.log('获取订单列表失败')
  208. }
  209. });
  210. },
  211. // 办理退房
  212. getOrderReturn(id) {
  213. // this.header = {
  214. // 'user_token':localStorage.getItem('user_token')
  215. // }
  216. // this.$myRequest({
  217. // url: `/ihotel/hotelOrder/user/order/return/${id}`,
  218. // headers: this.header,
  219. // }).then(res => {
  220. // console.log(res)
  221. // }).catch(err => {
  222. // console.log(err)
  223. // })
  224. let _self = this
  225. this.$axios.defaults.headers.common['user_token'] = localStorage.getItem('user_token');
  226. this.$axios.put(`/ihotel/hotelOrder/user/order/return/${id}`,).then(res => {
  227. res = res.data
  228. if (res.success) {
  229. console.log(res)
  230. res.data.list.forEach(data => {
  231. if (data.flag !== '-1') {
  232. alert('退房成功')
  233. }
  234. })
  235. } else {
  236. alert('退房失败')
  237. }
  238. });
  239. },
  240. /**
  241. * @Explain:选项卡点击切换
  242. */
  243. changeTab(Inv) {
  244. console.log(Inv)
  245. var that = this;
  246. this.Inv =Inv
  247. var arr = [];
  248. this.getOrderPage(this.Inv)
  249. that.room.map(item => {//遍历真实数据,拿到所需要的数据放在页面数据tlist中,展示在页面上
  250. if(item.orderStatu == this.Inv){
  251. arr.push(item);
  252. }
  253. })
  254. that.troom = arr;
  255. if(this.Inv == 6){//获取全部数据
  256. that.troom = that.room;
  257. }
  258. //滚动到顶部
  259. uni.pageScrollTo({
  260. duration: 0, //过渡时间必须为0,否则运行到手机会报错
  261. scrollTop: 0 //滚动到实际距离是元素距离顶部的距离减去最外层盒子的滚动距离(如res.top - data.top)
  262. })
  263. },
  264. // 倒计时
  265. timeup() {
  266. uni.showToast({
  267. title: '时间到'
  268. })
  269. this.timeupSecond = 1799
  270. },
  271. // 跳转到订单详情
  272. navigateToOrderMark(id) {
  273. // console.log(id)
  274. uni.navigateTo({
  275. url: "../order_mark/order_mark?orderId="+id,
  276. })
  277. },
  278. //办理续住弹窗
  279. navigateToXuzhu(){
  280. this.$refs.popup_xuzhu.open()
  281. },
  282. popupXuzhuClose() {
  283. this.$refs.popup_xuzhu.close()
  284. },
  285. // 续住里日期选择器弹窗
  286. openXuCalendar() {
  287. this.$refs.popup_xu.open()
  288. },
  289. changeXu(e) {
  290. console.log('1change 返回:', e)
  291. // 模拟动态打卡
  292. if (this.infoXu.selected.length > 5) return
  293. this.infoXu.selected.push({
  294. date: e.range.before,
  295. info: '到店'
  296. })
  297. this.infoXu.selected.push({
  298. date: e.range.after,
  299. info: '离店'
  300. })
  301. },
  302. },
  303. }
  304. </script>
  305. <style>
  306. @import url(./css/my_orderlist.css);
  307. </style>