123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324 |
- <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' @click="onChecked(item)">
- <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/shop.js';
- import {
- mapMutations,
- mapState
- } from 'vuex';
- export default {
- computed: {
- ...mapState('user', ['address'])
- },
- data() {
- return {
- 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;
- }
- 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) {
- 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
- })
- }
- },
- 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>
|