affirmOrder.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. <template>
  2. <view class="container">
  3. <!-- 导航栏图片区域 -->
  4. <view class="header">
  5. <img src="../../static/my/headerImg.png" />
  6. <!-- 标题区域 -->
  7. <view class="header_title">填写订单</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. },
  129. onLoad(options) {
  130. this.info = JSON.parse(options.info)
  131. uni.$on('change', this.change)
  132. },
  133. computed: {
  134. // 总费用
  135. totalPrice() {
  136. if (this.info.item) {
  137. return (this.roomCount * this.info.item.price * this.info.nightNum).toFixed(2)
  138. }
  139. }
  140. },
  141. methods: {
  142. change(e) {
  143. this.clientName = e.name
  144. this.clientPhone = e.phone
  145. },
  146. handleSelectClient() {
  147. uni.navigateTo({
  148. url: '/pages/common/common?type=1'
  149. })
  150. },
  151. confirm(e) {
  152. // console.log(e.value)
  153. let date = new Date(e.value)
  154. let month = date.getMonth() + 1
  155. let day = date.getDate()
  156. let H = date.getHours()
  157. let M = date.getMinutes()
  158. this.arriveTime = `${month}月${day}日${H}:${M}分之前`
  159. },
  160. formatter(type, value) {
  161. if (type === 'year') {
  162. return `${value}年`
  163. }
  164. if (type === 'month') {
  165. return `${value}月`
  166. }
  167. if (type === 'day') {
  168. return `${value}日`
  169. }
  170. return value
  171. },
  172. handleSelectTime() {
  173. this.$refs.datetimePicker.open()
  174. },
  175. handleAdd() {
  176. this.roomCount++
  177. },
  178. handleMinus() {
  179. if (this.roomCount > 1) {
  180. this.roomCount--
  181. } else {
  182. uni.showToast({
  183. title: '至少需要预定1间',
  184. icon: 'none'
  185. })
  186. }
  187. },
  188. // 提交订单按钮回调
  189. async goPagePay() {
  190. const reName = /^[\u4e00-\u9fa5]{2,4}$/
  191. const rePhone = /^[1][3,4,5,7,8,9][0-9]{9}$/
  192. if (!this.clientName) {
  193. uni.showToast({
  194. title: '请输入住客姓名',
  195. icon: 'none',
  196. mask: true
  197. })
  198. return
  199. }
  200. if (!reName.test(this.clientName)) {
  201. uni.showToast({
  202. title: '姓名格式有误',
  203. icon: 'none'
  204. })
  205. return
  206. }
  207. if (!this.clientPhone) {
  208. uni.showToast({
  209. title: '请输入联系电话',
  210. icon: 'none',
  211. mask: true
  212. })
  213. return
  214. }
  215. if (!rePhone.test(this.clientPhone)) {
  216. uni.showToast({
  217. title: '电话号码格式有误',
  218. icon: 'none'
  219. })
  220. return
  221. }
  222. const res = await this.$myRequest({
  223. url: '/mhotel/abkcreateOrder.action',
  224. data: {
  225. houseId: this.info.item.id,
  226. startTime: this.info.queryStartTime,
  227. endTime: this.info.queryEndTime,
  228. houseOrderNumber: this.roomCount,
  229. userName: this.clientName,
  230. userPhone: this.clientPhone,
  231. userId: uni.getStorageSync('userInfo').id
  232. }
  233. })
  234. // console.log(res)
  235. if (res.code === 200) {
  236. uni.navigateTo({
  237. url: `/pages/pay/pay?id=${res.data}`
  238. })
  239. }
  240. },
  241. handleBack() {
  242. uni.navigateBack(1)
  243. }
  244. }
  245. }
  246. </script>
  247. <style lang="scss" scoped>
  248. .container {
  249. position: relative;
  250. display: flex;
  251. flex-direction: column;
  252. height: 100vh;
  253. overflow: hidden;
  254. background-color: #ebeced;
  255. .header {
  256. position: relative;
  257. height: 145rpx;
  258. overflow: hidden;
  259. img {
  260. width: 100%;
  261. }
  262. .header_title {
  263. position: absolute;
  264. top: 65rpx;
  265. left: 308rpx;
  266. color: #fff;
  267. font-size: 28rpx;
  268. }
  269. .header_icon {
  270. position: absolute;
  271. top: 76rpx;
  272. left: 5rpx;
  273. width: 47rpx;
  274. height: 70rpx;
  275. img {
  276. width: 47rpx;
  277. height: 47rpx;
  278. }
  279. }
  280. }
  281. .body {
  282. height: calc(100vh - 271rpx);
  283. overflow-y: auto;
  284. .info {
  285. display: flex;
  286. flex-direction: column;
  287. box-sizing: border-box;
  288. padding: 0 30rpx;
  289. margin: 0 auto;
  290. margin-top: 18rpx;
  291. width: 710rpx;
  292. border-radius: 15rpx;
  293. background-color: #fff;
  294. .info_time {
  295. display: flex;
  296. align-items: center;
  297. margin-top: 20rpx;
  298. font-size: 32rpx;
  299. font-weight: bold;
  300. .time_line {
  301. width: 17rpx;
  302. height: 1rpx;
  303. background-color: #096562;
  304. }
  305. .time_num {
  306. box-sizing: border-box;
  307. padding: 0 15rpx;
  308. height: 46rpx;
  309. line-height: 46rpx;
  310. font-size: 24rpx;
  311. font-weight: 400;
  312. border-radius: 66rpx;
  313. border: 1rpx solid #096562;
  314. background-color: #f0f2f5;
  315. }
  316. .gap {
  317. margin: 0 10rpx;
  318. }
  319. text {
  320. font-size: 24rpx;
  321. font-weight: 400;
  322. }
  323. }
  324. .info_msg {
  325. margin-top: 15rpx;
  326. font-size: 28rpx;
  327. font-weight: bold;
  328. }
  329. .info_type {
  330. display: flex;
  331. flex-wrap: wrap;
  332. margin-top: 15rpx;
  333. .type_item {
  334. box-sizing: border-box;
  335. padding: 0 15rpx;
  336. margin-right: 20rpx;
  337. height: 41rpx;
  338. line-height: 41rpx;
  339. font-size: 24rpx;
  340. color: #fff;
  341. border-radius: 34rpx;
  342. background-color: #096562;
  343. }
  344. }
  345. .info_tag {
  346. display: flex;
  347. flex-wrap: wrap;
  348. margin: 18rpx 0 30rpx;
  349. color: #808080;
  350. font-size: 24rpx;
  351. .tag_item {
  352. margin-right: 20rpx;
  353. }
  354. }
  355. }
  356. .msg {
  357. box-sizing: border-box;
  358. padding-left: 26rpx;
  359. margin: auto;
  360. margin-top: 20rpx;
  361. width: 710rpx;
  362. border-radius: 15rpx;
  363. background-color: #fff;
  364. .msg_title {
  365. height: 87rpx;
  366. line-height: 87rpx;
  367. font-size: 28rpx;
  368. font-weight: bold;
  369. border-bottom: 1rpx solid #e6e6e6;
  370. }
  371. .msg_box {
  372. display: flex;
  373. align-items: center;
  374. height: 97rpx;
  375. font-size: 28rpx;
  376. border-bottom: 1rpx solid #e6e6e6;
  377. .box_key {
  378. width: 120rpx;
  379. color: #808080;
  380. }
  381. .box_value {
  382. margin-left: 30rpx;
  383. flex: 1;
  384. input {
  385. box-sizing: border-box;
  386. padding-right: 30rpx;
  387. width: 100%;
  388. }
  389. }
  390. .color {
  391. color: #808080;
  392. }
  393. .box_icon {
  394. display: flex;
  395. align-items: center;
  396. height: 100%;
  397. .img {
  398. width: 47rpx;
  399. height: 47rpx;
  400. }
  401. .img2 {
  402. margin: 0 30rpx;
  403. width: 37rpx;
  404. height: 37rpx;
  405. }
  406. .img3 {
  407. margin: 0 30rpx;
  408. width: 40rpx;
  409. height: 40rpx;
  410. }
  411. }
  412. }
  413. }
  414. .price {
  415. box-sizing: border-box;
  416. padding-left: 26rpx;
  417. margin: 20rpx auto;
  418. width: 710rpx;
  419. height: 197rpx;
  420. border-radius: 15rpx;
  421. background-color: #fff;
  422. .price_title {
  423. line-height: 92rpx;
  424. font-size: 28rpx;
  425. font-weight: bold;
  426. border-bottom: 1rpx solid #e6e6e6;
  427. }
  428. .price_box {
  429. display: flex;
  430. justify-content: space-between;
  431. align-items: center;
  432. height: 92rpx;
  433. font-size: 28rpx;
  434. .box_key {
  435. color: #808080;
  436. }
  437. .box_value {
  438. display: flex;
  439. align-items: center;
  440. text {
  441. color: #ff5733;
  442. font-size: 24rpx;
  443. }
  444. span {
  445. margin-right: 30rpx;
  446. color: #ff5733;
  447. }
  448. }
  449. }
  450. }
  451. .all {
  452. box-sizing: border-box;
  453. padding-left: 26rpx;
  454. margin: 0 auto 60rpx;
  455. width: 710rpx;
  456. border-radius: 15rpx;
  457. background-color: #fff;
  458. .all_title {
  459. display: flex;
  460. height: 92rpx;
  461. justify-content: space-between;
  462. align-items: center;
  463. font-size: 28rpx;
  464. font-weight: bold;
  465. border-bottom: 1rpx solid #e6e6e6;
  466. .mr_30 {
  467. margin-right: 30rpx;
  468. }
  469. }
  470. .all_box {
  471. box-sizing: border-box;
  472. padding-right: 26rpx;
  473. display: flex;
  474. justify-content: space-between;
  475. font-size: 28rpx;
  476. .box_list {
  477. margin-bottom: 28rpx;
  478. color: #808080;
  479. .list_item {
  480. margin-top: 30rpx;
  481. }
  482. }
  483. .box_total {
  484. display: flex;
  485. justify-content: center;
  486. align-items: center;
  487. }
  488. }
  489. }
  490. }
  491. .foot {
  492. position: absolute;
  493. left: 0;
  494. right: 0;
  495. bottom: 0;
  496. padding: 0 20rpx;
  497. display: flex;
  498. justify-content: space-between;
  499. align-items: center;
  500. height: 126rpx;
  501. background-color: #fff;
  502. .foot_left {
  503. margin-top: -10rpx;
  504. font-size: 40rpx;
  505. color: #ff5733;
  506. text {
  507. font-size: 24rpx;
  508. }
  509. }
  510. .foot_right {
  511. margin-top: -10rpx;
  512. display: flex;
  513. justify-content: center;
  514. align-items: center;
  515. width: 238rpx;
  516. height: 80rpx;
  517. color: #fff;
  518. font-size: 32rpx;
  519. border-radius: 64rpx;
  520. background-color: #096562;
  521. }
  522. }
  523. }
  524. </style>