my_orderlist.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  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">
  27. 待结账
  28. </text>
  29. <text v-if="item.orderStatu==5">已完成</text>
  30. </view>
  31. <view class="room-price">¥{{item.payAmount}}</view>
  32. </view>
  33. <uni-countdown v-if="item.orderStatu == 1" class="room-count" color="#FF5733" :show-day="false" :second="timeupSecond" @timeup="timeup(item.createTime)" />
  34. <text v-if="item.orderStatu == 1" class="room-count-txt">之后取消</text>
  35. <view class="room-button" v-if="item.orderStatu != 4 && item.orderStatu != 2 && item.orderStatu != 3">
  36. <text v-if="item.orderStatu == 0" @click="openDel(item.id,'warn')">删除</text>
  37. <text v-if="item.orderStatu == 1" @click="openQu(item.id,'warn')">取消订单</text>
  38. <text v-if="item.orderStatu == 5" @click="openDel(item.id,'warn')">删除</text>
  39. <!-- <text v-if="item.orderStatu == 2">取消订单</text> -->
  40. <!-- <text v-if="item.orderStatu == 3" @click="navigateToXuzhu">续住</text> -->
  41. </view>
  42. <view class="room-button2" :class="{'room-button3': item.orderStatu == 1 || item.orderStatu == 4}">
  43. <text v-if="item.orderStatu == 0" @click="navigateToZaici(item.enableStartTime,item.enableEndTime,item.roomTypeId)">再次预定</text>
  44. <text v-if="item.orderStatu == 1" @click="getOrderPay(item.id)">支付</text>
  45. <text v-if="item.orderStatu == 4" @click="navigateToJiezhang(item.id)">去处理</text>
  46. <text v-if="item.orderStatu == 5" @click="navigateToWanchengZaici(item.roomTypeId)">再次预定</text>
  47. <text v-if="item.orderStatu == 2" @click="openRu(item.id,'warn')">办理入住</text>
  48. <text v-if="item.orderStatu == 3" @click="openTui(item.id,'warn')">退房</text>
  49. </view>
  50. <view class="room-line" v-if="index<(troom.length-1)"></view>
  51. </view>
  52. </view>
  53. <!-- 提示时弹框 -->
  54. <uni-popup ref="popup_order2" type="dialog">
  55. <uni-popup-dialog :type="msgType2" cancelText="关闭" confirmText="确定" :content='order_txt2' @confirm="dialogConfirm"
  56. @close="dialogClose"></uni-popup-dialog>
  57. </uni-popup>
  58. <uni-popup ref="popup_order" type="dialog">
  59. <uni-popup-dialog :type="msgType" cancelText="关闭" :content='order_txt'></uni-popup-dialog>
  60. </uni-popup>
  61. <!-- 办理续住弹窗 -->
  62. <uni-popup ref="popup_xuzhu" type="dialog" :mask-click="false">
  63. <view class="popup_bg_xu">
  64. <text class="popup_title">办理续住</text>
  65. <text class="popup_error" @click="popupXuzhuClose"></text>
  66. <text class="popup_xu_line"></text>
  67. <!-- 时间选择 -->
  68. <view class="select-time-xu" @click="openXuCalendar">
  69. <view class="select-time-one-xu">
  70. <text class="select-list">周四入住</text>
  71. <text class="select-list-time">07月21日</text>
  72. </view>
  73. <view class="select-center">
  74. <view class="select-line1"></view>
  75. <view class="select-circle">1晚</view>
  76. <view class="select-line2"></view>
  77. </view>
  78. <view class="select-time-one-xu">
  79. <text class="select-list">周五离店</text>
  80. <text class="select-list-time">07月22日</text>
  81. </view>
  82. </view>
  83. <text class="popup_xu_txt">注:办理续住最多7天,如超过7天需要重新预定</text>
  84. <!-- 支付框 -->
  85. <view class="fukuan">
  86. <view class="fu-price"><text style="font-size: 28rpx;">总计:</text>¥20.00</view>
  87. <view class="fu-zhifu">立即支付</view>
  88. </view>
  89. </view>
  90. </uni-popup>
  91. <uni-popup ref="popup_xu" :mask-click="true">
  92. <uni-calendar :selected="infoXu.selected" class="uni-calendar--hook" :clear-date="true" :date="infoXu.date" :insert="infoXu.insert" :lunar="infoXu.lunar" :startDate="infoXu.startDate"
  93. :endDate="infoXu.endDate" :range="infoXu.range" @change="changeXu"/>
  94. </uni-popup>
  95. </view>
  96. </template>
  97. <script>
  98. /**
  99. * 获取任意时间
  100. */
  101. function getDate(date, AddDayCount = 0) {
  102. if (!date) {
  103. date = new Date()
  104. }
  105. if (typeof date !== 'object') {
  106. date = date.replace(/-/g, '/')
  107. }
  108. const dd = new Date(date)
  109. dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
  110. var a = new Array("日", "一", "二", "三", "四", "五", "六");
  111. var week = new Date().getDay();
  112. var week2 = new Date().getDay()+1;
  113. const y = dd.getFullYear()
  114. const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
  115. const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
  116. const h = dd.getHours() < 10 ? '0' + dd.getHours() : dd.getHours()
  117. const f = dd.getMinutes() < 10 ? '0' + dd.getMinutes() : dd.getMinutes()
  118. const s = dd.getSeconds() < 10 ? '0' + dd.getSeconds() : dd.getSeconds()
  119. return {
  120. fullDate: y + '-' + m + '-' + d,
  121. fullDate2: y + '-' + m + '-' + d+' '+h+':'+f+':'+s,
  122. fullTime: m + '月' + d + '日',
  123. year: y,
  124. month: m,
  125. date: d,
  126. day: dd.getDay(),
  127. sWeek:"周"+ a[week],
  128. eWeek:"周"+ a[week2]
  129. }
  130. }
  131. // 导入图片
  132. import room1 from '../../static/index/room_image.svg'
  133. import room2 from '../../static/index/room_image.svg'
  134. export default {
  135. data(){
  136. return {
  137. Inv: 6,
  138. room:[],
  139. troom:[],
  140. timeupSecond:null,
  141. //续住里选择器
  142. infoXu: {
  143. lunar: true,
  144. range: true,
  145. insert: true,
  146. selected: [],
  147. startDate:'',
  148. date:'',
  149. endDate:'',
  150. order_txt:'',//提交订单时信息
  151. },
  152. msgType:'warn',
  153. msgType2:'warn',
  154. order_txt:'',//
  155. order_txt2:'',//
  156. tankuang:false,//弹框是否确定
  157. order_txt_id:'',
  158. }
  159. },
  160. filters:{
  161. //字过长变为...
  162. snippet: function(value) {
  163. if(value.length>=10) {
  164. return value.slice(0, 10);
  165. } else {
  166. return value
  167. }
  168. },
  169. },
  170. onShow() {
  171. // 模拟从后台拿到的数据
  172. var room = []
  173. // list数组中为每一项添加双向绑定的属性---这个属性要在页面显示(onShow)添加
  174. room.forEach(el => el.isChecked = false);
  175. this.room = room;
  176. this.troom = room;//真实数据赋值给页面数据
  177. this.changeTab(this.Inv)
  178. },
  179. onLoad(option) {
  180. this.Inv=option.Inv;
  181. },
  182. /**
  183. * 生命周期函数--监听页面卸载
  184. */
  185. onUnload: function () {
  186. clearInterval(this.timer);
  187. },
  188. mounted(){
  189. },
  190. onReady() {
  191. this.$nextTick(() => {
  192. this.showCalendar = true
  193. })
  194. // TODO 模拟请求异步同步数据
  195. setTimeout(() => {
  196. // console.log('date:'+getDate(new Date()).fullDate)
  197. // console.log('startDate:'+getDate(new Date()).fullDate)
  198. // console.log('endDate:'+getDate(new Date(),6).fullDate)
  199. this.infoXu.date = getDate(new Date()).fullDate
  200. this.infoXu.startDate = getDate(new Date()).fullDate
  201. this.infoXu.endDate = getDate(new Date(),6).fullDate
  202. }, 2000)
  203. },
  204. methods:{
  205. // 订单列表
  206. getOrderPage() {
  207. let _self = this
  208. var Inv2=this.Inv
  209. _self.troom = []
  210. _self.room = []
  211. if (this.Inv==6) {
  212. Inv2=''
  213. }
  214. this.$axios.get("/hotel/ihotel-api/ihotel/hotelOrder/user/order/page?curPage=1&pageSize=100&statu="+Inv2,
  215. {
  216. headers:{
  217. 'user_token':localStorage.getItem('token')
  218. }
  219. }).then(res => {
  220. res = res.data
  221. if (res.success) {
  222. // console.log(res)
  223. res.data.list.forEach(data => {
  224. _self.troom.push(data)
  225. _self.room.push(data)
  226. })
  227. } else {
  228. console.log('获取订单列表失败')
  229. }
  230. });
  231. },
  232. //待确认的弹框操作
  233. dialogConfirm() {
  234. this.$refs.popup_order2.close()
  235. this.tankuang=true
  236. if(this.tankuang==true) {
  237. if(this.order_txt2=='确定删除?') {
  238. this.getOrderDelete(this.order_txt_id)
  239. } else if(this.order_txt2=='确定退房?') {
  240. this.getOrderReturn(this.order_txt_id)
  241. } else if(this.order_txt2=='确定入住?') {
  242. this.getOrderHold(this.order_txt_id)
  243. } else if(this.order_txt2=='确定取消订单?') {
  244. this.getOrderCancel(this.order_txt_id)
  245. }
  246. }
  247. },
  248. dialogClose(){
  249. this.$refs.popup_order2.close()
  250. },
  251. //删除弹框
  252. openDel(id,type){
  253. this.order_txt_id=id
  254. this.msgType2 = type
  255. this.order_txt2='确定删除?'
  256. this.$refs.popup_order2.open()
  257. },
  258. //退房弹框
  259. openTui(id,type) {
  260. this.order_txt_id=id
  261. this.msgType2 = type
  262. this.order_txt2='确定退房?'
  263. this.$refs.popup_order2.open()
  264. },
  265. //入住弹框
  266. openRu(id,type) {
  267. this.order_txt_id=id
  268. this.msgType2 = type
  269. this.order_txt2='确定入住?'
  270. this.$refs.popup_order2.open()
  271. },
  272. //取消订单弹框
  273. openQu(id,type) {
  274. this.order_txt_id=id
  275. this.msgType2 = type
  276. this.order_txt2='确定取消订单?'
  277. this.$refs.popup_order2.open()
  278. },
  279. // 支付订单
  280. getOrderPay(id) {
  281. let _self = this
  282. this.$axios.get(`/hotel/ihotel-api/ihotel/hotelOrder/user/order/pay/${id}`,
  283. {
  284. headers:{
  285. 'user_token':localStorage.getItem('token')
  286. }
  287. }).then(res => {
  288. res = res.data
  289. if (res.success) {
  290. if(res.data.payAmount==0) {
  291. uni.navigateTo({
  292. url: '../zhifuchenggong/zhifuchenggong?orderId='+res.data.orderId
  293. })
  294. } else {
  295. window.location.href = res.data.payUrl;
  296. }
  297. } else {
  298. this.order_txt=res.message
  299. this.$refs.popup_order.open()
  300. console.log('支付失败')
  301. }
  302. });
  303. },
  304. // 办理退房
  305. getOrderReturn(order_txt_id) {
  306. let _self = this
  307. this.$axios.defaults.headers.common['user_token'] = localStorage.getItem('token');
  308. this.$axios.put(`/hotel/ihotel-api/ihotel/hotelOrder/user/order/return/${this.order_txt_id}`,).then(res => {
  309. res = res.data
  310. if (res.success) {
  311. this.order_txt='退房成功'
  312. this.$refs.popup_order.open()
  313. this.getOrderPage()
  314. } else {
  315. this.order_txt=res.message
  316. this.$refs.popup_order.open()
  317. }
  318. });
  319. this.tankuang==false
  320. },
  321. // 办理入住
  322. getOrderHold(order_txt_id) {
  323. let _self = this
  324. this.$axios.defaults.headers.common['user_token'] = localStorage.getItem('token');
  325. this.$axios.put(`/hotel/ihotel-api/ihotel/hotelOrder/user/order/hold/${this.order_txt_id}`,).then(res => {
  326. res = res.data
  327. if (res.success) {
  328. this.order_txt='办理入住成功'
  329. this.$refs.popup_order.open()
  330. this.getOrderPage()
  331. } else {
  332. this.order_txt=res.message
  333. this.$refs.popup_order.open()
  334. }
  335. });
  336. },
  337. // 删除订单
  338. getOrderDelete(order_txt_id) {
  339. let _self = this
  340. this.$axios.defaults.headers.common['user_token'] = localStorage.getItem('token');
  341. this.$axios.delete(`/hotel/ihotel-api/ihotel/hotelOrder/user/order/${this.order_txt_id}`,).then(res => {
  342. res = res.data
  343. if (res.success) {
  344. this.order_txt='删除订单成功'
  345. this.$refs.popup_order.open()
  346. this.getOrderPage()
  347. } else {
  348. this.order_txt=res.message
  349. this.$refs.popup_order.open()
  350. }
  351. });
  352. this.tankuang==false
  353. },
  354. // 待支付取消订单
  355. getOrderCancel(order_txt_id) {
  356. let _self = this
  357. this.$axios.defaults.headers.common['user_token'] = localStorage.getItem('token');
  358. this.$axios.put(`/hotel/ihotel-api/ihotel/hotelOrder/user/order/cancel/${this.order_txt_id}`,).then(res => {
  359. res = res.data
  360. if (res.success) {
  361. this.order_txt='取消成功'
  362. this.$refs.popup_order.open()
  363. this.getOrderPage()
  364. } else {
  365. this.order_txt=res.message
  366. this.$refs.popup_order.open()
  367. }
  368. });
  369. },
  370. // 订单取消再次预订
  371. navigateToZaici(enableStartTime,enableEndTime,roomTypeId){
  372. uni.navigateTo({
  373. 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
  374. })
  375. },
  376. // 订单已完成再次预订
  377. navigateToWanchengZaici(roomTypeId){
  378. uni.navigateTo({
  379. url:'../order_room/order_room?roomTypeId='+roomTypeId
  380. })
  381. },
  382. //处理结账
  383. navigateToJiezhang(id) {
  384. uni.navigateTo({
  385. url:"../order_mark/order_mark?orderId="+id
  386. })
  387. },
  388. /*
  389. * @Explain:选项卡点击切换
  390. */
  391. changeTab(Inv) {
  392. console.log(Inv)
  393. var that = this;
  394. this.Inv =Inv
  395. var arr = [];
  396. this.getOrderPage(this.Inv)
  397. that.room.map(item => {//遍历真实数据,拿到所需要的数据放在页面数据tlist中,展示在页面上
  398. if(item.orderStatu == this.Inv){
  399. arr.push(item);
  400. }
  401. })
  402. that.troom = arr;
  403. // if(this.Inv == 6){//获取全部数据
  404. // that.troom = that.room;
  405. // }
  406. //滚动到顶部
  407. uni.pageScrollTo({
  408. duration: 0, //过渡时间必须为0,否则运行到手机会报错
  409. scrollTop: 0 //滚动到实际距离是元素距离顶部的距离减去最外层盒子的滚动距离(如res.top - data.top)
  410. })
  411. },
  412. // 倒计时
  413. timeup(createTime) {
  414. var that = this;
  415. /**setInterval间歇调用 */
  416. that.timer = setInterval(function () {
  417. //订单下单时间
  418. var buy_time = createTime;
  419. //计算剩余下单时间
  420. var time = (new Date(buy_time).getTime() + 10* 60 * 1000) - (new Date().getTime());
  421. if(time>0){
  422. //计算剩余的分钟
  423. var minutes = parseInt(time / 1000 / 60 % 60, 10);
  424. //计算剩余的秒数
  425. var seconds = parseInt(time / 1000 % 60, 10);
  426. that.timeupSecond=parseInt(time / 1000);
  427. // console.log(that.timeupSecond)
  428. //判断分钟和秒数小于10要在前面加个0.
  429. if(minutes<10){
  430. minutes = '0' + minutes;
  431. }
  432. if (seconds < 10) {
  433. seconds = '0' + seconds;
  434. }
  435. var timer = minutes + ":" + seconds;
  436. }
  437. }, 1000);
  438. if(that.timeupSecond==0) {
  439. uni.showToast({
  440. title: '时间到'
  441. })
  442. this.getOrderPage()
  443. }
  444. // this.timeupSecond = 0
  445. },
  446. // 跳转到订单详情
  447. navigateToOrderMark(id) {
  448. // console.log(id)
  449. uni.navigateTo({
  450. url: "../order_mark/order_mark?orderId="+id,
  451. })
  452. },
  453. //办理续住弹窗
  454. navigateToXuzhu(){
  455. this.$refs.popup_xuzhu.open()
  456. },
  457. popupXuzhuClose() {
  458. this.$refs.popup_xuzhu.close()
  459. },
  460. // 续住里日期选择器弹窗
  461. openXuCalendar() {
  462. this.$refs.popup_xu.open()
  463. },
  464. changeXu(e) {
  465. console.log('1change 返回:', e)
  466. // 模拟动态打卡
  467. if (this.infoXu.selected.length > 5) return
  468. this.infoXu.selected.push({
  469. date: e.range.before,
  470. info: '到店'
  471. })
  472. this.infoXu.selected.push({
  473. date: e.range.after,
  474. info: '离店'
  475. })
  476. },
  477. },
  478. }
  479. </script>
  480. <style>
  481. @import url(./css/my_orderlist.css);
  482. </style>