searchResult.vue 6.6 KB

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