<template> <view class="container"> <view class="topNav flex"> <!-- <image @click="backIndex" class="back" src="../../static/icon/back.png" mode="widthFix"></image> --> <view class="inputbox flex"> <image class="search" src="../../static/icon/search.png" mode="widthFix"></image> <input class="input" confirm-type='搜索' @confirm='searchData' placeholder="请输入城市或者门店" type="text" v-model="search" /> </view> </view> <!-- <pickerAddress class="" @change="onCityClick"> <view class="address flex"> <view class="flex"> <text class="text">{{province}}</text> <image class="tipButtom" src="../../static/icon/dom.png" mode="widthFix"></image> </view> <view class="flex"> <text class="text">{{city}}</text> <image class="tipButtom" src="../../static/icon/dom.png" mode="widthFix"></image> </view> <view class="flex"> <text class="text">{{district}}</text> <image class="tipButtom" src="../../static/icon/dom.png" mode="widthFix"></image> </view> </view> </pickerAddress> --> <scroll-view class="list-scroll-content" scroll-y @scrolltolower="storeList"> <!-- 空白页 --> <!-- <empty v-if="loaded === true && orderList.length === 0"></empty> --> <!-- 订单列表 --> <view class="itemList"> <view class="item flex" v-for="(item,index) in orderList" :key='index' > <view class="imgBox"> <image class="logo" :src="item.image" mode="aspectFit"></image> </view> <view class="padding-l-20 flex-grow-true"> <view class="title clamp flex"> <view class="name"> {{item.name}} </view> <!-- <view class="km"> {{item.range<1?item.distance+'m':item.range+'km'}} </view> --> </view> <view class="list margin-t-20"> 营业时间:{{item.day_time}} </view> <view class="list"> 联系电话:{{item.phone}} </view> <view class="flex addressBox "> <image class="iconA margin-r-10" src="../../static/icon/shopAddress.png" mode="heightFix"> </image> <text class="clamp"> {{item.address}} </text> </view> </view> </view> </view> <uni-load-more :status="loadingType"></uni-load-more> </scroll-view> </view> </template> <script> import { storeList, } from '@/api/order.js'; import { mapMutations, mapState } from 'vuex'; export default { computed: { ...mapState('user', ['address']) }, data() { return { select: 0, search: '', //查询内容 loadingType: 'more', orderList: [], page: 1, //当前页数 limit: 10, //每次信息条数 province: '请选择', //省 city: '请选择', //市 district: '请选择', //区 loaded: false, type: 0 //默认为切换商店,1为不切换 }; }, onLoad: function(option) { console.log(option.type); if (option.type) { this.type = option.type; } if(option.select) { this.select = option.select; } this.storeList(); }, methods: { ...mapMutations('shop', ['setShopInfo']), toJSON() { return this; }, backIndex() { uni.switchTab({ url: '/pages/index/index' }) }, // 查询方法 searchData() { // 初始化数据重新搜索 this.loaded = false; this.page = 1; this.orderList = []; this.loadingType = 'more'; this.storeList() }, // 存储当前的门店 onChecked(item) { let that = this if(this.select == 0) { if (this.type == 0) { this.setShopInfo(item); uni.showToast({ title: '切换成功', mask: true, duration: 1500 }); setTimeout((e) => { uni.switchTab({ url: '/pages/index/index' }) }, 1500) } console.log(); // if (+this.type == 1) { // this.setShopInfo(item); // uni.navigateTo({ // url: '/pages/shop/shopIndex?id=' + item.id // }) // } }else { let prepage = that.$api.prePage(); prepage.selctStore = item uni.navigateBack() } }, storeList(source) { //这里是将订单挂载到tab列表下 let navItem = this; if (source === 'tabChange' && navItem.loaded === true) { //tab切换只有第一次需要加载数据 return; } if (navItem.loadingType === 'loading') { //防止重复加载 return; } if (navItem.loadingType === 'noMore') { //防止重复加载 return; } // 修改当前对象状态为加载中 navItem.loadingType = 'loading'; let city = `${this.province},${this.city},${this.district}`; if (this.province == '请选择') { city = ''; } storeList({ city, page: navItem.page, limit: navItem.limit, key: this.search, // latitude: this.address.latitude, // longitude: this.address.longitude, }) .then(({ data }) => { let arr = data.list.map(e => { return e; }); navItem.orderList = navItem.orderList.concat(arr); // console.log(navItem.orderList); navItem.page++; if (navItem.limit == arr.length) { //判断是否还有数据, 有改为 more, 没有改为noMore navItem.loadingType = 'more'; return; } else { //判断是否还有数据, 有改为 more, 没有改为noMore navItem.loadingType = 'noMore'; } uni.hideLoading(); this.$set(navItem, 'loaded', true); console.log(this, '结果'); }) .catch(e => { console.log(e); }); }, // 内容改变事件 onCityClick(item) { const arr = item.data; this.province = arr[0]; this.city = arr[1]; this.district = arr[2]; // 开始查询 console.log(this.province, this.city, this.district); console.log(arr); this.searchData() } }, }; </script> <style lang="scss"> page, .container { height: 100%; } /* #ifdef APP */ .container { padding-top: var(--status-bar-height); } /* #endif */ .list-scroll-content { height: calc(100% - 44px); position: relative; overflow: hidden; z-index: 100; } .itemList { padding: 30rpx $page-row-spacing; .item { background-color: #FFFFFF; margin-bottom: 30rpx; padding: 30rpx; border-radius: 20rpx; .list,.km{ color: $font-color-light; font-size: $font-sm; } .logo { height: 200rpx; width: 200rpx; border-radius: 20rpx; } .title { font-size: 36rpx; color: $font-color-dark; } .iconR { height: 24rpx; } .iconA { width: 24rpx; height: 24rpx; } .addressBox { font-size: 24rpx; color: $font-color-light; justify-content: flex-start; } } } .address { background-color: #FFFFFF; justify-content: space-around; height: 40px; .text { font-size: 22rpx; color: $font-color-dark; margin-right: 5px; } .tipButtom { width: 11px; } } .topNav { height: 44px; background-color: #FFFFFF; padding: 0 15px; /* #ifdef MP */ height:calc(44px + var(--status-bar-height)) ; padding-top: calc(var(--status-bar-height) - 15px); /* #endif */ .back { width: 13px; } .inputbox { background-color: $page-color-base; height: 15px; flex-grow: 1; margin-left: 15px; border-radius: 50px; height: 30px; padding-left: 20px; /* #ifdef MP */ margin-right: 200rpx; /* #endif */ font-size: $font-base; .search { width: 18px; } .input { height: 100%; width: 100%; text-align: left; padding-left: 10px; } } } </style>