123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299 |
- <template>
- <view class="searchResult">
- <zs-choose-tab :tabList="tabList" @choose="chooseTab"></zs-choose-tab>
- <zs-list mt="0" @load="loadMore" :status="status">
- <view class="item" v-for="(item,index) in list" :key="index">
- <zs-img class="icon" :src="item.logoPath" radius="full" width="120rpx" height="120rpx" @click.native="goShopDetail(item)"></zs-img>
- <view class="shop-box">
- <view class="shop-info">
- <view class="shop-name" @click="goShopDetail(item)">
- {{item.shopVo.shopName}}
- </view>
- <view class="address-box">
- <view class="address">
- {{item.district}}
- </view>
- <view class="distance">
- {{(item.shopVo.distance/1000).toFixed(2)}}km
- </view>
- </view>
- </view>
-
- <!-- <view class="goods-list"> -->
- <scroll-view class="goods-list" enable-flex scroll-x="true">
- <view class="goods-item" v-for="(i,d) in item.goodsVos" :key="d" @click="goGoodsDetail(item,i)">
- <zs-img :src="i.goodsImg" width="160rpx" height="160rpx"></zs-img>
- <view class="goods-name">
- {{i.goodsName}}
- </view>
- <view class="price-box">
- <view class="price">
- ¥{{i.realPrice}}
- </view>
- <view class="old-price">
- ¥{{i.marketPrice}}
- </view>
- </view>
- </view>
-
- </scroll-view>
- <!-- </view> -->
- </view>
- </view>
- </zs-list>
- </view>
- </template>
- <script>
- import {
- search
- } from '@/api/shop.js';
- import {
- getMenu,
- } from '@/api/common.js'
- export default {
- data() {
- return {
- location:'',
- query: {
- district:'',
- pageCurrent: 1,
- pageSize: 10,
- 'location.lat': 0,
- 'location.lon': 0,
- range:'',
- queryName: ''
- },
- status: 'more',
- list: [],
- tabList: [{
- id: 1,
- label: '区域',
- list: [
-
- {
- id: 1,
- label: '观山湖'
- },
- {
- id: 2,
- label: '白云区'
- },
- {
- id: 3,
- label: '花果山区'
- }
- ]
- },
- {
- id: 1,
- label: '全部分类',
- list: []
- },
-
- {
- id: 1,
- label: '附近',
- list: [
- {
- id:5,
- label: '5KM'
- },
- {
- id:10,
- label: '10KM'
- },
- {
- id:20,
- label: '20KM'
- },
- {
- id:50,
- label: '50KM'
- }
- ]
- },
- ]
- }
- },
- methods: {
- goShopDetail(item) {
- let shopInfo = {
- shopId:item.shopVo.shopId,
- shopName:item.shopVo.shopName,
- detailContent:item.detailContent,
- logoPath:item.logoPath,
- }
- uni.setStorageSync('shopInfo', JSON.stringify(shopInfo))
- uni.navigateTo({
- url: '/detail/shopDetail/shopDetail'
- })
- },
- goGoodsDetail(item,i) {
- uni.setStorageSync('shopInfo', JSON.stringify(item))
- uni.reLaunch({
- url: `/detail/goodsDetail/index?id=${i.goodsId}`
- })
- },
- chooseTab(val) {
- console.log(val);
- this.query.range = val[2].id
- if(val[0]){
- // this.query['location.lat'] = val[0].location.lat
- // this.query['location.lon'] = val[0].location.lng
- this.query.range = 50
- this.query.district = val[0].label
- }else if(!val[0]){
- this.query['location.lat'] = this.location.latitude
- this.query['location.lon'] = this.location.longitude
- this.query.district = ''
- }
- if(val[1]){
- this.query.menuId = val[1].id
- }else if(!val[1]){
- this.query.menuId = ''
- }
- this.query.pageCurrent = 1
- this.status = 'more'
- this.list = []
- this.search()
- },
- search() {
- // if(this.status == 'noMore') return
- this.status = 'loading'
- let obj = JSON.parse(JSON.stringify(this.query))
- if(!obj.range){
- delete obj.range
- }
- search(obj).then(res => {
- if (res.state == 'Success') {
- this.list = this.list.concat(res.content.records)
- console.log(res.content.total>=this.list.length);
- if(res.content.total>this.list.length){
- this.status = 'more'
- }else{
- this.status = 'noMore'
- this.query.pageCurrent++
- }
- }
- })
- },
- loadMore() {
- this.search()
- },
- // 金刚区
- getMenu(){
- getMenu({currentPage:1,pageSize:10,status:2}).then(res=>{
- if(res.state == 'Success'){
- let list = []
- res.content.records.map(item => {
- list.push({
- id: item.id,
- label: item.menuName
- })
- })
- this.tabList[1].list = list
- }
- })
- },
- },
- onLoad(options) {
- this.tabList[0].list = JSON.parse(uni.getStorageSync('districtList'))
- this.location = JSON.parse(uni.getStorageSync('location'))
- this.query['location.lat'] = this.location.latitude
- this.query['location.lon'] = this.location.longitude
- this.query.queryName = options.search
- this.search()
- this.getMenu()
- }
- }
- </script>
- <style lang="scss" scoped>
- .searchResult{
- padding: 100rpx 24rpx 20rpx;
- background: #F9F9F9;
- .item{
- padding: 24rpx;
- background: #FFFFFF;
- border-radius: 16rpx 16rpx 16rpx 16rpx;
- display: flex;
- align-items: flex-start;
- margin-bottom: 20rpx;
-
- .icon{
- width: 120rpx;
- }
- .shop-box{
- flex: 1;
- margin-left: 20rpx;
- .shop-info{
- .shop-name{
- font-weight: 600;
- font-size: 36rpx;
- color: #222222;
- width: 100%;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- .address-box{
- display: flex;
- justify-content: space-between;
- align-items: center;
- font-weight: 300;
- font-size: 24rpx;
- color: #AAAAAA;
- margin-top: 25rpx;
- .address{
- width: 400rpx;
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- }
- }
- .goods-list{
- display: flex;
- align-items: flex-start;
- margin-top: 20rpx;
- overflow: auto;
- width: calc(750rpx - 94rpx - 120rpx - 20rpx);
- .goods-item{
- display: inline-block;
- width: 160rpx;
- margin-right: 20rpx;
- .goods-name{
- margin-top: 20rpx;
- width: 100%;
- overflow: hidden;
- text-overflow: ellipsis;
- /* 弹性伸缩盒子模型显示 */
- display: -webkit-box;
- /* 限制在一个块元素显示的文本的行数 */
- -webkit-line-clamp: 2;
- /* 设置或检索伸缩盒对象的子元素的排列方式 */
- -webkit-box-orient: vertical;
- }
- }
- .price-box{
- display: flex;
- align-items: center;
- margin-top: 20rpx;
- .price{
- font-weight: 600;
- font-size: 28rpx;
- color: #FF4D3A;
- }
- .old-price{
- font-weight: 300;
- font-size: 20rpx;
- color: #AAAAAA;
- text-decoration: line-through;
- }
- }
- }
- }
- }
- }
- </style>
|