hoteldetail.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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="tabIndex==4 ? 'active' : ''">分类
  40. <img v-if="tabIndex != 4" style="width: 36upx;height: 36upx;" src='../../static/sortb.png' />
  41. <img v-if="tabIndex == 4" style="width: 36upx;height: 36upx;" src='../../static/sortb_up.png' />
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <view style="padding: 10upx 12upx;display: flex;flex-wrap: wrap;" v-if="tabIndex==4">
  47. <view style=" flex: 1;width: 20%;min-width: 20%;max-width: 20%;margin: 24rpx 0 25rpx 4%;"
  48. v-for="(item, index) in category_list" :key="index"
  49. @click.stop="confirm(item)" >
  50. {{item.gc_name}}
  51. </view>
  52. </view>
  53. <scroll-view class="floor-list"
  54. :scroll-top="scrollTop" scroll-y="true" @scroll="scroll" @scrolltoupper="upper" @scrolltolower="lower"
  55. refresher-enabled="true">
  56. <!-- 商品列表 -->
  57. <shopList :productList="goods_list" />
  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. isTop: 0,
  73. isprice: 0,
  74. goods_list:[],
  75. scrollTop: 0,
  76. old: {
  77. scrollTop: 0
  78. },
  79. chosegoods_commonid: true,
  80. chosegoods_price: true,
  81. ispull: false,
  82. istopclick: 0,
  83. tabIndex: 1,
  84. title:'',
  85. store_id:'',
  86. category_list:[],
  87. page: 1,
  88. page_size: 10,
  89. gc_id_1:'',// 一级分类id
  90. gc_id_2:'',// 二级分类id
  91. goods_commonid:'',// 上新排序 desc-降序 asc-尚需
  92. goods_price :'',// 价格排序 desc-降序 asc-尚需
  93. praise :'',// 好评率排序 desc-降序 asc-尚需
  94. }
  95. },
  96. onLoad(options){
  97. this.title = options.gc_name;
  98. this.gc_id_1 = options.id;
  99. this.store_id = options.store_id;
  100. uni.setNavigationBarTitle({
  101. title: options.gc_name
  102. });
  103. this.getshopdetail();
  104. this.hotelsecondmenu(); // 二级菜单
  105. },
  106. methods: {
  107. getop() {
  108. this.scrollTop = this.old.scrollTop
  109.                 this.$nextTick(function(){
  110.                     this.scrollTop=0;
  111.                 });
  112. this.isTop = false;
  113. },
  114. choseType(e) {
  115. this.page = 1;
  116. this.tabIndex = e;
  117. //this.goods_list = [];
  118. if(this.tabIndex == 1) { // 服务
  119. this.istopclick = 0;
  120. this.isprice = 0;
  121. this.gc_id_2 = '';
  122. this.goods_price = '';
  123. this.goods_commonid = '';
  124. this.getshopdetail(2);
  125. }else if(this.tabIndex == 2){ //伤
  126. this.chosegoods_price = true;
  127. this.istopclick = this.chosegoods_commonid?1:2;
  128. this.isprice = 0;
  129. this.goods_price = '';
  130. this.goods_commonid = this.chosegoods_commonid?'asc':'desc';
  131. //this.gc_id_1 = '';
  132. this.chosegoods_commonid = !this.chosegoods_commonid;
  133. this.getshopdetail(2);
  134. }else if(this.tabIndex == 3){ // 价格
  135. this.chosegoods_commonid = true;
  136. this.isprice = this.chosegoods_price?3:4;
  137. this.goods_price = this.chosegoods_price?'desc':'asc';
  138. this.goods_commonid = '';
  139. this.istopclick = 0;
  140. //this.gc_id_1 = '';
  141. this.chosegoods_price = !this.chosegoods_price;
  142. this.getshopdetail(2);
  143. }else if(this.tabIndex ==4) { // 分类
  144. this.istopclick = 0;
  145. this.isprice = 0;
  146. this.goods_price = '';
  147. this.goods_commonid = '';
  148. this.chosegoods_price = true;
  149. this.chosegoods_commonid = true;
  150. }
  151. },
  152. // 点击图标上下筛选切换
  153. changeisclick(e) {
  154. },
  155. confirm(e) {
  156. this.tabIndex = 0;
  157. this.gc_id_2 = e.gc_id;
  158. this.getshopdetail(2);
  159. },
  160. // 获取商品详情
  161. getshopdetail(e) {
  162. let _this = this;
  163. this.request({
  164.                 url:"/v2/entry/storeGoods",
  165.                 method:'get',
  166. data: {
  167. store_id: _this.store_id,
  168. page: _this.page,
  169. goods_commonid: _this.goods_commonid, // 上新排序
  170. goods_price: _this.goods_price,
  171. gc_id_1: _this.gc_id_1,
  172. gc_id_2: _this.gc_id_2
  173. },
  174. success: function(res) {
  175. if(res.data.data.goods_list.length>10) {
  176. _this.ispill = true;
  177. }else {
  178. _this.ispill = false;
  179. }
  180. if(e == 2) {
  181. _this.goods_list = [];
  182. }
  183. _this.goods_list = _this.goods_list.concat(res.data.data.goods_list);
  184. },
  185. })
  186. },
  187. // 二级菜单
  188. hotelsecondmenu(){
  189. let that = this;
  190. this.request({
  191. url:'/v1/entry/storeCategory2',
  192. method:'POST',
  193. data: {
  194. store_id: this.store_id,
  195. gc_id: this.gc_id_1
  196. },
  197. success: function(res) {
  198. let { category_list } = res.data.data;
  199. let array = [{gc_id:'',gc_name:'全部'}];
  200. that.category_list = array.concat(category_list)
  201. }
  202. })
  203. },
  204. // 滚动到顶部
  205. upper(e) {
  206. console.log("顶部")
  207. },
  208. // 滚到底部
  209. lower(e) {
  210. if(this.ispill) {
  211. this.page = this.page + 1;
  212. this.getshopdetail();
  213. }
  214. },
  215. // 滚动时触发
  216. scroll(e) {
  217. if(e.detail.scrollTop > 400) {
  218. this.isTop = true;
  219. }else{ //当距离小于500时显示回到顶部按钮
  220. this.isTop = false;
  221. }
  222. this.old.scrollTop = e.detail.scrollTop
  223. }
  224. }
  225. }
  226. </script>
  227. <style>
  228. .active {
  229. color: #F76260;
  230. }
  231. .typeItem {
  232. width: 25%;
  233. display: inline-block;
  234. text-align: center;
  235. }
  236. .iconClass {
  237. display: flex;
  238. flex-direction: row;
  239. align-items: center;
  240. justify-content: center;
  241. }
  242. </style>