searchResult.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360
  1. <template>
  2. <view class="searchResult">
  3. <zs-choose-tab :tabList="tabList" @choose="chooseTab"></zs-choose-tab>
  4. <view class="goods-list">
  5. <zs-list class="store-box" mt="0" @load="loadMore" :status="status">
  6. <view class="left">
  7. <view
  8. class="store-item"
  9. v-for="(item, index) in list"
  10. :key="index"
  11. @click="goGoodsDetail(item)"
  12. >
  13. <zs-img
  14. :src="item.goodsImg"
  15. width="340rpx"
  16. height="340rpx"
  17. mode="widthFix"
  18. ></zs-img>
  19. <view class="info">
  20. <view class="title">
  21. {{ item.goodsName }}
  22. </view>
  23. <view class="goods-price">
  24. <view> ¥{{ item.realPrice }} </view>
  25. <view class="distance">
  26. 销售{{ item.saleNum.toFixed(2) }}
  27. </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">
  57. 销售{{ item.saleNum.toFixed(2) }}
  58. </view>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </zs-list>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import { appSearch } from "@/api/shop.js";
  69. import { getMenu } from "@/api/common.js";
  70. export default {
  71. data() {
  72. return {
  73. location: "",
  74. query: {
  75. district: "",
  76. pageCurrent: 1,
  77. pageSize: 10,
  78. "location.lat": 0,
  79. "location.lon": 0,
  80. range: "",
  81. columnName: "",
  82. goodsName: "",
  83. shopId: "",
  84. status: 3,
  85. currentPage:0
  86. },
  87. status: "more",
  88. list: [],
  89. list1: [],
  90. tabList: [
  91. // {
  92. // id: 1,
  93. // label: '区域',
  94. // list: [
  95. // {
  96. // id: 1,
  97. // label: '观山湖'
  98. // },
  99. // {
  100. // id: 2,
  101. // label: '白云区'
  102. // },
  103. // {
  104. // id: 3,
  105. // label: '花果山区'
  106. // }
  107. // ]
  108. // },
  109. {
  110. id: 1,
  111. label: "全部分类",
  112. list: [],
  113. },
  114. // {
  115. // id: 1,
  116. // label: '附近',
  117. // list: [
  118. // {
  119. // id:5,
  120. // label: '5KM'
  121. // },
  122. // {
  123. // id:10,
  124. // label: '10KM'
  125. // },
  126. // {
  127. // id:20,
  128. // label: '20KM'
  129. // },
  130. // {
  131. // id:50,
  132. // label: '50KM'
  133. // }
  134. // ]
  135. // },
  136. ],
  137. };
  138. },
  139. methods: {
  140. goShopDetail(item) {
  141. uni.setStorageSync("shopInfo", JSON.stringify(item));
  142. uni.navigateTo({
  143. url: "/detail/shopDetail/shopDetail",
  144. });
  145. },
  146. goGoodsDetail(item, i) {
  147. uni.setStorageSync("shopInfo", JSON.stringify(item));
  148. uni.reLaunch({
  149. url: `/detail/goodsDetail/index?id=${item.goodsId}`,
  150. });
  151. },
  152. chooseTab(val) {
  153. console.log(val);
  154. this.query.range = val[2].id;
  155. if (val[0]) {
  156. this.query["location.lat"] = val[0].location.lat;
  157. this.query["location.lon"] = val[0].location.lng;
  158. this.query.range = 50;
  159. this.query.district = val[0].label;
  160. } else if (!val[0]) {
  161. this.query["location.lat"] = this.location.latitude;
  162. this.query["location.lon"] = this.location.longitude;
  163. this.query.district = "";
  164. }
  165. if (val[1]) {
  166. this.query.menuId = val[1].id;
  167. } else if (!val[1]) {
  168. this.query.menuId = "";
  169. }
  170. this.query.pageCurrent = 1;
  171. this.status = "more";
  172. this.list = [];
  173. this.search();
  174. },
  175. search() {
  176. // if(this.status == 'noMore') return
  177. this.status = "loading";
  178. let obj = JSON.parse(JSON.stringify(this.query));
  179. if (!obj.range) {
  180. delete obj.range;
  181. }
  182. appSearch(obj).then((res) => {
  183. if (res.state == "Success") {
  184. this.loading = false;
  185. let list = [];
  186. let list1 = [];
  187. res.content.records.map((item, index) => {
  188. if (index % 2) {
  189. list1.push(item);
  190. } else {
  191. list.push(item);
  192. }
  193. });
  194. this.list = this.list.concat(list);
  195. this.list1 = this.list1.concat(list1);
  196. let total = this.list.length + this.list1.length;
  197. console.log("list", this.list, this.list1);
  198. if (total >= res.content.total) {
  199. this.status = "noMore";
  200. } else {
  201. this.status = "more";
  202. this.query.currentPage++;
  203. }
  204. }
  205. });
  206. },
  207. loadMore() {
  208. this.search();
  209. },
  210. // 金刚区
  211. getMenu() {
  212. getMenu({ currentPage: 1, pageSize: 10, status: 2 }).then((res) => {
  213. if (res.state == "Success") {
  214. let list = [];
  215. res.content.records.map((item) => {
  216. list.push({
  217. id: item.id,
  218. label: item.menuName,
  219. });
  220. });
  221. // this.tabList[1].list = list;
  222. }
  223. });
  224. },
  225. },
  226. onLoad(options) {
  227. let list = uni.getStorageSync("districtList") || "[]";
  228. this.tabList[0].list = JSON.parse(list);
  229. this.location = JSON.parse(uni.getStorageSync("location"));
  230. this.query.shopId = uni.getStorageSync("gdShopId");
  231. this.query["location.lat"] = this.location.latitude;
  232. this.query["location.lon"] = this.location.longitude;
  233. this.query.goodsName = options?.search || "";
  234. if (!this.query.goodsName) {
  235. this.query.columnName = options.column;
  236. uni.setNavigationBarTitle({
  237. title: options.column,
  238. });
  239. }
  240. this.search();
  241. // this.getMenu();
  242. },
  243. };
  244. </script>
  245. <style lang="scss" scoped>
  246. .searchResult {
  247. padding: 100rpx 24rpx 20rpx;
  248. background: #f9f9f9;
  249. .goods-list {
  250. border-radius: 16rpx 16rpx 0 0;
  251. margin-bottom: 60rpx;
  252. }
  253. }
  254. ::v-deep .zs-list {
  255. display: flex;
  256. flex-wrap: wrap;
  257. justify-content: space-between;
  258. .left {
  259. .adv-swiper {
  260. width: 340rpx;
  261. height: 444rpx;
  262. margin-bottom: 25rpx;
  263. .adv-item {
  264. width: 340rpx;
  265. height: 444rpx;
  266. }
  267. }
  268. }
  269. .right {
  270. }
  271. .store-item {
  272. width: 340rpx;
  273. margin-bottom: 25rpx;
  274. // box-shadow: 0rpx 0rpx 24rpx 2rpx rgba(0, 0, 0, 0.08);
  275. border-radius: 16rpx;
  276. background: #fff;
  277. .icon {
  278. width: 100%;
  279. height: 300rpx;
  280. border-radius: 16rpx 16rpx 0 0;
  281. }
  282. .info {
  283. padding: 20rpx;
  284. background: #fff;
  285. border-radius: 0 0 16rpx 16rpx;
  286. position: relative;
  287. .title {
  288. // font-weight: bold;
  289. width: 100%;
  290. white-space: nowrap;
  291. text-overflow: ellipsis;
  292. overflow: hidden;
  293. }
  294. .tags {
  295. display: flex;
  296. align-items: center;
  297. .tag-item {
  298. line-height: 50rpx;
  299. border-radius: 8rpx;
  300. padding: 6rpx 0;
  301. font-size: 24rpx;
  302. margin-left: 10rpx;
  303. display: flex;
  304. .label {
  305. background: #fff;
  306. color: #fe5b47;
  307. padding: 0 10rpx;
  308. border-radius: 8rpx 0 0 8rpx;
  309. }
  310. .value {
  311. color: #fff;
  312. background: rgba(255, 255, 255, 0.2);
  313. padding: 0 14rpx;
  314. border-radius: 0 8rpx 8rpx 0;
  315. }
  316. }
  317. }
  318. .goods-price {
  319. display: flex;
  320. align-items: center;
  321. margin-top: 15rpx;
  322. justify-content: space-between;
  323. color: #ff4d3a;
  324. font-weight: bold;
  325. font-size: 30rpx;
  326. .distance {
  327. font-weight: normal;
  328. font-size: 20rpx;
  329. color: #999;
  330. }
  331. .position {
  332. color: 999;
  333. width: 25rpx;
  334. height: 29rpx;
  335. margin-right: 8rpx;
  336. }
  337. }
  338. }
  339. }
  340. }
  341. </style>