affirmOrder.vue 11 KB

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