searchResult.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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("?columnId="+this.query.itemId).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. this.query.itemId=options.itemId;
  186. uni.setNavigationBarTitle({
  187. title: options.column,
  188. });
  189. }
  190. this.search();
  191. this.getTabList();
  192. },
  193. };
  194. </script>
  195. <style lang="scss" scoped>
  196. .searchResult {
  197. padding: 100rpx 24rpx 20rpx;
  198. background: #f9f9f9;
  199. height: 100%;
  200. .goods-list {
  201. border-radius: 16rpx 16rpx 0 0;
  202. margin-bottom: 60rpx;
  203. }
  204. }
  205. ::v-deep .zs-list {
  206. display: flex;
  207. flex-wrap: wrap;
  208. justify-content: space-between;
  209. .left {
  210. .adv-swiper {
  211. width: 340rpx;
  212. height: 444rpx;
  213. margin-bottom: 25rpx;
  214. .adv-item {
  215. width: 340rpx;
  216. height: 444rpx;
  217. }
  218. }
  219. }
  220. .right {
  221. }
  222. .store-item {
  223. width: 340rpx;
  224. margin-bottom: 25rpx;
  225. // box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0, 0, 0, 0.08);
  226. border-radius: 16rpx;
  227. background: #fff;
  228. .icon {
  229. width: 100%;
  230. height: 300rpx;
  231. border-radius: 16rpx 16rpx 0 0;
  232. }
  233. .info {
  234. padding: 20rpx;
  235. background: #fff;
  236. border-radius: 0 0 16rpx 16rpx;
  237. position: relative;
  238. .title {
  239. // font-weight: bold;
  240. width: 100%;
  241. white-space: nowrap;
  242. text-overflow: ellipsis;
  243. overflow: hidden;
  244. }
  245. .tags {
  246. display: flex;
  247. align-items: center;
  248. .tag-item {
  249. line-height: 50rpx;
  250. border-radius: 8rpx;
  251. padding: 6rpx 0;
  252. font-size: 24rpx;
  253. margin-left: 10rpx;
  254. display: flex;
  255. .label {
  256. background: #fff;
  257. color: #fe5b47;
  258. padding: 0 10rpx;
  259. border-radius: 8rpx 0 0 8rpx;
  260. }
  261. .value {
  262. color: #fff;
  263. background: rgba(255, 255, 255, 0.2);
  264. padding: 0 14rpx;
  265. border-radius: 0 8rpx 8rpx 0;
  266. }
  267. }
  268. }
  269. .goods-price {
  270. display: flex;
  271. align-items: center;
  272. margin-top: 15rpx;
  273. justify-content: space-between;
  274. color: #ff4d3a;
  275. font-weight: bold;
  276. font-size: 30rpx;
  277. .distance {
  278. font-weight: normal;
  279. font-size: 20rpx;
  280. color: #999;
  281. }
  282. .position {
  283. color: 999;
  284. width: 25rpx;
  285. height: 29rpx;
  286. margin-right: 8rpx;
  287. }
  288. }
  289. }
  290. }
  291. }
  292. </style>