travelPeople.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. <template>
  2. <view class="curpage">
  3. <view class="top">
  4. <view class="image">
  5. <!-- <image src="https://t38.9026.com/uploads/golf/images/2022-05-31/20220531601652.png" mode="widthFix"></image> -->
  6. <image :src="goodsInfo.cover_picture"></image>
  7. </view>
  8. <view class="">
  9. <view class="" style="font-size: 32rpx;font-weight: 600;">
  10. <!-- 夕阳红康养团7日游 -->
  11. {{goodsInfo.name?goodsInfo.name:''}}
  12. </view>
  13. <view class="" style="font-size: 28rpx;margin-top: 20rpx;">
  14. 日期:{{day}}
  15. </view>
  16. </view>
  17. </view>
  18. <view class="house">
  19. <view class="" style="margin-bottom: 20rpx;font-weight: bold;font-size: 34rpx;">
  20. 入住房型
  21. </view>
  22. <view class="houseType">
  23. <view :class="houseType==index?'houseType-item-active':'houseType-item'" v-for="item,index in houselist"
  24. @click="chooseHouse(index,item.price,item.room_id)">
  25. <view class="image">
  26. <image :src="item.room_picture" @touchend="dblclick(item.room_picture)"></image>
  27. <view class="surplus">
  28. 剩余 {{item.number}}
  29. </view>
  30. </view>
  31. <view class="text">
  32. {{item.room_name}}
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="houseNumber">
  38. <view class="" style="margin-bottom: 20rpx;font-weight: bold;font-size: 34rpx;">
  39. 房间数量
  40. </view>
  41. <view class="housePrice">
  42. <view class="" style="font-size: 32rpx;color: #666666;">
  43. 套餐标准价格
  44. </view>
  45. <view class="" style="font-weight: bold;">
  46. <!-- ¥12399 -->
  47. ¥{{totalromprice}}
  48. </view>
  49. <u-number-box v-model="number" @change="valChange" bgColor="#ffffff"></u-number-box>
  50. </view>
  51. </view>
  52. <view class="travel">
  53. <u-cell title="出行人" isLink size="large" :border="false" :titleStyle="{color:'#666666'}" value="选择出行人"
  54. @click="choosePeople"></u-cell>
  55. <u-cell-group :border="false">
  56. <u-cell v-for="(item,index) in travelers" :title="item.name" isLink size="large" :border="false"
  57. :value="item.phone" @click="moveAdd(index)" :key="index"></u-cell>
  58. </u-cell-group>
  59. </view>
  60. <view class="Roommate">
  61. <view class="roommate-top">
  62. <view class="">
  63. 同住人
  64. </view>
  65. <view class="flex">
  66. <view :class="chooseroommate==1?'flex-item-active':'flex-item'" @click="chooseroommate=1">
  67. 随机安排
  68. </view>
  69. <view :class="chooseroommate==2?'flex-item-active':'flex-item'" @click="chooseroommate=2">
  70. 有同住人
  71. </view>
  72. </view>
  73. </view>
  74. <view class="travelList" v-if="chooseroommate==2">
  75. <view class="" style="margin: 20rpx 0;" v-for="(item,index) in cohabits" :key="index">
  76. <u--input placeholder="输入同住人姓名" border="bottom" clearable v-model="cohabits[index]"></u--input>
  77. </view>
  78. <view class="addpeople" @click="addcohabits">
  79. 增加同住人
  80. </view>
  81. </view>
  82. </view>
  83. <view class="remarks">
  84. <view class="text">
  85. 日期、房型相同的情况下可选择其他出行人同住,但有时候会出现人数不够分配的情况,会安排同性出行人同住。
  86. </view>
  87. </view>
  88. <view class="navbar">
  89. <view class="price">
  90. <view class="">
  91. 总金额
  92. </view>
  93. <view class="" style="margin: 0 10rpx 0 40rpx;" @click="details = true">
  94. ¥{{totalromprice}}
  95. </view>
  96. <u-icon name="arrow-up" color="#ffffff" @click="details = true"></u-icon>
  97. </view>
  98. <view class="next" @click="Submit">
  99. 提交订单
  100. </view>
  101. </view>
  102. <u-popup :show="details" @close="details = false" duration="0" :overlay="false"
  103. :customStyle="{'margin-bottom':'104rpx','background':' #F9F9F9 ','height':'104rpx'}">
  104. <view class="order">
  105. <view class="icon" @click="details = false">
  106. <u-icon name="arrow-down"></u-icon>
  107. </view>
  108. <view class="orderDetails">
  109. <view class="">
  110. 数量
  111. </view>
  112. <view class="">
  113. <text>{{value}}人</text>
  114. <text>¥{{totalromprice}}</text>
  115. </view>
  116. </view>
  117. </view>
  118. </u-popup>
  119. <view>
  120. <u-modal :show="showMoadl" :title="title" confirmText="知道了" confirmColor="#ffffff"
  121. @confirm="showMoadl=false">
  122. <view class="">
  123. 关注日月峡公众号
  124. <text style="color: #408B68;">日月峡</text>
  125. 及时获取出行信息
  126. </view>
  127. </u-modal>
  128. </view>
  129. </view>
  130. </template>
  131. <script>
  132. let that
  133. export default {
  134. data() {
  135. return {
  136. // 房型选择
  137. houseType: 0,
  138. state: 0,
  139. show: 0,
  140. name: '',
  141. touchNum: 0,
  142. // 房间类型
  143. houselist: [
  144. // {name:"多人间(上铺)",id:0,img:"../../static/house.jpg"},
  145. // {name:"三人间(3人)",id:1,img:"../../static/house.jpg"},
  146. // {name:"标间(2人)",id:2,img:"../../static/house.jpg"},
  147. // {name:"大床房(2人)",id:3,img:"../../static/house.jpg"},
  148. ],
  149. // 房间价格
  150. roomPrice: '',
  151. totalromprice: '',
  152. // 房间数量
  153. number: 0,
  154. // 选择样式
  155. active: false,
  156. showMoadl: true,
  157. title: '提示',
  158. // 添加同住人/随机
  159. chooseroommate: 1,
  160. // 金额详情
  161. details: false,
  162. goodsInfo: {},
  163. days: {},
  164. // 日期
  165. day: "",
  166. // 出行人
  167. travelers: [],
  168. // 同住人
  169. cohabits: [],
  170. room_id: 0,
  171. value: 1
  172. }
  173. },
  174. onLoad(options) {
  175. that = this
  176. console.log(options)
  177. let newdays = decodeURIComponent(options.obj)
  178. let datainfo = JSON.parse(newdays)
  179. this.days = datainfo.days
  180. // let goodsInfo=JSON.parse(options.goodsinfo)
  181. this.goodsInfo = datainfo.goodsinfo
  182. console.log(datainfo.days, 748789)
  183. // this.days=days
  184. //
  185. // console.log(this.days,this.goodsInfo)
  186. this.init()
  187. },
  188. onShow() {
  189. let open = this.$store.state.openpeopleList
  190. console.log(open, 890890890)
  191. if (open == 0) {
  192. this.$store.commit('getpeopleList', [])
  193. } else {
  194. let arr = this.$store.state.peopleList
  195. this.travelers = []
  196. arr.forEach(item => {
  197. if (item.checked) {
  198. this.travelers.push(item)
  199. }
  200. })
  201. }
  202. // console.log(this.$store.state.peopleList,7789789)
  203. },
  204. onUnload(event) { //监听是否跳转页面
  205. if (this.tjzt) {
  206. //tjzt为变量
  207. } else {
  208. let arr = []
  209. this.$store.commit("getpeopleList", arr)
  210. this.$store.commit("getopenpeopleList", 0)
  211. }
  212. },
  213. methods: {
  214. moveAdd(index) {
  215. let addPel = this.travelers[index]
  216. addPel.state = 0
  217. uni.navigateTo({
  218. url: `/pages/peopleList/addPeople?state=0&info=${JSON.stringify(addPel)}`
  219. })
  220. },
  221. dblclick(url, e) {
  222. this.touchNum++
  223. setTimeout(() => {
  224. if (this.touchNum == 1) {}
  225. if (this.touchNum >= 2) {
  226. let imgUrl = []
  227. imgUrl.push(url)
  228. console.log(imgUrl)
  229. uni.previewImage({
  230. current: imgUrl[0],
  231. urls: imgUrl,
  232. });
  233. }
  234. this.touchNum = 0
  235. }, 250)
  236. },
  237. init() {
  238. let newdays = this.days
  239. console.log(newdays)
  240. let start = newdays.start_at.slice(0, 10)
  241. let end = newdays.end_at.slice(0, 10)
  242. this.day = `${start}~${end}`
  243. this.houselist = newdays.rooms
  244. this.room_id = this.houselist[0].room_id
  245. this.houseType = 0
  246. this.roomPrice = Number(this.houselist[0].price)
  247. this.totalromprice = Number(this.houselist[0].price)
  248. console.log(this.day, this.houselist)
  249. },
  250. // 选择出行人
  251. choosePeople() {
  252. let list = this.$store.state.peopleList
  253. let obj = {
  254. value: this.value,
  255. list: list
  256. }
  257. console.log(obj, 9999999)
  258. uni.navigateTo({
  259. url: "/pages/peopleList/peopleList?obj=" + JSON.stringify(obj),
  260. })
  261. },
  262. // 查看出行人
  263. edit(item) {
  264. let info = JSON.stringify(item)
  265. uni.navigateTo({
  266. url: `/pages/peopleList/addPeople?info=${info}&state=0`
  267. })
  268. },
  269. // 点击放大图片
  270. previewImg(url, index) {
  271. let imgUrl = []
  272. imgUrl.push(url)
  273. console.log(imgUrl)
  274. uni.previewImage({
  275. current: imgUrl[0],
  276. urls: imgUrl,
  277. });
  278. },
  279. // 选择房间数量
  280. valChange(e) {
  281. let arr = []
  282. this.$store.commit("getpeopleList", arr)
  283. this.travelers = []
  284. console.log(this.travelers, 77788)
  285. this.value = e.value
  286. this.totalromprice = Number(this.roomPrice) * e.value
  287. },
  288. // 添加同住人e
  289. addcohabits() {
  290. for (let i in this.cohabits) {
  291. console.log(i)
  292. if (this.cohabits[i] == '') {
  293. console.log(i)
  294. this.$toast("请输入正确的同住人姓名")
  295. return
  296. }
  297. }
  298. this.cohabits.push("")
  299. console.log(this.cohabits)
  300. },
  301. chooseHouse(index, price, id) {
  302. this.houseType = index
  303. this.roomPrice = price
  304. this.room_id = id
  305. this.totalromprice = Number(this.roomPrice) * this.value
  306. console.log(index, price, id, "<=============")
  307. },
  308. // 提交订单
  309. Submit() {
  310. if (this.chooseroommate == 2) {
  311. for (let i in this.cohabits) {
  312. console.log(i)
  313. if (this.cohabits[i] == '') {
  314. console.log(i)
  315. this.$toast("请输入正确的同住人姓名")
  316. return
  317. }
  318. }
  319. }
  320. if (this.travelers.length == 0) {
  321. this.$toast("请选择出行人")
  322. return
  323. }
  324. let suborder = {}
  325. suborder.good_id = this.goodsInfo.id
  326. suborder.start_at = this.day.slice(0, 10)
  327. suborder.room_id = this.room_id
  328. suborder.number = this.value
  329. suborder.travelers = []
  330. suborder.cohabits = this.cohabits
  331. suborder.cohabit_type = this.chooseroommate
  332. suborder.total = this.totalromprice
  333. this.travelers.forEach((item, index) => {
  334. // console.log(item.id)
  335. suborder.travelers.push(item.id)
  336. })
  337. console.log(suborder, "<============提交订单的需要")
  338. uni.$u.http.post('/api/order/add', suborder, {
  339. custom: {
  340. auth: true
  341. }
  342. }).then((res) => {
  343. console.log(res)
  344. suborder.order_id = res.id // 订单id
  345. suborder.name = this.goodsInfo.name
  346. suborder.subtitle = this.goodsInfo.subtitle
  347. suborder.day = this.day
  348. suborder.people = []
  349. this.travelers.forEach((item, index) => {
  350. suborder.people.push(item.name)
  351. })
  352. uni.navigateTo({
  353. url: `/pages/travel/submitOrder?suborder=${JSON.stringify(suborder)}`
  354. })
  355. }).catch((err) => {
  356. console.log(err)
  357. uni.showToast({
  358. icon: "error",
  359. title: err.message,
  360. })
  361. })
  362. }
  363. }
  364. }
  365. </script>
  366. <style lang="less">
  367. page {
  368. background-color: #F4F4F4;
  369. font-family: PingFang-SC-Medium, PingFang-SC;
  370. font-size: 32rpx;
  371. }
  372. .curpage {
  373. .top {
  374. margin-top: 32rpx;
  375. padding: 10rpx 30rpx;
  376. display: flex;
  377. align-items: center;
  378. align-items: center;
  379. // background-color: #fff;
  380. margin-bottom: 30rpx;
  381. .image {
  382. margin: 20rpx;
  383. image {
  384. width: 180rpx;
  385. height: 110rpx;
  386. }
  387. }
  388. }
  389. .house {
  390. border-radius: 16rpx 56rpx 8rpx 8rpx;
  391. background-color: #FFF;
  392. padding: 50rpx 30rpx 40rpx;
  393. box-sizing: border-box;
  394. .houseType {
  395. display: flex;
  396. flex-wrap: wrap;
  397. box-sizing: border-box;
  398. .houseType-item-active {
  399. width: calc(90% / 3);
  400. padding: 10rpx;
  401. .image {
  402. width: 100%;
  403. position: relative;
  404. image {
  405. box-sizing: border-box;
  406. // width: 100%;
  407. width: 100%;
  408. height: 158rpx;
  409. border-radius: 8rpx 24rpx 8rpx 24rpx;
  410. border: 4rpx solid rgba(30, 159, 106, 1);
  411. }
  412. }
  413. .text {
  414. font-size: 26rpx;
  415. text-align: center;
  416. color: #1E9F6A;
  417. }
  418. }
  419. .houseType-item {
  420. width: calc(90% / 3);
  421. padding: 10rpx;
  422. .image {
  423. width: 100%;
  424. position: relative;
  425. image {
  426. width: 100%;
  427. height: 158rpx;
  428. border-radius: 8rpx 24rpx 8rpx 24rpx;
  429. }
  430. }
  431. .text {
  432. font-size: 26rpx;
  433. text-align: center;
  434. color: #101010;
  435. }
  436. }
  437. .surplus {
  438. width: 95rpx;
  439. height: 34rpx;
  440. line-height: 34rpx;
  441. padding: 0 10rpx;
  442. background: #030303;
  443. box-shadow: 0px 2rpx 11rpx 0px rgba(30, 159, 106, 0.22);
  444. border-radius: 2rpx 12rpx 2rpx 12rpx;
  445. opacity: 0.39;
  446. font-size: 20rpx;
  447. color: #FFFFFF;
  448. text-align: center;
  449. position: absolute;
  450. top: 0rpx;
  451. left: 0;
  452. right: 0;
  453. margin: 0 auto;
  454. margin-top: 15rpx;
  455. }
  456. }
  457. }
  458. .houseNumber {
  459. background-color: #ffffff;
  460. margin: 20rpx 0;
  461. padding: 50rpx 30rpx 40rpx;
  462. .housePrice {
  463. display: flex;
  464. justify-content: space-between;
  465. align-items: center;
  466. }
  467. }
  468. .travel {
  469. // display: flex;
  470. // justify-content: space-between;
  471. background-color: #ffffff;
  472. padding: 50rpx 0rpx;
  473. }
  474. .Roommate {
  475. .roommate-top {
  476. display: flex;
  477. justify-content: space-between;
  478. padding: 0 30rpx;
  479. }
  480. .travelList {
  481. padding: 0 20rpx;
  482. }
  483. padding:50rpx 0rpx;
  484. background-color: #ffffff;
  485. margin: 20rpx 0;
  486. .flex {
  487. display: flex;
  488. .flex-item {
  489. margin: 0 20rpx;
  490. width: 176rpx;
  491. height: 60rpx;
  492. line-height: 60rpx;
  493. background: #F4F4F4;
  494. border-radius: 2rpx 30rpx 2rpx 30rpx;
  495. font-size: 30rpx;
  496. text-align: center;
  497. }
  498. .flex-item-active {
  499. box-sizing: border-box;
  500. width: 176rpx;
  501. height: 60rpx;
  502. line-height: 60rpx;
  503. background: rgba(30, 159, 106, 0.1);
  504. border-radius: 2rpx 30rpx 2rpx 30rpx;
  505. border: 1rpx solid #1E9F6A;
  506. font-size: 30rpx;
  507. color: #1E9F6A;
  508. text-align: center;
  509. }
  510. }
  511. .addpeople {
  512. margin: 40rpx 20rpx 0;
  513. width: 176rpx;
  514. height: 60rpx;
  515. line-height: 60rpx;
  516. background: #F4F4F4;
  517. border-radius: 2rpx 30rpx 2rpx 30rpx;
  518. font-size: 30rpx;
  519. text-align: center;
  520. margin-left: 530rpx;
  521. }
  522. }
  523. .remarks {
  524. background-color: #ffffff;
  525. padding: 50rpx 30rpx;
  526. .text {
  527. background-color: #F4F4F4;
  528. padding: 40rpx 24rpx;
  529. font-size: 32rpx;
  530. }
  531. margin-bottom: 104rpx;
  532. }
  533. .navbar {
  534. z-index: 9999;
  535. box-sizing: border-box;
  536. padding: 0 30rpx;
  537. width: 100%;
  538. display: flex;
  539. justify-content: space-between;
  540. align-items: center;
  541. height: 104rpx;
  542. background: #1E9F6A;
  543. border-radius: 16rpx 16rpx 0px 0px;
  544. color: #ffffff;
  545. position: fixed;
  546. bottom: 0;
  547. left: 0;
  548. .next {
  549. width: 50%;
  550. // background-color: pink;
  551. text-align: center;
  552. border-left: 1rpx solid #ffffff;
  553. }
  554. .price {
  555. display: flex;
  556. }
  557. }
  558. }
  559. .order {
  560. margin-bottom: 104rpx;
  561. padding: 40rpx 30rpx 0;
  562. .icon {
  563. padding-left: 50%;
  564. }
  565. .orderDetails {
  566. display: flex;
  567. justify-content: space-between;
  568. }
  569. }
  570. .popupstyle {
  571. background-color: pink;
  572. }
  573. </style>