hotelsearch.vue 8.0 KB

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