feat: 新增地址选择插件及订阅消息等多项功能优化

- 新增地址选择插件,支持地图位置选择并返回地址和经纬度
- 新增微信订阅消息发送功能,支持审核结果、提现通知等场景
- 新增订单支付状态查询、提现收款人姓名保存等接口
- 新增服务区域管理,支持按省市区划分并同步到信息发布
- 新增资金流水和营收报表导出功能
- 新增可用优惠券查询、订单退款拆分处理等功能
- 优化后台角标显示、首页数据统计、UI配置下发等
- 修复订单支付并发问题、地区管理逻辑等
这个提交包含在:
2026-10-22 17:14:56 +08:00
父节点 088a08d43a
当前提交 cb12bf5fc8
共有 180 个文件被更改,包括 9695 次插入 和 1680 次删除

查看文件

@@ -7,7 +7,7 @@
<view class="admin__card">
<view class="admin__card-head">
<text class="admin__card-title">站点信息</text>
<text class="admin__card-tip">LOGO 会同步应用到小程序首页左上角、登录页、我的页与后台顶部</text>
<text class="admin__card-tip">LOGO 会同步应用到小程序首页、登录页与我的页</text>
</view>
<view class="admin__logo-row">
<view class="admin__logo-box">
@@ -165,10 +165,10 @@ export default {
success: async (r) => {
if (!r.confirm) return
try {
await adminApi.resetUiSetting()
const cfg = await adminApi.resetUiSetting()
this.form.logo = ''
this.form.icons = {}
applyUiConfig({ siteName: this.form.siteName })
applyUiConfig(cfg)
uni.showToast({ title: '已恢复默认', icon: 'none' })
} catch (e) {
uni.showToast({ title: e.message, icon: 'none' })

查看文件

@@ -22,7 +22,7 @@
<!-- 底部提示 -->
<view class="agreement__footer">
<text class="agreement__footer-text">同城分类信息便民平台 版权所有</text>
<text class="agreement__footer-text">{{ siteName }}便民平台 版权所有</text>
</view>
</view>
</view>
@@ -35,6 +35,7 @@
* 支持在后台配置内容,根据入参 type 动态渲染「用户协议」或「隐私政策」
*/
import settingApi from '@/common/api/setting.js'
import { loadUiConfig, uiState } from '@/common/store/ui.js'
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
export default {
@@ -56,6 +57,10 @@ export default {
pageTitle() {
return this.type === 'privacy' ? '隐私政策' : '用户协议'
},
/** 站点名称(后台「小程序配置」下发) */
siteName() {
return uiState.siteName || uiState.appName || '同城分类信息'
},
},
/**
* 页面加载生命周期
@@ -65,6 +70,7 @@ export default {
if (query && query.type) {
this.type = query.type
}
loadUiConfig()
this.fetchAgreement()
},
/**

查看文件

@@ -20,9 +20,15 @@
:class="{ 'list__filter--active': sort === s.value }" @click="changeSort(s.value)">
<text>{{ s.label }}</text>
</view>
<view class="list__filter list__filter--right" @click="showArea = true">
<text>{{ area || '区域 ▾' }}</text>
</view>
<fc-area-picker
class="list__filter-area"
:areas="areaRows"
:value="areaId"
allow-all
variant="chip"
placeholder="区域"
@change="onAreaChange"
/>
</view>
<!-- 骨架屏加载 -->
@@ -44,19 +50,6 @@
<view class="list__fab" @click="goCreate">
<text>+ 发布</text>
</view>
<!-- 区域筛选弹层 -->
<view v-if="showArea" class="list__mask" @click="showArea = false">
<view class="list__sheet" @click.stop>
<text class="list__sheet-title">选择区域</text>
<view class="list__sheet-list">
<view v-for="a in areaOptions" :key="a" class="list__sheet-item"
:class="{ 'list__sheet-item--active': area === a }" @click="pickArea(a)">
<text>{{ a }}</text>
</view>
</view>
</view>
</view>
</view>
</template>
@@ -64,11 +57,12 @@
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
import FcPostCard from '@/components/fc-post-card/fc-post-card.vue'
import FcEmpty from '@/components/fc-empty/fc-empty.vue'
import FcAreaPicker from '@/components/fc-area-picker/fc-area-picker.vue'
import homeApi from '@/common/api/home.js'
import { iconUrl, categoryIconUrl, catIcon, loadUiConfig } from '@/common/store/ui.js'
export default {
components: { FcNavbar, FcPostCard, FcEmpty },
components: { FcNavbar, FcPostCard, FcEmpty, FcAreaPicker },
data() {
return {
categories: [],
@@ -81,11 +75,17 @@ export default {
size: 10,
hasMore: true,
loading: false,
// 请求序号:快速切换分类/排序/区域时丢弃过期响应
reqSeq: 0,
sort: 'new',
area: '',
showArea: false,
// 区域选项由后台「区域管理」下发(/home/areas)
areaOptions: [],
// 区域筛选:业务只按服务区域(区县)筛选
areaId: 0,
areaText: '',
manualArea: false,
lat: null,
lng: null,
// 平铺服务区域(每条自带省/市/区县)
areaRows: [],
sorts: [
{ label: '最新', value: 'new' },
{ label: '最热', value: 'hot' },
@@ -141,18 +141,52 @@ export default {
}
} catch (e) {}
}
// 区域筛选项:后台「区域管理」下发,失败静默(不影响信息流)
// 服务区域:后台「区域管理」下发(平铺:每条自带省/市/区县),失败静默
try {
const areas = await homeApi.areas()
if (Array.isArray(areas) && areas.length) this.areaOptions = areas
const rows = await homeApi.areas()
this.areaRows = Array.isArray(rows) ? rows : []
} catch (e) {}
this.fetch(true)
// LBS:按定位匹配默认区域(失败/无权限静默,不阻塞列表)
this.fetchLocation()
},
/**
* 取用户坐标并匹配区域(gcj02)
*/
fetchLocation() {
if (typeof uni === 'undefined' || !uni.getLocation) return
uni.getLocation({
type: 'gcj02',
success: (res) => {
this.lat = res.latitude
this.lng = res.longitude
this.applyLocationArea().finally(() => {
this.page = 1
this.fetch(true)
})
},
fail: () => {},
})
},
/**
* 把定位坐标转换成区域筛选默认值(用户手动切换过则不覆盖)
*/
async applyLocationArea() {
if (this.manualArea || this.lat == null || this.lng == null) return
try {
const found = await homeApi.locate({ lat: this.lat, lng: this.lng })
if (found && found.areaId) {
this.areaId = Number(found.areaId) || 0
this.areaText = found.district || ''
}
} catch (e) {}
},
/**
* 分页获取分类信息列表
* @param {boolean} reset 是否重置分页重新拉取第一页
*/
async fetch(reset = false) {
const seq = ++this.reqSeq
this.loading = true
try {
const res = await homeApi.feed({
@@ -160,14 +194,17 @@ export default {
size: this.size,
categoryId: this.categoryId || undefined,
sort: this.sort,
area: this.area || undefined,
areaId: this.areaId || undefined,
})
// 期间又切换了筛选条件:以最后一次请求为准
if (seq !== this.reqSeq) return
this.list = reset ? res.list : this.list.concat(res.list)
this.hasMore = res.hasMore
} catch (e) {
if (seq !== this.reqSeq) return
uni.showToast({ title: '加载失败', icon: 'none' })
} finally {
this.loading = false
if (seq === this.reqSeq) this.loading = false
}
},
/**
@@ -198,15 +235,22 @@ export default {
this.fetch(true)
},
/**
* 选择特定区域筛选信息
* @param {string} a 选中的区域名称
* 级联选择服务区域(null = 全部区域)
* @param {Object|null} area
*/
pickArea(a) {
this.area = this.area === a ? '' : a
this.showArea = false
onAreaChange(area) {
this.areaId = area ? Number(area.areaId) || 0 : 0
this.areaText = area ? area.district || '' : ''
this.manualArea = true
this.page = 1
this.fetch(true)
},
/** 使用当前位置:清除手动选择,重新定位并匹配区域 */
useCurrentLocation() {
this.manualArea = false
this.fetchLocation()
uni.showToast({ title: '已按当前位置匹配', icon: 'none' })
},
/**
* 跳转到信息详情页
* @param {Object} p 信息项
@@ -298,10 +342,9 @@ export default {
color: $fc-primary-text;
font-weight: 700;
}
&--right {
margin-left: auto;
margin-right: 0;
}
}
.list__filter-area {
margin-left: auto;
}
.list__loading {
padding: 24rpx;
@@ -328,50 +371,4 @@ export default {
font-weight: 700;
box-shadow: 0 10rpx 28rpx rgba(4, 48, 30, 0.4);
}
.list__mask {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 200;
background: rgba(4, 48, 42, 0.5);
display: flex;
align-items: flex-end;
}
.list__sheet {
width: 100%;
background: #ffffff;
border-radius: 32rpx 32rpx 0 0;
padding: 36rpx 32rpx 60rpx;
}
.list__sheet-title {
display: block;
text-align: center;
font-size: $fc-font-lg;
font-weight: 700;
margin-bottom: 28rpx;
}
.list__sheet-list {
display: flex;
flex-wrap: wrap;
}
.list__sheet-item {
width: 30%;
margin: 0 1.5% 20rpx;
height: 76rpx;
border-radius: $fc-radius;
background: $fc-bg;
display: flex;
align-items: center;
justify-content: center;
font-size: $fc-font;
color: $fc-text-regular;
&--active {
background: $fc-primary-lighter;
color: $fc-primary-text;
font-weight: 700;
border: 2rpx solid $fc-primary-text;
}
}
</style>

查看文件

@@ -128,6 +128,8 @@ export default {
total: 0,
hasMore: true,
loading: false,
// 请求序号:切换分类/排序/搜索时丢弃过期响应,避免「点了筛选但列表没变」
reqSeq: 0,
lat: null,
lng: null,
}
@@ -174,6 +176,13 @@ export default {
success: (res) => {
this.lat = res.latitude
this.lng = res.longitude
// 定位晚于「附近」点击返回时,坐标到手后重排一次
if (this.sort === 'nearby' && this.currentCategory) {
this.page = 1
this.list = []
this.hasMore = true
this.fetchPosts()
}
},
fail: () => {},
})
@@ -219,12 +228,18 @@ export default {
this.list = []
this.hasMore = true
this.fetchPosts()
// 「附近」依赖坐标:无坐标时补取一次定位(成功后自动重排)
if (s === 'nearby' && (!this.lat || !this.lng)) {
uni.showToast({ title: '正在获取定位…', icon: 'none' })
this.initLocation()
}
},
/**
* 获取当前分类下的信息列表(支持关键字在当前页面直接检索)
*/
async fetchPosts() {
if (this.loading || !this.currentCategory) return
if (!this.currentCategory) return
const seq = ++this.reqSeq
this.loading = true
try {
const params = {
@@ -241,14 +256,17 @@ export default {
params.lng = this.lng
}
const res = await homeApi.feed(params)
// 期间又切换了分类/排序/搜索:以最后一次请求为准
if (seq !== this.reqSeq) return
const rows = (res && res.list) || []
this.list = this.page === 1 ? rows : this.list.concat(rows)
this.total = (res && res.total) || 0
this.hasMore = res ? !!res.hasMore : false
} catch (e) {
if (seq !== this.reqSeq) return
uni.showToast({ title: '加载信息失败', icon: 'none' })
} finally {
this.loading = false
if (seq === this.reqSeq) this.loading = false
}
},
/**

查看文件

@@ -216,8 +216,8 @@ import postApi from '@/common/api/post.js'
import favoriteApi from '@/common/api/favorite.js'
import reportApi from '@/common/api/report.js'
import { REPORT_REASONS } from '@/common/constants/report.js'
import { iconUrl, categoryIconUrl, loadUiConfig } from '@/common/store/ui.js'
import { fromNow, maskPhone } from '@/common/utils/format.js'
import { iconUrl, categoryIconUrl, loadUiConfig, uiState } from '@/common/store/ui.js'
import { fromNow } from '@/common/utils/format.js'
import { pay } from '@/common/utils/pay.js'
import { useUserStore } from '@/common/store/index.js'
import config from '@/common/config/index.js'
@@ -245,6 +245,8 @@ export default {
// 支付/提交中:防连点重复下单(余额支付是即时扣款)
submitting: false,
activeSwiperIndex: 0,
// 首次详情已加载(用于返回页面时只刷新解锁态,不重复拉整页)
loaded: false,
}
},
computed: {
@@ -275,6 +277,23 @@ export default {
loadUiConfig()
this.fetch()
},
/** 从会员中心 / 登录页返回时,刷新解锁态(已开通会员应立即能看到联系方式) */
onShow() {
if (this.loaded) this.refreshAccess()
},
/** 转发:优先用信息标题,否则用后台分享标题 */
onShareAppMessage() {
return {
title: (this.post && this.post.title) || uiState.shareTitle || uiState.siteName || '同城分类信息',
path: '/pages/detail/detail?id=' + this.id,
}
},
onShareTimeline() {
return {
title: (this.post && this.post.title) || uiState.shareTitle || uiState.siteName || '同城分类信息',
query: 'id=' + this.id,
}
},
methods: {
iconUrl,
catIcon() {
@@ -291,7 +310,9 @@ export default {
} catch (e) {
this.comments = []
}
this.contact = { phone: maskPhone(res.contact), wechat: '' }
// 解锁态由后端判定(会员 / 已付费 / 本人发布),不再只依赖本地点击
this.applyAccess(res)
this.loaded = true
// 契约:详情出参已带 faved/followed,先用返回值回显;
// 兼容旧后端:缺失时再用 /favorite/status 批量回显。
this.faved = !!res.faved
@@ -312,6 +333,26 @@ export default {
return false
}
},
/**
* 应用详情接口返回的解锁态:
* 后端按「会员有效期内 / 已付费解锁 / 本人发布」返回 unlocked=true + 明文联系方式,
* 其余情况返回脱敏串,前端据此决定显示「已受保护」还是联系方式。
*/
applyAccess(res) {
this.unlocked = !!(res && res.unlocked)
this.contact = this.unlocked
? { phone: (res && res.contact) || '', wechat: (res && res.wechat) || '' }
: { phone: '', wechat: '' }
},
/** 返回详情页时只刷新解锁态(例如刚在会员中心开通完会员) */
async refreshAccess() {
try {
const res = await postApi.detail(this.id, { accessOnly: 1 })
this.applyAccess(res)
} catch (e) {
// 静默失败,保持现有展示
}
},
/** 进入详情时回显收藏 / 关注状态(失败静默,保持默认状态) */
async loadInteractStatus() {
const publisherId = this.post.publisher && this.post.publisher.id

查看文件

@@ -202,8 +202,14 @@
</view>
<text class="dist__record-time">{{ timeText(w.createdAt) }}</text>
<text class="dist__record-no fc-ellipsis">单号 {{ w.withdrawNo }}</text>
<text v-if="w.status === 'failed' && w.failReason" class="dist__record-no fc-ellipsis">失败原因:{{ w.failReason }}</text>
</view>
<view class="dist__record-right">
<text class="dist__record-amount">-¥{{ money(w.amount) }}</text>
<view v-if="w.status === 'paying'" class="dist__record-action" @click="confirmTransfer(w)">
<text>{{ w.transferStatus === 'WAIT_USER_CONFIRM' ? '去确认收款' : '转账中' }}</text>
</view>
</view>
<text class="dist__record-amount">-¥{{ money(w.amount) }}</text>
</view>
<view v-if="records.length > 5" class="dist__more" @click="recordsExpanded = !recordsExpanded">
@@ -231,6 +237,17 @@
<text class="dist__sheet-balance-num">{{ money(overview.withdrawable) }}</text>
</view>
<view v-if="!realname" class="dist__sheet-field">
<input
v-model="realnameInput"
class="dist__sheet-input dist__sheet-input--name"
type="text"
maxlength="20"
placeholder="收款人真实姓名(需与微信实名一致)"
placeholder-class="dist__sheet-placeholder"
/>
</view>
<view class="dist__sheet-field">
<text class="dist__sheet-symbol">¥</text>
<input
@@ -276,9 +293,11 @@
<script>
import distributionApi from '@/common/api/distribution.js'
import authApi from '@/common/api/auth.js'
import { WITHDRAW_TEXT } from '@/common/constants/ui.js'
import { fromNow } from '@/common/utils/format.js'
import { iconUrl, loadUiConfig } from '@/common/store/ui.js'
import { requestSubscribe } from '@/common/utils/subscribe.js'
import { iconUrl, loadUiConfig, uiState } from '@/common/store/ui.js'
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
export default {
@@ -293,6 +312,9 @@ export default {
minWithdraw: 50,
showWithdraw: false,
withdrawAmount: '',
// 收款人实名(提现转账用;为空时弹层内采集)
realname: '',
realnameInput: '',
submitting: false,
loading: true,
loadError: false,
@@ -376,7 +398,7 @@ export default {
onShareAppMessage() {
const code = this.overview.inviteCode || ''
return {
title: '同城分类信息 · 本地生活便民服务',
title: uiState.shareTitle || uiState.siteName || '同城分类信息',
path: '/pages/index/index?ic=' + encodeURIComponent(code),
}
},
@@ -386,7 +408,7 @@ export default {
onShareTimeline() {
const code = this.overview.inviteCode || ''
return {
title: '同城分类信息 · 本地生活便民服务',
title: uiState.shareTitle || uiState.siteName || '同城分类信息',
query: 'ic=' + encodeURIComponent(code),
}
},
@@ -410,6 +432,9 @@ export default {
if (overview && overview.minWithdraw != null) {
this.minWithdraw = Number(overview.minWithdraw) || 0
}
if (overview && overview.realname != null) {
this.realname = String(overview.realname)
}
} catch (e) {
this.loadError = true
uni.showToast({ title: '分销数据加载失败', icon: 'none' })
@@ -563,8 +588,8 @@ export default {
try {
navigator
.share({
title: '同城分类信息 · 本地生活便民服务',
text: '邀请你加入同城分类信息,发布、找工作、找房子都方便',
title: uiState.shareTitle || uiState.siteName || '同城分类信息 · 本地生活便民服务',
text: `邀请你加入${uiState.siteName || '同城分类信息'},发布、找工作、找房子都方便`,
url: this.inviteLink,
})
.catch((err) => {
@@ -603,6 +628,30 @@ export default {
this.showWithdraw = true
},
/**
* 拉起微信「确认收款」页(商家转账 · 用户确认模式)
*/
confirmTransfer(w) {
if (!w || !w.packageInfo) {
uni.showToast({ title: '转账处理中,请在微信消息中确认收款', icon: 'none' })
return
}
if (typeof uni === 'undefined' || !uni.requestMerchantTransfer) {
uni.showToast({ title: '请在微信消息中确认收款', icon: 'none' })
return
}
uni.requestMerchantTransfer({
mchId: (this.overview && this.overview.transferMchId) || '',
appId: (this.overview && this.overview.transferAppId) || '',
package: w.packageInfo,
success: () => {
uni.showToast({ title: '已确认,等待到账', icon: 'none' })
setTimeout(() => this.refreshAfterWithdraw(), 1500)
},
fail: () => uni.showToast({ title: '已取消确认', icon: 'none' }),
})
},
/**
* 关闭提现弹层
*/
@@ -624,8 +673,7 @@ export default {
*/
async submitWithdraw() {
if (this.submitting) return
if (!this.canSubmit) {
const amount = Number(this.withdrawAmount)
if (!this.canSubmit) { const amount = Number(this.withdrawAmount)
if (!amount || amount <= 0) {
uni.showToast({ title: '请输入提现金额', icon: 'none' })
} else if (amount < Number(this.minWithdraw || 0)) {
@@ -636,8 +684,27 @@ export default {
return
}
// 订阅消息授权(提现到账);未配置模板时静默跳过
await requestSubscribe('transfer')
this.submitting = true
try {
// 未填写收款人实名:先采集并保存(微信商家转账会校验实名)
if (!this.realname) {
const name = String(this.realnameInput || '').trim()
if (!/^[\u4e00-\u9fa5·]{2,20}$/.test(name)) {
uni.showToast({ title: '请填写 2-20 位中文真实姓名', icon: 'none' })
return
}
try {
await authApi.saveRealname({ realname: name })
this.realname = name
} catch (e) {
uni.showToast({ title: e.message || '姓名保存失败', icon: 'none' })
return
}
}
const amount = Math.round(Number(this.withdrawAmount) * 100) / 100
await distributionApi.withdraw({ amount, channel: 'wxpay' })
this.showWithdraw = false
@@ -1127,6 +1194,21 @@ export default {
font-weight: 700;
color: $fc-text;
}
.dist__record-right {
display: flex;
flex-direction: column;
align-items: flex-end;
flex-shrink: 0;
}
.dist__record-action {
margin-top: 10rpx;
padding: 6rpx 18rpx;
border-radius: 24rpx;
background: $fc-primary;
color: $fc-on-primary;
font-size: 22rpx;
line-height: 1.6;
}
/* ==================== 空态 / 骨架 / 展开 ==================== */
.dist__empty {
@@ -1328,6 +1410,12 @@ export default {
font-weight: 700;
color: $fc-text;
}
/* 收款人姓名输入(字号比金额小一号,避免喧宾夺主) */
.dist__sheet-input--name {
padding-left: 24rpx;
font-size: 30rpx;
font-weight: 500;
}
.dist__sheet-placeholder {
color: $fc-text-placeholder;
font-weight: 400;

查看文件

@@ -11,7 +11,7 @@
}"
>
<image class="fc-logo fc-logo--sm" :src="logoUrl()" mode="aspectFit" />
<view class="home__location" @click="onLocation">
<view class="home__location" @click="useCurrentLocation">
<image class="home__location-icon" :src="iconUrl('home-location')" mode="aspectFit" />
<text class="home__location-text fc-ellipsis">{{ currentCityText }}</text>
<text class="home__location-arrow">▾</text>
@@ -100,9 +100,15 @@
:class="{ 'home__filter-item--active': sort === s.value }" @click="changeSort(s.value)">
<text>{{ s.label }}</text>
</view>
<view class="home__filter-item home__filter-item--area" @click="showAreaPicker = true">
<text>{{ area || '区域' }} ▾</text>
</view>
<fc-area-picker
class="home__filter-area"
:areas="areaRows"
:value="areaId"
allow-all
variant="chip"
placeholder="区域"
@change="onAreaChange"
/>
</view>
<!-- 骨架屏 -->
@@ -131,19 +137,6 @@
<view class="home__tabbar-space"></view>
<fc-tabbar :current="0" />
<!-- 区域选择弹层 -->
<view v-if="showAreaPicker" class="home__mask" @click="showAreaPicker = false">
<view class="home__sheet" @click.stop>
<text class="home__sheet-title">选择区域</text>
<view class="home__sheet-list">
<view v-for="a in areaOptions" :key="a" class="home__sheet-item"
:class="{ 'home__sheet-item--active': area === a }" @click="pickArea(a)">
<text>{{ a }}</text>
</view>
</view>
</view>
</view>
</view>
</template>
@@ -151,16 +144,17 @@
import FcPostCard from '@/components/fc-post-card/fc-post-card.vue'
import FcTabbar from '@/components/fc-tabbar/fc-tabbar.vue'
import FcEmpty from '@/components/fc-empty/fc-empty.vue'
import FcAreaPicker from '@/components/fc-area-picker/fc-area-picker.vue'
import homeApi from '@/common/api/home.js'
import memberApi from '@/common/api/member.js'
import messageApi from '@/common/api/message.js'
import { useUserStore } from '@/common/store/index.js'
import { iconUrl, logoUrl, categoryIconUrl, loadUiConfig } from '@/common/store/ui.js'
import { iconUrl, logoUrl, categoryIconUrl, loadUiConfig, uiState } from '@/common/store/ui.js'
import { bannerArtUrl, bannerHasValue, bannerBg } from '@/common/assets/banners.js'
import { getNavMetrics } from '@/common/utils/navbar.js'
export default {
components: { FcPostCard, FcTabbar, FcEmpty },
components: { FcPostCard, FcTabbar, FcEmpty, FcAreaPicker },
data() {
return {
statusBarHeight: 20,
@@ -177,12 +171,16 @@ export default {
hasMore: true,
loading: false,
sort: 'new',
area: '',
// 区域筛选:业务只按服务区域(区县)筛选
areaId: 0,
areaText: '',
manualArea: false,
lat: null,
lng: null,
showAreaPicker: false,
// 区域选项由后台「区域管理」下发(/home/areas),不再前端写死
areaOptions: [],
// 请求序号:快速切换排序/区域时丢弃过期响应,避免旧结果覆盖新筛选
reqSeq: 0,
// 平铺服务区域(每条自带省/市/区县),交给级联选择器分组
areaRows: [],
// 会员权益 / 套餐(/member/benefits、/member/plans),用于下方会员引导条
benefits: {},
plans: [],
@@ -210,15 +208,13 @@ export default {
},
/** 会员引导条副标题:免费查看条数来自 /member/benefits,价格取 /member/plans 最低价 */
/**
* 顶栏显示的城市或区域文案(优先当前选中区域,其次真实定位,缺省回退到同城服务)
* 顶栏显示的城市或区域文案(优先当前筛选区域,其次真实定位,缺省回退到同城服务)
*/
currentCityText() {
if (this.area) return this.area
if (this.areaText) return this.areaText
if (this.location) return this.location
if (this.areaOptions && this.areaOptions.length) {
const first = this.areaOptions[0]
return typeof first === 'string' ? first : (first.name || '同城服务')
}
const first = (this.areaRows || [])[0]
if (first && first.city) return first.city
return '同城服务'
},
vipSub() {
@@ -254,6 +250,20 @@ export default {
// 登录状态可能在别处变化(如从登录页返回),回首页时同步未读角标
this.loadUnread()
},
/** 转发标题统一取后台「小程序配置 → 分享标题」 */
onShareAppMessage() {
return {
title: uiState.shareTitle || uiState.siteName || '同城分类信息',
path: '/pages/index/index',
}
},
/** 分享到朋友圈 */
onShareTimeline() {
return {
title: uiState.shareTitle || uiState.siteName || '同城分类信息',
query: '',
}
},
onPullDownRefresh() {
this.page = 1
this.hasMore = true
@@ -291,11 +301,11 @@ export default {
await this.fetchFeed(true)
this.loading = false
},
/** 区域选项(后台「区域管理」下发) */
/** 服务区域(后台「区域管理」下发,平铺:每条自带省/市/区县) */
async loadAreas() {
try {
const areas = await homeApi.areas()
if (Array.isArray(areas) && areas.length) this.areaOptions = areas
const rows = await homeApi.areas()
this.areaRows = Array.isArray(rows) ? rows : []
} catch (e) {}
},
/** 会员权益与套餐(首页会员引导条) */
@@ -338,30 +348,50 @@ export default {
success: (res) => {
this.lat = res.latitude
this.lng = res.longitude
// 坐标到手后刷新一次(排序/距离随之生效)
this.page = 1
this.fetchFeed(true)
// 坐标到手后:先按定位匹配区域,再刷新一次信息流
this.applyLocationArea().finally(() => {
this.page = 1
this.fetchFeed(true)
})
},
fail: () => {},
})
},
/**
* 把定位坐标转换成区域筛选默认值(用户手动切换过则不覆盖)
*/
async applyLocationArea() {
if (this.manualArea || this.lat == null || this.lng == null) return
try {
const found = await homeApi.locate({ lat: this.lat, lng: this.lng })
if (found && found.areaId) {
this.areaId = Number(found.areaId) || 0
this.areaText = found.district || ''
this.location = found.city || ''
}
} catch (e) {}
},
async fetchFeed(reset = false) {
const seq = ++this.reqSeq
this.loading = true
try {
const res = await homeApi.feed({
page: this.page,
size: this.size,
sort: this.sort,
area: this.area || undefined,
areaId: this.areaId || undefined,
lat: this.lat != null ? this.lat : undefined,
lng: this.lng != null ? this.lng : undefined,
})
// 期间又切换了排序/区域:以最后一次请求为准
if (seq !== this.reqSeq) return
this.list = reset ? res.list : this.list.concat(res.list)
this.hasMore = res.hasMore
} catch (e) {
if (seq !== this.reqSeq) return
uni.showToast({ title: '加载失败,请稍后重试', icon: 'none' })
} finally {
this.loading = false
if (seq === this.reqSeq) this.loading = false
}
},
loadMore() {
@@ -374,13 +404,26 @@ export default {
this.sort = v
this.page = 1
this.fetchFeed(true)
// 「附近」依赖坐标:无坐标时补取一次定位(成功后自动重排)
if (v === 'nearby' && (this.lat == null || this.lng == null)) {
uni.showToast({ title: '正在获取定位…', icon: 'none' })
this.fetchLocation()
}
},
pickArea(a) {
this.area = this.area === a ? '' : a
this.showAreaPicker = false
/** 级联选择器选中服务区域(null = 全部区域) */
onAreaChange(area) {
this.areaId = area ? Number(area.areaId) || 0 : 0
this.areaText = area ? area.district || '' : ''
this.manualArea = true
this.page = 1
this.fetchFeed(true)
},
/** 使用当前位置:清除手动选择,重新定位并匹配区域 */
useCurrentLocation() {
this.manualArea = false
this.fetchLocation()
uni.showToast({ title: '已按当前位置匹配', icon: 'none' })
},
/**
* 页面跳转助手
* @param {string} url 目标路径
@@ -446,11 +489,6 @@ export default {
goDetail(p) {
uni.navigateTo({ url: `/pages/detail/detail?id=${p.id}` })
},
onLocation() {
// 手动点定位:重新取一次坐标(失败静默,保持现有显示)
this.fetchLocation()
uni.showToast({ title: '已按当前位置刷新', icon: 'none' })
},
},
}
</script>
@@ -815,10 +853,9 @@ export default {
color: $fc-primary-text;
font-weight: 700;
}
&--area {
margin-left: auto;
margin-right: 0;
}
}
.home__filter-area {
margin-left: auto;
}
.home__skeleton {
display: flex;
@@ -848,51 +885,5 @@ export default {
.home__tabbar-space {
height: 130rpx;
}
.home__mask {
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 200;
background: rgba(4, 48, 42, 0.5);
display: flex;
align-items: flex-end;
}
.home__sheet {
width: 100%;
background: #ffffff;
border-radius: 32rpx 32rpx 0 0;
padding: 36rpx 32rpx 60rpx;
}
.home__sheet-title {
display: block;
text-align: center;
font-size: $fc-font-lg;
font-weight: 700;
margin-bottom: 28rpx;
}
.home__sheet-list {
display: flex;
flex-wrap: wrap;
}
.home__sheet-item {
width: 30%;
margin: 0 1.5% 20rpx;
height: 76rpx;
border-radius: $fc-radius;
background: $fc-bg;
display: flex;
align-items: center;
justify-content: center;
font-size: $fc-font;
color: $fc-text-regular;
&--active {
background: $fc-primary-lighter;
color: $fc-primary-text;
font-weight: 700;
border: 2rpx solid $fc-primary-text;
}
}
</style>

查看文件

@@ -102,7 +102,7 @@
</view>
<!-- 底部版本信息(连续点击5次可唤起管理员快捷设置彩蛋) -->
<view class="mine__version" @click="handleVersionClick">同城分类信息 v1.1.0</view>
<view class="mine__version" @click="handleVersionClick">{{ siteName }} v1.1.0</view>
<view class="mine__tabbar-space"></view>
<fc-tabbar :current="4" />
@@ -113,7 +113,7 @@
import FcTabbar from '@/components/fc-tabbar/fc-tabbar.vue'
import memberApi from '@/common/api/member.js'
import { useUserStore } from '@/common/store/index.js'
import { iconUrl, loadUiConfig } from '@/common/store/ui.js'
import { iconUrl, loadUiConfig, uiState } from '@/common/store/ui.js'
import { formatTime, maskPhone, assetUrl } from '@/common/utils/format.js'
import { getNavMetrics } from '@/common/utils/navbar.js'
@@ -138,6 +138,10 @@ export default {
}
},
computed: {
/** 小程序名称(后台「小程序配置」下发) */
siteName() {
return uiState.siteName || uiState.appName || '同城分类信息'
},
/**
* 商家身份标签文案(展示在个人信息区,替代原独立商家卡片)
* @returns {string} 无商家身份时返回空串
@@ -447,15 +451,18 @@ export default {
* 在线客服处理
*/
handleSupport() {
// 客服电话来自后台「系统设置 → 系统配置 → 小程序配置」,留空时用内置兜底
const phone = (uiState.servicePhone || '400-888-6688').trim()
const dial = phone.replace(/[^\d]/g, '') || '4008886688'
uni.showModal({
title: '平台客服',
content: '客服电话:400-888-6688\n服务时间:09:00 - 21:00',
content: `客服电话:${phone}\n服务时间:09:00 - 21:00`,
confirmText: '拨打电话',
cancelText: '取消',
confirmColor: '#04874a',
success: (res) => {
if (res.confirm) {
uni.makePhoneCall({ phoneNumber: '4008886688', fail: () => {} })
uni.makePhoneCall({ phoneNumber: dial, fail: () => {} })
}
},
})
@@ -465,9 +472,12 @@ export default {
* 关于我们弹窗
*/
handleAbout() {
// 名称 / 关于我们均来自后台「系统配置 → 小程序配置」
const name = uiState.siteName || uiState.appName || '同城分类信息'
const about = uiState.aboutUs || '致力于为本地居民和商家提供真实、便捷、高效的便民信息服务平台。'
uni.showModal({
title: '关于同城分类信息',
content: '致力于为本地居民和商家提供真实、便捷、高效的便民信息服务平台。',
title: `关于${name}`,
content: about,
showCancel: false,
confirmText: '我知道了',
confirmColor: '#04874a',

查看文件

@@ -11,7 +11,7 @@
</template>
</fc-navbar>
<!-- 1. 分类选择单元格(由接口动态返回决定,支持海量分类弹窗抽屉与横向快捷选择) -->
<!-- 1. 分类选择单元格(唯一入口,点击唤起全部分类抽屉,避免同一分类重复展示) -->
<view class="fc-card create__section">
<view class="create__cell" @click="openCatDrawer">
<view class="create__cell-left">
@@ -27,29 +27,12 @@
<text class="create__arrow">›</text>
</view>
</view>
<!-- 快捷热门分类横向滑动胶囊流(接口动态下发,可横向自由滚动快捷点选) -->
<view v-if="categories.length > 0" class="create__quick-cats-wrap">
<scroll-view class="create__quick-cats" scroll-x :show-scrollbar="false">
<view
v-for="c in categories"
:key="c.id"
class="create__quick-cat"
:class="{ 'create__quick-cat--active': form.categoryId === c.id }"
@click="selectCat(c)"
>
<image class="create__quick-cat-icon" :src="catIcon(c)" mode="aspectFit" />
<text class="create__quick-cat-name">{{ c.name }}</text>
</view>
</scroll-view>
</view>
</view>
<!-- 2. 发布身份选择(仅已认证商家展示,可自由切换个人名义或商家名义) -->
<!-- 2. 发布身份选择(仅已认证商家展示,个人 / 商家二选一) -->
<view v-if="isMerchantUser" class="fc-card create__section">
<view class="create__label-row">
<text class="create__label">发布身份</text>
<text class="create__tip">选择商家身份将展示您的认证商铺信息</text>
</view>
<view class="create__identity-group">
<view
@@ -57,8 +40,8 @@
:class="{ 'create__identity-item--active': form.identityType === 'person' }"
@click="switchIdentity('person')"
>
<text class="create__identity-title">个人名义</text>
<text class="create__identity-desc">常规个人便民信息</text>
<text class="create__identity-title">个人</text>
<text class="create__identity-desc">发布便民信息</text>
</view>
<view
class="create__identity-item"
@@ -66,10 +49,10 @@
@click="switchIdentity('merchant')"
>
<view class="create__identity-title-row">
<text class="create__identity-title">商家名义</text>
<text class="create__identity-title">商家</text>
<text class="create__merchant-badge">已认证</text>
</view>
<text class="create__identity-desc fc-ellipsis">{{ merchantShopName || '展示店铺门店' }}</text>
<text class="create__identity-desc fc-ellipsis">{{ merchantShopName || '展示店铺信息' }}</text>
</view>
</view>
</view>
@@ -155,10 +138,23 @@
<text class="create__row-label">所在位置</text>
<view class="create__location">
<image class="fc-icon fc-icon--sm" :src="iconUrl('location')" mode="aspectFit" />
<text class="create__location-text fc-ellipsis">{{ form.address || '点击定位/选择商铺及区域' }}</text>
<text class="create__location-text fc-ellipsis">{{ form.address || '点击定位/选择商铺' }}</text>
<text class="create__location-arrow">›</text>
</view>
</view>
<view class="create__row create__row--line">
<text class="create__row-label">所属区域</text>
<fc-area-picker
class="create__area-picker"
:areas="areaRows"
:value="form.areaId"
variant="plain"
show-full
placeholder="请选择省 / 市 / 区"
@change="onRegionPicked"
/>
</view>
</view>
<!-- 5. 发布方式与计费(由后台「发布与费用配置」下发) -->
@@ -279,28 +275,32 @@
/**
* 信息发布页面(重构版)
* 核心优化:
* 1. 分类选择由接口动态返回决定(支持海量分类的抽屉选择器与快捷横滑标签,拒绝死板平铺);
* 1. 分类选择由接口动态返回决定,统一收敛为「所属分类单元格 + 全部分类抽屉」单一入口,
* 避免同一分类在页面内重复出现(已选值只展示一次);
* 2. 彻底剥离草稿箱列表到独立页面 /pages/post/drafts,发布页右上方提供直通入口与存草稿闭环;
* 3. 支持商家/个人身份自由切换(已认证商家可选择以商家名义发布并附带门店信息);
* 3. 支持个人 / 商家身份二选一(已认证商家可切换为商家身份发布并附带门店信息);
* 4. 严格遵循春绿规范,大厂级布局与无障碍高对比度。
*/
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
import FcAreaPicker from '@/components/fc-area-picker/fc-area-picker.vue'
import homeApi from '@/common/api/home.js'
import postApi from '@/common/api/post.js'
import { useUserStore } from '@/common/store/index.js'
import { iconUrl, categoryIconUrl, loadUiConfig } from '@/common/store/ui.js'
import { pay } from '@/common/utils/pay.js'
import { requestSubscribe } from '@/common/utils/subscribe.js'
import { assetUrl } from '@/common/utils/format.js'
import config from '@/common/config/index.js'
export default {
components: { FcNavbar },
components: { FcNavbar, FcAreaPicker },
data() {
return {
categories: [],
draftCount: 0,
currentDraftId: 0, // 当前正在编辑的草稿ID(编辑自某草稿)
areas: [],
// 平铺服务区域(每条自带省/市/区县),交给级联选择器分组
areaRows: [],
submitting: false,
uploading: false,
draftTimer: null,
@@ -315,6 +315,8 @@ export default {
contact: '',
phone: '',
address: '',
areaId: 0,
area: '',
lat: null,
lng: null,
plan: 'free',
@@ -453,8 +455,8 @@ export default {
}
try {
const areas = await homeApi.areas()
if (Array.isArray(areas) && areas.length) this.areas = areas
const rows = await homeApi.areas()
this.areaRows = Array.isArray(rows) ? rows : []
} catch (e) {}
this.loadPublish()
@@ -495,6 +497,8 @@ export default {
this.form.contact = target.contact || ''
this.form.phone = target.phone || ''
this.form.address = target.address || ''
this.form.areaId = target.areaId || 0
this.form.area = target.area || ''
if (Array.isArray(target.media)) this.form.media = [...target.media]
uni.showToast({ title: '已载入草稿内容', icon: 'none' })
}
@@ -514,6 +518,8 @@ export default {
this.form.contact = p.contact || ''
this.form.phone = p.phone || ''
this.form.address = p.address || ''
this.form.areaId = p.areaId || 0
this.form.area = p.area || ''
this.form.lat = p.lat || null
this.form.lng = p.lng || null
if (Array.isArray(p.media)) this.form.media = [...p.media]
@@ -650,24 +656,35 @@ export default {
this.form.address = res.address || res.name
this.form.lat = typeof res.latitude === 'number' ? res.latitude : null
this.form.lng = typeof res.longitude === 'number' ? res.longitude : null
// 定位成功后自动匹配省 / 市 / 区(失败保留用户已选区域)
this.matchRegionByLocation(this.form.lat, this.form.lng)
this.triggerAutoSave()
},
fail: () => {
if (!this.areas.length) {
uni.showToast({ title: '请填写具体地址', icon: 'none' })
return
}
uni.showActionSheet({
itemList: this.areas,
success: (r) => {
this.form.address = this.areas[r.tapIndex]
this.triggerAutoSave()
},
fail: () => {},
})
uni.showToast({ title: '请选择所属区域并填写地址', icon: 'none' })
},
})
},
/** 级联选择器选中服务区域 */
onRegionPicked(area) {
this.form.areaId = area ? Number(area.areaId) || 0 : 0
this.form.area = area ? area.district || '' : ''
this.triggerAutoSave()
},
/**
* 按经纬度匹配服务区域(后端 /home/locate)
* @param {number|null} lat
* @param {number|null} lng
*/
async matchRegionByLocation(lat, lng) {
if (lat == null || lng == null) return
try {
const found = await homeApi.locate({ lat, lng })
if (!found || !found.areaId) return
this.form.areaId = Number(found.areaId) || 0
this.form.area = found.district || ''
} catch (e) {}
},
onFieldInput() {
this.triggerAutoSave()
},
@@ -717,6 +734,7 @@ export default {
if (!this.form.categoryId) return '请选择所属分类'
if (!this.form.title || !this.form.title.trim()) return '请填写标题'
if (!this.form.content || !this.form.content.trim()) return '请填写详细内容'
if (!this.form.areaId) return '请选择所属区域'
if (this.form.phone && !/^1\d{10}$/.test(this.form.phone)) return '请输入正确的11位手机号'
return ''
},
@@ -737,6 +755,8 @@ export default {
this.submitting = true
try {
// 订阅消息授权(审核结果);未配置模板时静默跳过
await requestSubscribe('audit')
const res = await postApi.create({ ...this.form })
// 若有需要支付的订单
@@ -863,17 +883,13 @@ export default {
margin-bottom: 20rpx;
}
.create__tip {
font-size: 22rpx;
color: $fc-text-placeholder;
}
/* 1. 分类选择单元格 */
/* 分类选择单元格(唯一入口) */
.create__cell {
display: flex;
align-items: center;
justify-content: space-between;
padding: 10rpx 0;
min-height: 88rpx;
padding: 12rpx 0;
cursor: pointer;
}
@@ -920,50 +936,6 @@ export default {
color: #04874a;
}
/* 快捷热门分类横向滑动条 */
.create__quick-cats-wrap {
margin-top: 24rpx;
padding-top: 20rpx;
border-top: 1rpx solid #f0f5f2;
}
.create__quick-cats {
white-space: nowrap;
width: 100%;
}
.create__quick-cat {
display: inline-flex;
align-items: center;
background: #f5f9f6;
border: 1rpx solid #e2ece5;
border-radius: 28rpx;
padding: 10rpx 22rpx;
margin-right: 16rpx;
transition: all 0.15s ease;
&--active {
background: rgba(0, 224, 112, 0.14);
border-color: #00e070;
.create__quick-cat-name {
color: #04874a;
font-weight: 700;
}
}
}
.create__quick-cat-icon {
width: 30rpx;
height: 30rpx;
margin-right: 10rpx;
}
.create__quick-cat-name {
font-size: 24rpx;
color: $fc-text-sub;
}
/* 2. 身份切换组 */
.create__identity-group {
display: grid;
@@ -1178,6 +1150,10 @@ export default {
flex-shrink: 0;
}
.create__area-picker {
flex: 1;
margin-left: 16rpx;
}
.create__location {
display: flex;
align-items: center;