affirmOrder.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588
  1. <template>
  2. <view class="container">
  3. <!-- 导航栏图片区域 -->
  4. <view class="header">
  5. <img src="../../static/my/headerImg.png" />
  6. <!-- 标题区域 -->
  7. <view class="header_title">{{ hotelName }}</view>
  8. <!-- 返回图标区域 -->
  9. <view class="header_icon" @click="handleBack">
  10. <img src="../../static/index/left.png" />
  11. </view>
  12. </view>
  13. <view class="body">
  14. <!-- 房间信息区域 -->
  15. <view class="info">
  16. <view class="info_time">
  17. {{ info.startTimeMonth }}月{{ info.startTimeDay }}日
  18. <text class="gap">{{ info.startTimeWeek }}</text>
  19. <view class="time_line"></view>
  20. <view class="time_num">{{ info.nightNum }}晚</view>
  21. <view class="time_line"></view>
  22. <view class="gap">{{ info.endTimeMonth }}月{{ info.endTimeDay }}日</view>
  23. <text>{{ info.endTimeWeek }}</text>
  24. </view>
  25. <view class="info_msg">{{ info.item.hName }}</view>
  26. <view class="info_type">
  27. <view class="type_item">{{ info.hTypeName }}</view>
  28. </view>
  29. <view class="info_tag">
  30. <view class="tag_item">{{ info.item.hAreas }}㎡</view>
  31. <view class="tag_item" v-for="tag in info.item.hConfigList" :key="tag.id">{{ tag.name }}</view>
  32. </view>
  33. </view>
  34. <!-- 入住信息区域 -->
  35. <view class="msg">
  36. <view class="msg_title">入住信息</view>
  37. <view class="msg_box">
  38. <view class="box_key">房间数量</view>
  39. <view class="box_value">{{ roomCount }}间</view>
  40. <view class="box_icon">
  41. <img class="img" src="../../static/index/add.png" @click="handleAdd" />
  42. <img class="img2" src="../../static/index/minus.png" @click="handleMinus" />
  43. </view>
  44. </view>
  45. <view class="msg_box">
  46. <view class="box_key">住客姓名</view>
  47. <view class="box_value">
  48. <input type="text" placeholder="请输入住客姓名" v-model="clientName" />
  49. </view>
  50. <view class="box_icon" @click="handleSelectClient">
  51. <img class="img2" src="../../static/index/people.png" />
  52. </view>
  53. </view>
  54. <view class="msg_box">
  55. <view class="box_key">联系电话</view>
  56. <view class="box_value">
  57. <input type="number" maxlength="11" placeholder="请输入联系电话" v-model="clientPhone" />
  58. </view>
  59. </view>
  60. <view class="msg_box" @click="handleSelectTime">
  61. <view class="box_key">预计到店</view>
  62. <view class="box_value" :class="{ color: !arriveTime }">{{ arriveTime ? arriveTime : '请选择预计到店时间' }}</view>
  63. <view class="box_icon">
  64. <img class="img3" src="../../static/index/right2.png" />
  65. </view>
  66. </view>
  67. <uv-datetime-picker
  68. ref="datetimePicker"
  69. v-model="timeValue"
  70. mode="datetime"
  71. :closeOnClickOverlay="false"
  72. confirmColor="#096562"
  73. :formatter="formatter"
  74. @confirm="confirm"
  75. ></uv-datetime-picker>
  76. </view>
  77. <!-- 费用信息区域 -->
  78. <view class="price">
  79. <view class="price_title">费用明细</view>
  80. <view class="price_box">
  81. <view class="box_key">在线支付</view>
  82. <view class="box_value">
  83. {{ roomCount }}间{{ info.nightNum }}晚 共
  84. <text>¥</text>
  85. <span>{{ totalPrice }}</span>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="all">
  90. <view class="all_title">
  91. <text>房费</text>
  92. <text class="mr_30">¥{{ totalPrice }}</text>
  93. </view>
  94. <view class="all_box">
  95. <view class="box_list">
  96. <view class="list_item" v-for="(item, index) in info.dayList" :key="index">{{ item }}</view>
  97. </view>
  98. <view class="box_total">{{ roomCount }}间 x {{ info.nightNum }}晚 x ¥{{ info.item.price }}</view>
  99. </view>
  100. </view>
  101. </view>
  102. <!-- 底部提交订单区域 -->
  103. <view class="foot">
  104. <view class="foot_left">
  105. <text>¥</text>
  106. {{ totalPrice }}
  107. </view>
  108. <view class="foot_right" @click="goPagePay">提交订单</view>
  109. </view>
  110. </view>
  111. </template>
  112. <script>
  113. export default {
  114. data() {
  115. return {
  116. info: {},
  117. // 预定房间数量
  118. roomCount: 1,
  119. // 住客姓名
  120. clientName: '',
  121. // 联系电话
  122. clientPhone: '',
  123. // 预计到店时间
  124. arriveTime: '',
  125. // 当前时间
  126. timeValue: Number(new Date()),
  127. // 民宿名称
  128. hotelName: ''
  129. }
  130. },
  131. onLoad(options) {
  132. this.info = JSON.parse(options.info)
  133. this.hotelName = this.info.hotelName
  134. uni.$on('change', this.change)
  135. },
  136. computed: {
  137. // 总费用
  138. totalPrice() {
  139. if (this.info.item) {
  140. return (this.roomCount * this.info.item.price * this.info.nightNum).toFixed(2)
  141. }
  142. }
  143. },
  144. methods: {
  145. change(e) {
  146. this.clientName = e.name
  147. this.clientPhone = e.phone
  148. },
  149. handleSelectClient() {
  150. uni.navigateTo({
  151. url: '/pages/common/common?type=1'
  152. })
  153. },
  154. confirm(e) {
  155. // console.log(e.value)
  156. let date = new Date(e.value)
  157. let month = date.getMonth() + 1
  158. let day = date.getDate()
  159. let H = date.getHours()
  160. let M = date.getMinutes()
  161. this.arriveTime = `${month}月${day}日${H}:${M}分之前`
  162. },
  163. formatter(type, value) {
  164. if (type === 'year') {
  165. return `${value}年`
  166. }
  167. if (type === 'month') {
  168. return `${value}月`
  169. }
  170. if (type === 'day') {
  171. return `${value}日`
  172. }
  173. return value
  174. },
  175. handleSelectTime() {
  176. this.$refs.datetimePicker.open()
  177. },
  178. handleAdd() {
  179. this.roomCount++
  180. },
  181. handleMinus() {
  182. if (this.roomCount > 1) {
  183. this.roomCount--
  184. } else {
  185. uni.showToast({
  186. title: '至少需要预定1间',
  187. icon: 'none'
  188. })
  189. }
  190. },
  191. // 提交订单按钮回调
  192. async goPagePay() {
  193. const reName = /^[\u4e00-\u9fa5]{2,4}$/
  194. const rePhone = /^[1][3,4,5,7,8,9][0-9]{9}$/
  195. if (!this.clientName) {
  196. uni.showToast({
  197. title: '请输入住客姓名',
  198. icon: 'none',
  199. mask: true
  200. })
  201. return
  202. }
  203. if (!reName.test(this.clientName)) {
  204. uni.showToast({
  205. title: '姓名格式有误',
  206. icon: 'none'
  207. })
  208. return
  209. }
  210. if (!this.clientPhone) {
  211. uni.showToast({
  212. title: '请输入联系电话',
  213. icon: 'none',
  214. mask: true
  215. })
  216. return
  217. }
  218. if (!rePhone.test(this.clientPhone)) {
  219. uni.showToast({
  220. title: '电话号码格式有误',
  221. icon: 'none'
  222. })
  223. return
  224. }
  225. const res = await this.$myRequest({
  226. url: '/mhotel/abkcreateOrder.action',
  227. data: {
  228. houseId: this.info.item.id,
  229. startTime: this.info.queryStartTime,
  230. endTime: this.info.queryEndTime,
  231. houseOrderNumber: this.roomCount,
  232. userName: this.clientName,
  233. userPhone: this.clientPhone,
  234. userId: uni.getStorageSync('userInfo').id
  235. }
  236. })
  237. // console.log(res)
  238. if (res.code === 200) {
  239. uni.navigateTo({
  240. url: `/pages/pay/pay?id=${res.data}`
  241. })
  242. }
  243. },
  244. handleBack() {
  245. uni.navigateBack(1)
  246. }
  247. }
  248. }
  249. </script>
  250. <style lang="scss" scoped>
  251. .container {
  252. position: relative;
  253. display: flex;
  254. flex-direction: column;
  255. height: 100vh;
  256. overflow: hidden;
  257. background-color: #ebeced;
  258. .header {
  259. position: relative;
  260. height: 145rpx;
  261. overflow: hidden;
  262. img {
  263. width: 100%;
  264. }
  265. .header_title {
  266. position: absolute;
  267. top: 65rpx;
  268. left: 182rpx;
  269. width: 50%;
  270. color: #fff;
  271. text-align: center;
  272. font-size: 28rpx;
  273. overflow: hidden;
  274. text-overflow: ellipsis;
  275. white-space: nowrap;
  276. }
  277. .header_icon {
  278. position: absolute;
  279. top: 76rpx;
  280. left: 5rpx;
  281. width: 47rpx;
  282. height: 70rpx;
  283. img {
  284. width: 47rpx;
  285. height: 47rpx;
  286. }
  287. }
  288. }
  289. .body {
  290. height: calc(100vh - 271rpx);
  291. overflow-y: auto;
  292. .info {
  293. display: flex;
  294. flex-direction: column;
  295. box-sizing: border-box;
  296. padding: 0 30rpx;
  297. margin: 0 auto;
  298. margin-top: 18rpx;
  299. width: 710rpx;
  300. border-radius: 15rpx;
  301. background-color: #fff;
  302. .info_time {
  303. display: flex;
  304. align-items: center;
  305. margin-top: 20rpx;
  306. font-size: 32rpx;
  307. font-weight: bold;
  308. .time_line {
  309. width: 17rpx;
  310. height: 1rpx;
  311. background-color: #096562;
  312. }
  313. .time_num {
  314. box-sizing: border-box;
  315. padding: 0 15rpx;
  316. height: 46rpx;
  317. line-height: 46rpx;
  318. font-size: 24rpx;
  319. font-weight: 400;
  320. border-radius: 66rpx;
  321. border: 1rpx solid #096562;
  322. background-color: #f0f2f5;
  323. }
  324. .gap {
  325. margin: 0 10rpx;
  326. }
  327. text {
  328. font-size: 24rpx;
  329. font-weight: 400;
  330. }
  331. }
  332. .info_msg {
  333. margin-top: 15rpx;
  334. font-size: 28rpx;
  335. font-weight: bold;
  336. }
  337. .info_type {
  338. display: flex;
  339. flex-wrap: wrap;
  340. margin-top: 15rpx;
  341. .type_item {
  342. box-sizing: border-box;
  343. padding: 0 15rpx;
  344. margin-right: 20rpx;
  345. height: 41rpx;
  346. line-height: 41rpx;
  347. font-size: 24rpx;
  348. color: #fff;
  349. border-radius: 34rpx;
  350. background-color: #096562;
  351. }
  352. }
  353. .info_tag {
  354. display: flex;
  355. flex-wrap: wrap;
  356. margin: 18rpx 0 30rpx;
  357. color: #808080;
  358. font-size: 24rpx;
  359. .tag_item {
  360. margin-right: 20rpx;
  361. }
  362. }
  363. }
  364. .msg {
  365. box-sizing: border-box;
  366. padding-left: 26rpx;
  367. margin: auto;
  368. margin-top: 20rpx;
  369. width: 710rpx;
  370. border-radius: 15rpx;
  371. background-color: #fff;
  372. .msg_title {
  373. height: 87rpx;
  374. line-height: 87rpx;
  375. font-size: 28rpx;
  376. font-weight: bold;
  377. border-bottom: 1rpx solid #e6e6e6;
  378. }
  379. .msg_box {
  380. display: flex;
  381. align-items: center;
  382. height: 97rpx;
  383. font-size: 28rpx;
  384. border-bottom: 1rpx solid #e6e6e6;
  385. .box_key {
  386. width: 120rpx;
  387. color: #808080;
  388. }
  389. .box_value {
  390. margin-left: 30rpx;
  391. flex: 1;
  392. input {
  393. box-sizing: border-box;
  394. padding-right: 30rpx;
  395. width: 100%;
  396. }
  397. }
  398. .color {
  399. color: #808080;
  400. }
  401. .box_icon {
  402. display: flex;
  403. align-items: center;
  404. height: 100%;
  405. .img {
  406. width: 47rpx;
  407. height: 47rpx;
  408. }
  409. .img2 {
  410. margin: 0 30rpx;
  411. width: 37rpx;
  412. height: 37rpx;
  413. }
  414. .img3 {
  415. margin: 0 30rpx;
  416. width: 40rpx;
  417. height: 40rpx;
  418. }
  419. }
  420. }
  421. }
  422. .price {
  423. box-sizing: border-box;
  424. padding-left: 26rpx;
  425. margin: 20rpx auto;
  426. width: 710rpx;
  427. height: 197rpx;
  428. border-radius: 15rpx;
  429. background-color: #fff;
  430. .price_title {
  431. line-height: 92rpx;
  432. font-size: 28rpx;
  433. font-weight: bold;
  434. border-bottom: 1rpx solid #e6e6e6;
  435. }
  436. .price_box {
  437. display: flex;
  438. justify-content: space-between;
  439. align-items: center;
  440. height: 92rpx;
  441. font-size: 28rpx;
  442. .box_key {
  443. color: #808080;
  444. }
  445. .box_value {
  446. display: flex;
  447. align-items: center;
  448. text {
  449. color: #ff5733;
  450. font-size: 24rpx;
  451. }
  452. span {
  453. margin-right: 30rpx;
  454. color: #ff5733;
  455. }
  456. }
  457. }
  458. }
  459. .all {
  460. box-sizing: border-box;
  461. padding-left: 26rpx;
  462. margin: 0 auto 60rpx;
  463. width: 710rpx;
  464. border-radius: 15rpx;
  465. background-color: #fff;
  466. .all_title {
  467. display: flex;
  468. height: 92rpx;
  469. justify-content: space-between;
  470. align-items: center;
  471. font-size: 28rpx;
  472. font-weight: bold;
  473. border-bottom: 1rpx solid #e6e6e6;
  474. .mr_30 {
  475. margin-right: 30rpx;
  476. }
  477. }
  478. .all_box {
  479. box-sizing: border-box;
  480. padding-right: 26rpx;
  481. display: flex;
  482. justify-content: space-between;
  483. font-size: 28rpx;
  484. .box_list {
  485. margin-bottom: 28rpx;
  486. color: #808080;
  487. .list_item {
  488. margin-top: 30rpx;
  489. }
  490. }
  491. .box_total {
  492. display: flex;
  493. justify-content: center;
  494. align-items: center;
  495. }
  496. }
  497. }
  498. }
  499. .foot {
  500. position: absolute;
  501. left: 0;
  502. right: 0;
  503. bottom: 0;
  504. padding: 0 20rpx;
  505. display: flex;
  506. justify-content: space-between;
  507. align-items: center;
  508. height: 126rpx;
  509. background-color: #fff;
  510. .foot_left {
  511. margin-top: -10rpx;
  512. font-size: 40rpx;
  513. color: #ff5733;
  514. text {
  515. font-size: 24rpx;
  516. }
  517. }
  518. .foot_right {
  519. margin-top: -10rpx;
  520. display: flex;
  521. justify-content: center;
  522. align-items: center;
  523. width: 238rpx;
  524. height: 80rpx;
  525. color: #fff;
  526. font-size: 32rpx;
  527. border-radius: 64rpx;
  528. background-color: #096562;
  529. }
  530. }
  531. }
  532. </style>