order.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423
  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. this.updateOrder(this.orderList[index])
  126. this.updateCheckinInfo([])
  127. uni.navigateTo({
  128. url: '/subpkg_checkin/addGuest/addGuest'
  129. })
  130. },
  131. gotoExtend(index) {
  132. this.updateOrder(this.orderList[index])
  133. uni.navigateTo({
  134. url: '/subpkg/extend/extend'
  135. })
  136. },
  137. async getOrders(index) {
  138. uni.showLoading({
  139. title: '正在加载'
  140. })
  141. let condition = {
  142. name: this.userInfo.name,
  143. // phone: this.userInfo.phone,
  144. deleted: false,
  145. pageNo: this.pageNo,
  146. pageSize: this.pageSize,
  147. status: this.status[index],
  148. hotelId: this.currentHotel.hotelId
  149. }
  150. if (index == 0) {
  151. //只查询没过期的,pms推送的
  152. condition.outDated = false
  153. condition.orderSource = 'PMS_GREEN_CLOUD'
  154. } else {
  155. condition.paymentStatus = 'PAID'
  156. }
  157. let res = await uni.$http.post('/hotelOrder/queryByCondition', condition)
  158. this.orderList = [...this.orderList, ...res.data.data.records]
  159. this.total = res.data.data.total
  160. uni.hideLoading()
  161. },
  162. onReachBottom() {
  163. if (this.orderList.length < this.total) {
  164. this.pageNo += 1
  165. this.getOrders(this.current)
  166. } else {
  167. uni.$showMsg('已经到底啦!')
  168. }
  169. },
  170. onPullDownRefresh() {
  171. this.orderList = []
  172. this.pageNo = 1
  173. //加一点延迟,不然闪的很快,看起来不舒服
  174. setTimeout(() => {
  175. this.getOrders(this.current)
  176. uni.stopPullDownRefresh()
  177. }, 100)
  178. },
  179. formatTime(text) {
  180. return moment(text).format("MM月DD日")
  181. },
  182. getWeek(date) {
  183. let week = moment(date).day()
  184. switch (week) {
  185. case 1:
  186. return "周一"
  187. case 2:
  188. return "周二"
  189. case 3:
  190. return "周三"
  191. case 4:
  192. return "周四"
  193. case 5:
  194. return "周五"
  195. case 6:
  196. return "周六"
  197. case 0:
  198. return "周日"
  199. default:
  200. break;
  201. }
  202. },
  203. getPicPath(path) {
  204. return IMG_BASE_URL + '/' + path
  205. },
  206. gotoOrderDetail(orderId) {
  207. uni.navigateTo({
  208. url: '/subpkg/orderDetail/orderDetail?orderId=' + orderId
  209. })
  210. }
  211. },
  212. onShow() {
  213. this.orderList = []
  214. this.getOrders(this.current)
  215. },
  216. // #ifdef MP-WEIXIN
  217. onShareAppMessage(info) {
  218. return {
  219. title: '源享住',
  220. path: 'pages/login/login',
  221. imageUrl: "/static/logo.png"
  222. }
  223. }
  224. // #endif
  225. }
  226. </script>
  227. <style lang="scss">
  228. page {
  229. background-color: #EBEAF0;
  230. width: 100%;
  231. .sticky {
  232. position: sticky;
  233. background-color: #fff;
  234. width: 100%;
  235. top: 0;
  236. z-index: 999;
  237. }
  238. .order-item {
  239. width: 100%;
  240. display: flex;
  241. flex-direction: column;
  242. .one-order {
  243. display: flex;
  244. flex-direction: column;
  245. background-color: #FFFFFF;
  246. margin-top: 2*5rpx;
  247. margin-left: 2*10rpx;
  248. margin-right: 2*10rpx;
  249. margin-bottom: 2*5rpx;
  250. border-radius: 2*12rpx;
  251. .order--no {
  252. display: flex;
  253. flex-direction: row;
  254. font-size: 28rpx;
  255. margin-top: 2*10rpx;
  256. margin-left: 2*10rpx;
  257. margin-right: 2*10rpx;
  258. margin-bottom: 2*5rpx;
  259. .order--no__no {
  260. display: flex;
  261. flex-direction: row;
  262. }
  263. }
  264. .order--room {
  265. display: flex;
  266. flex-direction: row;
  267. background-color: #F1F1F4;
  268. margin-left: 2*10rpx;
  269. margin-right: 2*10rpx;
  270. margin-top: 2*5rpx;
  271. margin-bottom: 2*5rpx;
  272. padding-top: 2*12rpx;
  273. padding-bottom: 2*12rpx;
  274. border-radius: 2*8rpx;
  275. .order--room__pic {
  276. padding-left: 5rpx;
  277. width: 190rpx;
  278. }
  279. .order--room__desc {
  280. display: flex;
  281. align-items: center;
  282. width: 100%;
  283. padding-left: 20rpx;
  284. }
  285. .order--room__price {
  286. display: flex;
  287. align-items: center;
  288. justify-content: end;
  289. width: 200rpx;
  290. padding-right: 20rpx;
  291. color: red;
  292. font-size: 40rpx;
  293. }
  294. }
  295. .order--duration {
  296. display: flex;
  297. flex-direction: row;
  298. background-color: #F1F1F4;
  299. margin-left: 2*10rpx;
  300. margin-right: 2*10rpx;
  301. margin-top: 2*5rpx;
  302. margin-bottom: 2*5rpx;
  303. border-radius: 2*8rpx;
  304. .order--duration__start {
  305. display: flex;
  306. flex-direction: column;
  307. width: 1000rpx;
  308. margin-top: 2*5rpx;
  309. margin-bottom: 2*10rpx;
  310. margin-left: 2*5rpx;
  311. margin-right: 2*5rpx;
  312. .order--duration__start-title {
  313. display: flex;
  314. font-size: 28rpx;
  315. height: 60rpx;
  316. align-items: center;
  317. }
  318. .order--duration__start-date {
  319. display: flex;
  320. flex-direction: row;
  321. justify-content: space-between;
  322. height: 50rpx;
  323. align-items: center;
  324. font-size: 24rpx;
  325. }
  326. }
  327. .order--duration__end {
  328. display: flex;
  329. flex-direction: column;
  330. width: 1000rpx;
  331. margin-top: 2*5rpx;
  332. margin-bottom: 2*10rpx;
  333. margin-left: 2*30rpx;
  334. margin-right: 2*5rpx;
  335. .order--duration__end-title {
  336. display: flex;
  337. font-size: 28rpx;
  338. height: 60rpx;
  339. align-items: center;
  340. }
  341. .order--duration__end-date {
  342. display: flex;
  343. flex-direction: row;
  344. justify-content: space-between;
  345. height: 50rpx;
  346. align-items: center;
  347. font-size: 24rpx;
  348. }
  349. }
  350. .order--duration__total {
  351. width: 100%;
  352. display: flex;
  353. align-items: center;
  354. justify-content: flex-end;
  355. padding-right: 20rpx;
  356. font-weight: bold;
  357. }
  358. }
  359. .order--option {
  360. display: flex;
  361. justify-content: flex-end;
  362. flex-direction: row;
  363. margin-left: 2*10rpx;
  364. margin-right: 2*15rpx;
  365. margin-top: 2*5rpx;
  366. margin-bottom: 2*5rpx;
  367. .order--option__btn {
  368. margin-left: 20rpx;
  369. width: 160rpx;
  370. .u-button {
  371. height: 60rpx;
  372. border: 2rpx solid #9e97c3;
  373. color: #9e97c3;
  374. }
  375. .u-button--active {
  376. background-color: #9e97c3;
  377. color: #FFFFFF;
  378. &:before {
  379. opacity: 0;
  380. }
  381. }
  382. }
  383. }
  384. }
  385. .card-item {
  386. margin-top: 10rpx;
  387. margin-bottom: 10rpx;
  388. display: flex;
  389. .card-item-left {
  390. width: 140rpx;
  391. }
  392. }
  393. }
  394. }
  395. </style>