order.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429
  1. <template>
  2. <view class="page">
  3. <view class="sticky">
  4. <NavigateBar title="我的订单" bgcolor="#a09cc4"></NavigateBar>
  5. <u-tabs :list="orderTypelist" @click="tabChange" lineWidth="40" scrollable="false"
  6. :itemStyle="{width:'205rpx', height:'80rpx'}"></u-tabs>
  7. </view>
  8. <view class="order-item" v-for="(order,index) in orderList" :key="index">
  9. <view class="one-order">
  10. <view class="order--no" @click="gotoOrderDetail(order.orderId)">
  11. <view class="order--no__no">
  12. <view>订单号:</view>
  13. <view>{{ order.orderId.toUpperCase() }}</view>
  14. </view>
  15. <view class="order--no__status"></view>
  16. </view>
  17. <view class="order--room" @click="gotoOrderDetail(order.orderId)">
  18. <view class="order--room__pic">
  19. <u-image :src="getPicPath(order.roomPicPath)" width="180rpx" height="180rpx"></u-image>
  20. </view>
  21. <view class="order--room__desc">
  22. {{ order.roomTypeName }}
  23. </view>
  24. <view class="order--room__price" v-if="order.status=='ORDER_PLACED'||order.status=='ROOM_SELECTED'">
  25. {{ "¥"+ order.price }}
  26. </view>
  27. </view>
  28. <view class="order--duration" @click="gotoOrderDetail(order.orderId)">
  29. <view class="order--duration__start">
  30. <view class="order--duration__start-title">入住日期</view>
  31. <view class="order--duration__start-date">
  32. <view>{{ formatTime(order.startTime) }}</view>
  33. <view>{{ getWeek(order.startTime) }}</view>
  34. </view>
  35. </view>
  36. <view class="order--duration__end">
  37. <view class="order--duration__end-title">离店日期</view>
  38. <view class="order--duration__end-date">
  39. <view>{{ formatTime(order.endTime) }}</view>
  40. <view>{{ getWeek(order.endTime) }}</view>
  41. </view>
  42. </view>
  43. <view class="order--duration__total">
  44. {{ `共${order.dayNum}晚` }}
  45. </view>
  46. </view>
  47. <view class="order--option">
  48. <view class="order--option__btn" v-if="order.status=='ORDER_PLACED'||order.status=='ROOM_SELECTED'">
  49. <u-button text="去入住" shape="circle" @click="gotoAddGuest(index)"></u-button>
  50. </view>
  51. <view class="order--option__btn" v-if="order.status=='CHECK_IN'">
  52. <u-button text="续住" shape="circle" @click="gotoExtend"></u-button>
  53. </view>
  54. <view class="order--option__btn" v-if="order.status=='CHECK_IN'">
  55. <u-button text="退房" shape="circle" @click="gotoExtend"></u-button>
  56. </view>
  57. <!-- <view class="order--option__btn" v-if="order.status=='FINISHED'">
  58. 已完成
  59. </view> -->
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import {
  67. stringHasText
  68. } from '../../utils/commonUtils.js'
  69. import moment from "moment"
  70. import {
  71. IMG_BASE_URL
  72. } from "../../config"
  73. import {
  74. mapState,
  75. mapMutations
  76. } from 'vuex'
  77. import NavigateBar from '../../components/navigateBar/navigate-bar.vue';
  78. export default {
  79. components: {
  80. NavigateBar
  81. },
  82. data() {
  83. return {
  84. orderList: [],
  85. orderTypelist: [{
  86. index: 0,
  87. name: '未入住',
  88. },
  89. {
  90. index: 1,
  91. name: '已入住',
  92. },
  93. {
  94. index: 2,
  95. name: '已完成',
  96. }
  97. ],
  98. status: ['ORDER_PLACED_OR_ROOM_SELECTED', 'CHECK_IN', 'CHECK_OUT_OR_FINISHED'],
  99. current: 0,
  100. pageSize: 10,
  101. pageNo: 1,
  102. total: 0,
  103. };
  104. },
  105. computed: {
  106. ...mapState('m_user', ['userInfo']),
  107. ...mapState('m_business', ['currentHotel']),
  108. },
  109. methods: {
  110. ...mapMutations('m_business', ['updateOrder', 'updateCheckinInfo']),
  111. tabChange(item) {
  112. if (this.current != item.index) {
  113. this.orderList = []
  114. this.pageNo = 1
  115. this.current = item.index
  116. this.getOrders(item.index)
  117. }
  118. },
  119. gotoAddGuest(index) {
  120. if (new Date(this.orderList[index].endTime).valueOf() < new Date().valueOf()) {
  121. uni.$showMsg('订单已过期,无法入住!')
  122. return
  123. }
  124. let order = this.orderList[index]
  125. if (order.orderSource == 'MINI_APP') {
  126. this.orderList[index].isResv = false
  127. } else {
  128. this.orderList[index].isResv = true
  129. }
  130. this.updateOrder(this.orderList[index])
  131. this.updateCheckinInfo([])
  132. uni.navigateTo({
  133. url: '/subpkg_checkin/addGuest/addGuest'
  134. })
  135. },
  136. gotoExtend(index) {
  137. this.updateOrder(this.orderList[index])
  138. uni.navigateTo({
  139. url: '/subpkg/extend/extend'
  140. })
  141. },
  142. async getOrders(index) {
  143. uni.showLoading({
  144. title: '正在加载'
  145. })
  146. let condition = {
  147. name: this.userInfo.name,
  148. // phone: this.userInfo.phone,
  149. deleted: false,
  150. pageNo: this.pageNo,
  151. pageSize: this.pageSize,
  152. status: this.status[index],
  153. hotelId: this.currentHotel.hotelId
  154. }
  155. if (index == 0) {
  156. //只查询没过期的,pms推送的
  157. condition.outDated = false
  158. condition.orderSource = 'PMS_GREEN_CLOUD'
  159. } else {
  160. condition.paymentStatus = 'PAID'
  161. }
  162. let res = await uni.$http.post('/hotelOrder/queryByCondition', condition)
  163. this.orderList = [...this.orderList, ...res.data.data.records]
  164. this.total = res.data.data.total
  165. uni.hideLoading()
  166. },
  167. onReachBottom() {
  168. if (this.orderList.length < this.total) {
  169. this.pageNo += 1
  170. this.getOrders(this.current)
  171. } else {
  172. uni.$showMsg('已经到底啦!')
  173. }
  174. },
  175. onPullDownRefresh() {
  176. this.orderList = []
  177. this.pageNo = 1
  178. //加一点延迟,不然闪的很快,看起来不舒服
  179. setTimeout(() => {
  180. this.getOrders(this.current)
  181. uni.stopPullDownRefresh()
  182. }, 100)
  183. },
  184. formatTime(text) {
  185. return moment(text).format("MM月DD日")
  186. },
  187. getWeek(date) {
  188. let week = moment(date).day()
  189. switch (week) {
  190. case 1:
  191. return "周一"
  192. case 2:
  193. return "周二"
  194. case 3:
  195. return "周三"
  196. case 4:
  197. return "周四"
  198. case 5:
  199. return "周五"
  200. case 6:
  201. return "周六"
  202. case 0:
  203. return "周日"
  204. default:
  205. break;
  206. }
  207. },
  208. getPicPath(path) {
  209. return IMG_BASE_URL + '/' + path
  210. },
  211. gotoOrderDetail(orderId) {
  212. uni.navigateTo({
  213. url: '/subpkg/orderDetail/orderDetail?orderId=' + orderId
  214. })
  215. }
  216. },
  217. onShow() {
  218. this.orderList = []
  219. this.getOrders(this.current)
  220. },
  221. // #ifdef MP-WEIXIN
  222. onShareAppMessage(info) {
  223. return {
  224. title: '源享住',
  225. path: 'pages/login/login',
  226. imageUrl: "/static/logo.png"
  227. }
  228. }
  229. // #endif
  230. }
  231. </script>
  232. <style lang="scss">
  233. page {
  234. background-color: #EBEAF0;
  235. width: 100%;
  236. .sticky {
  237. position: sticky;
  238. background-color: #fff;
  239. width: 100%;
  240. top: 0;
  241. z-index: 999;
  242. }
  243. .order-item {
  244. width: 100%;
  245. display: flex;
  246. flex-direction: column;
  247. .one-order {
  248. display: flex;
  249. flex-direction: column;
  250. background-color: #FFFFFF;
  251. margin-top: 2*5rpx;
  252. margin-left: 2*10rpx;
  253. margin-right: 2*10rpx;
  254. margin-bottom: 2*5rpx;
  255. border-radius: 2*12rpx;
  256. .order--no {
  257. display: flex;
  258. flex-direction: row;
  259. font-size: 28rpx;
  260. margin-top: 2*10rpx;
  261. margin-left: 2*10rpx;
  262. margin-right: 2*10rpx;
  263. margin-bottom: 2*5rpx;
  264. .order--no__no {
  265. display: flex;
  266. flex-direction: row;
  267. }
  268. }
  269. .order--room {
  270. display: flex;
  271. flex-direction: row;
  272. background-color: #F1F1F4;
  273. margin-left: 2*10rpx;
  274. margin-right: 2*10rpx;
  275. margin-top: 2*5rpx;
  276. margin-bottom: 2*5rpx;
  277. padding-top: 2*12rpx;
  278. padding-bottom: 2*12rpx;
  279. border-radius: 2*8rpx;
  280. .order--room__pic {
  281. padding-left: 5rpx;
  282. width: 190rpx;
  283. }
  284. .order--room__desc {
  285. display: flex;
  286. align-items: center;
  287. width: 100%;
  288. padding-left: 20rpx;
  289. }
  290. .order--room__price {
  291. display: flex;
  292. align-items: center;
  293. justify-content: end;
  294. width: 200rpx;
  295. padding-right: 20rpx;
  296. color: red;
  297. font-size: 40rpx;
  298. }
  299. }
  300. .order--duration {
  301. display: flex;
  302. flex-direction: row;
  303. background-color: #F1F1F4;
  304. margin-left: 2*10rpx;
  305. margin-right: 2*10rpx;
  306. margin-top: 2*5rpx;
  307. margin-bottom: 2*5rpx;
  308. border-radius: 2*8rpx;
  309. .order--duration__start {
  310. display: flex;
  311. flex-direction: column;
  312. width: 1000rpx;
  313. margin-top: 2*5rpx;
  314. margin-bottom: 2*10rpx;
  315. margin-left: 2*5rpx;
  316. margin-right: 2*5rpx;
  317. .order--duration__start-title {
  318. display: flex;
  319. font-size: 28rpx;
  320. height: 60rpx;
  321. align-items: center;
  322. }
  323. .order--duration__start-date {
  324. display: flex;
  325. flex-direction: row;
  326. justify-content: space-between;
  327. height: 50rpx;
  328. align-items: center;
  329. font-size: 24rpx;
  330. }
  331. }
  332. .order--duration__end {
  333. display: flex;
  334. flex-direction: column;
  335. width: 1000rpx;
  336. margin-top: 2*5rpx;
  337. margin-bottom: 2*10rpx;
  338. margin-left: 2*30rpx;
  339. margin-right: 2*5rpx;
  340. .order--duration__end-title {
  341. display: flex;
  342. font-size: 28rpx;
  343. height: 60rpx;
  344. align-items: center;
  345. }
  346. .order--duration__end-date {
  347. display: flex;
  348. flex-direction: row;
  349. justify-content: space-between;
  350. height: 50rpx;
  351. align-items: center;
  352. font-size: 24rpx;
  353. }
  354. }
  355. .order--duration__total {
  356. width: 100%;
  357. display: flex;
  358. align-items: center;
  359. justify-content: flex-end;
  360. padding-right: 20rpx;
  361. font-weight: bold;
  362. }
  363. }
  364. .order--option {
  365. display: flex;
  366. justify-content: flex-end;
  367. flex-direction: row;
  368. margin-left: 2*10rpx;
  369. margin-right: 2*15rpx;
  370. margin-top: 2*5rpx;
  371. margin-bottom: 2*5rpx;
  372. .order--option__btn {
  373. margin-left: 20rpx;
  374. width: 160rpx;
  375. .u-button {
  376. height: 60rpx;
  377. border: 2rpx solid #9e97c3;
  378. color: #9e97c3;
  379. }
  380. .u-button--active {
  381. background-color: #9e97c3;
  382. color: #FFFFFF;
  383. &:before {
  384. opacity: 0;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. .card-item {
  391. margin-top: 10rpx;
  392. margin-bottom: 10rpx;
  393. display: flex;
  394. .card-item-left {
  395. width: 140rpx;
  396. }
  397. }
  398. }
  399. }
  400. </style>