hotel.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. <template>
  2. <view>
  3. <view style="height: 65upx;"></view>
  4. <scroll-view style="height: 95vh;" class="floor-list"
  5. :scroll-top="scrollTop" scroll-y="true" @scroll="scroll" @scrolltoupper="upper" @scrolltolower="lower"
  6. refresher-enabled="true">
  7. <view class="scrollswiper">
  8. <swiper class="swiper"
  9. indicator-dots circular=true
  10. :autoplay="autoplay"
  11. :interval="interval"
  12. :duration="duration"
  13. >
  14. <swiper-item v-for="(item,index) in store_slide" :key="index">
  15. <view style="height: 100%;" class="swiper-item">
  16. <image style="height: 100%;width: 100%;" :src='item' />
  17. </view>
  18. </swiper-item>
  19. </swiper>
  20. </view>
  21. <view class="titeTop" :class="iScrolltop == 2?'activeColor' : ''">
  22. <view @tap="goback()" class="topleft">
  23. <uniIcon type="back" size="22" color="#666666" />
  24. </view>
  25. <view @click="gotosearch">
  26. <view class="input-view">
  27. <uniIcon type="search" size="22" color="#666666" />
  28. <input confirm-type="search" class="input" type="text" placeholder="输入搜索关键词" @confirm="confirm" />
  29. </view>
  30. </view>
  31. <!-- <view class="topright">
  32. <uniIcon type="arrowright" size="22" color="#666666" />
  33. </view> -->
  34. </view>
  35. <view class="tip">
  36. <view style="font-size: 36upx;color: #303133;">{{hotelitle}}</view>
  37. <view >
  38. <van-icon name="star-o" @click="gocollect" v-if="has_collected == 0" size="22" />
  39. <van-icon name="star-o" @click="gocollect" v-if="has_collected == 1" size="22" color= "#D9332E" />
  40. </view>
  41. </view>
  42. <view v-if="store_summary" style="padding: 0 32upx;">{{store_summary}}</view>
  43. <view>
  44. <van-tabs v-model="activeindex" @click.stop="onChange">
  45. <van-tab :name="0" title="服务">
  46. <view>
  47. <view class="giveList">
  48. <view class="giveItem" v-for="(item,index) in category_list" :key="index" @click.stop="godetail(item)">
  49. <image :src="item.pic"
  50. style="width:100%;height: 100upx;background: #909399">
  51. </image>
  52. <p style="text-align: center;">{{item.gc_name}}</p>
  53. </view>
  54. </view>
  55. <view style="padding: 0upx 18upx;">
  56. <view style="width: 95%;margin: 0 auto;">
  57. <view @click.stop="choseType(1)" :class="tabIndex==1 ? 'active' : ''" class="typeItem">
  58. 综合
  59. </view>
  60. <view@click.stop="choseType(2)" class="typeItem">
  61. <view class="iconClass">
  62. <view :class="tabIndex==2 ? 'active' : ''">上新</view>
  63. <view style="display: flex;flex-direction: column;margin-left: 10rpx;">
  64. <view v-if="istopclick==0">
  65. <!-- <van-icon size="8px" name="arrow-up" :class="istopclick==1 ? 'active' : ''" /> -->
  66. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort.png' />
  67. </view>
  68. <view v-if="istopclick==1">
  69. <!-- <van-icon size="8px" name="arrow-up" :class="istopclick==1 ? 'active' : ''" /> -->
  70. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_down.png' />
  71. </view>
  72. <view v-if="istopclick==2">
  73. <!-- <van-icon :class="istopclick==2 ? 'active' : ''" size="8px" name="arrow-down" /> -->
  74. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_up.png' />
  75. </view>
  76. </view>
  77. </view>
  78. </view>
  79. <view @click.stop="choseType(3)" class="typeItem">
  80. <view class="iconClass">
  81. <view :class="tabIndex==3 ? 'active' : ''">价格</view>
  82. <view style="display: flex;flex-direction: column;margin-left: 10rpx;">
  83. <!-- <view @click.stop="changeisclick(3)" >
  84. <van-icon :class="istopclick==3 ? 'active' : ''" size="8px" name="arrow-up" />
  85. </view>
  86. <view @click.stop="changeisclick(4)">
  87. <van-icon :class="istopclick==4 ? 'active' : ''" size="8px" name="arrow-down" />
  88. </view> -->
  89. <view v-if="isprice==0">
  90. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort.png' />
  91. </view>
  92. <view v-if="isprice==3">
  93. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_down.png' />
  94. </view>
  95. <view v-if="isprice==4">
  96. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_up.png' />
  97. </view>
  98. </view>
  99. </view>
  100. </view>
  101. <view @click.stop="choseType(4)" class="typeItem">
  102. <view :class="tabIndex==4 ? 'active' : ''">分类
  103. <img v-if="tabIndex != 4" style="width: 36upx;height: 36upx;" src='../../static/sortb.png' />
  104. <img v-if="tabIndex == 4" style="width: 36upx;height: 36upx;" src='../../static/sortb_up.png' />
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. <view v-if="tabIndex==4">
  110. <view style="margin: 18upx 36upx;float: left;width: 110upx;text-align: center;"
  111. v-for="(item, index) in classify" :key="index"
  112. @click.stop="confirm(item)" >
  113. {{item.gc_name}}
  114. </view>
  115. </view>
  116. <!-- 商品列表 -->
  117. <shopList :productList="goods_list" />
  118. </view>
  119. </van-tab>
  120. <van-tab :name="1" :title="'评价' +' '+hoteldetail.feedback_count">
  121. <!-- 评价列表 -->
  122. <assess :feedback_list="feedback_list" />
  123. </van-tab>
  124. <van-tab :name="2" title="酒店信息">
  125. <view style="padding: 20upx 32upx 0upx 32upx;margin-bottom: 200upx;">
  126. <rich-text :nodes="store_description"></rich-text>
  127. </view>
  128. </van-tab>
  129. </van-tabs>
  130. <view v-if="activeindex == 2" class="bottomButton">
  131. <button type="warn" @click="gofeedback">您的入住意见反馈(反馈送圈币)</button>
  132. </view>
  133. </view>
  134. </scroll-view>
  135. <Gobacktop @getop="getop" v-if="isTop" />
  136. </view>
  137. </template>
  138. <script>
  139. import {
  140. mapMutations,mapState
  141. } from 'vuex'
  142. import uniIcon from '@/component/uni-icon/uni-icon.vue'
  143. import uniNavBar from '@/component/uni-nav-bar/uni-nav-bar.vue'
  144. import commoNar from '@/component/commoNar.vue' // 筛选栏
  145. import shopList from '@/component/shopList.vue' // 商品列表
  146. import assess from '@/component/assess.vue' // 评价列表
  147. import Gobacktop from '@/component/Gobacktop.vue'
  148. export default {
  149. components: {
  150. uniIcon,
  151. uniNavBar,
  152. commoNar,
  153. assess,
  154. shopList,
  155. Gobacktop
  156. },
  157. data() {
  158. return {
  159. isTop: 0,
  160. hoteldetail: {},
  161. has_collected: 0, // 收藏酒店
  162. chosegoods_commonid: true,
  163. chosegoods_price: true,
  164. firstwo: 1,
  165. isDetail: 1,
  166. pictureUrl: this.pictureUrl,
  167. showdialog: false,
  168. store_description: '', //酒店信息
  169. store_summary:'', // 标签
  170. store_slide: [], //banner
  171. goods_list:[], // 首页酒店商品列表
  172. isnexttwo: 1,
  173. feedback_list:[], // 评价列表
  174. hotelitle: '', // 酒店名称
  175. istopclick: 0,
  176. page: 1,
  177. goodId: 0,
  178. page_size: 10,
  179. gc_id_1:'',// 一级分类id
  180. gc_id_2:'',// 二级分类id
  181. goods_commonid:'',// 上新排序 desc-降序 asc-尚需
  182. goods_price :'',// 价格排序 desc-降序 asc-尚需
  183. praise :'',// 好评率排序 desc-降序 asc-尚需
  184. keyword:'',//g 关键字搜索
  185. category_list: [{gc_id_1:'',gc_name:'全部'}], // 一级菜单栏
  186. tabIndex: 1,
  187. isprice:0,
  188. menu: [{
  189. name: '综合',
  190. id: '0'
  191. }, {
  192. name: '上新',
  193. id: '1'
  194. }, {
  195. name: '价格',
  196. id: '2'
  197. },
  198. {
  199. name:'分类',
  200. id:'3'
  201. }
  202. ],
  203. classify: [],
  204. background: ['color1', 'color2', 'color3'],
  205. indicatorDots: true,
  206. autoplay: true,
  207. interval: 2000,
  208. duration: 500,
  209. activeindex: 0,
  210. scrollTop: 0,
  211. old: {
  212. scrollTop: 0
  213. },
  214. value1: 0,
  215. iScrolltop: 1
  216. }
  217. },
  218. onShareAppMessage(res) {
  219. uni.showShareMenu({
  220. withShareTicket: true
  221. });
  222. let that = this;
  223. let id = this.goodId; // 商品Id
  224. if (res.from === 'button') {
  225. // 来自页面内分享按钮
  226. console.log(res.target)
  227. }
  228. return {
  229. title: that.hotelitle,
  230. path: `/pages/index/shop?id=${id}`,
  231. imageUrl:that.store_slide[0]
  232. }
  233. },
  234. // 初次渲染进来关闭分享菜单栏
  235. onReady:function(){
  236. // uni.hideShareMenu({
  237. // success(res) {
  238. // console.log(res)
  239. // console.log("kkkkkkkkkkkk")
  240. // },
  241. // fail(res){
  242. // console.log(res)
  243. // console.log("dddddd")
  244. // }
  245. // });
  246. },
  247. onLoad(options){
  248. this.goodId = options.id; // 商品和酒店Id
  249. this.activeindex = 0;
  250. this.getshopdetail(); // 获取商品详情
  251. this.hotelmenu(); // 一级菜单
  252. this.gethoteil(); // 获取酒店信息
  253. },
  254. computed:{
  255. ...mapState([
  256. 'hasLogin',
  257. 'userInfo',
  258. 'successlogion'
  259. ]),
  260. },
  261. methods: {
  262. getop() {
  263. this.scrollTop = this.old.scrollTop
  264.                 this.$nextTick(function(){
  265.                     this.scrollTop=0;
  266.                 });
  267. this.isTop = false;
  268. },
  269. // 入住酒店反馈
  270. gofeedback() {
  271. if(this.hoteldetail.can_feedback == 0) {
  272. this.$msg(this.hoteldetail.feedback_msg);
  273. return;
  274. }
  275. let store_id = this.goodId;
  276. uni.navigateTo({
  277. url: `/pages/index/feedback?store_id=${store_id}`
  278. });
  279. },
  280. // 搜说
  281. gotosearch() {
  282. let store_id = this.goodId;
  283. uni.navigateTo({
  284. url: `/pages/index/hotelsearch?store_id=${store_id}`
  285. });
  286. },
  287. // 收藏
  288. gocollect() {
  289. if(this.hasLogin && this.successlogion) {
  290. this.request({
  291. url: '/v1/favorites/collect',
  292. method: 'post',
  293. data: {
  294. type:'store',
  295. fav_id: this.goodId
  296. },
  297. success: () => {
  298. this.gethoteil()
  299. }
  300. })
  301. }else {
  302. // this.showdialog = true;
  303. uni.navigateTo({
  304. url:'/pages/myCenter/logion'
  305. })
  306. }
  307. },
  308. // 关闭弹窗
  309. // cancelDiaolog() {
  310. // this.showdialog = false;
  311. // },
  312. // // 确定
  313. // confirmDiaolog() {
  314. // this.showdialog = false;
  315. // },
  316. choseType(e) {
  317. this.tabIndex = e;
  318. this.isDetail = 1;
  319. this.page = 1;
  320. //this.goods_list = [];
  321. if(this.tabIndex == 1) { // 服务
  322. this.istopclick = 0;
  323. this.isprice = 0;
  324. this.gc_id_1 = '';
  325. this.goods_price = '';
  326. this.goods_commonid = '';
  327. this.getshopdetail(2);
  328. }else if(this.tabIndex == 2){ //伤
  329. this.chosegoods_price = true;
  330. console.log(this.chosegoods_commonid);
  331. this.istopclick = this.chosegoods_commonid?1:2;
  332. this.isprice = 0;
  333. this.goods_price = '';
  334. this.goods_commonid = this.chosegoods_commonid?'asc':'desc';
  335. this.chosegoods_commonid = !this.chosegoods_commonid;
  336. this.getshopdetail(2);
  337. }else if(this.tabIndex == 3){ // 价格
  338. this.chosegoods_commonid = true;
  339. console.log(this.chosegoods_price);
  340. this.istopclick = 0;
  341. this.isprice = this.chosegoods_price?3:4;
  342. this.goods_price = this.chosegoods_price?'desc':'asc';
  343. this.goods_commonid = '';
  344. this.chosegoods_price = !this.chosegoods_price;
  345. this.getshopdetail(2);
  346. }else if(this.tabIndex ==4) { // 分类
  347. this.istopclick = 0;
  348. this.isprice = 0;
  349. this.goods_price = '';
  350. this.goods_commonid = '';
  351. this.chosegoods_price = true;
  352. this.chosegoods_commonid = true;
  353. }
  354. },
  355. // 点击切换上下
  356. changeisclick(e) {
  357. },
  358. godetail(item) {
  359. console.log(item);
  360. let id = item.gc_id; // 一级菜单id
  361. let store_id = this.goodId;
  362. let gc_name = item.gc_name;
  363. uni.navigateTo({
  364. url: `/pages/index/hoteldetail?id=${id}&gc_name=${gc_name}&store_id=${store_id}`
  365. });
  366. },
  367. // 获取商品详情
  368. getshopdetail(e) {
  369. this.request({
  370.                 url:"/v2/entry/storeGoods",
  371.                 method:'get',
  372. data: {
  373. store_id: this.goodId,
  374. page: this.page,
  375. goods_commonid: this.goods_commonid, // 上新排序
  376. goods_price: this.goods_price,
  377. gc_id_1: this.gc_id_1
  378. },
  379. success: (res) => {
  380. if(e == 2) {
  381. this.goods_list = [];
  382. }
  383. this.goods_list = this.goods_list.concat(res.data.data.goods_list);
  384. if(res.data.data.goods_list.length < 10) {
  385. this.isDetail = 2;
  386. }
  387. },
  388. })
  389. },
  390. // 一级菜单
  391. hotelmenu() {
  392. let _this = this;
  393. this.request({
  394.                 url:"/v1/entry/storeCategory",
  395.                 method:'get',
  396. data: {
  397. store_id: this.goodId,
  398. },
  399. success: function(res) {
  400. let { category_list } = res.data.data;
  401. category_list.forEach((item,idx) => {
  402. item.text = item.gc_name;
  403. item.value = idx;
  404. })
  405. let array = [{gc_id:'',gc_name:'全部'}];
  406. _this.classify = array.concat(category_list);
  407. _this.category_list = category_list.splice(0,10);
  408. console.log(_this.category_list)
  409. },
  410. })
  411. },
  412. onChange(event) {
  413. this.activeindex = event.detail.name;
  414. this.page = 1;
  415. if(event.detail.name == 1) {
  416. this.getcomment();
  417. }else if(event.detail.name == 0) {
  418. this.getshopdetail()
  419. }
  420. },
  421. // 获取酒店评价
  422. getcomment() {
  423. this.request({
  424. url:'/v1/store/feedbackList',
  425. method: 'POST',
  426. data: {
  427. page: this.page,
  428. page_size: 10,
  429. store_id: this.goodId
  430. },
  431. success: (res) => {
  432. this.feedback_list = res.data.data.feedback_list;
  433. if(res.data.data.feedback_list.length < 10) {
  434. this.isnexttwo = 2;
  435. }
  436. }
  437. })
  438. },
  439. // 获取酒店信息
  440. gethoteil() {
  441. this.request({
  442. url:'/v1/store/info',
  443. method:'get',
  444. data: {
  445. store_id: this.goodId
  446. },
  447. success: (res) => {
  448. let { data } = res.data;
  449. this.hoteldetail = data;
  450. this.hotelitle = data.store_name;
  451. this.store_slide = data.store_slide;
  452. this.store_summary = data.store_summary;
  453. this.store_description = data.store_description;
  454. this.has_collected = data.has_collected; // 是否收藏
  455. }
  456. })
  457. },
  458. changemenu(e) {
  459. },
  460. confirm(e) {
  461. this.tabIndex = 0;
  462. this.gc_id_1 = e.gc_id;
  463. this.getshopdetail(2);
  464. },
  465. upper(e) {
  466. console.log("顶部")
  467. },
  468. // 滚到底部
  469. lower(e) {
  470. console.log(this.activeindex)
  471. console.log(this.isDetail)
  472. // if(this.activeindex == 1) {
  473. if(this.isnexttwo == 1 && this.activeindex == 1) {
  474. this.page = this.page + 1;
  475. //}
  476. this.getcomment();
  477. // this.activeindex == 0 &&
  478. }else if( this.isDetail == 1) {
  479. this.page = this.page + 1;
  480. this.getshopdetail();
  481. }
  482. },
  483. // 滚动时触发
  484. scroll(e) {
  485. if(e.detail.scrollTop > 400) {
  486. this.isTop = true;
  487. }else{ //当距离小于500时显示回到顶部按钮
  488. this.isTop = false;
  489. }
  490. if(e.detail.scrollTop > 160) {
  491. this.iScrolltop = 2;
  492. }else {
  493. this.iScrolltop = 1;
  494. }
  495. this.old.scrollTop = e.detail.scrollTop
  496. },
  497. // 返回上一页
  498. goback() {
  499. uni.navigateBack()
  500. },
  501. }
  502. }
  503. </script>
  504. <style scoped>
  505. .scrollswiper {
  506. width: 100%;
  507. position: relative;
  508. }
  509. .titleFixed {
  510. position: absolute;
  511. top: 0;
  512. left: 0;
  513. z-index: 99;
  514. padding-top: 0;
  515. }
  516. .van-nav-bar {
  517. padding-top: 0!important;
  518. /* background: #000000!important; */
  519. /* opacity: 0.2; */
  520. background:rgba(0,0,0,0.2)!important;
  521. }
  522. .swiper {
  523. height: 380upx;
  524. }
  525. .swiper-item {
  526. display: block;
  527. height: 100%!important;
  528. line-height: 300upx;
  529. text-align: center;
  530. }
  531. .tip {
  532. display: flex;
  533. justify-content: space-between;
  534. padding: 36upx 32upx;
  535. }
  536. .giveList {
  537. padding: 10upx 12upx;
  538. display: flex;
  539. flex-wrap: wrap;
  540. }
  541. .giveItem {
  542. height: 120rpx;
  543. flex: 1;
  544. width: 16%;
  545. min-width: 16%;
  546. max-width: 16%;
  547. /* margin: 24rpx 0 25rpx 4%; */
  548. margin: 24upx 2%;
  549. }
  550. .active {
  551. color: #F76260;
  552. }
  553. .typeItem {
  554. width: 25%;
  555. display: inline-block;
  556. text-align: center;
  557. }
  558. .iconClass {
  559. display: flex;
  560. flex-direction: row;
  561. align-items: center;
  562. justify-content: center;
  563. }
  564. .hotlItem {
  565. padding: 22upx 30upx;
  566. border-bottom: 1px solid #EEEEEE;
  567. display: flex;
  568. justify-content: space-between;
  569. }
  570. .bottomButton {
  571. width: 95%;
  572. left: 2.5%;
  573. position: fixed;
  574. bottom: 2.5%;
  575. }
  576. .titeTop {
  577. display: flex;
  578. /* justify-content: space-between; */
  579. align-items: center;
  580. position: absolute;
  581. top: 10upx;
  582. width: 100%;
  583. }
  584. .topleft {
  585. }
  586. .topright {
  587. }
  588. .input-view {
  589. width: 85%;
  590. display: flex;
  591. height: 30px;
  592. border-radius: 15px;
  593. padding: 0 4%;
  594. flex-wrap: nowrap;
  595. margin: 7px 0;
  596. line-height: 30px;
  597. margin: 24upx auto;
  598. background:rgba(0,0,0,1);
  599. border-radius:15px;
  600. opacity:0.4;
  601. }
  602. .input-view .uni-icon {
  603. line-height: 30px !important;
  604. }
  605. .input-view .input {
  606. height: 30px;
  607. line-height: 30px;
  608. width: 94%;
  609. padding: 0 3%;
  610. }
  611. .activeColor {
  612. background: #fff!important;
  613. position: fixed;
  614. background-color: #fff;
  615. top: 65upx;
  616. left: 0;
  617. z-index: 99;
  618. }
  619. .listType {
  620. }
  621. </style>