hoteldetail.vue 7.6 KB

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