hoteldetail.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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 class="floor-list"
  61. :scroll-top="scrollTop" scroll-y="true" @scroll="scroll" @scrolltoupper="upper" @scrolltolower="lower"
  62. refresher-enabled="true">
  63. <!-- 商品列表 -->
  64. <shopList :goodId="store_id" :productList="goods_list" />
  65. </scroll-view>
  66. <Gobacktop @getop="getop" v-if="isTop" />
  67. </view>
  68. </template>
  69. <script>
  70. import shopList from '@/component/shopList.vue' // 商品列表
  71. import Gobacktop from '@/component/Gobacktop.vue'
  72. export default {
  73. components: {
  74. shopList,
  75. Gobacktop
  76. },
  77. data() {
  78. return {
  79. ishowpull: false,
  80. isTop: 0,
  81. isprice: 0,
  82. goods_list:[],
  83. scrollTop: 0,
  84. old: {
  85. scrollTop: 0
  86. },
  87. chosegoods_commonid: true,
  88. chosegoods_price: true,
  89. ispull: false,
  90. istopclick: 0,
  91. tabIndex: 1,
  92. title:'',
  93. store_id:'',
  94. category_list:[],
  95. page: 1,
  96. page_size: 10,
  97. gc_id_1:'',// 一级分类id
  98. gc_id_2:'',// 二级分类id
  99. goods_commonid:'',// 上新排序 desc-降序 asc-尚需
  100. goods_price :'',// 价格排序 desc-降序 asc-尚需
  101. praise :'',// 好评率排序 desc-降序 asc-尚需
  102. }
  103. },
  104. onLoad(options){
  105. this.title = options.gc_name;
  106. this.gc_id_1 = options.id;
  107. this.store_id = options.store_id;
  108. uni.setNavigationBarTitle({
  109. title: options.gc_name
  110. });
  111. this.getshopdetail();
  112. this.hotelsecondmenu(); // 二级菜单
  113. },
  114. methods: {
  115. getop() {
  116. this.scrollTop = this.old.scrollTop
  117.                 this.$nextTick(function(){
  118.                     this.scrollTop=0;
  119.                 });
  120. this.isTop = false;
  121. },
  122. choseType(e) {
  123. this.page = 1;
  124. this.tabIndex = e;
  125. //this.goods_list = [];
  126. if(this.tabIndex == 1) { // 服务
  127. this.istopclick = 0;
  128. this.isprice = 0;
  129. this.gc_id_2 = '';
  130. this.goods_price = '';
  131. this.goods_commonid = '';
  132. this.getshopdetail(2);
  133. }else if(this.tabIndex == 2){ //伤
  134. this.chosegoods_price = true;
  135. this.istopclick = this.chosegoods_commonid?1:2;
  136. this.isprice = 0;
  137. this.goods_price = '';
  138. this.goods_commonid = this.chosegoods_commonid?'asc':'desc';
  139. //this.gc_id_1 = '';
  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.gc_id_1 = '';
  149. this.chosegoods_price = !this.chosegoods_price;
  150. this.getshopdetail(2);
  151. }else if(this.tabIndex ==4) { // 分类
  152. this.istopclick = 0;
  153. this.isprice = 0;
  154. this.goods_price = '';
  155. this.goods_commonid = '';
  156. this.chosegoods_price = true;
  157. this.chosegoods_commonid = true;
  158. this.ishowpull = !this.ishowpull;
  159. }
  160. },
  161. // 点击图标上下筛选切换
  162. changeisclick(e) {
  163. },
  164. confirm(e) {
  165. this.tabIndex = 0;
  166. this.gc_id_2 = e.gc_id;
  167. this.ishowpull = false;
  168. this.getshopdetail(2);
  169. },
  170. // 获取商品详情
  171. getshopdetail(e) {
  172. let _this = this;
  173. this.request({
  174.                 url:"/v2/entry/storeGoods",
  175.                 method:'get',
  176. data: {
  177. store_id: _this.store_id,
  178. page: _this.page,
  179. goods_commonid: _this.goods_commonid, // 上新排序
  180. goods_price: _this.goods_price,
  181. gc_id_1: _this.gc_id_1,
  182. gc_id_2: _this.gc_id_2
  183. },
  184. success: function(res) {
  185. if(res.data.data.goods_list.length>10) {
  186. _this.ispill = true;
  187. }else {
  188. _this.ispill = false;
  189. }
  190. if(e == 2) {
  191. _this.goods_list = [];
  192. }
  193. _this.goods_list = _this.goods_list.concat(res.data.data.goods_list);
  194. },
  195. })
  196. },
  197. // 二级菜单
  198. hotelsecondmenu(){
  199. let that = this;
  200. this.request({
  201. url:'/v1/entry/storeCategory2',
  202. method:'POST',
  203. data: {
  204. store_id: this.store_id,
  205. gc_id: this.gc_id_1
  206. },
  207. success: function(res) {
  208. let { category_list } = res.data.data;
  209. let array = [{gc_id:'',gc_name:'全部'}];
  210. that.category_list = array.concat(category_list)
  211. }
  212. })
  213. },
  214. // 滚动到顶部
  215. upper(e) {
  216. console.log("顶部")
  217. },
  218. // 滚到底部
  219. lower(e) {
  220. if(this.ispill) {
  221. this.page = this.page + 1;
  222. this.getshopdetail();
  223. }
  224. },
  225. // 滚动时触发
  226. scroll(e) {
  227. if(e.detail.scrollTop > 400) {
  228. this.isTop = true;
  229. }else{ //当距离小于500时显示回到顶部按钮
  230. this.isTop = false;
  231. }
  232. this.old.scrollTop = e.detail.scrollTop
  233. }
  234. }
  235. }
  236. </script>
  237. <style>
  238. .active {
  239. color: #F76260;
  240. }
  241. .typeItem {
  242. width: 25%;
  243. display: inline-block;
  244. text-align: center;
  245. }
  246. .iconClass {
  247. display: flex;
  248. flex-direction: row;
  249. align-items: center;
  250. justify-content: center;
  251. }
  252. .spacedance {
  253. border:1px solid #666;
  254. flex: 1;width: 20%;
  255. text-align: center;
  256. min-width: 20%;
  257. max-width: 20%;
  258. margin: 6rpx 0 25rpx 4%;
  259. padding:4upx 0;
  260. }
  261. </style>