searchResult.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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. getSearchTypeData().then((res) => {
  151. this.tabList = [
  152. {
  153. id: 0,
  154. cateName: "全部分类",
  155. child: res.content,
  156. },
  157. {
  158. id: 1,
  159. cateName: "价格排序",
  160. child: [
  161. {
  162. id: "acs",
  163. cateName: "价格升序",
  164. },
  165. {
  166. id: "desc",
  167. cateName: "价格降序",
  168. },
  169. ],
  170. },
  171. ];
  172. });
  173. },
  174. },
  175. onLoad(options) {
  176. // let list = uni.getStorageSync("districtList") || "[]";
  177. // this.tabList[0].list = JSON.parse(list);
  178. this.location = JSON.parse(uni.getStorageSync("location"));
  179. this.query.shopId = uni.getStorageSync("gdShopId");
  180. this.query["location.lat"] = this.location.latitude;
  181. this.query["location.lon"] = this.location.longitude;
  182. this.query.goodsName = options?.search || "";
  183. if (!this.query.goodsName) {
  184. this.query.goodsCateId = options.columnId;
  185. uni.setNavigationBarTitle({
  186. title: options.column,
  187. });
  188. }
  189. this.search();
  190. this.getTabList();
  191. },
  192. };
  193. </script>
  194. <style lang="scss" scoped>
  195. .searchResult {
  196. padding: 100rpx 24rpx 20rpx;
  197. background: #f9f9f9;
  198. height: 100%;
  199. .goods-list {
  200. border-radius: 16rpx 16rpx 0 0;
  201. margin-bottom: 60rpx;
  202. }
  203. }
  204. ::v-deep .zs-list {
  205. display: flex;
  206. flex-wrap: wrap;
  207. justify-content: space-between;
  208. .left {
  209. .adv-swiper {
  210. width: 340rpx;
  211. height: 444rpx;
  212. margin-bottom: 25rpx;
  213. .adv-item {
  214. width: 340rpx;
  215. height: 444rpx;
  216. }
  217. }
  218. }
  219. .right {
  220. }
  221. .store-item {
  222. width: 340rpx;
  223. margin-bottom: 25rpx;
  224. // box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0, 0, 0, 0.08);
  225. border-radius: 16rpx;
  226. background: #fff;
  227. .icon {
  228. width: 100%;
  229. height: 300rpx;
  230. border-radius: 16rpx 16rpx 0 0;
  231. }
  232. .info {
  233. padding: 20rpx;
  234. background: #fff;
  235. border-radius: 0 0 16rpx 16rpx;
  236. position: relative;
  237. .title {
  238. // font-weight: bold;
  239. width: 100%;
  240. white-space: nowrap;
  241. text-overflow: ellipsis;
  242. overflow: hidden;
  243. }
  244. .tags {
  245. display: flex;
  246. align-items: center;
  247. .tag-item {
  248. line-height: 50rpx;
  249. border-radius: 8rpx;
  250. padding: 6rpx 0;
  251. font-size: 24rpx;
  252. margin-left: 10rpx;
  253. display: flex;
  254. .label {
  255. background: #fff;
  256. color: #fe5b47;
  257. padding: 0 10rpx;
  258. border-radius: 8rpx 0 0 8rpx;
  259. }
  260. .value {
  261. color: #fff;
  262. background: rgba(255, 255, 255, 0.2);
  263. padding: 0 14rpx;
  264. border-radius: 0 8rpx 8rpx 0;
  265. }
  266. }
  267. }
  268. .goods-price {
  269. display: flex;
  270. align-items: center;
  271. margin-top: 15rpx;
  272. justify-content: space-between;
  273. color: #ff4d3a;
  274. font-weight: bold;
  275. font-size: 30rpx;
  276. .distance {
  277. font-weight: normal;
  278. font-size: 20rpx;
  279. color: #999;
  280. }
  281. .position {
  282. color: 999;
  283. width: 25rpx;
  284. height: 29rpx;
  285. margin-right: 8rpx;
  286. }
  287. }
  288. }
  289. }
  290. }
  291. </style>