hoteldetail.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. <template>
  2. <view>
  3. <view style='width: 100%;height: 70upx;'>
  4. <view style="width: 95%;margin: 0 auto;height: 80upx;position: fixed;top:0;width: 100%;background-color: #fff;z-index:99;">
  5. <view @click="choseType(1)" :class="tabIndex==1 ? 'active' : ''" class="typeItem">
  6. 综合
  7. </view>
  8. <view @click="choseType(2)" class="typeItem">
  9. <view class="iconClass">
  10. <view :class="tabIndex==2 ? 'active' : ''">上新</view>
  11. <view v-if="istopclick==0">
  12. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort.png' />
  13. </view>
  14. <view v-if="istopclick==1">
  15. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_down.png' />
  16. </view>
  17. <view v-if="istopclick==2">
  18. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_up.png' />
  19. </view>
  20. </view>
  21. </view>
  22. <view @click="choseType(3)" class="typeItem">
  23. <view class="iconClass">
  24. <view :class="tabIndex==3 ? 'active' : ''">价格</view>
  25. <view style="display: flex;flex-direction: column;margin-left: 10rpx;">
  26. <view v-if="isprice==0">
  27. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort.png' />
  28. </view>
  29. <view v-if="isprice==3">
  30. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_down.png' />
  31. </view>
  32. <view v-if="isprice==4">
  33. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_up.png' />
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. <view @click.stop="choseType(4)" class="typeItem">
  39. <view :class="ishowpull ? 'active' : ''">分类
  40. <img v-if="!ishowpull" style="width: 36upx;height: 36upx;" src='../../static/sortb.png' />
  41. <img v-if="ishowpull" style="width: 36upx;height: 36upx;" src='../../static/sortb_up.png' />
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view style="clear: both;
  47. overflow: hidden;
  48. position: fixed;
  49. z-index: 99;
  50. background: #fff;">
  51. <view style="padding: 10upx 12upx;display: flex;flex-wrap: wrap;" v-if="ishowpull">
  52. <view class="spacedance"
  53. v-for="(item, index) in category_list" :key="index"
  54. @click.stop="confirm(item)" >
  55. {{item.gc_name}}
  56. </view>
  57. </view>
  58. </view>
  59. <scroll-view class="floor-list"
  60. :scroll-top="scrollTop" scroll-y="true" @scroll="scroll" @scrolltoupper="upper" @scrolltolower="lower"
  61. refresher-enabled="true">
  62. <!-- 商品列表 -->
  63. <shopList :productList="goods_list" />
  64. </scroll-view>
  65. <Gobacktop @getop="getop" v-if="isTop" />
  66. </view>
  67. </template>
  68. <script>
  69. import shopList from '@/component/shopList.vue' // 商品列表
  70. import Gobacktop from '@/component/Gobacktop.vue'
  71. export default {
  72. components: {
  73. shopList,
  74. Gobacktop
  75. },
  76. data() {
  77. return {
  78. ishowpull: false,
  79. isTop: 0,
  80. isprice: 0,
  81. goods_list:[],
  82. scrollTop: 0,
  83. old: {
  84. scrollTop: 0
  85. },
  86. chosegoods_commonid: true,
  87. chosegoods_price: true,
  88. ispull: false,
  89. istopclick: 0,
  90. tabIndex: 1,
  91. title:'',
  92. store_id:'',
  93. category_list:[],
  94. page: 1,
  95. page_size: 10,
  96. gc_id_1:'',// 一级分类id
  97. gc_id_2:'',// 二级分类id
  98. goods_commonid:'',// 上新排序 desc-降序 asc-尚需
  99. goods_price :'',// 价格排序 desc-降序 asc-尚需
  100. praise :'',// 好评率排序 desc-降序 asc-尚需
  101. }
  102. },
  103. onLoad(options){
  104. this.title = options.gc_name;
  105. this.gc_id_1 = options.id;
  106. this.store_id = options.store_id;
  107. uni.setNavigationBarTitle({
  108. title: options.gc_name
  109. });
  110. this.getshopdetail();
  111. this.hotelsecondmenu(); // 二级菜单
  112. },
  113. methods: {
  114. getop() {
  115. this.scrollTop = this.old.scrollTop
  116.                 this.$nextTick(function(){
  117.                     this.scrollTop=0;
  118.                 });
  119. this.isTop = false;
  120. },
  121. choseType(e) {
  122. this.page = 1;
  123. this.tabIndex = e;
  124. //this.goods_list = [];
  125. if(this.tabIndex == 1) { // 服务
  126. this.istopclick = 0;
  127. this.isprice = 0;
  128. this.gc_id_2 = '';
  129. this.goods_price = '';
  130. this.goods_commonid = '';
  131. this.getshopdetail(2);
  132. }else if(this.tabIndex == 2){ //伤
  133. this.chosegoods_price = true;
  134. this.istopclick = this.chosegoods_commonid?1:2;
  135. this.isprice = 0;
  136. this.goods_price = '';
  137. this.goods_commonid = this.chosegoods_commonid?'asc':'desc';
  138. //this.gc_id_1 = '';
  139. this.chosegoods_commonid = !this.chosegoods_commonid;
  140. this.getshopdetail(2);
  141. }else if(this.tabIndex == 3){ // 价格
  142. this.chosegoods_commonid = true;
  143. this.isprice = this.chosegoods_price?3:4;
  144. this.goods_price = this.chosegoods_price?'desc':'asc';
  145. this.goods_commonid = '';
  146. this.istopclick = 0;
  147. //this.gc_id_1 = '';
  148. this.chosegoods_price = !this.chosegoods_price;
  149. this.getshopdetail(2);
  150. }else if(this.tabIndex ==4) { // 分类
  151. this.istopclick = 0;
  152. this.isprice = 0;
  153. this.goods_price = '';
  154. this.goods_commonid = '';
  155. this.chosegoods_price = true;
  156. this.chosegoods_commonid = true;
  157. this.ishowpull = !this.ishowpull;
  158. }
  159. },
  160. // 点击图标上下筛选切换
  161. changeisclick(e) {
  162. },
  163. confirm(e) {
  164. this.tabIndex = 0;
  165. this.gc_id_2 = e.gc_id;
  166. this.ishowpull = false;
  167. this.getshopdetail(2);
  168. },
  169. // 获取商品详情
  170. getshopdetail(e) {
  171. let _this = this;
  172. this.request({
  173.                 url:"/v2/entry/storeGoods",
  174.                 method:'get',
  175. data: {
  176. store_id: _this.store_id,
  177. page: _this.page,
  178. goods_commonid: _this.goods_commonid, // 上新排序
  179. goods_price: _this.goods_price,
  180. gc_id_1: _this.gc_id_1,
  181. gc_id_2: _this.gc_id_2
  182. },
  183. success: function(res) {
  184. if(res.data.data.goods_list.length>10) {
  185. _this.ispill = true;
  186. }else {
  187. _this.ispill = false;
  188. }
  189. if(e == 2) {
  190. _this.goods_list = [];
  191. }
  192. _this.goods_list = _this.goods_list.concat(res.data.data.goods_list);
  193. },
  194. })
  195. },
  196. // 二级菜单
  197. hotelsecondmenu(){
  198. let that = this;
  199. this.request({
  200. url:'/v1/entry/storeCategory2',
  201. method:'POST',
  202. data: {
  203. store_id: this.store_id,
  204. gc_id: this.gc_id_1
  205. },
  206. success: function(res) {
  207. let { category_list } = res.data.data;
  208. let array = [{gc_id:'',gc_name:'全部'}];
  209. that.category_list = array.concat(category_list)
  210. }
  211. })
  212. },
  213. // 滚动到顶部
  214. upper(e) {
  215. console.log("顶部")
  216. },
  217. // 滚到底部
  218. lower(e) {
  219. if(this.ispill) {
  220. this.page = this.page + 1;
  221. this.getshopdetail();
  222. }
  223. },
  224. // 滚动时触发
  225. scroll(e) {
  226. if(e.detail.scrollTop > 400) {
  227. this.isTop = true;
  228. }else{ //当距离小于500时显示回到顶部按钮
  229. this.isTop = false;
  230. }
  231. this.old.scrollTop = e.detail.scrollTop
  232. }
  233. }
  234. }
  235. </script>
  236. <style>
  237. .active {
  238. color: #F76260;
  239. }
  240. .typeItem {
  241. width: 25%;
  242. display: inline-block;
  243. text-align: center;
  244. }
  245. .iconClass {
  246. display: flex;
  247. flex-direction: row;
  248. align-items: center;
  249. justify-content: center;
  250. }
  251. .spacedance {
  252. border:1px solid #666;
  253. flex: 1;width: 20%;
  254. text-align: center;
  255. min-width: 20%;
  256. max-width: 20%;
  257. margin: 6rpx 0 25rpx 4%;
  258. padding:4upx 0;
  259. }
  260. </style>