travelPeople.vue 15 KB

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