hoteldetail.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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="padding: 10upx 12upx;display: flex;flex-wrap: wrap;" v-if="ishowpull">
  47. <view class="spacedance"
  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. ishowpull: false,
  73. isTop: 0,
  74. isprice: 0,
  75. goods_list:[],
  76. scrollTop: 0,
  77. old: {
  78. scrollTop: 0
  79. },
  80. chosegoods_commonid: true,
  81. chosegoods_price: true,
  82. ispull: false,
  83. istopclick: 0,
  84. tabIndex: 1,
  85. title:'',
  86. store_id:'',
  87. category_list:[],
  88. page: 1,
  89. page_size: 10,
  90. gc_id_1:'',// 一级分类id
  91. gc_id_2:'',// 二级分类id
  92. goods_commonid:'',// 上新排序 desc-降序 asc-尚需
  93. goods_price :'',// 价格排序 desc-降序 asc-尚需
  94. praise :'',// 好评率排序 desc-降序 asc-尚需
  95. }
  96. },
  97. onLoad(options){
  98. this.title = options.gc_name;
  99. this.gc_id_1 = options.id;
  100. this.store_id = options.store_id;
  101. uni.setNavigationBarTitle({
  102. title: options.gc_name
  103. });
  104. this.getshopdetail();
  105. this.hotelsecondmenu(); // 二级菜单
  106. },
  107. methods: {
  108. getop() {
  109. this.scrollTop = this.old.scrollTop
  110.                 this.$nextTick(function(){
  111.                     this.scrollTop=0;
  112.                 });
  113. this.isTop = false;
  114. },
  115. choseType(e) {
  116. this.page = 1;
  117. this.tabIndex = e;
  118. //this.goods_list = [];
  119. if(this.tabIndex == 1) { // 服务
  120. this.istopclick = 0;
  121. this.isprice = 0;
  122. this.gc_id_2 = '';
  123. this.goods_price = '';
  124. this.goods_commonid = '';
  125. this.getshopdetail(2);
  126. }else if(this.tabIndex == 2){ //伤
  127. this.chosegoods_price = true;
  128. this.istopclick = this.chosegoods_commonid?1:2;
  129. this.isprice = 0;
  130. this.goods_price = '';
  131. this.goods_commonid = this.chosegoods_commonid?'asc':'desc';
  132. //this.gc_id_1 = '';
  133. this.chosegoods_commonid = !this.chosegoods_commonid;
  134. this.getshopdetail(2);
  135. }else if(this.tabIndex == 3){ // 价格
  136. this.chosegoods_commonid = true;
  137. this.isprice = this.chosegoods_price?3:4;
  138. this.goods_price = this.chosegoods_price?'desc':'asc';
  139. this.goods_commonid = '';
  140. this.istopclick = 0;
  141. //this.gc_id_1 = '';
  142. this.chosegoods_price = !this.chosegoods_price;
  143. this.getshopdetail(2);
  144. }else if(this.tabIndex ==4) { // 分类
  145. this.istopclick = 0;
  146. this.isprice = 0;
  147. this.goods_price = '';
  148. this.goods_commonid = '';
  149. this.chosegoods_price = true;
  150. this.chosegoods_commonid = true;
  151. this.ishowpull = !this.ishowpull;
  152. }
  153. },
  154. // 点击图标上下筛选切换
  155. changeisclick(e) {
  156. },
  157. confirm(e) {
  158. this.tabIndex = 0;
  159. this.gc_id_2 = e.gc_id;
  160. this.ishowpull = false;
  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. .spacedance {
  246. border:1px solid #666;
  247. flex: 1;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. </style>