searchResult.vue 6.6 KB

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