hotelsearch.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. <template>
  2. <view class="searchType" style="background: #fff">
  3. <view class="flex-box flex-v-ce tops">
  4. <view class="input-view flex-1">
  5. <uni-icon type="search" size="22" color="#666666" />
  6. <input confirm-type="search" class="input" type="text" placeholder="输入搜索关键词" @input="confirm" @confirm="confirm" />
  7. </view>
  8. <view @click="search" class="search">取消</view>
  9. </view>
  10. <view class="sx">
  11. <view style="width: 95%;margin: 0 auto;">
  12. <view @click="choseType(1)" :class="tabIndex == 1 ? 'active' : ''" class="typeItem">综合</view>
  13. <view @click="choseType(2)" class="typeItem">
  14. <view class="iconClass">
  15. <view :class="tabIndex == 2 ? 'active' : ''">上新</view>
  16. <view v-if="istopclick == 0"><img style="width: 36upx;height: 36upx;vertical-align: middle;" src="../../static/sort.png" /></view>
  17. <view v-if="istopclick == 1"><img style="width: 36upx;height: 36upx;vertical-align: middle;" src="../../static/sort_down.png" /></view>
  18. <view v-if="istopclick == 2"><img style="width: 36upx;height: 36upx;vertical-align: middle;" src="../../static/sort_up.png" /></view>
  19. </view>
  20. </view>
  21. <view @click="choseType(3)" class="typeItem">
  22. <view class="iconClass">
  23. <view :class="tabIndex == 3 ? 'active' : ''">价格</view>
  24. <view style="display: flex;flex-direction: column;margin-left: 10rpx;">
  25. <view v-if="isprice == 0"><img style="width: 36upx;height: 36upx;vertical-align: middle;" src="../../static/sort.png" /></view>
  26. <view v-if="isprice == 3"><img style="width: 36upx;height: 36upx;vertical-align: middle;" src="../../static/sort_down.png" /></view>
  27. <view v-if="isprice == 4"><img style="width: 36upx;height: 36upx;vertical-align: middle;" src="../../static/sort_up.png" /></view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. <scroll-view
  34. style="height:calc(100vh - 172upx);"
  35. class="floor-list"
  36. :scroll-top="scrollTop"
  37. scroll-y="true"
  38. @scroll="scroll"
  39. @scrolltoupper="upper"
  40. @scrolltolower="lower"
  41. :refresher-enabled="false"
  42. >
  43. <!-- 商品列表 -->
  44. <shopList :goodId="store_id" :productList="goods_list" />
  45. <view v-if="goods_list.length == 0" class="noData">未找到内容</view>
  46. </scroll-view>
  47. <Gobacktop @getop="getop" v-if="isTop" />
  48. </view>
  49. </template>
  50. <script>
  51. import Gobacktop from '@/component/Gobacktop.vue';
  52. import uniIcon from '@/component/uni-icon/uni-icon.vue';
  53. import shopList from '@/component/shopList.vue'; // 商品列表
  54. export default {
  55. components: {
  56. uniIcon,
  57. shopList
  58. },
  59. onLoad(a) {
  60. this.store_id = a.store_id;
  61. },
  62. data() {
  63. return {
  64. isTop: 0,
  65. scrollTop: 0,
  66. old: {
  67. scrollTop: 0
  68. },
  69. isDetail: 1,
  70. isprice: 0,
  71. page: 1,
  72. store_id: 0,
  73. tabIndex: 1,
  74. istopclick: 0,
  75. goods_price: '',
  76. goods_commonid: '',
  77. chosegoods_commonid: true,
  78. chosegoods_price: true,
  79. searchvalue: '',
  80. goods_list: [],
  81. isLoad: true
  82. };
  83. },
  84. methods: {
  85. getop() {
  86. this.scrollTop = this.old.scrollTop;
  87. this.$nextTick(function() {
  88. this.scrollTop = 0;
  89. });
  90. this.isTop = false;
  91. },
  92. search() {
  93. uni.navigateBack();
  94. },
  95. confirm(e) {
  96. if (e.detail.value) {
  97. this.searchvalue = e.detail.value;
  98. this.goods_list = [];
  99. if (this.isLoad) {
  100. this.getshopdetail();
  101. }
  102. } else {
  103. this.goods_list = [];
  104. }
  105. },
  106. // 滚动到顶部
  107. upper(e) {},
  108. // 滚到底部
  109. lower(e) {
  110. if (this.isDetail == 1) {
  111. this.page = this.page + 1;
  112. this.getshopdetail();
  113. }
  114. },
  115. // 滚动时触发
  116. scroll(e) {
  117. if (e.detail.scrollTop > 250) {
  118. this.isTop = true;
  119. } else {
  120. //当距离小于500时显示回到顶部按钮
  121. this.isTop = false;
  122. }
  123. this.old.scrollTop = e.detail.scrollTop;
  124. },
  125. // 获取商品详情
  126. getshopdetail(e) {
  127. this.isLoad = false;
  128. uni.showLoading();
  129. this.request({
  130. url: '/v2/entry/storeGoods',
  131. method: 'get',
  132. data: {
  133. store_id: this.store_id,
  134. page: this.page,
  135. goods_commonid: this.goods_commonid, // 上新排序
  136. goods_price: this.goods_price,
  137. keyword: this.searchvalue
  138. },
  139. success: res => {
  140. uni.hideLoading();
  141. if (e == 2) {
  142. this.goods_list = [];
  143. }
  144. this.goods_list = this.goods_list.concat(res.data.data.goods_list);
  145. if (res.data.data.goods_list.length < 10) {
  146. this.isDetail = 2;
  147. }
  148. this.isLoad = true;
  149. }
  150. });
  151. },
  152. choseType(e) {
  153. this.page = 1;
  154. this.tabIndex = e;
  155. if (this.tabIndex == 1) {
  156. // 服务
  157. this.istopclick = 0;
  158. this.isprice = 0;
  159. this.gc_id_2 = '';
  160. this.goods_price = '';
  161. this.goods_commonid = '';
  162. this.getshopdetail(2);
  163. } else if (this.tabIndex == 2) {
  164. //伤
  165. this.chosegoods_price = true;
  166. this.istopclick = this.chosegoods_commonid ? 1 : 2;
  167. this.isprice = 0;
  168. this.goods_price = '';
  169. this.goods_commonid = this.chosegoods_commonid ? 'asc' : 'desc';
  170. this.chosegoods_commonid = !this.chosegoods_commonid;
  171. this.getshopdetail(2);
  172. } else if (this.tabIndex == 3) {
  173. // 价格
  174. this.chosegoods_commonid = true;
  175. this.isprice = this.chosegoods_price ? 3 : 4;
  176. this.goods_price = this.chosegoods_price ? 'desc' : 'asc';
  177. this.goods_commonid = '';
  178. this.istopclick = 0;
  179. this.chosegoods_price = !this.chosegoods_price;
  180. this.getshopdetail(2);
  181. }
  182. }
  183. }
  184. };
  185. </script>
  186. <style>
  187. .noData {
  188. margin-top: 30%;
  189. text-align: center;
  190. color: #999;
  191. }
  192. .sx {
  193. padding: 20upx 18upx;
  194. padding-top: 0rpx;
  195. margin-top: 108upx;
  196. border-bottom: 1px solid #f1f1f1;
  197. position: sticky;
  198. top: 108upx;
  199. }
  200. .tops {
  201. position: fixed;
  202. top: 0;
  203. left: 0;
  204. right: 0;
  205. z-index: 999;
  206. background: #fff;
  207. }
  208. .search {
  209. color: #999;
  210. padding: 0 32rpx;
  211. }
  212. .searchType .input-view {
  213. display: flex;
  214. background-color: #e7e7e7;
  215. height: 30px;
  216. border-radius: 15px;
  217. padding: 0 4%;
  218. flex-wrap: nowrap;
  219. margin: 7px 0;
  220. line-height: 30px;
  221. margin: 24upx 0 24upx 32upx;
  222. }
  223. .searchType .input-view .uni-icon {
  224. line-height: 30px !important;
  225. }
  226. .searchType .input-view .input {
  227. height: 30px;
  228. line-height: 30px;
  229. width: 94%;
  230. padding: 0 3%;
  231. }
  232. .van-cell__title {
  233. flex: 6 !important;
  234. }
  235. .searchclass {
  236. display: flex;
  237. align-items: center;
  238. justify-content: center;
  239. }
  240. .active {
  241. color: #f76260;
  242. }
  243. .typeItem {
  244. width: 33%;
  245. display: inline-block;
  246. text-align: center;
  247. }
  248. .iconClass {
  249. display: flex;
  250. flex-direction: row;
  251. align-items: center;
  252. justify-content: center;
  253. }
  254. </style>