hoteldetail.vue 7.1 KB

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