hotelsearch.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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.goodId = 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. goodId: 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. };
  82. },
  83. methods: {
  84. getop() {
  85. this.scrollTop = this.old.scrollTop;
  86. this.$nextTick(function() {
  87. this.scrollTop = 0;
  88. });
  89. this.isTop = false;
  90. },
  91. search() {
  92. uni.navigateBack()
  93. },
  94. confirm(e) {
  95. if(e.detail.value){
  96. this.searchvalue = e.detail.value;
  97. this.goods_list = [];
  98. this.getshopdetail();
  99. }else{
  100. this.goods_list = [];
  101. }
  102. },
  103. // 滚动到顶部
  104. upper(e) {},
  105. // 滚到底部
  106. lower(e) {
  107. if (this.isDetail == 1) {
  108. this.page = this.page + 1;
  109. this.getshopdetail();
  110. }
  111. },
  112. // 滚动时触发
  113. scroll(e) {
  114. if (e.detail.scrollTop > 250) {
  115. this.isTop = true;
  116. } else {
  117. //当距离小于500时显示回到顶部按钮
  118. this.isTop = false;
  119. }
  120. this.old.scrollTop = e.detail.scrollTop;
  121. },
  122. // 获取商品详情
  123. getshopdetail(e) {
  124. uni.showLoading();
  125. this.request({
  126. url: '/v2/entry/storeGoods',
  127. method: 'get',
  128. data: {
  129. store_id: this.goodId,
  130. page: this.page,
  131. goods_commonid: this.goods_commonid, // 上新排序
  132. goods_price: this.goods_price,
  133. keyword: this.searchvalue
  134. },
  135. success: res => {
  136. uni.hideLoading();
  137. if (e == 2) {
  138. this.goods_list = [];
  139. }
  140. this.goods_list = this.goods_list.concat(res.data.data.goods_list);
  141. if (res.data.data.goods_list.length < 10) {
  142. this.isDetail = 2;
  143. }
  144. }
  145. });
  146. },
  147. choseType(e) {
  148. this.page = 1;
  149. this.tabIndex = e;
  150. if (this.tabIndex == 1) {
  151. // 服务
  152. this.istopclick = 0;
  153. this.isprice = 0;
  154. this.gc_id_2 = '';
  155. this.goods_price = '';
  156. this.goods_commonid = '';
  157. this.getshopdetail(2);
  158. } else if (this.tabIndex == 2) {
  159. //伤
  160. this.chosegoods_price = true;
  161. this.istopclick = this.chosegoods_commonid ? 1 : 2;
  162. this.isprice = 0;
  163. this.goods_price = '';
  164. this.goods_commonid = this.chosegoods_commonid ? 'asc' : 'desc';
  165. this.chosegoods_commonid = !this.chosegoods_commonid;
  166. this.getshopdetail(2);
  167. } else if (this.tabIndex == 3) {
  168. // 价格
  169. this.chosegoods_commonid = true;
  170. this.isprice = this.chosegoods_price ? 3 : 4;
  171. this.goods_price = this.chosegoods_price ? 'desc' : 'asc';
  172. this.goods_commonid = '';
  173. this.istopclick = 0;
  174. this.chosegoods_price = !this.chosegoods_price;
  175. this.getshopdetail(2);
  176. }
  177. }
  178. }
  179. };
  180. </script>
  181. <style>
  182. .noData {
  183. margin-top: 30%;
  184. text-align: center;
  185. color: #999;
  186. }
  187. .sx {
  188. padding: 20upx 18upx;
  189. padding-top: 0rpx;
  190. margin-top: 108upx;
  191. border-bottom: 1px solid #f1f1f1;
  192. position: sticky;
  193. top: 108upx;
  194. }
  195. .tops {
  196. position: fixed;
  197. top: 0;
  198. left: 0;
  199. right: 0;
  200. z-index: 999;
  201. background: #fff;
  202. }
  203. .search {
  204. color: #999;
  205. padding: 0 32rpx;
  206. }
  207. .searchType .input-view {
  208. display: flex;
  209. background-color: #e7e7e7;
  210. height: 30px;
  211. border-radius: 15px;
  212. padding: 0 4%;
  213. flex-wrap: nowrap;
  214. margin: 7px 0;
  215. line-height: 30px;
  216. margin: 24upx 0 24upx 32upx;
  217. }
  218. .searchType .input-view .uni-icon {
  219. line-height: 30px !important;
  220. }
  221. .searchType .input-view .input {
  222. height: 30px;
  223. line-height: 30px;
  224. width: 94%;
  225. padding: 0 3%;
  226. }
  227. .van-cell__title {
  228. flex: 6 !important;
  229. }
  230. .searchclass {
  231. display: flex;
  232. align-items: center;
  233. justify-content: center;
  234. }
  235. .active {
  236. color: #f76260;
  237. }
  238. .typeItem {
  239. width: 33%;
  240. display: inline-block;
  241. text-align: center;
  242. }
  243. .iconClass {
  244. display: flex;
  245. flex-direction: row;
  246. align-items: center;
  247. justify-content: center;
  248. }
  249. </style>