searchResult.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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.native="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. console.log(11111111);
  117. uni.setStorageSync('shopInfo', JSON.stringify(item))
  118. uni.navigateTo({
  119. url: '/detail/shopDetail/shopDetail'
  120. })
  121. },
  122. goGoodsDetail(item,i) {
  123. uni.setStorageSync('shopInfo', JSON.stringify(item))
  124. uni.reLaunch({
  125. url: `/detail/goodsDetail/index?id=${i.goodsId}`
  126. })
  127. },
  128. chooseTab(val) {
  129. console.log(val);
  130. this.query.range = val[2].id
  131. if(val[0]){
  132. this.query['location.lat'] = val[0].location.lat
  133. this.query['location.lon'] = val[0].location.lng
  134. this.query.range = 50
  135. this.query.district = val[0].label
  136. }else if(!val[0]){
  137. this.query['location.lat'] = this.location.latitude
  138. this.query['location.lon'] = this.location.longitude
  139. this.query.district = ''
  140. }
  141. if(val[1]){
  142. this.query.menuId = val[1].id
  143. }else if(!val[1]){
  144. this.query.menuId = ''
  145. }
  146. this.query.pageCurrent = 1
  147. this.status = 'more'
  148. this.list = []
  149. this.search()
  150. },
  151. search() {
  152. // if(this.status == 'noMore') return
  153. this.status = 'loading'
  154. let obj = JSON.parse(JSON.stringify(this.query))
  155. if(!obj.range){
  156. delete obj.range
  157. }
  158. search(obj).then(res => {
  159. if (res.state == 'Success') {
  160. this.list = this.list.concat(res.content.records)
  161. console.log(res.content.total>=this.list.length);
  162. if(res.content.total>this.list.length){
  163. this.status = 'more'
  164. }else{
  165. this.status = 'noMore'
  166. this.query.pageCurrent++
  167. }
  168. }
  169. })
  170. },
  171. loadMore() {
  172. this.search()
  173. },
  174. // 金刚区
  175. getMenu(){
  176. getMenu({currentPage:1,pageSize:10,status:2}).then(res=>{
  177. if(res.state == 'Success'){
  178. let list = []
  179. res.content.records.map(item => {
  180. list.push({
  181. id: item.id,
  182. label: item.menuName
  183. })
  184. })
  185. this.tabList[1].list = list
  186. }
  187. })
  188. },
  189. },
  190. onLoad(options) {
  191. this.tabList[0].list = JSON.parse(uni.getStorageSync('districtList'))
  192. this.location = JSON.parse(uni.getStorageSync('location'))
  193. this.query['location.lat'] = this.location.latitude
  194. this.query['location.lon'] = this.location.longitude
  195. this.query.queryName = options.search
  196. this.search()
  197. this.getMenu()
  198. }
  199. }
  200. </script>
  201. <style lang="scss" scoped>
  202. .searchResult{
  203. padding: 100rpx 24rpx 20rpx;
  204. background: #F9F9F9;
  205. .item{
  206. padding: 24rpx;
  207. background: #FFFFFF;
  208. border-radius: 16rpx 16rpx 16rpx 16rpx;
  209. display: flex;
  210. align-items: flex-start;
  211. margin-bottom: 20rpx;
  212. .icon{
  213. width: 120rpx;
  214. }
  215. .shop-box{
  216. flex: 1;
  217. margin-left: 20rpx;
  218. .shop-info{
  219. .shop-name{
  220. font-weight: 600;
  221. font-size: 36rpx;
  222. color: #222222;
  223. width: 100%;
  224. white-space: nowrap;
  225. overflow: hidden;
  226. text-overflow: ellipsis;
  227. }
  228. .address-box{
  229. display: flex;
  230. justify-content: space-between;
  231. align-items: center;
  232. font-weight: 300;
  233. font-size: 24rpx;
  234. color: #AAAAAA;
  235. margin-top: 25rpx;
  236. .address{
  237. width: 400rpx;
  238. white-space: nowrap;
  239. overflow: hidden;
  240. text-overflow: ellipsis;
  241. }
  242. }
  243. }
  244. .goods-list{
  245. display: flex;
  246. align-items: flex-start;
  247. margin-top: 20rpx;
  248. overflow: auto;
  249. width: calc(750rpx - 94rpx - 120rpx - 20rpx);
  250. .goods-item{
  251. display: inline-block;
  252. width: 160rpx;
  253. margin-right: 20rpx;
  254. .goods-name{
  255. margin-top: 20rpx;
  256. width: 100%;
  257. overflow: hidden;
  258. text-overflow: ellipsis;
  259. /* 弹性伸缩盒子模型显示 */
  260. display: -webkit-box;
  261. /* 限制在一个块元素显示的文本的行数 */
  262. -webkit-line-clamp: 2;
  263. /* 设置或检索伸缩盒对象的子元素的排列方式 */
  264. -webkit-box-orient: vertical;
  265. }
  266. }
  267. .price-box{
  268. display: flex;
  269. align-items: center;
  270. margin-top: 20rpx;
  271. .price{
  272. font-weight: 600;
  273. font-size: 28rpx;
  274. color: #FF4D3A;
  275. }
  276. .old-price{
  277. font-weight: 300;
  278. font-size: 20rpx;
  279. color: #AAAAAA;
  280. text-decoration: line-through;
  281. }
  282. }
  283. }
  284. }
  285. }
  286. }
  287. </style>