affirmOrder.vue 11 KB

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