2024-06-05 18:45:30 +08:00
|
|
|
<template>
|
|
|
|
<view class="multiple">
|
|
|
|
<view class="multiple-search">
|
|
|
|
<u-search v-model="queryParams.name" :animation="true" :showAction="false" bgColor="#f6f6f6"
|
|
|
|
placeholder="请输入门店"></u-search>
|
|
|
|
<view class="multiple-search-txt" @click.native="handleSearch">搜索</view>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
<view class="multiple-card">
|
|
|
|
<scroll-view :scroll-y="true" style="height:100%;" @scrolltolower="onReachBottom">
|
|
|
|
<view class="multiple-card-wrap" style="padding-top: 12rpx;">
|
|
|
|
<block v-for="(item,indx) in shopList" :key="indx">
|
|
|
|
<view class="multiple-card-item" :class="{active:currShop == item.id}"
|
2024-06-08 16:05:05 +08:00
|
|
|
@click="onChooseShop(item)">
|
2024-06-05 18:45:30 +08:00
|
|
|
<view class="multiple-card-item-left">
|
|
|
|
<view class="multiple-card-item-left-title">{{item.name}}</view>
|
|
|
|
<view class="multiple-card-item-left-tag">
|
|
|
|
<text class="yellow" v-if="item.is_store == 1">可自提</text>
|
|
|
|
<text class="green" v-if="item.is_send == 1">可配送</text>
|
|
|
|
</view>
|
|
|
|
<view class="multiple-card-item-left-info">
|
2024-06-09 20:32:49 +08:00
|
|
|
<u-image src="../../multipleShop/images/location_small.jpg" width="24rpx"
|
2024-06-05 18:45:30 +08:00
|
|
|
height="24rpx" />
|
|
|
|
<text>{{item.detailed_address || '-'}}</text>
|
|
|
|
</view>
|
|
|
|
<view class="multiple-card-item-left-info">
|
2024-06-09 20:32:49 +08:00
|
|
|
<u-image src="../../multipleShop/images/time.jpg" width="24rpx" height="24rpx" />
|
2024-06-05 18:45:30 +08:00
|
|
|
<text
|
|
|
|
v-if="item.day_start && item.day_end">{{item.day_start + '-' + item.day_end}}</text>
|
|
|
|
<text v-else>9:00-18:00</text>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="multiple-card-item-right">
|
|
|
|
<view class="multiple-card-item-right-distance">距离{{parseDistance(item.distance)}}
|
|
|
|
</view>
|
|
|
|
<view class="multiple-card-item-right-icon">
|
|
|
|
<view style="margin-right: 30rpx;" @click.stop="onPhoneCall(item.phone)">
|
2024-06-09 20:32:49 +08:00
|
|
|
<u-image src="../../multipleShop/images/phone.jpg" width="48rpx"
|
2024-06-05 18:45:30 +08:00
|
|
|
height="48rpx" />
|
|
|
|
</view>
|
|
|
|
<view @click.stop="onNavgation(item)">
|
2024-06-09 20:32:49 +08:00
|
|
|
<u-image src="../../multipleShop/images/location.jpg" width="48rpx"
|
2024-06-05 18:45:30 +08:00
|
|
|
height="48rpx" />
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</block>
|
|
|
|
</view>
|
|
|
|
|
2024-06-06 17:50:25 +08:00
|
|
|
<up-loadmore :status="status" iconColor="#b3b3b3" color="#b3b3b3" />
|
2024-06-05 18:45:30 +08:00
|
|
|
</scroll-view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import {
|
|
|
|
reactive,
|
|
|
|
ref,
|
|
|
|
} from "vue";
|
|
|
|
import {
|
|
|
|
shopListApi
|
|
|
|
} from "@/api/multipleShop.js";
|
|
|
|
import {
|
|
|
|
onLoad,
|
|
|
|
onShow
|
|
|
|
} from "@dcloudio/uni-app";
|
|
|
|
|
|
|
|
const currShop = ref(''); // 选择门店
|
|
|
|
const shopList = ref([]); // 门店列表
|
|
|
|
const status = ref(''); // 滚动状态
|
|
|
|
|
|
|
|
// 查询参数
|
|
|
|
const queryParams = reactive({
|
|
|
|
longitude: '',
|
|
|
|
latitude: '',
|
|
|
|
phone: '',
|
|
|
|
name: '',
|
|
|
|
page_no: 1,
|
|
|
|
page_size: 6
|
|
|
|
})
|
|
|
|
|
|
|
|
// 初始化
|
|
|
|
onLoad(() => {
|
|
|
|
// 获取定位
|
|
|
|
getLocation();
|
|
|
|
});
|
|
|
|
|
|
|
|
// 门店选择
|
2024-06-08 16:05:05 +08:00
|
|
|
const onChooseShop = (item) => {
|
2024-06-18 19:03:33 +08:00
|
|
|
return
|
2024-06-08 16:05:05 +08:00
|
|
|
currShop.value = item.id;
|
2024-06-15 18:41:12 +08:00
|
|
|
uni.setStorageSync('STORE_INFO', JSON.stringify(item));
|
|
|
|
// 如果选择了新店铺,删除之前的分享信息
|
|
|
|
uni.removeStorageSync('SHARE_INFO');
|
2024-06-05 18:45:30 +08:00
|
|
|
setTimeout(() => {
|
|
|
|
uni.reLaunch({
|
2024-06-08 16:05:05 +08:00
|
|
|
url: '/pages/index/index?id=' + item.id,
|
2024-06-05 18:45:30 +08:00
|
|
|
fail(err) {
|
|
|
|
console.log(err);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}, 300)
|
|
|
|
}
|
|
|
|
|
|
|
|
// 触底刷新
|
|
|
|
const onReachBottom = () => {
|
|
|
|
getShopList();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 搜索
|
|
|
|
const handleSearch = () => {
|
2024-06-15 18:41:12 +08:00
|
|
|
if (!queryParams.latitude || !queryParams.longitude) return;
|
2024-06-05 18:45:30 +08:00
|
|
|
shopList.value = [];
|
|
|
|
queryParams.page_no = 1;
|
|
|
|
status.value = '';
|
|
|
|
getShopList();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取门店
|
|
|
|
const getShopList = () => {
|
|
|
|
if (status.value == 'nomore') return;
|
|
|
|
if (status.value == 'loading') return;
|
|
|
|
|
|
|
|
status.value == 'loading';
|
|
|
|
shopListApi(queryParams).then(res => {
|
|
|
|
let len = res.data.lists;
|
2024-06-06 17:50:25 +08:00
|
|
|
status.value = queryParams.page_size > len.length ? 'nomore' : 'loadmore';
|
2024-06-05 18:45:30 +08:00
|
|
|
shopList.value = shopList.value.concat(res.data.lists);
|
|
|
|
if (status.value == 'loadmore') queryParams.page_no += 1;
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 门店距离处理
|
|
|
|
const parseDistance = (e) => {
|
|
|
|
if (!e) return '-';
|
|
|
|
if (e > 1) {
|
|
|
|
return (e.toFixed(1)) + 'km';
|
|
|
|
} else {
|
|
|
|
return (e * 1000).toFixed(0) + 'm';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 拨打门店电话
|
|
|
|
const onPhoneCall = (phone) => {
|
|
|
|
if (!phone) return;
|
|
|
|
uni.makePhoneCall({
|
|
|
|
phoneNumber: phone
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 导航
|
|
|
|
const onNavgation = (item) => {
|
|
|
|
uni.openLocation({
|
|
|
|
latitude: Number(item.latitude),
|
|
|
|
longitude: Number(item.longitude),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// 获取定位
|
|
|
|
const getLocation = () => {
|
|
|
|
let location = uni.getStorageSync('location');
|
|
|
|
if (location) {
|
2024-06-18 19:03:33 +08:00
|
|
|
queryParams.longitude = location.lat
|
|
|
|
queryParams.latitude = location.long
|
2024-06-05 18:45:30 +08:00
|
|
|
// 加载店铺列表
|
|
|
|
getShopList();
|
|
|
|
} else {
|
|
|
|
uni.getLocation({
|
|
|
|
type: "gcj02",
|
|
|
|
success(res) {
|
|
|
|
queryParams.latitude = res.latitude;
|
|
|
|
queryParams.longitude = res.longitude;
|
|
|
|
|
|
|
|
// 加载店铺列表
|
|
|
|
getShopList();
|
|
|
|
|
|
|
|
// 避免下次再获取
|
2024-06-18 19:03:33 +08:00
|
|
|
uni.setStorageSync('location', {
|
|
|
|
lat: queryParams.latitude,
|
|
|
|
long: queryParams.longitude
|
|
|
|
})
|
2024-06-05 18:45:30 +08:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
2024-06-03 18:25:34 +08:00
|
|
|
<style lang="scss">
|
|
|
|
page {
|
|
|
|
background: #FAFAFA;
|
|
|
|
}
|
|
|
|
|
|
|
|
.multiple {
|
|
|
|
padding-bottom: 30rpx;
|
|
|
|
|
|
|
|
.multiple-search {
|
|
|
|
position: sticky;
|
|
|
|
top: 0;
|
|
|
|
z-index: 10;
|
|
|
|
display: flex;
|
|
|
|
height: 90rpx;
|
|
|
|
background-color: #fff;
|
|
|
|
padding: 0 24rpx;
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
|
|
|
.multiple-search-txt {
|
|
|
|
position: absolute;
|
|
|
|
right: 28rpx;
|
|
|
|
top: 50%;
|
2024-06-05 18:45:30 +08:00
|
|
|
z-index: 11;
|
2024-06-03 18:25:34 +08:00
|
|
|
transform: translateY(-50%);
|
|
|
|
width: 110rpx;
|
|
|
|
height: 52rpx;
|
|
|
|
line-height: 52rpx;
|
|
|
|
text-align: center;
|
|
|
|
background: #FFFFFF;
|
|
|
|
border-radius: 30rpx 30rpx 30rpx 30rpx;
|
|
|
|
font-size: 28rpx;
|
|
|
|
color: #20B128;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.multiple-card {
|
2024-06-05 18:45:30 +08:00
|
|
|
height: calc(100vh - 90rpx);
|
|
|
|
padding-bottom: 12rpx;
|
|
|
|
|
|
|
|
.u-loadmore {
|
|
|
|
padding-bottom: 40rpx;
|
|
|
|
}
|
2024-06-03 18:25:34 +08:00
|
|
|
|
|
|
|
.multiple-card-item {
|
|
|
|
display: flex;
|
|
|
|
background: #FFFFFF;
|
|
|
|
border-radius: 16rpx;
|
|
|
|
margin: 0 24rpx 20rpx;
|
|
|
|
padding: 30rpx 0 42rpx 30rpx;
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
.multiple-card-item-left {
|
|
|
|
width: 70%;
|
|
|
|
border-right: 2rpx solid #F1F1F1;
|
|
|
|
|
|
|
|
.multiple-card-item-left-title {
|
|
|
|
margin-bottom: 14rpx;
|
|
|
|
font-weight: bold;
|
|
|
|
font-size: 28rpx;
|
|
|
|
color: #444444;
|
2024-06-05 18:45:30 +08:00
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
2024-06-03 18:25:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
.multiple-card-item-left-tag {
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
align-items: center;
|
|
|
|
margin-bottom: 16rpx;
|
|
|
|
|
|
|
|
text {
|
|
|
|
width: 90rpx;
|
|
|
|
height: 42rpx;
|
|
|
|
line-height: 42rpx;
|
|
|
|
text-align: center;
|
|
|
|
border-radius: 8rpx;
|
|
|
|
font-size: 24rpx;
|
|
|
|
margin-right: 16rpx;
|
|
|
|
padding: 4rpx 10rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.yellow {
|
|
|
|
background-color: #FFF8F1;
|
|
|
|
color: #FFB76D;
|
|
|
|
}
|
|
|
|
|
|
|
|
.green {
|
|
|
|
color: #20B128;
|
|
|
|
background-color: #F2FFF3;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.multiple-card-item-left-info {
|
|
|
|
display: flex;
|
2024-06-05 18:45:30 +08:00
|
|
|
padding-right: 10rpx;
|
2024-06-03 18:25:34 +08:00
|
|
|
|
|
|
|
&:nth-child(1) {
|
2024-06-05 18:45:30 +08:00
|
|
|
margin-bottom: 16rpx;
|
2024-06-03 18:25:34 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
text {
|
|
|
|
font-weight: 400;
|
|
|
|
font-size: 24rpx;
|
|
|
|
color: #777777;
|
|
|
|
margin-left: 4rpx;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.multiple-card-item-right {
|
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
width: 30%;
|
2024-06-05 18:45:30 +08:00
|
|
|
flex-shrink: 0;
|
2024-06-03 18:25:34 +08:00
|
|
|
|
|
|
|
.multiple-card-item-right-distance {
|
|
|
|
margin-bottom: 20rpx;
|
|
|
|
font-size: 22rpx;
|
|
|
|
color: #777777;
|
|
|
|
}
|
|
|
|
|
|
|
|
.multiple-card-item-right-icon {
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
.active {
|
|
|
|
position: relative;
|
|
|
|
border: 2rpx solid #20B128;
|
|
|
|
|
|
|
|
&::after {
|
|
|
|
content: "";
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
right: -34rpx;
|
|
|
|
bottom: -8rpx;
|
|
|
|
width: 0;
|
|
|
|
height: 0;
|
|
|
|
border-left: 50rpx solid transparent;
|
|
|
|
border-right: 50rpx solid transparent;
|
|
|
|
border-bottom: 50rpx solid #20B128;
|
|
|
|
transform: rotate(135deg);
|
|
|
|
}
|
|
|
|
|
|
|
|
&::before {
|
|
|
|
content: "√";
|
|
|
|
display: block;
|
|
|
|
|
|
|
|
position: absolute;
|
|
|
|
right: 10rpx;
|
|
|
|
bottom: 4rpx;
|
|
|
|
color: #fff;
|
|
|
|
z-index: 11;
|
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-06-05 18:45:30 +08:00
|
|
|
</style>
|