travelPeople.vue 12 KB

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