my_orderlist.vue 11 KB

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