hoteldetail.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. <!-- <van-icon size="8px" name="arrow-up" :class="istopclick==1 ? 'active' : ''" /> -->
  13. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort.png' />
  14. </view>
  15. <view v-if="istopclick==1">
  16. <!-- <van-icon size="8px" name="arrow-up" :class="istopclick==1 ? 'active' : ''" /> -->
  17. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_down.png' />
  18. </view>
  19. <view v-if="istopclick==2">
  20. <!-- <van-icon :class="istopclick==2 ? 'active' : ''" size="8px" name="arrow-down" /> -->
  21. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_up.png' />
  22. </view>
  23. </view>
  24. </view>
  25. <view @click="choseType(3)" class="typeItem">
  26. <view class="iconClass">
  27. <view :class="tabIndex==3 ? 'active' : ''">价格</view>
  28. <view style="display: flex;flex-direction: column;margin-left: 10rpx;">
  29. <view v-if="isprice==0">
  30. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort.png' />
  31. </view>
  32. <view v-if="isprice==3">
  33. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_down.png' />
  34. </view>
  35. <view v-if="isprice==4">
  36. <img style="width: 36upx;height: 36upx;vertical-align: middle;" src='../../static/sort_up.png' />
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <view @click.stop="choseType(4)" class="typeItem">
  42. <view :class="tabIndex==4 ? 'active' : ''">分类
  43. <img v-if="tabIndex != 4" style="width: 36upx;height: 36upx;" src='../../static/sortb.png' />
  44. <img v-if="tabIndex == 4" style="width: 36upx;height: 36upx;" src='../../static/sortb_up.png' />
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view style="padding: 10upx 12upx;display: flex;flex-wrap: wrap;" v-if="tabIndex==4">
  50. <view style=" flex: 1;width: 20%;min-width: 20%;max-width: 20%;margin: 24rpx 0 25rpx 4%;"
  51. v-for="(item, index) in category_list" :key="index"
  52. @click.stop="confirm(item)" >
  53. {{item.gc_name}}
  54. </view>
  55. </view>
  56. <scroll-view class="floor-list"
  57. :scroll-top="scrollTop" scroll-y="true" @scroll="scroll" @scrolltoupper="upper" @scrolltolower="lower"
  58. refresher-enabled="true">
  59. <!-- 商品列表 -->
  60. <shopList :productList="goods_list" />
  61. </scroll-view>
  62. <Gobacktop @getop="getop" v-if="isTop" />
  63. </view>
  64. </template>
  65. <script>
  66. import shopList from '@/component/shopList.vue' // 商品列表
  67. import Gobacktop from '@/component/Gobacktop.vue'
  68. export default {
  69. components: {
  70. shopList,
  71. Gobacktop
  72. },
  73. data() {
  74. return {
  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. ispull: false,
  85. istopclick: 0,
  86. tabIndex: 1,
  87. title:'',
  88. store_id:'',
  89. category_list:[],
  90. page: 1,
  91. page_size: 10,
  92. gc_id_1:'',// 一级分类id
  93. gc_id_2:'',// 二级分类id
  94. goods_commonid:'',// 上新排序 desc-降序 asc-尚需
  95. goods_price :'',// 价格排序 desc-降序 asc-尚需
  96. praise :'',// 好评率排序 desc-降序 asc-尚需
  97. }
  98. },
  99. onLoad(options){
  100. this.title = options.gc_name;
  101. this.gc_id_1 = options.id;
  102. this.store_id = options.store_id;
  103. uni.setNavigationBarTitle({
  104. title: options.gc_name
  105. });
  106. this.getshopdetail();
  107. this.hotelsecondmenu(); // 二级菜单
  108. },
  109. methods: {
  110. getop() {
  111. this.scrollTop = this.old.scrollTop
  112.                 this.$nextTick(function(){
  113.                     this.scrollTop=0;
  114.                 });
  115. this.isTop = false;
  116. },
  117. choseType(e) {
  118. this.page = 1;
  119. this.tabIndex = e;
  120. //this.goods_list = [];
  121. if(this.tabIndex == 1) { // 服务
  122. this.istopclick = 0;
  123. this.isprice = 0;
  124. this.gc_id_2 = '';
  125. this.goods_price = '';
  126. this.goods_commonid = '';
  127. this.getshopdetail(2);
  128. }else if(this.tabIndex == 2){ //伤
  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.gc_id_1 = '';
  135. this.chosegoods_commonid = !this.chosegoods_commonid;
  136. this.getshopdetail(2);
  137. }else if(this.tabIndex == 3){ // 价格
  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.gc_id_1 = '';
  144. this.chosegoods_price = !this.chosegoods_price;
  145. this.getshopdetail(2);
  146. }else if(this.tabIndex ==4) { // 分类
  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. }
  154. },
  155. // 点击图标上下筛选切换
  156. changeisclick(e) {
  157. },
  158. confirm(e) {
  159. this.tabIndex = 0;
  160. this.gc_id_2 = e.gc_id;
  161. this.getshopdetail(2);
  162. },
  163. // 获取商品详情
  164. getshopdetail(e) {
  165. let _this = this;
  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: function(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. console.log("顶部")
  210. },
  211. // 滚到底部
  212. lower(e) {
  213. if(this.ispill) {
  214. this.page = this.page + 1;
  215. this.getshopdetail();
  216. }
  217. },
  218. // 滚动时触发
  219. scroll(e) {
  220. if(e.detail.scrollTop > 400) {
  221. this.isTop = true;
  222. }else{ //当距离小于500时显示回到顶部按钮
  223. this.isTop = false;
  224. }
  225. this.old.scrollTop = e.detail.scrollTop
  226. }
  227. }
  228. }
  229. </script>
  230. <style>
  231. .active {
  232. color: #F76260;
  233. }
  234. .typeItem {
  235. width: 25%;
  236. display: inline-block;
  237. text-align: center;
  238. }
  239. .iconClass {
  240. display: flex;
  241. flex-direction: row;
  242. align-items: center;
  243. justify-content: center;
  244. }
  245. </style>