hotel.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  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. <view class="giveList">
  49. <view class="giveItem" v-for="(item,index) in category_list" :key="index" @click.stop="godetail(item)">
  50. <image :src="item.pic"
  51. style="width:100%;height: 100upx;background: #909399">
  52. </image>
  53. <p style="text-align: center;">{{item.gc_name}}</p>
  54. </view>
  55. </view>
  56. <view style="padding: 0upx 18upx;">
  57. <view style="width: 95%;margin: 0 auto;">
  58. <view @click.stop="choseType(1)" :class="tabIndex==1 ? 'active' : ''" class="typeItem">
  59. 综合
  60. </view>
  61. <view@click.stop="choseType(2)" class="typeItem">
  62. <view class="iconClass">
  63. <view :class="tabIndex==2 ? 'active' : ''">上新</view>
  64. <view style="display: flex;flex-direction: column;margin-left: 10rpx;">
  65. <view v-if="istopclick==0">
  66. <!-- <van-icon size="8px" name="arrow-up" :class="istopclick==1 ? 'active' : ''" /> -->
  67. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort.png' />
  68. </view>
  69. <view v-if="istopclick==1">
  70. <!-- <van-icon size="8px" name="arrow-up" :class="istopclick==1 ? 'active' : ''" /> -->
  71. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_down.png' />
  72. </view>
  73. <view v-if="istopclick==2">
  74. <!-- <van-icon :class="istopclick==2 ? 'active' : ''" size="8px" name="arrow-down" /> -->
  75. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_up.png' />
  76. </view>
  77. </view>
  78. </view>
  79. </view>
  80. <view @click.stop="choseType(3)" class="typeItem">
  81. <view class="iconClass">
  82. <view :class="tabIndex==3 ? 'active' : ''">价格</view>
  83. <view style="display: flex;flex-direction: column;margin-left: 10rpx;">
  84. <!-- <view @click.stop="changeisclick(3)" >
  85. <van-icon :class="istopclick==3 ? 'active' : ''" size="8px" name="arrow-up" />
  86. </view>
  87. <view @click.stop="changeisclick(4)">
  88. <van-icon :class="istopclick==4 ? 'active' : ''" size="8px" name="arrow-down" />
  89. </view> -->
  90. <view v-if="isprice==0">
  91. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort.png' />
  92. </view>
  93. <view v-if="isprice==3">
  94. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_down.png' />
  95. </view>
  96. <view v-if="isprice==4">
  97. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_up.png' />
  98. </view>
  99. </view>
  100. </view>
  101. </view>
  102. <view @click.stop="choseType(4)" class="typeItem">
  103. <view :class="tabIndex==4 ? 'active' : ''">分类
  104. <img v-if="tabIndex != 4" style="width: 36upx;height: 36upx;" src='../../static/sortb.png' />
  105. <img v-if="tabIndex == 4" style="width: 36upx;height: 36upx;" src='../../static/sortb_up.png' />
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. <view v-if="tabIndex==4">
  111. <view style="margin: 18upx 36upx;float: left;width: 110upx;text-align: center;"
  112. v-for="(item, index) in classify" :key="index"
  113. @click.stop="confirm(item)" >
  114. {{item.gc_name}}
  115. </view>
  116. </view>
  117. <!-- 商品列表 -->
  118. <shopList :productList="goods_list" />
  119. </view>
  120. </van-tab>
  121. <van-tab :name="1" :title="'评价' +' '+hoteldetail.feedback_count">
  122. <!-- 评价列表 -->
  123. <assess :feedback_list="feedback_list" />
  124. </van-tab>
  125. <van-tab :name="2" title="酒店信息">
  126. <view style="padding: 20upx 32upx 0upx 32upx;margin-bottom: 200upx;">
  127. <rich-text :nodes="store_description"></rich-text>
  128. </view>
  129. </van-tab>
  130. </van-tabs>
  131. </view>
  132. </scroll-view>
  133. <view v-if="activeindex == 2" class="bottomButton">
  134. <button type="warn" @click="gofeedback">您的入住意见反馈(反馈送圈币)</button>
  135. </view>
  136. <Gobacktop @getop="getop" v-if="isTop" />
  137. </view>
  138. </template>
  139. <script>
  140. import {
  141. mapMutations,mapState
  142. } from 'vuex'
  143. import uniIcon from '@/component/uni-icon/uni-icon.vue'
  144. import uniNavBar from '@/component/uni-nav-bar/uni-nav-bar.vue'
  145. import commoNar from '@/component/commoNar.vue' // 筛选栏
  146. import shopList from '@/component/shopList.vue' // 商品列表
  147. import assess from '@/component/assess.vue' // 评价列表
  148. import Gobacktop from '@/component/Gobacktop.vue'
  149. export default {
  150. components: {
  151. uniIcon,
  152. uniNavBar,
  153. commoNar,
  154. assess,
  155. shopList,
  156. Gobacktop
  157. },
  158. data() {
  159. return {
  160. isTop: 0,
  161. hoteldetail: {},
  162. has_collected: 0, // 收藏酒店
  163. chosegoods_commonid: true,
  164. chosegoods_price: true,
  165. firstwo: 1,
  166. isDetail: 1,
  167. pictureUrl: this.pictureUrl,
  168. showdialog: false,
  169. store_description: '', //酒店信息
  170. store_summary:'', // 标签
  171. store_slide: [], //banner
  172. goods_list:[], // 首页酒店商品列表
  173. isnexttwo: 1,
  174. feedback_list:[], // 评价列表
  175. hotelitle: '', // 酒店名称
  176. istopclick: 0,
  177. page: 1,
  178. goodId: 0,
  179. page_size: 10,
  180. gc_id_1:'',// 一级分类id
  181. gc_id_2:'',// 二级分类id
  182. goods_commonid:'',// 上新排序 desc-降序 asc-尚需
  183. goods_price :'',// 价格排序 desc-降序 asc-尚需
  184. praise :'',// 好评率排序 desc-降序 asc-尚需
  185. keyword:'',//g 关键字搜索
  186. category_list: [{gc_id_1:'',gc_name:'全部'}], // 一级菜单栏
  187. tabIndex: 1,
  188. isprice:0,
  189. menu: [{
  190. name: '综合',
  191. id: '0'
  192. }, {
  193. name: '上新',
  194. id: '1'
  195. }, {
  196. name: '价格',
  197. id: '2'
  198. },
  199. {
  200. name:'分类',
  201. id:'3'
  202. }
  203. ],
  204. classify: [],
  205. background: ['color1', 'color2', 'color3'],
  206. indicatorDots: true,
  207. autoplay: true,
  208. interval: 2000,
  209. duration: 500,
  210. activeindex: 0,
  211. scrollTop: 0,
  212. old: {
  213. scrollTop: 0
  214. },
  215. value1: 0,
  216. iScrolltop: 1
  217. }
  218. },
  219. onShareAppMessage(res) {
  220. uni.showShareMenu({
  221. withShareTicket: true
  222. });
  223. let that = this;
  224. let id = this.goodId; // 商品Id
  225. if (res.from === 'button') {
  226. // 来自页面内分享按钮
  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. this.istopclick = this.chosegoods_commonid?1:2;
  331. this.isprice = 0;
  332. this.goods_price = '';
  333. this.goods_commonid = this.chosegoods_commonid?'asc':'desc';
  334. this.chosegoods_commonid = !this.chosegoods_commonid;
  335. this.getshopdetail(2);
  336. }else if(this.tabIndex == 3){ // 价格
  337. this.chosegoods_commonid = true;
  338. this.istopclick = 0;
  339. this.isprice = this.chosegoods_price?3:4;
  340. this.goods_price = this.chosegoods_price?'desc':'asc';
  341. this.goods_commonid = '';
  342. this.chosegoods_price = !this.chosegoods_price;
  343. this.getshopdetail(2);
  344. }else if(this.tabIndex ==4) { // 分类
  345. this.istopclick = 0;
  346. this.isprice = 0;
  347. this.goods_price = '';
  348. this.goods_commonid = '';
  349. this.chosegoods_price = true;
  350. this.chosegoods_commonid = true;
  351. }
  352. },
  353. // 点击切换上下
  354. changeisclick(e) {
  355. },
  356. godetail(item) {
  357. let id = item.gc_id; // 一级菜单id
  358. let store_id = this.goodId;
  359. let gc_name = item.gc_name;
  360. uni.navigateTo({
  361. url: `/pages/index/hoteldetail?id=${id}&gc_name=${gc_name}&store_id=${store_id}`
  362. });
  363. },
  364. // 获取商品详情
  365. getshopdetail(e) {
  366. this.request({
  367.                 url:"/v2/entry/storeGoods",
  368.                 method:'get',
  369. data: {
  370. store_id: this.goodId,
  371. page: this.page,
  372. goods_commonid: this.goods_commonid, // 上新排序
  373. goods_price: this.goods_price,
  374. gc_id_1: this.gc_id_1
  375. },
  376. success: (res) => {
  377. if(e == 2) {
  378. this.goods_list = [];
  379. }
  380. this.goods_list = this.goods_list.concat(res.data.data.goods_list);
  381. if(res.data.data.goods_list.length < 10) {
  382. this.isDetail = 2;
  383. }
  384. },
  385. })
  386. },
  387. // 一级菜单
  388. hotelmenu() {
  389. let _this = this;
  390. this.request({
  391.                 url:"/v1/entry/storeCategory",
  392.                 method:'get',
  393. data: {
  394. store_id: this.goodId,
  395. },
  396. success: function(res) {
  397. let { category_list } = res.data.data;
  398. category_list.forEach((item,idx) => {
  399. item.text = item.gc_name;
  400. item.value = idx;
  401. })
  402. let array = [{gc_id:'',gc_name:'全部'}];
  403. _this.classify = array.concat(category_list);
  404. _this.category_list = category_list.splice(0,10);
  405. },
  406. })
  407. },
  408. onChange(event) {
  409. this.activeindex = event.detail.name;
  410. this.page = 1;
  411. if(event.detail.name == 1) {
  412. this.getcomment();
  413. }else if(event.detail.name == 0) {
  414. this.getshopdetail()
  415. }
  416. },
  417. // 获取酒店评价
  418. getcomment() {
  419. this.request({
  420. url:'/v1/store/feedbackList',
  421. method: 'POST',
  422. data: {
  423. page: this.page,
  424. page_size: 10,
  425. store_id: this.goodId
  426. },
  427. success: (res) => {
  428. this.feedback_list = res.data.data.feedback_list;
  429. if(res.data.data.feedback_list.length < 10) {
  430. this.isnexttwo = 2;
  431. }
  432. }
  433. })
  434. },
  435. // 获取酒店信息
  436. gethoteil() {
  437. this.request({
  438. url:'/v1/store/info',
  439. method:'get',
  440. data: {
  441. store_id: this.goodId
  442. },
  443. success: (res) => {
  444. let { data } = res.data;
  445. this.hoteldetail = data;
  446. this.hotelitle = data.store_name;
  447. this.store_slide = data.store_slide;
  448. this.store_summary = data.store_summary;
  449. const regex = new RegExp('<img', 'gi');
  450. // class="changeimg"
  451. data.store_description = data.store_description.replace(regex,
  452. `<img style="width: 100%;height: auto;display: block;text-align: center;`);
  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. },
  467. // 滚到底部
  468. lower(e) {
  469. // if(this.activeindex == 1) {
  470. if(this.isnexttwo == 1 && this.activeindex == 1) {
  471. this.page = this.page + 1;
  472. //}
  473. this.getcomment();
  474. // this.activeindex == 0 &&
  475. }else if( this.isDetail == 1) {
  476. this.page = this.page + 1;
  477. this.getshopdetail();
  478. }
  479. },
  480. // 滚动时触发
  481. scroll(e) {
  482. if(e.detail.scrollTop > 400) {
  483. this.isTop = true;
  484. }else{ //当距离小于500时显示回到顶部按钮
  485. this.isTop = false;
  486. }
  487. if(e.detail.scrollTop > 160) {
  488. this.iScrolltop = 2;
  489. }else {
  490. this.iScrolltop = 1;
  491. }
  492. this.old.scrollTop = e.detail.scrollTop
  493. },
  494. // 返回上一页
  495. goback() {
  496. uni.navigateBack()
  497. },
  498. }
  499. }
  500. </script>
  501. <style scoped>
  502. .scrollswiper {
  503. width: 100%;
  504. position: relative;
  505. }
  506. .titleFixed {
  507. position: absolute;
  508. top: 0;
  509. left: 0;
  510. z-index: 99;
  511. padding-top: 0;
  512. }
  513. .van-nav-bar {
  514. padding-top: 0!important;
  515. /* background: #000000!important; */
  516. /* opacity: 0.2; */
  517. background:rgba(0,0,0,0.2)!important;
  518. }
  519. .swiper {
  520. height: 380upx;
  521. }
  522. .swiper-item {
  523. display: block;
  524. height: 100%!important;
  525. line-height: 300upx;
  526. text-align: center;
  527. }
  528. .tip {
  529. display: flex;
  530. justify-content: space-between;
  531. padding: 36upx 32upx;
  532. }
  533. .giveList {
  534. padding: 10upx 12upx;
  535. display: flex;
  536. flex-wrap: wrap;
  537. }
  538. .giveItem {
  539. height: 120rpx;
  540. flex: 1;
  541. width: 16%;
  542. min-width: 16%;
  543. max-width: 16%;
  544. /* margin: 24rpx 0 25rpx 4%; */
  545. margin: 24upx 2%;
  546. }
  547. .active {
  548. color: #F76260;
  549. }
  550. .typeItem {
  551. width: 25%;
  552. display: inline-block;
  553. text-align: center;
  554. }
  555. .iconClass {
  556. display: flex;
  557. flex-direction: row;
  558. align-items: center;
  559. justify-content: center;
  560. }
  561. .hotlItem {
  562. padding: 22upx 30upx;
  563. border-bottom: 1px solid #EEEEEE;
  564. display: flex;
  565. justify-content: space-between;
  566. }
  567. .bottomButton {
  568. width: 95%;
  569. left: 2.5%;
  570. position: fixed;
  571. bottom: 2.5%;
  572. }
  573. .titeTop {
  574. display: flex;
  575. /* justify-content: space-between; */
  576. align-items: center;
  577. position: absolute;
  578. top: 10upx;
  579. width: 100%;
  580. }
  581. .topleft {
  582. }
  583. .topright {
  584. }
  585. .input-view {
  586. width: 85%;
  587. display: flex;
  588. height: 30px;
  589. border-radius: 15px;
  590. padding: 0 4%;
  591. flex-wrap: nowrap;
  592. margin: 7px 0;
  593. line-height: 30px;
  594. margin: 24upx auto;
  595. background:rgba(0,0,0,1);
  596. border-radius:15px;
  597. opacity:0.4;
  598. }
  599. .input-view .uni-icon {
  600. line-height: 30px !important;
  601. }
  602. .input-view .input {
  603. height: 30px;
  604. line-height: 30px;
  605. width: 94%;
  606. padding: 0 3%;
  607. }
  608. .activeColor {
  609. background: #fff!important;
  610. position: fixed;
  611. background-color: #fff;
  612. top: 65upx;
  613. left: 0;
  614. z-index: 99;
  615. }
  616. .listType {
  617. }
  618. .changeimg {
  619. width: 100%;
  620. height: auto!important;
  621. display: block;
  622. text-align: center;
  623. }
  624. </style>