order.vue 9.6 KB

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