travelPeople.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  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. suborder.number = this.value
  359. suborder.travelers = []
  360. suborder.cohabits = this.cohabits
  361. suborder.cohabit_type = this.chooseroommate
  362. suborder.total = this.totalromprice
  363. this.travelers.forEach((item, index) => {
  364. // console.log(item.id)
  365. suborder.travelers.push(item.id)
  366. })
  367. console.log(suborder, "<============提交订单的需要")
  368. uni.$u.http.post('/api/order/add', suborder, {
  369. custom: {
  370. auth: true
  371. }
  372. }).then((res) => {
  373. console.log(res)
  374. suborder.order_id = res.id // 订单id
  375. suborder.name = this.goodsInfo.name
  376. suborder.subtitle = this.goodsInfo.subtitle
  377. suborder.day = this.day
  378. suborder.people = []
  379. this.travelers.forEach((item, index) => {
  380. suborder.people.push(item.name)
  381. })
  382. uni.navigateTo({
  383. url: "/pages/travel/submitOrder?suborder="+encodeURIComponent(JSON.stringify(suborder))
  384. // url: `/pages/travel/submitOrder?suborder=${JSON.stringify(suborder)}`
  385. })
  386. }).catch((err) => {
  387. console.log(err)
  388. this.$toast(err.message)
  389. })
  390. }
  391. }
  392. }
  393. </script>
  394. <style lang="less">
  395. page {
  396. background-color: #F4F4F4;
  397. font-family: PingFang-SC-Medium, PingFang-SC;
  398. font-size: 32rpx;
  399. }
  400. .curpage {
  401. .top {
  402. margin-top: 32rpx;
  403. padding: 10rpx 30rpx;
  404. display: flex;
  405. align-items: center;
  406. align-items: center;
  407. // background-color: #fff;
  408. margin-bottom: 30rpx;
  409. .image {
  410. margin: 20rpx;
  411. image {
  412. width: 180rpx;
  413. height: 110rpx;
  414. }
  415. }
  416. }
  417. .house {
  418. border-radius: 16rpx 56rpx 8rpx 8rpx;
  419. background-color: #FFF;
  420. padding: 50rpx 30rpx 40rpx;
  421. box-sizing: border-box;
  422. .houseType {
  423. display: flex;
  424. flex-wrap: wrap;
  425. box-sizing: border-box;
  426. .houseType-item-active {
  427. width: calc(90% / 3);
  428. padding: 10rpx;
  429. .image {
  430. width: 100%;
  431. position: relative;
  432. image {
  433. box-sizing: border-box;
  434. // width: 100%;
  435. width: 100%;
  436. height: 158rpx;
  437. border-radius: 8rpx 24rpx 8rpx 24rpx;
  438. border: 4rpx solid rgba(30, 159, 106, 1);
  439. }
  440. }
  441. .text {
  442. font-size: 26rpx;
  443. text-align: center;
  444. color: #1E9F6A;
  445. }
  446. }
  447. .houseType-item {
  448. width: calc(90% / 3);
  449. padding: 10rpx;
  450. .image {
  451. width: 100%;
  452. position: relative;
  453. image {
  454. width: 100%;
  455. height: 158rpx;
  456. border-radius: 8rpx 24rpx 8rpx 24rpx;
  457. }
  458. }
  459. .text {
  460. font-size: 26rpx;
  461. text-align: center;
  462. color: #101010;
  463. }
  464. }
  465. .surplus {
  466. width: 95rpx;
  467. height: 34rpx;
  468. line-height: 34rpx;
  469. padding: 0 10rpx;
  470. background: #030303;
  471. box-shadow: 0px 2rpx 11rpx 0px rgba(30, 159, 106, 0.22);
  472. border-radius: 2rpx 12rpx 2rpx 12rpx;
  473. opacity: 0.39;
  474. font-size: 20rpx;
  475. color: #FFFFFF;
  476. text-align: center;
  477. position: absolute;
  478. top: 0rpx;
  479. left: 0;
  480. right: 0;
  481. margin: 0 auto;
  482. margin-top: 15rpx;
  483. }
  484. }
  485. }
  486. .houseNumber {
  487. background-color: #ffffff;
  488. margin: 20rpx 0;
  489. padding: 50rpx 30rpx 40rpx;
  490. .housePrice {
  491. display: flex;
  492. justify-content: space-between;
  493. align-items: center;
  494. }
  495. }
  496. .travel {
  497. // display: flex;
  498. // justify-content: space-between;
  499. background-color: #ffffff;
  500. padding: 50rpx 0rpx;
  501. }
  502. .Roommate {
  503. .roommate-top {
  504. display: flex;
  505. justify-content: space-between;
  506. padding: 0 30rpx;
  507. }
  508. .travelList {
  509. padding: 0 20rpx;
  510. .clearmore{
  511. position: relative;
  512. }
  513. .clearbox{
  514. z-index: 999;
  515. position: absolute;
  516. width: 45rpx;
  517. height: 45rpx;
  518. border-radius: 50%;
  519. background-color: #F4F4F4;
  520. display: flex;
  521. align-items: center;
  522. justify-content: center;
  523. right:10rpx;
  524. top: 0;
  525. bottom: 0;
  526. margin: auto 0;
  527. }
  528. }
  529. padding:50rpx 0rpx;
  530. background-color: #ffffff;
  531. margin: 20rpx 0;
  532. .flex {
  533. display: flex;
  534. .flex-item {
  535. margin: 0 20rpx;
  536. width: 176rpx;
  537. height: 60rpx;
  538. line-height: 60rpx;
  539. background: #F4F4F4;
  540. border-radius: 2rpx 30rpx 2rpx 30rpx;
  541. font-size: 30rpx;
  542. text-align: center;
  543. }
  544. .flex-item-active {
  545. box-sizing: border-box;
  546. width: 176rpx;
  547. height: 60rpx;
  548. line-height: 60rpx;
  549. background: rgba(30, 159, 106, 0.1);
  550. border-radius: 2rpx 30rpx 2rpx 30rpx;
  551. border: 1rpx solid #1E9F6A;
  552. font-size: 30rpx;
  553. color: #1E9F6A;
  554. text-align: center;
  555. }
  556. }
  557. .addpeople {
  558. margin: 40rpx 20rpx 0;
  559. width: 176rpx;
  560. height: 60rpx;
  561. line-height: 60rpx;
  562. background: #F4F4F4;
  563. border-radius: 2rpx 30rpx 2rpx 30rpx;
  564. font-size: 30rpx;
  565. text-align: center;
  566. margin-left: 530rpx;
  567. }
  568. }
  569. .remarks {
  570. background-color: #ffffff;
  571. padding: 50rpx 30rpx;
  572. .text {
  573. background-color: #F4F4F4;
  574. padding: 40rpx 24rpx;
  575. font-size: 32rpx;
  576. }
  577. margin-bottom: 104rpx;
  578. }
  579. .navbar {
  580. z-index: 9999;
  581. box-sizing: border-box;
  582. padding: 0 30rpx;
  583. width: 100%;
  584. display: flex;
  585. justify-content: space-between;
  586. align-items: center;
  587. height: 104rpx;
  588. background: #1E9F6A;
  589. border-radius: 16rpx 16rpx 0px 0px;
  590. color: #ffffff;
  591. position: fixed;
  592. bottom: 0;
  593. left: 0;
  594. .next {
  595. width: 50%;
  596. // background-color: pink;
  597. text-align: center;
  598. border-left: 1rpx solid #ffffff;
  599. }
  600. .price {
  601. display: flex;
  602. }
  603. }
  604. }
  605. .order {
  606. margin-bottom: 104rpx;
  607. padding: 40rpx 30rpx 0;
  608. .icon {
  609. padding-left: 50%;
  610. }
  611. .orderDetails {
  612. display: flex;
  613. justify-content: space-between;
  614. }
  615. }
  616. .popupstyle {
  617. background-color: pink;
  618. }
  619. </style>