hotel.vue 20 KB

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