hoteldetail.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  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;">
  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;">
  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="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. ispull: false,
  66. istopclick: 0,
  67. tabIndex: 1,
  68. title:'',
  69. store_id:'',
  70. category_list:[],
  71. page: 1,
  72. page_size: 10,
  73. gc_id_1:'',// 一级分类id
  74. gc_id_2:'',// 二级分类id
  75. goods_commonid:'',// 上新排序 desc-降序 asc-尚需
  76. goods_price :'',// 价格排序 desc-降序 asc-尚需
  77. praise :'',// 好评率排序 desc-降序 asc-尚需
  78. }
  79. },
  80. onLoad(options){
  81. console.log(options)
  82. this.title = options.gc_name;
  83. this.gc_id_1 = options.id;
  84. this.store_id = options.store_id;
  85. uni.setNavigationBarTitle({
  86. title: options.gc_name
  87. });
  88. this.getshopdetail();
  89. this.hotelsecondmenu(); // 二级菜单
  90. },
  91. methods: {
  92. choseType(e) {
  93. this.tabIndex = e;
  94. if(this.tabIndex == 1) {
  95. this.istopclick = 0;
  96. this.goods_price = '';
  97. this.goods_commonid = '';
  98. }else if(this.tabIndex == 2){
  99. this.istopclick = 1;
  100. this.goods_commonid = 'asc';
  101. this.goods_price = '';
  102. this.gc_id_2 = '';
  103. }else if(this.tabIndex == 3){
  104. this.istopclick = 3;
  105. this.goods_price = 'asc';
  106. this.goods_commonid = '';
  107. this.gc_id_2 = '';
  108. }else if(this.tabIndex ==4) {
  109. this.istopclick = 0;
  110. this.goods_price = '';
  111. this.goods_commonid = '';
  112. }
  113. this.getshopdetail();
  114. },
  115. changeisclick(e) {
  116. this.istopclick = e;
  117. this.gc_id_2 = '';
  118. if(e == 2) {
  119. this.goods_commonid = 'desc';
  120. this.goods_price = ''
  121. this.tabIndex = 2;
  122. }else if(e == 4) {
  123. this.goods_price = 'desc';
  124. this.goods_commonid = '';
  125. this.tabIndex = 3;
  126. }else if(e == 1) {
  127. this.tabIndex = 2;
  128. this.goods_commonid = 'asc';
  129. this.goods_price = ''
  130. }else if(e == 3) {
  131. this.tabIndex = 3;
  132. this.goods_commonid = '';
  133. this.goods_price = 'asc';
  134. }
  135. this.getshopdetail();
  136. },
  137. confirm(e) {
  138. console.log(e);
  139. this.tabIndex = 0;
  140. console.log(this.tabIndex);
  141. this.gc_id_2 = e.gc_id;
  142. this.getshopdetail();
  143. },
  144. // 获取商品详情
  145. getshopdetail() {
  146. let _this = this;
  147. this.request({
  148.                 url:"/v2/entry/storeGoods",
  149.                 method:'get',
  150. data: {
  151. store_id: _this.store_id,
  152. page: _this.page,
  153. goods_commonid: _this.goods_commonid, // 上新排序
  154. goods_price: _this.goods_price,
  155. gc_id_1: _this.gc_id_1,
  156. gc_id_2: _this.gc_id_2
  157. },
  158. success: function(res) {
  159. if(res.data.data.goods_list.length>10) {
  160. _this.ispill = true;
  161. }else {
  162. _this.ispill = false;
  163. }
  164. _this.goods_list = res.data.data.goods_list;
  165. },
  166. })
  167. },
  168. // 二级菜单
  169. hotelsecondmenu(){
  170. let that = this;
  171. this.request({
  172. url:'/v1/entry/storeCategory2',
  173. method:'POST',
  174. data: {
  175. store_id: this.store_id,
  176. gc_id: this.gc_id_1
  177. },
  178. success: function(res) {
  179. let { category_list } = res.data.data;
  180. that.category_list = category_list;
  181. }
  182. })
  183. },
  184. // 滚动到顶部
  185. upper(e) {
  186. console.log("顶部")
  187. },
  188. // 滚到底部
  189. lower(e) {
  190. if(this.ispull) {
  191. this.page = this.page + 1;
  192. this.gethotelist();
  193. }
  194. },
  195. // 滚动时触发
  196. scroll(e) {
  197. this.old.scrollTop = e.detail.scrollTop
  198. }
  199. }
  200. }
  201. </script>
  202. <style>
  203. .active {
  204. color: #F76260;
  205. }
  206. .typeItem {
  207. width: 25%;
  208. display: inline-block;
  209. text-align: center;
  210. }
  211. .iconClass {
  212. display: flex;
  213. flex-direction: row;
  214. align-items: center;
  215. justify-content: space-around;
  216. }
  217. </style>