searchResult.vue 8.3 KB

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