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. console.log(this.info)
  130. uni.$on('change', this.change)
  131. },
  132. methods: {
  133. change(e) {
  134. this.clientName = e.name
  135. this.clientPhone = e.phone
  136. },
  137. handleSelectClient() {
  138. uni.navigateTo({
  139. url: '/pages/common/common?type=1'
  140. })
  141. },
  142. confirm(e) {
  143. // console.log(e.value)
  144. let date = new Date(e.value)
  145. let month = date.getMonth() + 1
  146. let day = date.getDate()
  147. let H = date.getHours()
  148. let M = date.getMinutes()
  149. this.arriveTime = `${month}月${day}日${H}:${M}分之前`
  150. },
  151. formatter(type, value) {
  152. if (type === 'year') {
  153. return `${value}年`
  154. }
  155. if (type === 'month') {
  156. return `${value}月`
  157. }
  158. if (type === 'day') {
  159. return `${value}日`
  160. }
  161. return value
  162. },
  163. handleSelectTime() {
  164. this.$refs.datetimePicker.open()
  165. },
  166. handleAdd() {
  167. this.roomCount++
  168. },
  169. handleMinus() {
  170. if (this.roomCount > 1) {
  171. this.roomCount--
  172. } else {
  173. uni.showToast({
  174. title: '至少需要预定1间',
  175. icon: 'none'
  176. })
  177. }
  178. },
  179. // 提交订单按钮回调
  180. async goPagePay() {
  181. const reName = /^[\u4e00-\u9fa5]{2,4}$/
  182. const rePhone = /^[1][3,4,5,7,8,9][0-9]{9}$/
  183. if (!this.clientName) {
  184. uni.showToast({
  185. title: '请输入住客姓名',
  186. icon: 'none',
  187. mask: true
  188. })
  189. return
  190. }
  191. if (!reName.test(this.clientName)) {
  192. uni.showToast({
  193. title: '姓名格式有误',
  194. icon: 'none'
  195. })
  196. return
  197. }
  198. if (!this.clientPhone) {
  199. uni.showToast({
  200. title: '请输入联系电话',
  201. icon: 'none',
  202. mask: true
  203. })
  204. return
  205. }
  206. if (!rePhone.test(this.clientPhone)) {
  207. uni.showToast({
  208. title: '电话号码格式有误',
  209. icon: 'none'
  210. })
  211. return
  212. }
  213. const res = await this.$myRequest({
  214. url: '/mhotel/abkcreateOrder.action',
  215. data: {
  216. houseId: this.info.item.id,
  217. startTime: this.info.queryStartTime,
  218. endTime: this.info.queryEndTime,
  219. houseOrderNumber: this.roomCount,
  220. userName: this.clientName,
  221. userPhone: this.clientPhone,
  222. userId: uni.getStorageSync('userInfo').id
  223. }
  224. })
  225. // console.log(res)
  226. if (res.code === 200) {
  227. uni.navigateTo({
  228. url: `/pages/pay/pay?id=${res.data}`
  229. })
  230. }
  231. },
  232. handleBack() {
  233. uni.navigateBack(1)
  234. }
  235. }
  236. }
  237. </script>
  238. <style lang="scss" scoped>
  239. .container {
  240. position: relative;
  241. display: flex;
  242. flex-direction: column;
  243. height: 100vh;
  244. overflow: hidden;
  245. background-color: #ebeced;
  246. .header {
  247. position: relative;
  248. height: 145rpx;
  249. overflow: hidden;
  250. img {
  251. width: 100%;
  252. }
  253. .header_title {
  254. position: absolute;
  255. top: 65rpx;
  256. left: 308rpx;
  257. color: #fff;
  258. font-size: 28rpx;
  259. }
  260. .header_icon {
  261. position: absolute;
  262. top: 76rpx;
  263. left: 5rpx;
  264. width: 47rpx;
  265. height: 47rpx;
  266. }
  267. }
  268. .body {
  269. height: calc(100vh - 271rpx);
  270. overflow-y: auto;
  271. .info {
  272. display: flex;
  273. flex-direction: column;
  274. box-sizing: border-box;
  275. padding: 0 30rpx;
  276. margin: 0 auto;
  277. margin-top: 18rpx;
  278. width: 710rpx;
  279. border-radius: 15rpx;
  280. background-color: #fff;
  281. .info_time {
  282. display: flex;
  283. align-items: center;
  284. margin-top: 20rpx;
  285. font-size: 32rpx;
  286. font-weight: bold;
  287. .time_line {
  288. width: 17rpx;
  289. height: 1rpx;
  290. background-color: #096562;
  291. }
  292. .time_num {
  293. box-sizing: border-box;
  294. padding: 0 15rpx;
  295. height: 46rpx;
  296. line-height: 46rpx;
  297. font-size: 24rpx;
  298. font-weight: 400;
  299. border-radius: 66rpx;
  300. border: 1rpx solid #096562;
  301. background-color: #f0f2f5;
  302. }
  303. .gap {
  304. margin: 0 10rpx;
  305. }
  306. text {
  307. font-size: 24rpx;
  308. font-weight: 400;
  309. }
  310. }
  311. .info_msg {
  312. margin-top: 15rpx;
  313. font-size: 28rpx;
  314. font-weight: bold;
  315. }
  316. .info_type {
  317. display: flex;
  318. flex-wrap: wrap;
  319. margin-top: 15rpx;
  320. .type_item {
  321. box-sizing: border-box;
  322. padding: 0 15rpx;
  323. margin-right: 20rpx;
  324. height: 41rpx;
  325. line-height: 41rpx;
  326. font-size: 24rpx;
  327. color: #fff;
  328. border-radius: 34rpx;
  329. background-color: #096562;
  330. }
  331. }
  332. .info_tag {
  333. display: flex;
  334. flex-wrap: wrap;
  335. margin: 18rpx 0 30rpx;
  336. color: #808080;
  337. font-size: 24rpx;
  338. .tag_item {
  339. margin-right: 20rpx;
  340. }
  341. }
  342. }
  343. .msg {
  344. box-sizing: border-box;
  345. padding-left: 26rpx;
  346. margin: auto;
  347. margin-top: 20rpx;
  348. width: 710rpx;
  349. border-radius: 15rpx;
  350. background-color: #fff;
  351. .msg_title {
  352. height: 87rpx;
  353. line-height: 87rpx;
  354. font-size: 28rpx;
  355. font-weight: bold;
  356. border-bottom: 1rpx solid #e6e6e6;
  357. }
  358. .msg_box {
  359. display: flex;
  360. align-items: center;
  361. height: 97rpx;
  362. font-size: 28rpx;
  363. border-bottom: 1rpx solid #e6e6e6;
  364. .box_key {
  365. width: 120rpx;
  366. color: #808080;
  367. }
  368. .box_value {
  369. margin-left: 30rpx;
  370. flex: 1;
  371. input {
  372. box-sizing: border-box;
  373. padding-right: 30rpx;
  374. width: 100%;
  375. }
  376. }
  377. .color {
  378. color: #808080;
  379. }
  380. .box_icon {
  381. display: flex;
  382. align-items: center;
  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>