searchResult.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315
  1. <template>
  2. <view class="searchResult">
  3. <!-- <zs-choose-tab :tabList="tabList" @choose="chooseTab"></zs-choose-tab> -->
  4. <zs-choose-tab-union :level="2" :tabList="tabList" @choose="chooseTab">
  5. </zs-choose-tab-union>
  6. <view class="goods-list">
  7. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  8. <view class="left">
  9. <view
  10. class="store-item"
  11. v-for="(item, index) in list"
  12. :key="index"
  13. @click="goGoodsDetail(item)"
  14. >
  15. <zs-img
  16. :src="item.goodsImg"
  17. width="340rpx"
  18. height="340rpx"
  19. mode="widthFix"
  20. ></zs-img>
  21. <view class="info">
  22. <view class="title">
  23. {{ item.goodsName }}
  24. </view>
  25. <view class="goods-price">
  26. <view> ¥{{ item.realPrice }} </view>
  27. <view class="distance"> 销售{{ item.saleNum }} </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. <view class="right">
  33. <view
  34. class="store-item"
  35. v-for="(item, index) in list1"
  36. :key="index"
  37. @click="goGoodsDetail(item)"
  38. >
  39. <zs-img
  40. :src="item.goodsImg"
  41. width="340rpx"
  42. height="340rpx"
  43. mode="widthFix"
  44. ></zs-img>
  45. <view class="info">
  46. <view class="title">
  47. {{ item.goodsName }}
  48. </view>
  49. <view class="goods-price">
  50. <!-- <image
  51. class="position"
  52. src="../../static/position.png"
  53. mode=""
  54. ></image> -->
  55. <view> ¥{{ item.realPrice }}</view>
  56. <view class="distance"> 销售{{ item.saleNum }} </view>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </zs-list>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import { appSearch, getSearchTypeData } from "@/api/shop.js";
  67. export default {
  68. data() {
  69. return {
  70. location: "",
  71. query: {
  72. district: "",
  73. pageCurrent: 1,
  74. pageSize: 10,
  75. "location.lat": 0,
  76. "location.lon": 0,
  77. range: "",
  78. goodsCateId: "",
  79. goodsName: "",
  80. realPriceOrder: "", //desc,asc
  81. shopId: "",
  82. status: 3,
  83. currentPage: 0,
  84. },
  85. status: "more",
  86. list: [],
  87. list1: [],
  88. tabList: [],
  89. };
  90. },
  91. methods: {
  92. goShopDetail(item) {
  93. uni.setStorageSync("shopInfo", JSON.stringify(item));
  94. uni.navigateTo({
  95. url: "/detail/shopDetail/shopDetail",
  96. });
  97. },
  98. goGoodsDetail(item, i) {
  99. uni.setStorageSync("shopInfo", JSON.stringify(item));
  100. uni.reLaunch({
  101. url: `/detail/goodsDetail/index?id=${item.goodsId}`,
  102. });
  103. },
  104. chooseTab(val) {
  105. this.query.goodsCateId = val[0].id;
  106. this.query.realPriceOrder = val[1].id || "";
  107. this.query.pageCurrent = 1;
  108. this.status = "more";
  109. this.list = [];
  110. this.list1 = [];
  111. this.search();
  112. },
  113. search() {
  114. // if(this.status == 'noMore') return
  115. this.status = "loading";
  116. let obj = JSON.parse(JSON.stringify(this.query));
  117. if (!obj.range) {
  118. delete obj.range;
  119. }
  120. appSearch(obj).then((res) => {
  121. if (res.state == "Success") {
  122. this.loading = false;
  123. let list = [];
  124. let list1 = [];
  125. res.content.records.map((item, index) => {
  126. if (index % 2) {
  127. list1.push(item);
  128. } else {
  129. list.push(item);
  130. }
  131. });
  132. this.list = this.list.concat(list);
  133. this.list1 = this.list1.concat(list1);
  134. let total = this.list.length + this.list1.length;
  135. console.log("list", this.list, this.list1);
  136. if (total >= res.content.total) {
  137. this.status = "noMore";
  138. } else {
  139. this.status = "more";
  140. this.query.currentPage++;
  141. }
  142. }
  143. });
  144. },
  145. loadMore() {
  146. this.search();
  147. },
  148. getTabList() {
  149. // 如果是栏目点进来则更新标题
  150. let query = this.query.itemId;
  151. let str = "";
  152. if(query){
  153. str="?columnId="+query;
  154. this.query.columnId=query;
  155. }
  156. getSearchTypeData(str).then((res) => {
  157. this.tabList = [
  158. {
  159. id: 0,
  160. cateName: "全部分类",
  161. child: res.content,
  162. },
  163. {
  164. id: 1,
  165. cateName: "价格排序",
  166. child: [
  167. {
  168. id: "asc",
  169. cateName: "价格升序",
  170. },
  171. {
  172. id: "desc",
  173. cateName: "价格降序",
  174. },
  175. ],
  176. },
  177. ];
  178. });
  179. },
  180. },
  181. onLoad(options) {
  182. // let list = uni.getStorageSync("districtList") || "[]";
  183. // this.tabList[0].list = JSON.parse(list);
  184. this.location = JSON.parse(uni.getStorageSync("location"));
  185. this.query.shopId = uni.getStorageSync("gdShopId");
  186. this.query["location.lat"] = this.location.latitude;
  187. this.query["location.lon"] = this.location.longitude;
  188. this.query.goodsName = options?.search || "";
  189. if (!this.query.goodsName) {
  190. this.query.columnId = options.columnId || "";
  191. this.query.itemId = options.columnId || "";
  192. uni.setNavigationBarTitle({
  193. title: options.column || "搜索结果",
  194. });
  195. }
  196. this.search();
  197. this.getTabList();
  198. },
  199. };
  200. </script>
  201. <style lang="scss" scoped>
  202. .searchResult {
  203. padding: 100rpx 24rpx 20rpx;
  204. background: #f9f9f9;
  205. height: 100%;
  206. .goods-list {
  207. border-radius: 16rpx 16rpx 0 0;
  208. margin-bottom: 60rpx;
  209. }
  210. }
  211. ::v-deep .zs-list {
  212. display: flex;
  213. flex-wrap: wrap;
  214. justify-content: space-between;
  215. .left {
  216. .adv-swiper {
  217. width: 340rpx;
  218. height: 444rpx;
  219. margin-bottom: 25rpx;
  220. .adv-item {
  221. width: 340rpx;
  222. height: 444rpx;
  223. }
  224. }
  225. }
  226. .right {
  227. }
  228. .store-item {
  229. width: 340rpx;
  230. margin-bottom: 25rpx;
  231. // box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0, 0, 0, 0.08);
  232. border-radius: 16rpx;
  233. background: #fff;
  234. .icon {
  235. width: 100%;
  236. height: 300rpx;
  237. border-radius: 16rpx 16rpx 0 0;
  238. }
  239. .info {
  240. padding: 20rpx;
  241. background: #fff;
  242. border-radius: 0 0 16rpx 16rpx;
  243. position: relative;
  244. .title {
  245. // font-weight: bold;
  246. width: 100%;
  247. white-space: nowrap;
  248. text-overflow: ellipsis;
  249. overflow: hidden;
  250. }
  251. .tags {
  252. display: flex;
  253. align-items: center;
  254. .tag-item {
  255. line-height: 50rpx;
  256. border-radius: 8rpx;
  257. padding: 6rpx 0;
  258. font-size: 24rpx;
  259. margin-left: 10rpx;
  260. display: flex;
  261. .label {
  262. background: #fff;
  263. color: #fe5b47;
  264. padding: 0 10rpx;
  265. border-radius: 8rpx 0 0 8rpx;
  266. }
  267. .value {
  268. color: #fff;
  269. background: rgba(255, 255, 255, 0.2);
  270. padding: 0 14rpx;
  271. border-radius: 0 8rpx 8rpx 0;
  272. }
  273. }
  274. }
  275. .goods-price {
  276. display: flex;
  277. align-items: center;
  278. margin-top: 15rpx;
  279. justify-content: space-between;
  280. color: #ff4d3a;
  281. font-weight: bold;
  282. font-size: 30rpx;
  283. .distance {
  284. font-weight: normal;
  285. font-size: 20rpx;
  286. color: #999;
  287. }
  288. .position {
  289. color: 999;
  290. width: 25rpx;
  291. height: 29rpx;
  292. margin-right: 8rpx;
  293. }
  294. }
  295. }
  296. }
  297. }
  298. </style>