hoteldetail.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  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. console.log(options)
  101. this.title = options.gc_name;
  102. this.gc_id_1 = options.id;
  103. this.store_id = options.store_id;
  104. uni.setNavigationBarTitle({
  105. title: options.gc_name
  106. });
  107. this.getshopdetail();
  108. this.hotelsecondmenu(); // 二级菜单
  109. },
  110. methods: {
  111. getop() {
  112. this.scrollTop = this.old.scrollTop
  113.                 this.$nextTick(function(){
  114.                     this.scrollTop=0;
  115.                 });
  116. this.isTop = false;
  117. },
  118. choseType(e) {
  119. this.page = 1;
  120. this.tabIndex = e;
  121. //this.goods_list = [];
  122. if(this.tabIndex == 1) { // 服务
  123. this.istopclick = 0;
  124. this.isprice = 0;
  125. this.gc_id_2 = '';
  126. this.goods_price = '';
  127. this.goods_commonid = '';
  128. this.getshopdetail(2);
  129. }else if(this.tabIndex == 2){ //伤
  130. this.chosegoods_price = true;
  131. console.log(this.chosegoods_commonid);
  132. this.istopclick = this.chosegoods_commonid?1:2;
  133. this.isprice = 0;
  134. this.goods_price = '';
  135. this.goods_commonid = this.chosegoods_commonid?'asc':'desc';
  136. //this.gc_id_1 = '';
  137. this.chosegoods_commonid = !this.chosegoods_commonid;
  138. this.getshopdetail(2);
  139. }else if(this.tabIndex == 3){ // 价格
  140. this.chosegoods_commonid = true;
  141. console.log(this.chosegoods_price);
  142. this.isprice = this.chosegoods_price?3:4;
  143. this.goods_price = this.chosegoods_price?'desc':'asc';
  144. this.goods_commonid = '';
  145. this.istopclick = 0;
  146. //this.gc_id_1 = '';
  147. this.chosegoods_price = !this.chosegoods_price;
  148. this.getshopdetail(2);
  149. }else if(this.tabIndex ==4) { // 分类
  150. this.istopclick = 0;
  151. this.isprice = 0;
  152. this.goods_price = '';
  153. this.goods_commonid = '';
  154. this.chosegoods_price = true;
  155. this.chosegoods_commonid = true;
  156. console.log(this.goods_list);
  157. }
  158. },
  159. // 点击图标上下筛选切换
  160. changeisclick(e) {
  161. },
  162. confirm(e) {
  163. console.log(e);
  164. this.tabIndex = 0;
  165. this.gc_id_2 = e.gc_id;
  166. this.getshopdetail(2);
  167. },
  168. // 获取商品详情
  169. getshopdetail(e) {
  170. let _this = this;
  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: function(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. console.log(that.category_list)
  210. }
  211. })
  212. },
  213. // 滚动到顶部
  214. upper(e) {
  215. console.log("顶部")
  216. },
  217. // 滚到底部
  218. lower(e) {
  219. if(this.ispill) {
  220. this.page = this.page + 1;
  221. this.getshopdetail();
  222. }
  223. },
  224. // 滚动时触发
  225. scroll(e) {
  226. if(e.detail.scrollTop > 400) {
  227. this.isTop = true;
  228. }else{ //当距离小于500时显示回到顶部按钮
  229. this.isTop = false;
  230. }
  231. this.old.scrollTop = e.detail.scrollTop
  232. }
  233. }
  234. }
  235. </script>
  236. <style>
  237. .active {
  238. color: #F76260;
  239. }
  240. .typeItem {
  241. width: 25%;
  242. display: inline-block;
  243. text-align: center;
  244. }
  245. .iconClass {
  246. display: flex;
  247. flex-direction: row;
  248. align-items: center;
  249. justify-content: center;
  250. }
  251. </style>