order.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. <template>
  2. <view>
  3. <view class="top-subsection">
  4. <u-subsection :list="orderTypelist" :current="current" mode="subsection" @change="sectionChange"
  5. inactiveColor="#509AFE" activeColor="#509AFE"></u-subsection>
  6. </view>
  7. <view class="order-item" v-for="order in orderList">
  8. <view class="one-order">
  9. <view class="order--no">
  10. <view class="order--no__no">
  11. <view>订单号:</view>
  12. <view>{{ order.orderId.toUpperCase() }}</view>
  13. </view>
  14. <view class="order--no__status"></view>
  15. </view>
  16. <view class="order--room">
  17. <view class="order--room__pic">
  18. <u-image :src="getPicPath(order.roomPicPath)" width="180rpx" height="180rpx"></u-image>
  19. </view>
  20. <view class="order--room__desc">
  21. {{ order.roomTypeName }}
  22. </view>
  23. <view class="order--room__price">
  24. {{ "¥"+ order.price }}
  25. </view>
  26. </view>
  27. <view class="order--duration">
  28. <view class="order--duration__start">
  29. <view class="order--duration__start-title">入住日期</view>
  30. <view class="order--duration__start-date">
  31. <view>{{ formatTime(order.startTime) }}</view>
  32. <view>{{ getWeek(order.startTime) }}</view>
  33. </view>
  34. </view>
  35. <view class="order--duration__end">
  36. <view class="order--duration__end-title">离店日期</view>
  37. <view class="order--duration__end-date">
  38. <view>{{ formatTime(order.endTime) }}</view>
  39. <view>{{ getWeek(order.endTime) }}</view>
  40. </view>
  41. </view>
  42. <view class="order--duration__total">
  43. {{ `共${order.dayNum}晚` }}
  44. </view>
  45. </view>
  46. <view class="order--option"></view>
  47. </view>
  48. </view>
  49. </view>
  50. </template>
  51. <script>
  52. import moment from "moment";
  53. import {
  54. IMG_BASE_URL
  55. } from "../../config"
  56. import {
  57. mapState,
  58. mapMutations
  59. } from 'vuex'
  60. export default {
  61. data() {
  62. return {
  63. orderList: [],
  64. orderTypelist: ['全部', '已支付', '待支付'],
  65. current: 0
  66. };
  67. },
  68. computed: {
  69. ...mapState('m_user', ['userInfo']),
  70. ...mapState('m_business', ['currentHotelId', 'reservationInfo']),
  71. },
  72. methods: {
  73. async sectionChange(index) {
  74. this.current = index
  75. let status
  76. if (index == 0) {
  77. let res = await uni.$http.post('/hotelOrder/queryByCondition', {
  78. name: this.userInfo.name,
  79. phone: this.userInfo.phone,
  80. deleted: false,
  81. pageNo: 1,
  82. pageSize: 999
  83. })
  84. this.orderList = res.data.data.records
  85. } else if (index == 1) {
  86. let res = await uni.$http.post('/hotelOrder/queryByCondition', {
  87. name: this.userInfo.name,
  88. phone: this.userInfo.phone,
  89. deleted: false,
  90. pageNo: 1,
  91. pageSize: 999,
  92. status: 1
  93. })
  94. this.orderList = res.data.data.records
  95. res = await uni.$http.post('/hotelOrder/queryByCondition', {
  96. name: this.userInfo.name,
  97. phone: this.userInfo.phone,
  98. deleted: false,
  99. pageNo: 1,
  100. pageSize: 999,
  101. status: 2
  102. })
  103. this.orderList = [...this.orderList, ...res.data.data.records]
  104. } else {
  105. let res = await uni.$http.post('/hotelOrder/queryByCondition', {
  106. name: this.userInfo.name,
  107. phone: this.userInfo.phone,
  108. deleted: false,
  109. pageNo: 1,
  110. pageSize: 999,
  111. status: 0
  112. })
  113. this.orderList = res.data.data.records
  114. }
  115. },
  116. async queryAllOrders() {
  117. let res = await uni.$http.post('/hotelOrder/queryByCondition', {
  118. name: this.userInfo.name,
  119. phone: this.userInfo.phone,
  120. deleted: false,
  121. pageNo: 1,
  122. pageSize: 999
  123. })
  124. console.log(res)
  125. this.orderList = res.data.data.records
  126. },
  127. formatTime(text) {
  128. return moment(text).format("MM月DD日HH时")
  129. },
  130. getWeek(date) {
  131. let week = moment(date).day()
  132. switch (week) {
  133. case 1:
  134. return "周一"
  135. case 2:
  136. return "周二"
  137. case 3:
  138. return "周三"
  139. case 4:
  140. return "周四"
  141. case 5:
  142. return "周五"
  143. case 6:
  144. return "周六"
  145. case 0:
  146. return "周日"
  147. default:
  148. break;
  149. }
  150. },
  151. getPicPath(path) {
  152. return IMG_BASE_URL + '/' + path
  153. }
  154. },
  155. onLoad() {
  156. this.queryAllOrders()
  157. }
  158. }
  159. </script>
  160. <style lang="scss">
  161. page {
  162. background-color: #EBEAF0;
  163. position: absolute;
  164. .top-subsection {
  165. top: 0;
  166. position: sticky;
  167. background-color: #EBEAF0;
  168. z-index: 99;
  169. }
  170. .order-item {
  171. width: 100%;
  172. display: flex;
  173. flex-direction: column;
  174. &:first-child {
  175. margin-top: 80rpx;
  176. }
  177. .one-order {
  178. display: flex;
  179. flex-direction: column;
  180. background-color: #ffffff;
  181. margin-top: 2*5rpx;
  182. margin-left: 2*10rpx;
  183. margin-right: 2*10rpx;
  184. margin-bottom: 2*5rpx;
  185. border-radius: 2*12rpx;
  186. .order--no {
  187. display: flex;
  188. flex-direction: row;
  189. font-size: 28rpx;
  190. margin-top: 2*10rpx;
  191. margin-left: 2*10rpx;
  192. margin-right: 2*10rpx;
  193. margin-bottom: 2*5rpx;
  194. .order--no__no {
  195. display: flex;
  196. flex-direction: row;
  197. }
  198. }
  199. .order--room {
  200. display: flex;
  201. flex-direction: row;
  202. background-color: #f1f1f4;
  203. margin-left: 2*10rpx;
  204. margin-right: 2*10rpx;
  205. margin-top: 2*5rpx;
  206. margin-bottom: 2*5rpx;
  207. padding-top: 2*12rpx;
  208. padding-bottom: 2*12rpx;
  209. border-radius: 2*8rpx;
  210. .order--room__pic {
  211. padding-left: 5rpx;
  212. width: 190rpx;
  213. }
  214. .order--room__desc {
  215. display: flex;
  216. align-items: center;
  217. width: 100%;
  218. padding-left: 20rpx;
  219. }
  220. .order--room__price {
  221. display: flex;
  222. align-items: center;
  223. justify-content: end;
  224. width: 200rpx;
  225. padding-right: 20rpx;
  226. color: red;
  227. font-size: 40rpx;
  228. }
  229. }
  230. .order--duration {
  231. display: flex;
  232. flex-direction: row;
  233. background-color: #f1f1f4;
  234. margin-left: 2*10rpx;
  235. margin-right: 2*10rpx;
  236. margin-top: 2*5rpx;
  237. margin-bottom: 2*5rpx;
  238. border-radius: 2*8rpx;
  239. .order--duration__start {
  240. display: flex;
  241. flex-direction: column;
  242. width: 1000rpx;
  243. margin-top: 2*5rpx;
  244. margin-bottom: 2*10rpx;
  245. margin-left: 2*5rpx;
  246. margin-right: 2*5rpx;
  247. .order--duration__start-title {
  248. display: flex;
  249. font-size: 28rpx;
  250. height: 60rpx;
  251. align-items: center;
  252. }
  253. .order--duration__start-date {
  254. display: flex;
  255. flex-direction: row;
  256. justify-content: space-between;
  257. height: 50rpx;
  258. align-items: center;
  259. font-size: 24rpx;
  260. }
  261. }
  262. .order--duration__end {
  263. display: flex;
  264. flex-direction: column;
  265. width: 1000rpx;
  266. margin-top: 2*5rpx;
  267. margin-bottom: 2*10rpx;
  268. margin-left: 2*30rpx;
  269. margin-right: 2*5rpx;
  270. .order--duration__end-title {
  271. display: flex;
  272. font-size: 28rpx;
  273. height: 60rpx;
  274. align-items: center;
  275. }
  276. .order--duration__end-date {
  277. display: flex;
  278. flex-direction: row;
  279. justify-content: space-between;
  280. height: 50rpx;
  281. align-items: center;
  282. font-size: 24rpx;
  283. }
  284. }
  285. .order--duration__total {
  286. width: 100%;
  287. display: flex;
  288. align-items: center;
  289. justify-content: flex-end;
  290. padding-right: 20rpx;
  291. font-weight: bold;
  292. }
  293. }
  294. .order--option {
  295. display: flex;
  296. flex-direction: row;
  297. margin-left: 2*10rpx;
  298. margin-right: 2*10rpx;
  299. margin-top: 2*5rpx;
  300. margin-bottom: 2*5rpx;
  301. }
  302. }
  303. .card-item {
  304. margin-top: 10rpx;
  305. margin-bottom: 10rpx;
  306. display: flex;
  307. .card-item-left {
  308. width: 140rpx;
  309. }
  310. }
  311. }
  312. }
  313. </style>