- 新增商家/信息详情页电话拨打接口,支持每日额度限制与拨打日志记录 - 新增平台免责声明内容及协议接口,完善用户服务协议相关配置 - 新增农产品分类图标与上市角标展示,优化分类管理界面样式 - 新增全国行政区划工具类与城市选择组件,重构地区数据结构 - 新增SSH自检与部署脚本,完善项目部署流程
266 行
6.9 KiB
Vue
266 行
6.9 KiB
Vue
<template>
|
||
<view v-if="visible" class="fc-cp" @click="$emit('close')" @touchmove.stop.prevent>
|
||
<view class="fc-cp__sheet" @click.stop>
|
||
<view class="fc-cp__handle"></view>
|
||
<slot name="header"></slot>
|
||
|
||
<!-- 全国省 / 市 两列联动直选面板(筛选只到市级,轻氧浅绿风格) -->
|
||
<view class="fc-cp__cascade">
|
||
<view class="fc-cp__cascade-head">
|
||
<text class="fc-cp__cascade-label fc-cp__cascade-label--prov">省份 / 全国</text>
|
||
<text class="fc-cp__cascade-label fc-cp__cascade-label--city">城市</text>
|
||
</view>
|
||
<view class="fc-cp__cascade-body">
|
||
<!-- 第一列:全国 + 省份 -->
|
||
<scroll-view class="fc-cp__col fc-cp__col--prov" scroll-y :show-scrollbar="false">
|
||
<view
|
||
class="fc-cp__item"
|
||
:class="{ 'fc-cp__item--active': activeProvince === '' }"
|
||
@click="onPickProvince('')"
|
||
>
|
||
<text class="fc-cp__text">全国</text>
|
||
<text v-if="activeProvince === ''" class="fc-cp__check">✓</text>
|
||
</view>
|
||
<view
|
||
v-for="p in tree"
|
||
:key="p.name"
|
||
class="fc-cp__item"
|
||
:class="{ 'fc-cp__item--active': activeProvince === p.name }"
|
||
@click="onPickProvince(p.name)"
|
||
>
|
||
<text class="fc-cp__text fc-ellipsis">{{ p.name }}</text>
|
||
</view>
|
||
</scroll-view>
|
||
|
||
<!-- 第二列:全部(全省) + 地级市/州 -->
|
||
<scroll-view class="fc-cp__col fc-cp__col--city" scroll-y :show-scrollbar="false">
|
||
<view
|
||
class="fc-cp__item"
|
||
:class="{ 'fc-cp__item--active': activeCity === '' }"
|
||
@click="onPickCity('')"
|
||
>
|
||
<text class="fc-cp__text">全部</text>
|
||
<text v-if="activeCity === ''" class="fc-cp__check">✓</text>
|
||
</view>
|
||
<view
|
||
v-for="c in cities"
|
||
:key="c.name"
|
||
class="fc-cp__item"
|
||
:class="{ 'fc-cp__item--active': activeCity === c.name }"
|
||
@click="onPickCity(c.name)"
|
||
>
|
||
<text class="fc-cp__text fc-ellipsis">{{ c.name }}</text>
|
||
</view>
|
||
</scroll-view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</view>
|
||
</template>
|
||
|
||
<script>
|
||
import { groupAreaTree } from '@/common/utils/area.js'
|
||
|
||
/**
|
||
* 城市选择底部抽屉(省 / 全国 → 市 两列级联,筛选只到市级)
|
||
*
|
||
* 数据源为平铺的 /home/areas 列表,组件内部按 省 > 市 分组;
|
||
* 点选「全国」或「全部(全省)」或具体城市时立即向上抛出 select 事件,
|
||
* payload 统一为 { province, city },空串表示全国 / 全省。
|
||
* header 插槽可用于放置标题、当前定位卡片等自定义内容。
|
||
*/
|
||
export default {
|
||
name: 'FcCityPicker',
|
||
props: {
|
||
// 是否显示抽屉
|
||
visible: { type: Boolean, default: false },
|
||
// 平铺服务区域:[{ id, province, city, district }]
|
||
areas: { type: Array, default: () => [] },
|
||
// 回显:当前选中省份(空串 = 全国)
|
||
province: { type: String, default: '' },
|
||
// 回显:当前选中城市(空串 = 全省/全国)
|
||
city: { type: String, default: '' },
|
||
},
|
||
data() {
|
||
return {
|
||
activeProvince: '',
|
||
activeCity: '',
|
||
}
|
||
},
|
||
computed: {
|
||
/** 平铺列表 → 省市级联树 */
|
||
tree() {
|
||
return groupAreaTree(this.areas || [])
|
||
},
|
||
/** 当前选中省份下的城市列表 */
|
||
cities() {
|
||
if (!this.activeProvince) return []
|
||
const prov = this.tree.find((p) => p.name === this.activeProvince)
|
||
return (prov && prov.cities) || []
|
||
},
|
||
},
|
||
watch: {
|
||
visible: {
|
||
handler(open) {
|
||
if (!open) return
|
||
// 打开时按当前选中值回显;缺省定位到第一个省份的首个城市
|
||
this.activeProvince = this.province || ''
|
||
this.activeCity = this.city || ''
|
||
if (!this.activeProvince && this.tree.length) {
|
||
this.activeProvince = this.tree[0].name
|
||
}
|
||
if (this.activeProvince && !this.activeCity) {
|
||
const prov = this.tree.find((p) => p.name === this.activeProvince)
|
||
this.activeCity = prov && prov.cities && prov.cities[0] ? prov.cities[0].name : ''
|
||
}
|
||
},
|
||
immediate: true,
|
||
},
|
||
},
|
||
methods: {
|
||
/**
|
||
* 点击第一列(全国或省份)
|
||
* @param {string} provName 省份名称(空串代表全国)
|
||
*/
|
||
onPickProvince(provName) {
|
||
this.activeProvince = provName || ''
|
||
if (!provName) {
|
||
// 全国:直接应用
|
||
this.$emit('select', { province: '', city: '' })
|
||
return
|
||
}
|
||
const prov = this.tree.find((p) => p.name === provName)
|
||
this.activeCity = prov && prov.cities && prov.cities[0] ? prov.cities[0].name : ''
|
||
},
|
||
/**
|
||
* 点击第二列(全部 = 全省,具体城市 = 全市)
|
||
* @param {string} cityName 城市名称(空串代表全省全部)
|
||
*/
|
||
onPickCity(cityName) {
|
||
this.activeCity = cityName || ''
|
||
this.$emit('select', { province: this.activeProvince, city: cityName || '' })
|
||
},
|
||
},
|
||
}
|
||
</script>
|
||
|
||
<style lang="scss" scoped>
|
||
.fc-cp {
|
||
position: fixed;
|
||
left: 0;
|
||
right: 0;
|
||
top: 0;
|
||
bottom: 0;
|
||
background: rgba(0, 0, 0, 0.45);
|
||
backdrop-filter: blur(4px);
|
||
z-index: 999;
|
||
display: flex;
|
||
flex-direction: column;
|
||
justify-content: flex-end;
|
||
animation: fcCpFade 0.22s ease-out;
|
||
}
|
||
.fc-cp__sheet {
|
||
background: #ffffff;
|
||
border-radius: 36rpx 36rpx 0 0;
|
||
padding: 20rpx 32rpx calc(48rpx + env(safe-area-inset-bottom));
|
||
animation: fcCpUp 0.26s cubic-bezier(0.16, 1, 0.3, 1);
|
||
box-shadow: 0 -8rpx 36rpx rgba(4, 48, 30, 0.12);
|
||
}
|
||
.fc-cp__handle {
|
||
width: 72rpx;
|
||
height: 8rpx;
|
||
background: #dcece3;
|
||
border-radius: 999rpx;
|
||
margin: 0 auto 24rpx;
|
||
}
|
||
|
||
/* 全国省/市 两列级联面板(薄荷容器 + 白色圆角列卡 + 柔绿选中态) */
|
||
.fc-cp__cascade {
|
||
background: #f2fef7;
|
||
border-radius: 24rpx;
|
||
padding: 24rpx 20rpx 20rpx;
|
||
}
|
||
.fc-cp__cascade-head {
|
||
display: flex;
|
||
margin-bottom: 16rpx;
|
||
}
|
||
.fc-cp__cascade-label {
|
||
font-size: 22rpx;
|
||
font-weight: 600;
|
||
color: $fc-text-muted;
|
||
padding-left: 24rpx;
|
||
box-sizing: border-box;
|
||
|
||
&--prov {
|
||
width: 40%;
|
||
}
|
||
&--city {
|
||
width: 60%;
|
||
}
|
||
}
|
||
.fc-cp__cascade-body {
|
||
display: flex;
|
||
height: 560rpx;
|
||
background: #ffffff;
|
||
border-radius: 20rpx;
|
||
overflow: hidden;
|
||
box-shadow: 0 4rpx 16rpx rgba(4, 48, 30, 0.05);
|
||
}
|
||
.fc-cp__col {
|
||
height: 100%;
|
||
box-sizing: border-box;
|
||
&--prov {
|
||
width: 40%;
|
||
background: #f7fcf9;
|
||
border-right: 1rpx solid #eef6f1;
|
||
}
|
||
&--city {
|
||
width: 60%;
|
||
background: #ffffff;
|
||
}
|
||
}
|
||
.fc-cp__item {
|
||
min-height: 80rpx;
|
||
margin: 6rpx 12rpx;
|
||
padding: 10rpx 18rpx;
|
||
display: flex;
|
||
align-items: center;
|
||
justify-content: space-between;
|
||
box-sizing: border-box;
|
||
border-radius: 14rpx;
|
||
transition: background-color 0.15s ease;
|
||
|
||
&--active {
|
||
background: linear-gradient(90deg, rgba(0, 210, 106, 0.14), rgba(0, 224, 112, 0.07));
|
||
|
||
.fc-cp__text {
|
||
color: #04874a;
|
||
font-weight: 700;
|
||
}
|
||
}
|
||
}
|
||
.fc-cp__text {
|
||
font-size: 26rpx;
|
||
color: $fc-text-regular;
|
||
flex: 1;
|
||
line-height: 1.5;
|
||
}
|
||
.fc-cp__check {
|
||
font-size: 26rpx;
|
||
color: #00c566;
|
||
font-weight: 700;
|
||
margin-left: 8rpx;
|
||
flex-shrink: 0;
|
||
}
|
||
|
||
/* 动效 */
|
||
@keyframes fcCpFade {
|
||
from { opacity: 0; }
|
||
to { opacity: 1; }
|
||
}
|
||
@keyframes fcCpUp {
|
||
from { transform: translateY(100%); }
|
||
to { transform: translateY(0); }
|
||
}
|
||
</style>
|