hoteldetail.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. <template>
  2. <view>
  3. <scroll-view style="height: 100vh;" class="floor-list"
  4. :scroll-top="scrollTop" scroll-y="true" @scroll="scroll" @scrolltoupper="upper" @scrolltolower="lower"
  5. refresher-enabled="true">
  6. <view style="padding: 40upx 18upx;">
  7. <view style="width: 95%;margin: 0 auto;">
  8. <view @click="choseType(1)" :class="tabIndex==1 ? 'active' : ''" class="typeItem">
  9. 全部
  10. </view>
  11. <view @click="choseType(2)" class="typeItem">
  12. <view class="iconClass">
  13. <view :class="tabIndex==2 ? 'active' : ''">上新</view>
  14. <view style="display: flex;flex-direction: column;margin-left: 10rpx;">
  15. <view @click.stop="changeisclick(1)"><van-icon size="8px" name="arrow-up" :class="istopclick==1 ? 'active' : ''" /></view>
  16. <view @click.stop="changeisclick(2)">
  17. <van-icon :class="istopclick==2 ? 'active' : ''" size="8px" name="arrow-down" />
  18. </view>
  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 @click.stop="changeisclick(3)" >
  27. <van-icon :class="istopclick==3 ? 'active' : ''" size="8px" name="arrow-up" />
  28. </view>
  29. <view @click.stop="changeisclick(4)">
  30. <van-icon :class="istopclick==4 ? 'active' : ''" size="8px" name="arrow-down" />
  31. </view>
  32. </view>
  33. </view>
  34. </view>
  35. <view @click.stop="choseType(4)" class="typeItem">
  36. <view :class="tabIndex==4 ? 'active' : ''">分类</view>
  37. </view>
  38. </view>
  39. </view>
  40. <view style="padding: 10upx 12upx;display: flex;flex-wrap: wrap;" v-if="tabIndex==4">
  41. <view style=" flex: 1;width: 20%;min-width: 20%;max-width: 20%;margin: 24rpx 0 25rpx 4%;"
  42. v-for="(item, index) in category_list" :key="index"
  43. @click.stop="confirm(item)" >
  44. {{item.gc_name}}
  45. </view>
  46. </view>
  47. <!-- 商品列表 -->
  48. <shopList :productList="goods_list" />
  49. </scroll-view>
  50. </view>
  51. </template>
  52. <script>
  53. import shopList from '@/component/shopList.vue' // 商品列表
  54. export default {
  55. components: {
  56. shopList
  57. },
  58. data() {
  59. return {
  60. goods_list:[],
  61. scrollTop: 0,
  62. old: {
  63. scrollTop: 0
  64. },
  65. chosegoods_commonid: true,
  66. chosegoods_price: true,
  67. ispull: false,
  68. istopclick: 0,
  69. tabIndex: 1,
  70. title:'',
  71. store_id:'',
  72. category_list:[],
  73. page: 1,
  74. page_size: 10,
  75. gc_id_1:'',// 一级分类id
  76. gc_id_2:'',// 二级分类id
  77. goods_commonid:'',// 上新排序 desc-降序 asc-尚需
  78. goods_price :'',// 价格排序 desc-降序 asc-尚需
  79. praise :'',// 好评率排序 desc-降序 asc-尚需
  80. }
  81. },
  82. onLoad(options){
  83. console.log(options)
  84. this.title = options.gc_name;
  85. this.gc_id_1 = options.id;
  86. this.store_id = options.store_id;
  87. uni.setNavigationBarTitle({
  88. title: options.gc_name
  89. });
  90. this.getshopdetail();
  91. this.hotelsecondmenu(); // 二级菜单
  92. },
  93. methods: {
  94. choseType(e) {
  95. this.page = 1;
  96. this.tabIndex = e;
  97. this.goods_list = [];
  98. if(this.tabIndex == 1) { // 服务
  99. this.istopclick = 0;
  100. this.gc_id_1 = '';
  101. this.goods_price = '';
  102. this.goods_commonid = '';
  103. }else if(this.tabIndex == 2){ //伤
  104. this.chosegoods_price = true;
  105. console.log(this.chosegoods_commonid);
  106. this.istopclick = this.chosegoods_commonid?1:2;
  107. this.goods_price = '';
  108. this.goods_commonid = this.chosegoods_commonid?'asc':'desc';
  109. this.gc_id_1 = '';
  110. this.chosegoods_commonid = !this.chosegoods_commonid;
  111. }else if(this.tabIndex == 3){ // 价格
  112. this.chosegoods_commonid = true;
  113. console.log(this.chosegoods_price);
  114. this.istopclick = this.chosegoods_price?3:4;
  115. this.goods_price = this.chosegoods_price?'desc':'asc';
  116. this.goods_commonid = '';
  117. this.gc_id_1 = '';
  118. this.chosegoods_price = !this.chosegoods_price;
  119. }else if(this.tabIndex ==4) { // 分类
  120. this.istopclick = 0;
  121. this.goods_price = '';
  122. this.goods_commonid = '';
  123. this.chosegoods_price = true;
  124. this.chosegoods_commonid = true;
  125. }
  126. this.getshopdetail();
  127. },
  128. // 点击图标上下筛选切换
  129. changeisclick(e) {
  130. },
  131. confirm(e) {
  132. console.log(e);
  133. this.tabIndex = 0;
  134. console.log(this.tabIndex);
  135. this.gc_id_2 = e.gc_id;
  136. this.getshopdetail();
  137. },
  138. // 获取商品详情
  139. getshopdetail() {
  140. let _this = this;
  141. this.request({
  142.                 url:"/v2/entry/storeGoods",
  143.                 method:'get',
  144. data: {
  145. store_id: _this.store_id,
  146. page: _this.page,
  147. goods_commonid: _this.goods_commonid, // 上新排序
  148. goods_price: _this.goods_price,
  149. gc_id_1: _this.gc_id_1,
  150. gc_id_2: _this.gc_id_2
  151. },
  152. success: function(res) {
  153. if(res.data.data.goods_list.length>10) {
  154. _this.ispill = true;
  155. }else {
  156. _this.ispill = false;
  157. }
  158. _this.goods_list = res.data.data.goods_list;
  159. },
  160. })
  161. },
  162. // 二级菜单
  163. hotelsecondmenu(){
  164. let that = this;
  165. this.request({
  166. url:'/v1/entry/storeCategory2',
  167. method:'POST',
  168. data: {
  169. store_id: this.store_id,
  170. gc_id: this.gc_id_1
  171. },
  172. success: function(res) {
  173. let { category_list } = res.data.data;
  174. that.category_list = category_list;
  175. }
  176. })
  177. },
  178. // 滚动到顶部
  179. upper(e) {
  180. console.log("顶部")
  181. },
  182. // 滚到底部
  183. lower(e) {
  184. if(this.ispull) {
  185. this.page = this.page + 1;
  186. this.gethotelist();
  187. }
  188. },
  189. // 滚动时触发
  190. scroll(e) {
  191. this.old.scrollTop = e.detail.scrollTop
  192. }
  193. }
  194. }
  195. </script>
  196. <style>
  197. .active {
  198. color: #F76260;
  199. }
  200. .typeItem {
  201. width: 25%;
  202. display: inline-block;
  203. text-align: center;
  204. }
  205. .iconClass {
  206. display: flex;
  207. flex-direction: row;
  208. align-items: center;
  209. justify-content: space-around;
  210. }
  211. </style>