searchResult.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <view class="searchResult">
  3. <zs-choose-tab :tabList="tabList" @choose="chooseTab"></zs-choose-tab>
  4. <zs-list mt="0" @load="loadMore" :status="status">
  5. <view class="item" v-for="(item,index) in list" :key="index">
  6. <zs-img class="icon" :src="item.logoPath" radius="full" width="120rpx" height="120rpx" @click="goShopDetail(item)"></zs-img>
  7. <view class="shop-box">
  8. <view class="shop-info">
  9. <view class="shop-name" @click="goShopDetail(item)">
  10. {{item.shopVo.shopName}}
  11. </view>
  12. <view class="address-box">
  13. <view class="address">
  14. {{item.district}}
  15. </view>
  16. <view class="distance">
  17. {{(item.shopVo.distance/1000).toFixed(2)}}km
  18. </view>
  19. </view>
  20. </view>
  21. <!-- <view class="goods-list"> -->
  22. <scroll-view class="goods-list" enable-flex scroll-x="true">
  23. <view class="goods-item" v-for="(i,d) in item.goodsVos" :key="d" @click="goGoodsDetail(item,i)">
  24. <zs-img :src="i.goodsImg" width="160rpx" height="160rpx"></zs-img>
  25. <view class="goods-name">
  26. {{i.goodsName}}
  27. </view>
  28. <view class="price-box">
  29. <view class="price">
  30. ¥{{i.realPrice}}
  31. </view>
  32. <view class="old-price">
  33. ¥{{i.marketPrice}}
  34. </view>
  35. </view>
  36. </view>
  37. </scroll-view>
  38. <!-- </view> -->
  39. </view>
  40. </view>
  41. </zs-list>
  42. </view>
  43. </template>
  44. <script>
  45. import {
  46. search
  47. } from '@/api/shop.js';
  48. import {
  49. getMenu,
  50. } from '@/api/common.js'
  51. export default {
  52. data() {
  53. return {
  54. location:'',
  55. query: {
  56. district:'',
  57. pageCurrent: 1,
  58. pageSize: 10,
  59. 'location.lat': 0,
  60. 'location.lon': 0,
  61. range:'',
  62. queryName: ''
  63. },
  64. status: 'more',
  65. list: [],
  66. tabList: [{
  67. id: 1,
  68. label: '区域',
  69. list: [
  70. {
  71. id: 1,
  72. label: '观山湖'
  73. },
  74. {
  75. id: 2,
  76. label: '白云区'
  77. },
  78. {
  79. id: 3,
  80. label: '花果山区'
  81. }
  82. ]
  83. },
  84. {
  85. id: 1,
  86. label: '全部分类',
  87. list: []
  88. },
  89. {
  90. id: 1,
  91. label: '附近',
  92. list: [
  93. {
  94. id:5,
  95. label: '5KM'
  96. },
  97. {
  98. id:10,
  99. label: '10KM'
  100. },
  101. {
  102. id:20,
  103. label: '20KM'
  104. },
  105. {
  106. id:50,
  107. label: '50KM'
  108. }
  109. ]
  110. },
  111. ]
  112. }
  113. },
  114. methods: {
  115. goShopDetail(item) {
  116. uni.setStorageSync('shopInfo', JSON.stringify(item))
  117. uni.navigateTo({
  118. url: '/detail/shopDetail/shopDetail'
  119. })
  120. },
  121. goGoodsDetail(item,i) {
  122. uni.setStorageSync('shopInfo', JSON.stringify(item))
  123. uni.reLaunch({
  124. url: `/detail/goodsDetail/index?id=${i.goodsId}`
  125. })
  126. },
  127. chooseTab(val) {
  128. console.log(val);
  129. this.query.range = val[2].id
  130. if(val[0]){
  131. this.query['location.lat'] = val[0].location.lat
  132. this.query['location.lon'] = val[0].location.lng
  133. this.query.range = 50
  134. this.query.district = val[0].label
  135. }else if(!val[0]){
  136. this.query['location.lat'] = this.location.latitude
  137. this.query['location.lon'] = this.location.longitude
  138. this.query.district = ''
  139. }
  140. if(val[1]){
  141. this.query.menuId = val[1].id
  142. }else if(!val[1]){
  143. this.query.menuId = ''
  144. }
  145. this.query.pageCurrent = 1
  146. this.status = 'more'
  147. this.list = []
  148. this.search()
  149. },
  150. search() {
  151. // if(this.status == 'noMore') return
  152. this.status = 'loading'
  153. let obj = JSON.parse(JSON.stringify(this.query))
  154. if(!obj.range){
  155. delete obj.range
  156. }
  157. search(obj).then(res => {
  158. if (res.state == 'Success') {
  159. this.list = this.list.concat(res.content.records)
  160. console.log(res.content.total>=this.list.length);
  161. if(res.content.total>this.list.length){
  162. this.status = 'more'
  163. }else{
  164. this.status = 'noMore'
  165. this.query.pageCurrent++
  166. }
  167. }
  168. })
  169. },
  170. loadMore() {
  171. this.search()
  172. },
  173. // 金刚区
  174. getMenu(){
  175. getMenu({currentPage:1,pageSize:10,status:2}).then(res=>{
  176. if(res.state == 'Success'){
  177. let list = []
  178. res.content.records.map(item => {
  179. list.push({
  180. id: item.id,
  181. label: item.menuName
  182. })
  183. })
  184. this.tabList[1].list = list
  185. }
  186. })
  187. },
  188. },
  189. onLoad(options) {
  190. this.tabList[0].list = JSON.parse(uni.getStorageSync('districtList'))
  191. this.location = JSON.parse(uni.getStorageSync('location'))
  192. this.query['location.lat'] = this.location.latitude
  193. this.query['location.lon'] = this.location.longitude
  194. this.query.queryName = options.search
  195. this.search()
  196. this.getMenu()
  197. }
  198. }
  199. </script>
  200. <style lang="scss" scoped>
  201. .searchResult{
  202. padding: 100rpx 24rpx 20rpx;
  203. background: #F9F9F9;
  204. .item{
  205. padding: 24rpx;
  206. background: #FFFFFF;
  207. border-radius: 16rpx 16rpx 16rpx 16rpx;
  208. display: flex;
  209. align-items: flex-start;
  210. margin-bottom: 20rpx;
  211. .icon{
  212. width: 120rpx;
  213. }
  214. .shop-box{
  215. flex: 1;
  216. margin-left: 20rpx;
  217. .shop-info{
  218. .shop-name{
  219. font-weight: 600;
  220. font-size: 36rpx;
  221. color: #222222;
  222. width: 100%;
  223. white-space: nowrap;
  224. overflow: hidden;
  225. text-overflow: ellipsis;
  226. }
  227. .address-box{
  228. display: flex;
  229. justify-content: space-between;
  230. align-items: center;
  231. font-weight: 300;
  232. font-size: 24rpx;
  233. color: #AAAAAA;
  234. margin-top: 25rpx;
  235. .address{
  236. width: 400rpx;
  237. white-space: nowrap;
  238. overflow: hidden;
  239. text-overflow: ellipsis;
  240. }
  241. }
  242. }
  243. .goods-list{
  244. display: flex;
  245. align-items: flex-start;
  246. margin-top: 20rpx;
  247. overflow: auto;
  248. width: calc(750rpx - 94rpx - 120rpx - 20rpx);
  249. .goods-item{
  250. display: inline-block;
  251. width: 160rpx;
  252. margin-right: 20rpx;
  253. .goods-name{
  254. margin-top: 20rpx;
  255. width: 100%;
  256. overflow: hidden;
  257. text-overflow: ellipsis;
  258. /* 弹性伸缩盒子模型显示 */
  259. display: -webkit-box;
  260. /* 限制在一个块元素显示的文本的行数 */
  261. -webkit-line-clamp: 2;
  262. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  263. -webkit-box-orient: vertical;
  264. }
  265. }
  266. .price-box{
  267. display: flex;
  268. align-items: center;
  269. margin-top: 20rpx;
  270. .price{
  271. font-weight: 600;
  272. font-size: 28rpx;
  273. color: #FF4D3A;
  274. }
  275. .old-price{
  276. font-weight: 300;
  277. font-size: 20rpx;
  278. color: #AAAAAA;
  279. text-decoration: line-through;
  280. }
  281. }
  282. }
  283. }
  284. }
  285. }
  286. </style>