order.vue 9.6 KB

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