affirmOrder.vue 12 KB

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