searchResult.vue 7.0 KB

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