' +
- '

' +
+ return '
' +
+ '
' +
+ '

' +
+ '
' +
+ '
' +
'
';
}
},
- // 2. 分类名称(留足宽度,带主题色小圆点)
+ // 2. 分类名称(含层级缩进,带主题色小圆点)
{
field: 'name',
title: __('Name'),
@@ -81,21 +91,42 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], fu
width: '200px',
formatter: function (value, row, index) {
var color = row.color || '#00E070';
- var dot = '
';
- return '
' + dot + '' + value + '
';
+ var isSub = Number(row.pid || 0) > 0;
+ var dot = '
';
+ var nameStyle = isSub
+ ? 'font-weight:500;font-size:13.5px;color:#475569;'
+ : 'font-weight:700;font-size:14px;color:#1e293b;';
+ return '
' + dot + '' + value + '
';
}
},
- // 3. 主题色
+ // 2.5 所属大类
{
- field: 'color',
- title: __('Color'),
- operate: 'LIKE',
+ field: 'parent_name',
+ title: '上级分类',
+ operate: false,
align: 'center',
- width: '130px',
+ width: '120px',
formatter: function (value, row, index) {
- var color = value || '#00E070';
- return '
' + color + '';
+ if (!row.pid || Number(row.pid) === 0) {
+ return '
一级大类';
+ }
+ return '
' + (value || ('#' + row.pid)) + '';
+ }
+ },
+
+ // 2.6 分类类型(决定发布页是否显示产地规格字段)
+ {
+ field: 'kind',
+ title: '类型',
+ operate: false,
+ align: 'center',
+ width: '100px',
+ formatter: function (value, row, index) {
+ if (value === 'farm') {
+ return '
农产品';
+ }
+ return '
通用信息';
}
},
@@ -188,6 +219,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], fu
var $iconInput = $('#c-icon_key');
var $nameInput = $('#c-name');
var $colorInput = $('#c-color');
+ var $colorNative = $('#c-color-native');
var $colorAddon = $('#color-preview-addon');
var $previewBadge = $('#preview-badge');
var $previewIcon = $('#preview-icon');
@@ -198,7 +230,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], fu
// 刷新界面预览元素(纯视觉图形,无死板业务文字)
function updateLivePreview() {
var name = $nameInput.val() || '未命名分类';
- var key = $iconInput.val() || 'cat-job';
+ var key = $iconInput.val() || 'cat-veg';
var color = $colorInput.val() || '#00E070';
var iconUrl = resolveIconUrl(key);
@@ -213,6 +245,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], fu
});
}
if ($colorAddon.length) $colorAddon.css('background', color);
+ if ($colorNative.length) $colorNative.val(color);
}
// 确保初始状态完全隐藏
@@ -263,6 +296,11 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], fu
updateLivePreview();
});
+ // 5.1 原生取色器 → 十六进制输入框
+ $colorNative.on('input change', function () {
+ $colorInput.val($(this).val()).trigger('change');
+ });
+
$(document).on('click', '.fc-color-presets .fc-color-dot', function () {
var color = $(this).data('color');
$colorInput.val(color).trigger('change');
@@ -270,7 +308,7 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'backend/format'], fu
});
// 初始化回显
- var initKey = $iconInput.val() || 'cat-job';
+ var initKey = $iconInput.val() || 'cat-veg';
$('.fc-icon-chip[data-key="' + initKey + '"]').addClass('active');
updateLivePreview();
}
diff --git a/public/static/categories/cat-fruit.png b/public/static/categories/cat-fruit.png
new file mode 100644
index 0000000..7fce115
Binary files /dev/null and b/public/static/categories/cat-fruit.png differ
diff --git a/public/static/categories/cat-veg.png b/public/static/categories/cat-veg.png
new file mode 100644
index 0000000..019fe17
Binary files /dev/null and b/public/static/categories/cat-veg.png differ
diff --git a/public/static/categories/fruit-apple.png b/public/static/categories/fruit-apple.png
new file mode 100644
index 0000000..31f03f3
Binary files /dev/null and b/public/static/categories/fruit-apple.png differ
diff --git a/public/static/categories/fruit-grape.png b/public/static/categories/fruit-grape.png
new file mode 100644
index 0000000..a48391d
Binary files /dev/null and b/public/static/categories/fruit-grape.png differ
diff --git a/public/static/categories/fruit-kiwi.png b/public/static/categories/fruit-kiwi.png
new file mode 100644
index 0000000..d0e7df8
Binary files /dev/null and b/public/static/categories/fruit-kiwi.png differ
diff --git a/public/static/categories/fruit-orange.png b/public/static/categories/fruit-orange.png
new file mode 100644
index 0000000..0603e1a
Binary files /dev/null and b/public/static/categories/fruit-orange.png differ
diff --git a/public/static/categories/fruit-passion.png b/public/static/categories/fruit-passion.png
new file mode 100644
index 0000000..f58d88c
Binary files /dev/null and b/public/static/categories/fruit-passion.png differ
diff --git a/public/static/categories/fruit-peach.png b/public/static/categories/fruit-peach.png
new file mode 100644
index 0000000..03b4480
Binary files /dev/null and b/public/static/categories/fruit-peach.png differ
diff --git a/public/static/categories/fruit-strawberry.png b/public/static/categories/fruit-strawberry.png
new file mode 100644
index 0000000..52b1a0d
Binary files /dev/null and b/public/static/categories/fruit-strawberry.png differ
diff --git a/public/static/categories/fruit-watermelon.png b/public/static/categories/fruit-watermelon.png
new file mode 100644
index 0000000..5d7ac3c
Binary files /dev/null and b/public/static/categories/fruit-watermelon.png differ
diff --git a/public/static/categories/veg-cabbage.png b/public/static/categories/veg-cabbage.png
new file mode 100644
index 0000000..f286997
Binary files /dev/null and b/public/static/categories/veg-cabbage.png differ
diff --git a/public/static/categories/veg-chili.png b/public/static/categories/veg-chili.png
new file mode 100644
index 0000000..2b20d25
Binary files /dev/null and b/public/static/categories/veg-chili.png differ
diff --git a/public/static/categories/veg-green-cabbage.png b/public/static/categories/veg-green-cabbage.png
new file mode 100644
index 0000000..b457763
Binary files /dev/null and b/public/static/categories/veg-green-cabbage.png differ
diff --git a/public/static/categories/veg-greens.png b/public/static/categories/veg-greens.png
new file mode 100644
index 0000000..85d2aaa
Binary files /dev/null and b/public/static/categories/veg-greens.png differ
diff --git a/public/static/categories/veg-purple-cabbage.png b/public/static/categories/veg-purple-cabbage.png
new file mode 100644
index 0000000..a7d9d08
Binary files /dev/null and b/public/static/categories/veg-purple-cabbage.png differ
diff --git a/public/static/categories/veg-radish.png b/public/static/categories/veg-radish.png
new file mode 100644
index 0000000..85e13e1
Binary files /dev/null and b/public/static/categories/veg-radish.png differ
diff --git a/public/static/categories/veg-tomato.png b/public/static/categories/veg-tomato.png
new file mode 100644
index 0000000..31b7bb6
Binary files /dev/null and b/public/static/categories/veg-tomato.png differ
diff --git a/public/static/icons/cat-fruit.png b/public/static/icons/cat-fruit.png
new file mode 100644
index 0000000..7fce115
Binary files /dev/null and b/public/static/icons/cat-fruit.png differ
diff --git a/public/static/icons/cat-veg.png b/public/static/icons/cat-veg.png
new file mode 100644
index 0000000..019fe17
Binary files /dev/null and b/public/static/icons/cat-veg.png differ
diff --git a/tmp_img/cat-fruit.jpg b/tmp_img/cat-fruit.jpg
new file mode 100644
index 0000000..3b9ddd0
Binary files /dev/null and b/tmp_img/cat-fruit.jpg differ
diff --git a/tmp_img/cat-veg.jpg b/tmp_img/cat-veg.jpg
new file mode 100644
index 0000000..a1d6c3d
Binary files /dev/null and b/tmp_img/cat-veg.jpg differ
diff --git a/tmp_img/ssh_check.py b/tmp_img/ssh_check.py
new file mode 100644
index 0000000..532d926
--- /dev/null
+++ b/tmp_img/ssh_check.py
@@ -0,0 +1,22 @@
+# -*- coding: utf-8 -*-
+"""SSH 连接自检:仅执行只读命令,不改动服务器"""
+import paramiko, sys
+
+HOST, PORT, USER, PWD = "8.137.181.63", 22, "root", "liyanxia@6688"
+
+cmds = [
+ ("站点目录", "ls /www/wwwroot/fenleixinxi.gzyakj.com.cn | head -30"),
+ ("MySQL版本", "mysql -V"),
+ ("PHP版本", "php -v 2>/dev/null | head -1"),
+ ("远程.env", "cat /www/wwwroot/fenleixinxi.gzyakj.com.cn/.env 2>/dev/null"),
+ ("磁盘空间", "df -h /www | tail -1"),
+]
+
+cli = paramiko.SSHClient()
+cli.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+cli.connect(HOST, PORT, USER, PWD, timeout=20)
+for title, cmd in cmds:
+ _, out, err = cli.exec_command(cmd, timeout=30)
+ o, e = out.read().decode("utf-8", "ignore").strip(), err.read().decode("utf-8", "ignore").strip()
+ print(f"===== {title} =====\n{o or e}\n")
+cli.close()
diff --git a/tmp_img/ssh_check2.py b/tmp_img/ssh_check2.py
new file mode 100644
index 0000000..aa2fb5c
--- /dev/null
+++ b/tmp_img/ssh_check2.py
@@ -0,0 +1,17 @@
+# -*- coding: utf-8 -*-
+"""查看远程 extra 目录与代码版本概况(只读)"""
+import paramiko
+cli = paramiko.SSHClient()
+cli.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+cli.connect("8.137.181.63", 22, "root", "liyanxia@6688", timeout=20)
+cmds = [
+ ("remote extra", "ls /www/wwwroot/fenleixinxi.gzyakj.com.cn/application/extra/"),
+ ("remote FcConfig", "ls -la /www/wwwroot/fenleixinxi.gzyakj.com.cn/application/common/library/ | grep -i fc"),
+ ("remote uploads size", "du -sh /www/wwwroot/fenleixinxi.gzyakj.com.cn/public/uploads"),
+ ("remote public/static icons", "ls /www/wwwroot/fenleixinxi.gzyakj.com.cn/public/static/icons/ 2>/dev/null | head -20"),
+ ("mysql auth check", "mysql -ufenleixinxi -pfenleixinxi -e 'select 1' 2>&1 | head -2"),
+]
+for title, cmd in cmds:
+ _, out, err = cli.exec_command(cmd, timeout=30)
+ print(f"===== {title} =====\n{out.read().decode('utf-8','ignore').strip() or err.read().decode('utf-8','ignore').strip()}\n")
+cli.close()
diff --git a/tmp_img/step1_backup.py b/tmp_img/step1_backup.py
new file mode 100644
index 0000000..a61736c
--- /dev/null
+++ b/tmp_img/step1_backup.py
@@ -0,0 +1,29 @@
+# -*- coding: utf-8 -*-
+"""第一步:线上备份(代码 + 数据库),只做备份不做任何变更"""
+import paramiko
+cli = paramiko.SSHClient()
+cli.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+cli.connect("8.137.181.63", 22, "root", "liyanxia@6688", timeout=20)
+
+BASE = "/www/wwwroot/fenleixinxi.gzyakj.com.cn"
+BK = "/www/backup/fenleixinxi_dep_20261027"
+
+cmds = [
+ f"mkdir -p {BK}",
+ f"tar -czf {BK}/code_backup.tar.gz -C {BASE} application public extend addons 2>&1 | tail -3",
+ f"mysqldump -ufenleixinxi -pfenleixinxi --single-transaction --default-character-set=utf8mb4 fenleixinxi 2>/dev/null | gzip > {BK}/db_backup.sql.gz",
+ f"ls -lh {BK}",
+ # 远程库表数量留档
+ "mysql -ufenleixinxi -pfenleixinxi -N -e \"SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA='fenleixinxi';\" 2>/dev/null",
+]
+for cmd in cmds:
+ _, out, err = cli.exec_command(cmd, timeout=300)
+ rc = out.channel.recv_exit_status()
+ o = out.read().decode("utf-8", "ignore").strip()
+ e = err.read().decode("utf-8", "ignore").strip()
+ print(f"$ {cmd}\nrc={rc}\n{o}")
+ if e and rc != 0:
+ print("STDERR:", e)
+ print("-" * 50)
+cli.close()
+print("BACKUP DONE")
diff --git a/tmp_img/step2_upload.py b/tmp_img/step2_upload.py
new file mode 100644
index 0000000..52a333c
--- /dev/null
+++ b/tmp_img/step2_upload.py
@@ -0,0 +1,21 @@
+# -*- coding: utf-8 -*-
+"""第二步:上传代码包与数据库 SQL 到远程 /tmp/dep"""
+import paramiko, os
+cli = paramiko.SSHClient()
+cli.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+cli.connect("8.137.181.63", 22, "root", "liyanxia@6688", timeout=20)
+cli.exec_command("mkdir -p /tmp/dep")[1].channel.recv_exit_status()
+
+sftp = cli.open_sftp()
+BASE = r"d:\Softwares\phpstudy_pro\WWW\fenleixinxi\tmp_img"
+for local, remote in [
+ (os.path.join(BASE, "code.tar.gz"), "/tmp/dep/code.tar.gz"),
+ (os.path.join(BASE, "db_full.sql"), "/tmp/dep/db_full.sql"),
+]:
+ size = os.path.getsize(local)
+ print(f"uploading {local} ({size} bytes) ...")
+ sftp.put(local, remote)
+ print(f" remote size: {sftp.stat(remote).st_size} bytes")
+sftp.close()
+cli.close()
+print("UPLOAD DONE")
diff --git a/tmp_img/step3_deploy.py b/tmp_img/step3_deploy.py
new file mode 100644
index 0000000..38c9d2f
--- /dev/null
+++ b/tmp_img/step3_deploy.py
@@ -0,0 +1,28 @@
+# -*- coding: utf-8 -*-
+"""第三步:远程部署(解压代码、导入数据库、清缓存、重建菜单、修权限)"""
+import paramiko
+cli = paramiko.SSHClient()
+cli.set_missing_host_key_policy(paramiko.AutoAddPolicy())
+cli.connect("8.137.181.63", 22, "root", "liyanxia@6688", timeout=20)
+
+BASE = "/www/wwwroot/fenleixinxi.gzyakj.com.cn"
+steps = [
+ ("解压代码", f"cd {BASE} && tar -xzf /tmp/dep/code.tar.gz -C {BASE} && echo OK"),
+ ("导入数据库", f"mysql -ufenleixinxi -pfenleixinxi --default-character-set=utf8mb4 fenleixinxi < /tmp/dep/db_full.sql 2>&1 | grep -v 'insecure' ; echo rc=$?"),
+ ("校验表数量", "mysql -ufenleixinxi -pfenleixinxi -N -e \"SELECT COUNT(*) FROM information_schema.TABLES WHERE TABLE_SCHEMA='fenleixinxi';\" 2>/dev/null"),
+ ("清理runtime缓存", f"cd {BASE} && rm -rf runtime/cache/* runtime/temp/* && echo OK"),
+ ("重建后台菜单", f"cd {BASE} && php think fc:menu 2>&1 | tail -20"),
+ ("修正目录属主", f"chown -R www:www {BASE}/application {BASE}/public {BASE}/extend {BASE}/addons {BASE}/runtime && echo OK"),
+ ("校验national_areas", f"ls -la {BASE}/application/extra/national_areas.json {BASE}/application/common/library/NationalArea.php"),
+]
+for title, cmd in steps:
+ _, out, err = cli.exec_command(cmd, timeout=300)
+ rc = out.channel.recv_exit_status()
+ o = out.read().decode("utf-8", "ignore").strip()
+ e = err.read().decode("utf-8", "ignore").strip()
+ print(f"===== {title} ===== rc={rc}\n{o}")
+ if e:
+ print("STDERR:", e[:800])
+ print("-" * 60)
+cli.close()
+print("DEPLOY DONE")
diff --git a/tmp_img/veg-cabbage.jpg b/tmp_img/veg-cabbage.jpg
new file mode 100644
index 0000000..efee07e
Binary files /dev/null and b/tmp_img/veg-cabbage.jpg differ
diff --git a/tmp_img/veg-cauliflower.jpg b/tmp_img/veg-cauliflower.jpg
new file mode 100644
index 0000000..4e403e2
Binary files /dev/null and b/tmp_img/veg-cauliflower.jpg differ
diff --git a/tools/build_national_areas.mjs b/tools/build_national_areas.mjs
new file mode 100644
index 0000000..7633b18
--- /dev/null
+++ b/tools/build_national_areas.mjs
@@ -0,0 +1,192 @@
+/**
+ * 从 fastadmin-citypicker 的全国行政区划库生成标准全国省/市/区县平铺数据(application/extra/national_areas.json)
+ * 包含全国 34 个省级行政区、所有地级市与区县,并内置各省市及核心区县中心坐标,支持全国定位自动匹配。
+ */
+import fs from 'node:fs'
+import path from 'node:path'
+import vm from 'node:vm'
+import url from 'node:url'
+
+const ROOT = path.resolve(path.dirname(url.fileURLToPath(import.meta.url)), '..')
+const CITY_PICKER_PATH = path.join(ROOT, 'public/assets/libs/fastadmin-citypicker/dist/js/city-picker.data.js')
+const OUT_JSON_PATH = path.join(ROOT, 'application/extra/national_areas.json')
+
+const code = fs.readFileSync(CITY_PICKER_PATH, 'utf8')
+const sandbox = { window: {} }
+vm.createContext(sandbox)
+vm.runInContext(code, sandbox)
+const ChineseDistricts = sandbox.window.ChineseDistricts
+
+if (!ChineseDistricts || !ChineseDistricts[86]) {
+ throw new Error('Failed to load ChineseDistricts')
+}
+
+/**
+ * 规范化省级名称
+ * @param {string} name
+ * @returns {string}
+ */
+function normalizeProvince(name) {
+ const val = String(name || '').trim()
+ const map = {
+ '北京': '北京市',
+ '天津': '天津市',
+ '上海': '上海市',
+ '重庆': '重庆市',
+ '台湾': '台湾省',
+ }
+ return map[val] || val
+}
+
+// 保留现有数据库 ID 映射,确保历史帖子 district_id 与自动化测试 100% 兼容
+const LEGACY_ID_MAP = {
+ '贵州省|贵阳市|云岩区': { id: 1, lat: 26.605, lng: 106.710 },
+ '贵州省|贵阳市|南明区': { id: 2, lat: 26.568, lng: 106.716 },
+ '贵州省|贵阳市|观山湖区': { id: 3, lat: 26.625, lng: 106.625 },
+ '贵州省|贵阳市|花溪区': { id: 4, lat: 26.430, lng: 106.670 },
+ '贵州省|贵阳市|白云区': { id: 5, lat: 26.678, lng: 106.623 },
+ '贵州省|毕节市|七星关区': { id: 7, lat: 27.298273, lng: 105.305161 },
+}
+
+// 全国各省会、直辖市及贵州各市州/区县代表性中心坐标(gcj02),用于全国定位就近匹配
+const COORD_MAP = {
+ // 贵州省各市州及区县
+ '贵州省|贵阳市|乌当区': [26.630, 106.750],
+ '贵州省|贵阳市|开阳县': [27.057, 106.969],
+ '贵州省|贵阳市|息烽县': [27.090, 106.740],
+ '贵州省|贵阳市|修文县': [26.840, 106.590],
+ '贵州省|贵阳市|清镇市': [26.550, 106.470],
+ '贵州省|六盘水市': [26.592, 104.830],
+ '贵州省|遵义市': [27.725, 106.927],
+ '贵州省|安顺市': [26.253, 105.947],
+ '贵州省|毕节市': [27.298, 105.305],
+ '贵州省|铜仁市': [27.731, 109.189],
+ '贵州省|黔西南布依族苗族自治州': [25.087, 104.906],
+ '贵州省|黔东南苗族侗族自治州': [26.583, 107.982],
+ '贵州省|黔南布依族苗族自治州': [26.254, 107.522],
+ // 全国主要省级/省会坐标
+ '北京市': [39.9042, 116.4074],
+ '天津市': [39.0842, 117.2010],
+ '河北省': [38.0428, 114.5149],
+ '山西省': [37.8706, 112.5489],
+ '内蒙古自治区': [40.8426, 111.7492],
+ '辽宁省': [41.8057, 123.4315],
+ '吉林省': [43.8171, 125.3235],
+ '黑龙江省': [45.8038, 126.5350],
+ '上海市': [31.2304, 121.4737],
+ '江苏省': [32.0603, 118.7969],
+ '浙江省': [30.2741, 120.1551],
+ '安徽省': [31.8206, 117.2272],
+ '福建省': [26.0745, 119.2965],
+ '江西省': [28.6820, 115.8579],
+ '山东省': [36.6512, 117.1201],
+ '河南省': [34.7466, 113.6253],
+ '湖北省': [30.5928, 114.3055],
+ '湖南省': [28.2282, 112.9388],
+ '广东省': [23.1291, 113.2644],
+ '广西壮族自治区': [22.8170, 108.3665],
+ '海南省': [20.0440, 110.1999],
+ '重庆市': [29.5630, 106.5516],
+ '四川省': [30.5728, 104.0668],
+ '贵州省': [26.5982, 106.7074],
+ '云南省': [25.0406, 102.7123],
+ '西藏自治区': [29.6525, 91.1721],
+ '陕西省': [34.3416, 108.9398],
+ '甘肃省': [36.0611, 103.8343],
+ '青海省': [36.6171, 101.7782],
+ '宁夏回族自治区': [38.4872, 106.2309],
+ '新疆维吾尔自治区': [43.8256, 87.6168],
+ '台湾省': [25.0330, 121.5654],
+ '香港特别行政区': [22.3193, 114.1694],
+ '澳门特别行政区': [22.1987, 113.5439],
+}
+
+// 收集全部省份条目
+const provEntries = []
+for (const groupKey of Object.keys(ChineseDistricts[86])) {
+ const list = ChineseDistricts[86][groupKey]
+ if (Array.isArray(list)) {
+ for (const item of list) {
+ if (item && item.code && item.address) {
+ provEntries.push(item)
+ }
+ }
+ }
+}
+
+// 排序:将贵州省、重庆市、四川省、云南省排在前面方便本地及周边优先展示,同时包含全国所有省份
+const priorityOrder = ['520000', '500000', '510000', '530000']
+provEntries.sort((a, b) => {
+ const idxA = priorityOrder.indexOf(String(a.code))
+ const idxB = priorityOrder.indexOf(String(b.code))
+ if (idxA !== -1 && idxB !== -1) return idxA - idxB
+ if (idxA !== -1) return -1
+ if (idxB !== -1) return 1
+ return String(a.code).localeCompare(String(b.code))
+})
+
+const flatRows = []
+
+for (const prov of provEntries) {
+ const provCode = String(prov.code)
+ const provName = normalizeProvince(prov.address)
+ const citiesObj = ChineseDistricts[provCode] || {}
+
+ for (const cityCode of Object.keys(citiesObj)) {
+ const cityName = String(citiesObj[cityCode]).trim()
+ const districtsObj = ChineseDistricts[cityCode] || {}
+ const distCodes = Object.keys(districtsObj)
+
+ if (distCodes.length === 0) {
+ // 直筒子市(如东莞、中山、儋州等无下辖区县时以市名作为区县级节点)
+ const id = Number(cityCode)
+ const coord = COORD_MAP[`${provName}|${cityName}`] || COORD_MAP[provName] || [null, null]
+ flatRows.push({
+ id,
+ province: provName,
+ city: cityName,
+ district: cityName,
+ lat: coord[0],
+ lng: coord[1],
+ })
+ continue
+ }
+
+ let firstInCity = true
+ for (const distCode of distCodes) {
+ const distName = String(districtsObj[distCode]).trim()
+ const fullKey = `${provName}|${cityName}|${distName}`
+ const cityKey = `${provName}|${cityName}`
+ const legacy = LEGACY_ID_MAP[fullKey]
+
+ let lat = null
+ let lng = null
+ if (legacy) {
+ lat = legacy.lat
+ lng = legacy.lng
+ } else if (COORD_MAP[fullKey]) {
+ lat = COORD_MAP[fullKey][0]
+ lng = COORD_MAP[fullKey][1]
+ } else if (firstInCity && COORD_MAP[cityKey]) {
+ lat = COORD_MAP[cityKey][0]
+ lng = COORD_MAP[cityKey][1]
+ } else if (firstInCity && COORD_MAP[provName]) {
+ lat = COORD_MAP[provName][0]
+ lng = COORD_MAP[provName][1]
+ }
+ firstInCity = false
+
+ flatRows.push({
+ id: legacy ? legacy.id : Number(distCode),
+ province: provName,
+ city: cityName,
+ district: distName,
+ lat,
+ lng,
+ })
+ }
+ }
+}
+
+fs.writeFileSync(OUT_JSON_PATH, JSON.stringify(flatRows), 'utf8')
+console.log(`Generated ${flatRows.length} nationwide district rows -> ${OUT_JSON_PATH}`)
diff --git a/tools/generate_category_images.php b/tools/generate_category_images.php
new file mode 100644
index 0000000..bc83b68
--- /dev/null
+++ b/tools/generate_category_images.php
@@ -0,0 +1,188 @@
+ ['name' => '新鲜蔬菜', 'bg1' => [220, 252, 231], 'bg2' => [187, 247, 208], 'main' => [22, 163, 74], 'sub' => [134, 239, 172], 'shape' => 'leaf'],
+ 'cat-fruit' => ['name' => '时令水果', 'bg1' => [254, 243, 199], 'bg2' => [253, 230, 138], 'main' => [234, 88, 12], 'sub' => [251, 146, 60], 'shape' => 'fruit'],
+ // 蔬菜二级分类
+ 'veg-cauliflower' => ['name' => '花菜', 'bg1' => [240, 253, 244], 'bg2' => [220, 252, 231], 'main' => [250, 250, 240], 'sub' => [34, 197, 94], 'shape' => 'cauliflower'],
+ 'veg-cabbage' => ['name' => '白菜', 'bg1' => [240, 253, 244], 'bg2' => [209, 250, 229], 'main' => [134, 239, 172], 'sub' => [240, 253, 244], 'shape' => 'cabbage'],
+ 'veg-purple-cabbage' => ['name' => '紫甘蓝', 'bg1' => [250, 245, 255], 'bg2' => [243, 232, 255], 'main' => [147, 51, 234], 'sub' => [216, 180, 254], 'shape' => 'round_head'],
+ 'veg-green-cabbage' => ['name' => '青甘蓝', 'bg1' => [236, 253, 245], 'bg2' => [209, 250, 229], 'main' => [16, 185, 129], 'sub' => [167, 243, 208], 'shape' => 'round_head'],
+ 'veg-greens' => ['name' => '青菜', 'bg1' => [240, 253, 244], 'bg2' => [187, 247, 208], 'main' => [21, 128, 61], 'sub' => [74, 222, 128], 'shape' => 'greens'],
+ 'veg-radish' => ['name' => '萝卜', 'bg1' => [255, 251, 235], 'bg2' => [254, 243, 199], 'main' => [248, 250, 252], 'sub' => [34, 197, 94], 'shape' => 'radish'],
+ 'veg-chili' => ['name' => '辣椒', 'bg1' => [254, 242, 242], 'bg2' => [254, 226, 226], 'main' => [220, 38, 38], 'sub' => [22, 163, 74], 'shape' => 'chili'],
+ 'veg-tomato' => ['name' => '西红柿', 'bg1' => [254, 242, 242], 'bg2' => [254, 215, 170], 'main' => [239, 68, 68], 'sub' => [22, 163, 74], 'shape' => 'tomato'],
+ // 水果二级分类
+ 'fruit-apple' => ['name' => '苹果', 'bg1' => [254, 242, 242], 'bg2' => [254, 226, 226], 'main' => [225, 29, 72], 'sub' => [34, 197, 94], 'shape' => 'apple'],
+ 'fruit-orange' => ['name' => '柑橘', 'bg1' => [255, 247, 237], 'bg2' => [255, 237, 213], 'main' => [249, 115, 22], 'sub' => [34, 197, 94], 'shape' => 'orange'],
+ 'fruit-kiwi' => ['name' => '猕猴桃', 'bg1' => [247, 254, 231], 'bg2' => [217, 249, 157], 'main' => [101, 163, 13], 'sub' => [161, 98, 7], 'shape' => 'kiwi'],
+ 'fruit-strawberry' => ['name' => '草莓', 'bg1' => [255, 241, 242], 'bg2' => [255, 228, 230], 'main' => [244, 63, 94], 'sub' => [22, 163, 74], 'shape' => 'strawberry'],
+ 'fruit-watermelon' => ['name' => '西瓜', 'bg1' => [240, 253, 244], 'bg2' => [254, 226, 226], 'main' => [22, 163, 74], 'sub' => [239, 68, 68], 'shape' => 'watermelon'],
+ 'fruit-grape' => ['name' => '葡萄', 'bg1' => [250, 245, 255], 'bg2' => [233, 213, 255], 'main' => [126, 34, 206], 'sub' => [34, 197, 94], 'shape' => 'grape'],
+ 'fruit-peach' => ['name' => '蜜桃', 'bg1' => [253, 242, 248], 'bg2' => [252, 231, 243], 'main' => [244, 114, 182], 'sub' => [34, 197, 94], 'shape' => 'apple'],
+ 'fruit-passion' => ['name' => '百香果', 'bg1' => [254, 249, 195], 'bg2' => [243, 232, 255], 'main' => [147, 51, 234], 'sub' => [234, 179, 8], 'shape' => 'orange'],
+ ];
+
+ $fontFile = null;
+ foreach (['C:\\Windows\\Fonts\\msyhbd.ttc', 'C:\\Windows\\Fonts\\msyh.ttc', 'C:\\Windows\\Fonts\\simhei.ttf'] as $f) {
+ if (file_exists($f)) {
+ $fontFile = $f;
+ break;
+ }
+ }
+
+ foreach ($items as $key => $cfg) {
+ $size = 240;
+ $img = imagecreatetruecolor($size, $size);
+ imagealphablending($img, false);
+ imagesavealpha($img, true);
+ $trans = imagecolorallocatealpha($img, 0, 0, 0, 127);
+ imagefill($img, 0, 0, $trans);
+
+ // 圆角渐变底图
+ $rad = 44;
+ for ($y = 0; $y < $size; $y++) {
+ $ratio = $y / $size;
+ $r = (int)($cfg['bg1'][0] * (1 - $ratio) + $cfg['bg2'][0] * $ratio);
+ $g = (int)($cfg['bg1'][1] * (1 - $ratio) + $cfg['bg2'][1] * $ratio);
+ $b = (int)($cfg['bg1'][2] * (1 - $ratio) + $cfg['bg2'][2] * $ratio);
+ $col = imagecolorallocate($img, $r, $g, $b);
+ for ($x = 0; $x < $size; $x++) {
+ $in = true;
+ if ($x < $rad && $y < $rad) {
+ $in = (($x - $rad) ** 2 + ($y - $rad) ** 2) <= ($rad ** 2);
+ } elseif ($x >= ($size - $rad) && $y < $rad) {
+ $in = (($x - ($size - $rad)) ** 2 + ($y - $rad) ** 2) <= ($rad ** 2);
+ } elseif ($x < $rad && $y >= ($size - $rad)) {
+ $in = (($x - $rad) ** 2 + ($y - ($size - $rad)) ** 2) <= ($rad ** 2);
+ } elseif ($x >= ($size - $rad) && $y >= ($size - $rad)) {
+ $in = (($x - ($size - $rad)) ** 2 + ($y - ($size - $rad)) ** 2) <= ($rad ** 2);
+ }
+ if ($in) {
+ imagesetpixel($img, $x, $y, $col);
+ }
+ }
+ }
+
+ imagealphablending($img, true);
+ $mainCol = imagecolorallocate($img, $cfg['main'][0], $cfg['main'][1], $cfg['main'][2]);
+ $subCol = imagecolorallocate($img, $cfg['sub'][0], $cfg['sub'][1], $cfg['sub'][2]);
+ $white = imagecolorallocate($img, 255, 255, 255);
+ $stemCol = imagecolorallocate($img, 21, 128, 61);
+
+ $cx = 120;
+ $cy = 102;
+
+ switch ($cfg['shape']) {
+ case 'cauliflower':
+ // 绿叶托底 + 洁白花球
+ imagefilledellipse($img, $cx - 32, $cy + 22, 68, 54, $subCol);
+ imagefilledellipse($img, $cx + 32, $cy + 22, 68, 54, $subCol);
+ imagefilledellipse($img, $cx, $cy + 30, 80, 48, $subCol);
+ imagefilledellipse($img, $cx - 24, $cy, 62, 58, $mainCol);
+ imagefilledellipse($img, $cx + 24, $cy, 62, 58, $mainCol);
+ imagefilledellipse($img, $cx, $cy - 18, 68, 62, $mainCol);
+ imagefilledellipse($img, $cx, $cy + 8, 76, 60, $white);
+ break;
+
+ case 'cabbage':
+ case 'greens':
+ // 层叠菜叶 + 白帮
+ imagefilledellipse($img, $cx - 22, $cy - 8, 72, 92, $mainCol);
+ imagefilledellipse($img, $cx + 22, $cy - 8, 72, 92, $mainCol);
+ imagefilledellipse($img, $cx, $cy - 16, 82, 96, $subCol);
+ imagefilledellipse($img, $cx, $cy + 22, 58, 68, $white);
+ break;
+
+ case 'round_head':
+ // 甘蓝球体 + 纹理弧线
+ imagefilledellipse($img, $cx, $cy, 112, 106, $mainCol);
+ imagefilledellipse($img, $cx - 12, $cy - 10, 78, 74, $subCol);
+ imagefilledellipse($img, $cx - 16, $cy - 12, 58, 54, $mainCol);
+ break;
+
+ case 'radish':
+ // 白萝卜机身 + 绿缨
+ imagefilledellipse($img, $cx - 16, $cy - 44, 24, 42, $subCol);
+ imagefilledellipse($img, $cx + 16, $cy - 44, 24, 42, $subCol);
+ imagefilledellipse($img, $cx, $cy - 48, 26, 48, $stemCol);
+ imagefilledellipse($img, $cx, $cy + 10, 74, 102, $white);
+ break;
+
+ case 'chili':
+ // 红辣椒双果
+ imagefilledellipse($img, $cx - 14, $cy + 6, 46, 108, $mainCol);
+ imagefilledellipse($img, $cx + 18, $cy + 10, 44, 98, $mainCol);
+ imagefilledellipse($img, $cx - 14, $cy - 42, 22, 18, $subCol);
+ imagefilledellipse($img, $cx + 18, $cy - 34, 22, 18, $subCol);
+ break;
+
+ case 'grape':
+ // 晶莹葡萄串
+ $pts = [
+ [-26, -12], [0, -12], [26, -12],
+ [-14, 14], [14, 14],
+ [0, 38]
+ ];
+ foreach ($pts as $pt) {
+ imagefilledellipse($img, $cx + $pt[0], $cy + $pt[1], 40, 40, $mainCol);
+ imagefilledellipse($img, $cx + $pt[0] - 6, $cy + $pt[1] - 6, 10, 10, imagecolorallocatealpha($img, 255, 255, 255, 70));
+ }
+ imagefilledellipse($img, $cx, $cy - 40, 46, 22, $subCol);
+ break;
+
+ default:
+ // 饱满果实 + 绿叶高光
+ imagefilledellipse($img, $cx, $cy + 6, 106, 98, $mainCol);
+ imagefilledellipse($img, $cx + 18, $cy - 40, 42, 24, $subCol);
+ imagefilledellipse($img, $cx - 24, $cy - 12, 24, 34, imagecolorallocatealpha($img, 255, 255, 255, 80));
+ break;
+ }
+
+ // 底部清晰品类标签
+ if ($fontFile) {
+ $text = $cfg['name'];
+ $fontSize = 22;
+ $box = imagettfbbox($fontSize, 0, $fontFile, $text);
+ $tw = $box[2] - $box[0];
+ $tx = (int)(($size - $tw) / 2) - $box[0];
+ $ty = 208;
+ $textCol = imagecolorallocate($img, 30, 41, 59);
+ imagettftext($img, $fontSize, 0, $tx, $ty, $textCol, $fontFile, $text);
+ }
+
+ $out1 = __DIR__ . '/../public/static/categories/' . $key . '.png';
+ $out2 = __DIR__ . '/../uniapp/static/categories/' . $key . '.png';
+ imagepng($img, $out1);
+ imagepng($img, $out2);
+
+ if ($key === 'cat-veg' || $key === 'cat-fruit') {
+ imagepng($img, __DIR__ . '/../public/static/icons/' . $key . '.png');
+ imagepng($img, __DIR__ . '/../uniapp/static/icons/' . $key . '.png');
+ }
+ imagedestroy($img);
+ }
+
+ echo "Generated " . count($items) . " category product images.\n";
+}
+
+generateCategoryImages();
diff --git a/tools/verify-api.mjs b/tools/verify-api.mjs
index f0dce67..99131b5 100644
--- a/tools/verify-api.mjs
+++ b/tools/verify-api.mjs
@@ -392,10 +392,13 @@ async function adminMoney() {
/* ---------------- 七、后台 · 权限 / 设置(13) ---------------- */
async function adminRbacSetting() {
- await ok200('AR1 GET /admin/roles', 'GET', '/admin/roles', null, false,
+ const roleList = await ok200('AR1 GET /admin/roles', 'GET', '/admin/roles', null, false,
(d) => (Array.isArray(d) && 'name' in (d[0] || {}) && Array.isArray((d[0] || {}).permissions) ? '' : '缺 name/permissions'))
- await ok200('AR1 POST /admin/role', 'POST', '/admin/role',
- { name: '接口验证角色', permissions: ['dashboard', 'post'], remark: '由验证脚本创建' }, false,
+ // 幂等:复用已存在的「接口验证角色」(带 id 走更新),避免每次验证都新增一条角色记录
+ const reuseRole = Array.isArray(roleList) ? roleList.find((r) => r && r.name === '接口验证角色') : null
+ const rolePayload = { name: '接口验证角色', permissions: ['dashboard', 'post'], remark: '由验证脚本创建' }
+ if (reuseRole && reuseRole.id) rolePayload.id = reuseRole.id
+ await ok200('AR1 POST /admin/role', 'POST', '/admin/role', rolePayload, false,
(d) => (d && d.name === '接口验证角色' ? '' : 'name 不符'))
await expectFail('AR1 · 角色名必填 (BR-12)', 'POST', '/admin/role', { permissions: ['post'] }, false, '请填写角色名称')
await expectFail('AR1 · 权限必填 (BR-12)', 'POST', '/admin/role', { name: 'x', permissions: [] }, false, '请至少分配一项权限')
diff --git a/uniapp/common/api/home.js b/uniapp/common/api/home.js
index a3db778..f180c98 100644
--- a/uniapp/common/api/home.js
+++ b/uniapp/common/api/home.js
@@ -11,9 +11,10 @@ export const homeApi = {
categories: () => get('/home/categories', {}, { silent: true }),
/**
* 信息流(LBS + 筛选排序)
- * 入参:{ page, size, categoryId, keyword, areaId, area, sort, lat, lng }
+ * 入参:{ page, size, categoryId, subCategoryId, keyword, areaId, area, sort, lat, lng }
* 区域:只按服务区域(区县)筛选,兼容旧的 area 名称
- * sort: new 最新 / hot 最热 / price 价格 / nearby 附近(按 distance 升序,无坐标排最后)
+ * sort: new 最新 / hot 最热 / nearby 附近(按 distance 升序,无坐标排最后)
+ * price_asc 价格升序 / price_desc 价格降序(兼容旧值 price = 升序)
* 出参列表项含 distance(float|km,一位小数;信息无坐标时 null)
*/
feed: (params = {}) => get('/home/feed', params, { silent: true }),
diff --git a/uniapp/common/api/merchant.js b/uniapp/common/api/merchant.js
index d34f508..1d5d86c 100644
--- a/uniapp/common/api/merchant.js
+++ b/uniapp/common/api/merchant.js
@@ -4,7 +4,7 @@
* GET /api/v1/merchant/:id 获取商家门店公开主页与档案
* GET /api/v1/merchant/:id/posts 获取商家名下发布的信息列表
*/
-import { get } from '../utils/request.js'
+import { get, post } from '../utils/request.js'
export const merchantApi = {
/**
@@ -15,6 +15,14 @@ export const merchantApi = {
*/
detail: (id, params = {}) => get(`/merchant/${id}`, params, { silent: true }),
+ /**
+ * 申请拨打商家联系电话(校验每日拨打次数上限)
+ * @param {number|string} id 商家ID或用户ID
+ * @param {Object} payload
+ * @returns {Promise<{phoneNumber:string, dialDisplay:string, callQuotaLeft:number}>}
+ */
+ dial: (id, payload = {}) => post(`/merchant/${id}/dial`, payload, { silent: true }),
+
/**
* 获取商家发布的信息流(分页)
* @param {number|string} id 商家ID或用户ID
diff --git a/uniapp/common/api/post.js b/uniapp/common/api/post.js
index 50ddf96..aed0aa2 100644
--- a/uniapp/common/api/post.js
+++ b/uniapp/common/api/post.js
@@ -61,6 +61,8 @@ export const postApi = {
/** 详情(accessOnly=1:仅回读解锁态,不计浏览量) */
detail: (id, params = {}) => get(`/post/${id}`, params, { silent: true }),
+ /** 申请拨打联系电话(校验每日拨打次数上限并记录拨打日志) */
+ dial: (id, payload = {}) => post(`/post/${id}/dial`, payload, { silent: true }),
/** 付费查看联系方式(微信/余额) */
payView: (id, payload) => post(`/post/${id}/pay-view`, payload, { silent: true }),
/** 发表评价(评分 + 图文) */
diff --git a/uniapp/common/assets/icons.js b/uniapp/common/assets/icons.js
index 6f35b09..4bfd25e 100644
--- a/uniapp/common/assets/icons.js
+++ b/uniapp/common/assets/icons.js
@@ -28,6 +28,24 @@ export const ICON_GROUPS = [
{
group: '同城分类',
items: [
+ { key: 'cat-veg', name: '蔬菜大类', file: 'cat-veg.png' },
+ { key: 'cat-fruit', name: '水果大类', file: 'cat-fruit.png' },
+ { key: 'sub-cauliflower', name: '花菜', file: 'sub-cauliflower.png' },
+ { key: 'sub-cabbage', name: '白菜', file: 'sub-cabbage.png' },
+ { key: 'sub-purple-cabbage', name: '紫甘蓝', file: 'sub-purple-cabbage.png' },
+ { key: 'sub-green-cabbage', name: '青甘蓝', file: 'sub-green-cabbage.png' },
+ { key: 'sub-greens', name: '青菜', file: 'sub-greens.png' },
+ { key: 'sub-radish', name: '萝卜', file: 'sub-radish.png' },
+ { key: 'sub-chili', name: '辣椒', file: 'sub-chili.png' },
+ { key: 'sub-tomato', name: '西红柿', file: 'sub-tomato.png' },
+ { key: 'sub-apple', name: '苹果', file: 'sub-apple.png' },
+ { key: 'sub-orange', name: '柑橘', file: 'sub-orange.png' },
+ { key: 'sub-kiwi', name: '猕猴桃', file: 'sub-kiwi.png' },
+ { key: 'sub-strawberry', name: '草莓', file: 'sub-strawberry.png' },
+ { key: 'sub-watermelon', name: '西瓜', file: 'sub-watermelon.png' },
+ { key: 'sub-grape', name: '葡萄', file: 'sub-grape.png' },
+ { key: 'sub-peach', name: '蜜桃', file: 'sub-peach.png' },
+ { key: 'sub-passion', name: '百香果', file: 'sub-passion.png' },
{ key: 'cat-job', name: '招聘求职', file: 'cat-job.png' },
{ key: 'cat-house', name: '房产租售', file: 'cat-house.png' },
{ key: 'cat-goods', name: '二手闲置', file: 'cat-goods.png' },
diff --git a/uniapp/common/mock/index.js b/uniapp/common/mock/index.js
index 5b59943..dde8bc6 100644
--- a/uniapp/common/mock/index.js
+++ b/uniapp/common/mock/index.js
@@ -198,7 +198,8 @@ export const mockRoutes = {
})
list.sort((a, b) => (Number(b.isTop) - Number(a.isTop)) || (new Date(b.createdAt) - new Date(a.createdAt)))
- if (data && data.sort === 'price') list.sort((a, b) => (Number(b.isTop) - Number(a.isTop)) || ((a.price || 0) - (b.price || 0)))
+ if (data && (data.sort === 'price' || data.sort === 'price_asc')) list.sort((a, b) => (Number(b.isTop) - Number(a.isTop)) || ((a.price || 0) - (b.price || 0)))
+ if (data && data.sort === 'price_desc') list.sort((a, b) => (Number(b.isTop) - Number(a.isTop)) || ((b.price || 0) - (a.price || 0)))
if (data && data.sort === 'hot') list.sort((a, b) => (Number(b.isTop) - Number(a.isTop)) || (b.views - a.views))
// 附近:按距离升序,无坐标的排最后(置顶仍优先)
if (data && data.sort === 'nearby') {
diff --git a/uniapp/components/fc-call-modal/fc-call-modal.vue b/uniapp/components/fc-call-modal/fc-call-modal.vue
new file mode 100644
index 0000000..1041f91
--- /dev/null
+++ b/uniapp/components/fc-call-modal/fc-call-modal.vue
@@ -0,0 +1,266 @@
+
+
+
+
+
+
+
+
+
+
+ {{ dialDisplay || '暂无联系电话' }}
+
+
+ {{ quotaText }}
+
+
+
+
+
+
+ 请自行鉴别农产品信息真伪,在未核实清楚前不要提前给对方转账,慎防诈骗!
+
+
+
+
+
+ ✓
+
+ 我已阅读并同意
+ 《平台免责声明》
+
+
+
+
+
+ {{ loading ? '连接中…' : '立即拨打' }}
+
+
+
+
+
+
+
+
diff --git a/uniapp/components/fc-city-picker/fc-city-picker.vue b/uniapp/components/fc-city-picker/fc-city-picker.vue
new file mode 100644
index 0000000..fb3afe1
--- /dev/null
+++ b/uniapp/components/fc-city-picker/fc-city-picker.vue
@@ -0,0 +1,265 @@
+
+
+
+
+
+
+
+
+
+ 省份 / 全国
+ 城市
+
+
+
+
+
+ 全国
+ ✓
+
+
+ {{ p.name }}
+
+
+
+
+
+
+ 全部
+ ✓
+
+
+ {{ c.name }}
+
+
+
+
+
+
+
+
+
+
+
diff --git a/uniapp/components/fc-pay-password/fc-pay-password.vue b/uniapp/components/fc-pay-password/fc-pay-password.vue
index 4a3d934..9e9d179 100644
--- a/uniapp/components/fc-pay-password/fc-pay-password.vue
+++ b/uniapp/components/fc-pay-password/fc-pay-password.vue
@@ -1,6 +1,6 @@
-
+
{{ title }}
diff --git a/uniapp/components/fc-post-card/fc-post-card.vue b/uniapp/components/fc-post-card/fc-post-card.vue
index 8508004..24ccd99 100644
--- a/uniapp/components/fc-post-card/fc-post-card.vue
+++ b/uniapp/components/fc-post-card/fc-post-card.vue
@@ -17,13 +17,15 @@
{{ post.title }}
-
+
置顶
{{ post.categoryName }}
+
+ {{ harvestBadge }}
{{ t }}
@@ -40,7 +42,8 @@
{{ post.price }}
{{ post.priceUnit || '元' }}
-
面议
+
+
{{ post.priceUnit || '面议' }}
@@ -78,6 +81,14 @@ export default {
distanceText() {
return this.post.distance == null ? '' : formatKm(this.post.distance)
},
+ /**
+ * 农产品上市角标:解析采摘/上市日期(YYYY-MM-DD)提取月份,如「10月上市」
+ * 非标准日期格式(用户自定义文本)不展示角标,避免卡片排版溢出
+ */
+ harvestBadge() {
+ const m = /^(\d{4})-(\d{1,2})(-\d{1,2})?$/.exec(String(this.post.harvestTime || '').trim())
+ return m ? `${parseInt(m[2], 10)}月上市` : ''
+ },
/**
* 帖子封面图:优先使用实际上传封面或第一张实拍图,无图时回退为空由图标微卡片兜底
*/
@@ -223,6 +234,14 @@ export default {
padding: 2rpx 10rpx;
box-shadow: 0 2rpx 8rpx rgba(0, 210, 106, 0.35);
}
+/* 上市时间角标:阳光金浅底(价值/新鲜度信号),与全局价格色一致 */
+.fc-post-card__tag--harvest {
+ background: #fdf3e0;
+ color: #b47411;
+ font-weight: 600;
+ border-radius: 6rpx;
+ padding: 2rpx 10rpx;
+}
.fc-post-card__meta {
display: flex;
align-items: center;
diff --git a/uniapp/docs/03-接口文档.md b/uniapp/docs/03-接口文档.md
index e79aa4d..0d32d25 100644
--- a/uniapp/docs/03-接口文档.md
+++ b/uniapp/docs/03-接口文档.md
@@ -94,7 +94,7 @@
| GET | `/home/areas` | — | 平铺服务区域 `[{ id, province, city, district, lat, lng }]`(仅启用;区县为最终服务区域,省/市由前端生成级联列) |
| GET | `/home/locate` | `{ lat, lng }` | `{ areaId, province, city, district, distance }` 或 `null`(300km 内最近服务区域) |
-- `sort` 枚举:`new`(默认,按发布时间)/ `hot`(按浏览量)/ `price`(按价格升序)/ **`nearby`(v1.1.0,按距离升序)**
+- `sort` 枚举:`new`(默认,按发布时间)/ `hot`(按浏览量)/ `price_asc`(按价格升序)/ `price_desc`(按价格降序)/ **`nearby`(v1.1.0,按距离升序)**;兼容旧值 `price` = 升序
- **区域筛选(v1.8)**:每条服务区域数据自带省 / 市 / 区县,业务筛选只认 `areaId`(兼容旧参数 `area`=区县名称);省 / 市仅用于级联下拉选择,不作为筛选条件。前端默认用 `/home/locate` 把定位转成 `areaId`。
- **LBS 距离(v1.1.0)**:传入 `lat`/`lng`(gcj02,可与 `categoryId`/`keyword`/`area` 组合)后,列表项新增 `distance`(number|**km,一位小数**;请求未带坐标或信息未定位时为 `null`)。
`sort=nearby` 时按 `distance` 升序,**无坐标的信息排最后**;请求未带 `lat`/`lng` 时 `nearby` 回落发布时间倒序。距离由服务端 Haversine 计算(`Post`/`Home` 同一算法),客户端不参与排序。
diff --git a/uniapp/pages/auth/agreement.vue b/uniapp/pages/auth/agreement.vue
index 310c07c..8bf51f8 100644
--- a/uniapp/pages/auth/agreement.vue
+++ b/uniapp/pages/auth/agreement.vue
@@ -42,7 +42,7 @@ export default {
components: { FcNavbar },
data() {
return {
- type: 'service', // service | privacy
+ type: 'service', // service | privacy | disclaimer
title: '用户服务协议',
content: '',
updateTime: '2026-10-20',
@@ -55,7 +55,9 @@ export default {
* @returns {string}
*/
pageTitle() {
- return this.type === 'privacy' ? '隐私政策' : '用户协议'
+ if (this.type === 'privacy') return '隐私政策'
+ if (this.type === 'disclaimer') return '平台免责声明'
+ return '用户协议'
},
/** 站点名称(后台「小程序配置」下发) */
siteName() {
diff --git a/uniapp/pages/category/channel.vue b/uniapp/pages/category/channel.vue
index 99f2c71..a650df2 100644
--- a/uniapp/pages/category/channel.vue
+++ b/uniapp/pages/category/channel.vue
@@ -3,8 +3,36 @@
-
-
+
+
+
+
+
+
+
+ 全部
+
+
+
+
+
+ {{ sub.name }}
+
+
+
+
+
+
@@ -19,16 +47,17 @@
{{ s.label }}
+
+
+
+
+
+
+
+
+ {{ areaDisplay }}
+ ▾
-
@@ -50,6 +79,16 @@
+ 发布
+
+
+
@@ -57,16 +96,17 @@
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 FcCityPicker from '@/components/fc-city-picker/fc-city-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, FcAreaPicker },
+ components: { FcNavbar, FcPostCard, FcEmpty, FcCityPicker },
data() {
return {
categories: [],
categoryId: 0,
+ subCategoryId: 0,
// 固定具体分类ID(由路由传入,用于区分是否是进入具体分类列表)
fixedCategoryId: 0,
pageTitle: '',
@@ -78,9 +118,12 @@ export default {
// 请求序号:快速切换分类/排序/区域时丢弃过期响应
reqSeq: 0,
sort: 'new',
- // 区域筛选:业务只按服务区域(区县)筛选
- areaId: 0,
- areaText: '',
+ // 价格排序方向(asc 升序 / desc 降序),点击已选中的「价格」时切换
+ priceOrder: 'asc',
+ // 区域筛选:只到市级(全国/省/市),与首页口径一致
+ selectedProvince: '',
+ selectedCity: '',
+ showAreaPicker: false,
manualArea: false,
lat: null,
lng: null,
@@ -96,12 +139,31 @@ export default {
computed: {
/**
* 判断是否为具体分类展示模式
- * 当携带了具体 categoryId 进入时即为具体分类页,自动隐藏顶部横向切换栏
- * @returns {boolean} 是否为具体分类页面
+ * @returns {boolean}
*/
isSpecificCategory() {
return !!this.fixedCategoryId
},
+ /**
+ * 当前大类对象
+ */
+ currentParentCat() {
+ return (this.categories || []).find((c) => Number(c.id) === Number(this.categoryId)) || null
+ },
+ /**
+ * 当前大类下的二级分类列表
+ */
+ subCategories() {
+ return (this.currentParentCat && Array.isArray(this.currentParentCat.children)) ? this.currentParentCat.children : []
+ },
+ /**
+ * 筛选栏区域文案(城市 > 省份 > 缺省「区域」)
+ */
+ areaDisplay() {
+ if (this.selectedCity) return this.selectedCity
+ if (this.selectedProvince) return this.selectedProvince
+ return '区域'
+ },
},
/**
* 页面加载:读取分类入参并彻底防止 URL 编码乱码
@@ -145,23 +207,29 @@ export default {
* 页面初始化:拉取分类与区域筛选项,并执行首次信息流拉取
*/
async init() {
- // 若是具体分类页面,无须加载全部分类横滑列表;非具体分类才需要拉取
- if (!this.fixedCategoryId) {
- try {
- this.categories = await homeApi.categories()
- } catch (e) {}
- } else {
- // 若未传分类名或标题仍残留编码字符,通过接口查到名称补齐/修正导航栏标题
- try {
- const cats = await homeApi.categories()
- const current = (cats || []).find((c) => Number(c.id) === Number(this.categoryId))
+ try {
+ const cats = await homeApi.categories()
+ this.categories = Array.isArray(cats) ? cats : []
+ if (this.fixedCategoryId) {
+ let current = this.categories.find((c) => Number(c.id) === Number(this.categoryId))
+ if (!current) {
+ for (const p of this.categories) {
+ const sub = (p.children || []).find((s) => Number(s.id) === Number(this.categoryId))
+ if (sub) {
+ current = p
+ this.categoryId = Number(p.id)
+ this.subCategoryId = Number(sub.id)
+ break
+ }
+ }
+ }
if (current && (!this.pageTitle || /%[0-9a-fA-F]{2}/.test(this.pageTitle))) {
this.pageTitle = current.name
uni.setNavigationBarTitle({ title: current.name })
}
- } catch (e) {}
- }
- // 服务区域:后台「区域管理」下发(平铺:每条自带省/市/区县),失败静默
+ }
+ } catch (e) {}
+ // 服务区域:默认开放全国省/市/区县
try {
const rows = await homeApi.areas()
this.areaRows = Array.isArray(rows) ? rows : []
@@ -189,15 +257,15 @@ export default {
})
},
/**
- * 把定位坐标转换成区域筛选默认值(用户手动切换过则不覆盖)
+ * 把定位坐标转换成区域筛选默认值(只匹配到市级,用户手动切换过则不覆盖)
*/
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.selectedProvince = found.province || ''
+ this.selectedCity = found.city || ''
}
} catch (e) {}
},
@@ -213,8 +281,12 @@ export default {
page: this.page,
size: this.size,
categoryId: this.categoryId || undefined,
- sort: this.sort,
- areaId: this.areaId || undefined,
+ subCategoryId: this.subCategoryId || undefined,
+ // 价格排序带方向:price_asc / price_desc(后端按方向排序)
+ sort: this.sort === 'price' ? `price_${this.priceOrder}` : this.sort,
+ // 区域筛选只到市级:城市优先,其次省份
+ province: !this.selectedCity && this.selectedProvince ? this.selectedProvince : undefined,
+ city: this.selectedCity || undefined,
})
// 期间又切换了筛选条件:以最后一次请求为准
if (seq !== this.reqSeq) return
@@ -241,36 +313,63 @@ export default {
*/
changeCategory(c) {
this.categoryId = this.categoryId === c.id ? 0 : c.id
+ this.subCategoryId = 0
this.page = 1
this.fetch(true)
},
/**
- * 切换排序方式
+ * 切换二级分类筛选项
+ * @param {Object|null} sub 二级分类
+ */
+ changeSubCategory(sub) {
+ const nextId = sub ? Number(sub.id) : 0
+ if (this.subCategoryId === nextId) return
+ this.subCategoryId = nextId
+ this.page = 1
+ this.fetch(true)
+ },
+ /**
+ * 切换排序方式(价格项:首次点击升序,再次点击升降序来回切换)
* @param {string} v 排序字段(new/hot/price)
*/
changeSort(v) {
- if (this.sort === v) return
+ if (v === 'price') {
+ if (this.sort === 'price') {
+ this.priceOrder = this.priceOrder === 'asc' ? 'desc' : 'asc'
+ } else {
+ this.priceOrder = 'asc'
+ }
+ } else if (this.sort === v) {
+ return
+ }
this.sort = v
this.page = 1
this.fetch(true)
},
/**
- * 级联选择服务区域(null = 全部区域)
- * @param {Object|null} area
+ * 打开城市选择抽屉
*/
- onAreaChange(area) {
- this.areaId = area ? Number(area.areaId) || 0 : 0
- this.areaText = area ? area.district || '' : ''
+ openAreaPicker() {
+ this.showAreaPicker = true
+ },
+ /**
+ * 关闭城市选择抽屉
+ */
+ closeAreaPicker() {
+ this.showAreaPicker = false
+ },
+ /**
+ * 城市选择抽屉回调(全国/全省/全市统一入口)
+ * @param {Object} area { province, city },空串表示全国/全省
+ */
+ onAreaSelect(area) {
+ this.selectedProvince = (area && area.province) || ''
+ this.selectedCity = (area && area.city) || ''
this.manualArea = true
+ this.showAreaPicker = false
this.page = 1
this.fetch(true)
},
- /** 使用当前位置:清除手动选择,重新定位并匹配区域 */
- useCurrentLocation() {
- this.manualArea = false
- this.fetchLocation()
- uni.showToast({ title: '已按当前位置匹配', icon: 'none' })
- },
/**
* 跳转到信息详情页
* @param {Object} p 信息项
@@ -297,6 +396,56 @@ export default {
padding: 16rpx 0;
border-bottom: 2rpx solid $fc-border;
}
+.list__subcats {
+ background: #ffffff;
+ white-space: nowrap;
+ padding: 20rpx 0 16rpx;
+ border-bottom: 1rpx solid rgba(0, 0, 0, 0.04);
+}
+.list__subcats-inner {
+ display: inline-flex;
+ padding: 0 20rpx;
+ gap: 24rpx;
+}
+.list__subcat {
+ display: inline-flex;
+ flex-direction: column;
+ align-items: center;
+ flex: 0 0 auto;
+ &--active {
+ .list__subcat-thumb {
+ border-color: #00d26a;
+ background: #ecfdf5;
+ box-shadow: 0 4rpx 12rpx rgba(0, 210, 106, 0.22);
+ }
+ .list__subcat-name {
+ color: #00a854;
+ font-weight: 700;
+ }
+ }
+}
+.list__subcat-thumb {
+ width: 96rpx;
+ height: 96rpx;
+ border-radius: 24rpx;
+ background: #f8fafc;
+ border: 2rpx solid transparent;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 8rpx;
+ box-sizing: border-box;
+}
+.list__subcat-img {
+ width: 100%;
+ height: 100%;
+ border-radius: 16rpx;
+}
+.list__subcat-name {
+ margin-top: 8rpx;
+ font-size: 23rpx;
+ color: #334155;
+}
.list__cats-inner {
display: inline-flex;
padding: 0 16rpx;
@@ -360,13 +509,68 @@ export default {
margin-right: 28rpx;
font-size: $fc-font;
color: $fc-text-secondary;
+ display: inline-flex;
+ align-items: center;
&--active {
color: $fc-primary-text;
font-weight: 700;
}
}
-.list__filter-area {
+/* 价格排序双三角指示器(未选中灰、选中主题绿) */
+.list__caret {
+ display: inline-flex;
+ flex-direction: column;
+ align-items: center;
+ margin-left: 6rpx;
+ gap: 3rpx;
+}
+.list__caret-up {
+ width: 0;
+ height: 0;
+ border-left: 7rpx solid transparent;
+ border-right: 7rpx solid transparent;
+ border-bottom: 9rpx solid #cbd5e1;
+ &.is-on {
+ border-bottom-color: #00a854;
+ }
+}
+.list__caret-down {
+ width: 0;
+ height: 0;
+ border-left: 7rpx solid transparent;
+ border-right: 7rpx solid transparent;
+ border-top: 9rpx solid #cbd5e1;
+ &.is-on {
+ border-top-color: #00a854;
+ }
+}
+/* 筛选栏区域按钮(与首页定位胶囊同款:白底描边胶囊 + 主题绿字) */
+.list__filter-area-btn {
margin-left: auto;
+ display: inline-flex;
+ align-items: center;
+ padding: 8rpx 20rpx;
+ background: #ffffff;
+ border: 1rpx solid rgba(0, 168, 84, 0.22);
+ border-radius: 999rpx;
+ box-shadow: 0 2rpx 8rpx rgba(0, 168, 84, 0.06);
+}
+.list__filter-area-icon {
+ width: 24rpx;
+ height: 24rpx;
+ margin-right: 6rpx;
+ flex-shrink: 0;
+}
+.list__filter-area-txt {
+ font-size: 24rpx;
+ color: #00a854;
+ font-weight: 600;
+ max-width: 180rpx;
+}
+.list__filter-area-arrow {
+ font-size: 20rpx;
+ color: #00a854;
+ margin-left: 6rpx;
}
.list__loading {
padding: 24rpx;
diff --git a/uniapp/pages/category/index.vue b/uniapp/pages/category/index.vue
index ddf2309..6966559 100644
--- a/uniapp/pages/category/index.vue
+++ b/uniapp/pages/category/index.vue
@@ -41,14 +41,53 @@
-
+
-
+
+
+
+ {{ currentCategory ? currentCategory.name : '精选' }}品类
+ 查看全部 ›
+
+
+
+
+
+
+
+ 全部{{ currentCategory ? currentCategory.name : '' }}
+
+
+
+
+
+ {{ sub.name }}
+
+
+
+
+
+
- {{ s.label }}
+ {{ s.label }}
+
+
+
+
+
+
+
+
+ {{ currentAreaText }}
+ ▾
@@ -93,6 +142,97 @@
+
+
+
+
+
+
+
+ 切换服务位置
+ 筛选当前分类下的同城信息区域
+
+ ✕
+
+
+
+
+
+
+
+
+ 当前位置:
+ {{ currentAreaText }}
+ 手动选择
+ 定位匹配
+
+ {{ locStatusDesc }}
+
+
+
+ ⟳
+ {{ isLocating ? '定位中…' : '重新定位' }}
+
+
+
+
+
+
+ 省份 / 全国
+ 城市
+
+
+
+
+
+ 全国
+ ✓
+
+
+ {{ p.name }}
+
+
+
+
+
+
+ 全部
+ ✓
+
+
+ {{ c.name }}
+
+
+
+
+
+
@@ -104,6 +244,35 @@ import FcEmpty from '@/components/fc-empty/fc-empty.vue'
import homeApi from '@/common/api/home.js'
import { iconUrl, categoryIconUrl, catIcon, loadUiConfig } from '@/common/store/ui.js'
import { getNavMetrics } from '@/common/utils/navbar.js'
+import { groupAreaTree } from '@/common/utils/area.js'
+
+// 与首页共享的区域选择缓存(两端区域筛选状态互通)
+const STORAGE_KEY_SELECTED_AREA = 'fc_user_selected_area'
+
+/**
+ * 安全读取本地缓存
+ * @param {string} key 缓存键名
+ * @param {*} fallback 默认值
+ */
+function safeGetStorage(key, fallback = null) {
+ try {
+ const val = uni.getStorageSync(key)
+ return val !== undefined && val !== '' && val !== null ? val : fallback
+ } catch (e) {
+ return fallback
+ }
+}
+
+/**
+ * 安全写入本地缓存
+ * @param {string} key 缓存键名
+ * @param {*} value 存储内容
+ */
+function safeSetStorage(key, value) {
+ try {
+ uni.setStorageSync(key, value)
+ } catch (e) {}
+}
export default {
components: { FcNavbar, FcTabbar, FcPostCard, FcEmpty },
@@ -115,7 +284,20 @@ export default {
keyword: '',
categories: [],
currentCategory: null,
+ currentSubCategory: null,
sort: 'new',
+ // 价格排序方向(asc 升序 / desc 降序),点击已选中的「价格」时切换
+ priceOrder: 'asc',
+ // 区域筛选(与首页一致:筛选只到市级,省/市两列级联半屏面板)
+ areaRows: [],
+ areaTree: [],
+ selectedProvince: '',
+ selectedCity: '',
+ manualArea: false,
+ showLocModal: false,
+ isLocating: false,
+ activeProvince: '',
+ activeCity: '',
sortOptions: [
{ label: '最新', value: 'new' },
{ label: '最热', value: 'hot' },
@@ -136,19 +318,56 @@ export default {
},
computed: {
/**
- * 输入框占位文案,动态根据当前选中分类切换
+ * 输入框占位文案,动态根据当前选中一级/二级分类切换
*/
searchPlaceholder() {
- const name = this.currentCategory ? this.currentCategory.name : '本地'
+ const name = (this.currentSubCategory && this.currentSubCategory.name) || (this.currentCategory ? this.currentCategory.name : '农产品')
return '在“' + name + '”中搜索…'
},
+ /**
+ * 当前一级分类下的二级分类列表
+ */
+ currentSubCategories() {
+ if (!this.currentCategory || !Array.isArray(this.currentCategory.children)) return []
+ return this.currentCategory.children
+ },
+ /**
+ * 区域筛选按钮文案(市 > 省 > 全国)
+ */
+ currentAreaText() {
+ if (this.selectedCity) return this.selectedCity
+ if (this.selectedProvince) return this.selectedProvince
+ return '全国'
+ },
+ /**
+ * 位置面板内的状态描述文案
+ */
+ locStatusDesc() {
+ if (this.manualArea) {
+ return '当前由您手动锁定展示该区域信息'
+ }
+ if (this.lat != null && this.lng != null) {
+ return '已基于您的地理位置自动匹配所在城市'
+ }
+ return '暂未获取定位,展示全部区域信息'
+ },
+ /**
+ * 级联面板:当前选中省份下的城市列表
+ */
+ cascadeCities() {
+ if (!this.activeProvince || !Array.isArray(this.areaTree)) return []
+ const prov = this.areaTree.find((p) => p.name === this.activeProvince)
+ return (prov && prov.cities) || []
+ },
},
onShow() {
loadUiConfig(true)
+ this.syncAreaFromStorage()
},
onLoad(options) {
this.initMetrics()
this.initLocation()
+ this.fetchAreas()
this.fetchCategories(options && options.categoryId)
},
methods: {
@@ -168,7 +387,7 @@ export default {
this.capsulePadding = m.capsulePadding
},
/**
- * 初始化获取当前用户定位坐标(用于“附近”距离计算与排序)
+ * 初始化获取当前用户定位坐标(用于“附近”距离计算与排序;未手动选区时自动匹配所在城市)
*/
initLocation() {
uni.getLocation({
@@ -183,12 +402,39 @@ export default {
this.hasMore = true
this.fetchPosts()
}
+ // 未手动选区时,按定位自动匹配城市(与首页口径一致)
+ if (!this.manualArea) {
+ this.applyLocationArea()
+ }
},
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) {
+ const nextProv = found.province || ''
+ const nextCity = found.city || ''
+ if (nextProv !== this.selectedProvince || nextCity !== this.selectedCity) {
+ this.selectedProvince = nextProv
+ this.selectedCity = nextCity
+ this.activeProvince = nextProv
+ this.activeCity = nextCity
+ this.page = 1
+ this.list = []
+ this.hasMore = true
+ this.fetchPosts()
+ }
+ }
+ } catch (e) {}
+ },
+ /**
+ * 拉取全部分类数据(支持默认选中一级或二级分类)
* @param {string|number} defaultCatId 默认选中的分类 ID
*/
async fetchCategories(defaultCatId) {
@@ -196,33 +442,74 @@ export default {
const cats = await homeApi.categories()
this.categories = Array.isArray(cats) ? cats : []
if (this.categories.length) {
- const target = defaultCatId
- ? this.categories.find((c) => String(c.id) === String(defaultCatId))
- : null
- this.selectCategory(target || this.categories[0])
+ let targetParent = null
+ let targetSub = null
+ if (defaultCatId) {
+ targetParent = this.categories.find((c) => String(c.id) === String(defaultCatId)) || null
+ if (!targetParent) {
+ for (const p of this.categories) {
+ const foundSub = (p.children || []).find((s) => String(s.id) === String(defaultCatId))
+ if (foundSub) {
+ targetParent = p
+ targetSub = foundSub
+ break
+ }
+ }
+ }
+ }
+ this.currentCategory = targetParent || this.categories[0]
+ this.currentSubCategory = targetSub || null
+ this.page = 1
+ this.list = []
+ this.hasMore = true
+ this.fetchPosts()
}
} catch (e) {
uni.showToast({ title: '分类加载失败', icon: 'none' })
}
},
/**
- * 切换当前选中的左侧分类
- * @param {Object} cat 选中的分类对象
+ * 切换当前选中的左侧一级大类
+ * @param {Object} cat 选中的一级分类对象
*/
selectCategory(cat) {
- if (!cat || (this.currentCategory && this.currentCategory.id === cat.id)) return
+ if (!cat) return
+ if (this.currentCategory && this.currentCategory.id === cat.id && !this.currentSubCategory) return
this.currentCategory = cat
+ this.currentSubCategory = null
this.page = 1
this.list = []
this.hasMore = true
this.fetchPosts()
},
/**
- * 切换排序规则
+ * 切换右侧二级分类(如:花菜、白菜、紫甘蓝、青甘蓝、青菜等)
+ * @param {Object|null} sub 二级分类对象(null代表当前大类全部)
+ */
+ selectSubCategory(sub) {
+ const nextId = sub ? Number(sub.id) : 0
+ const curId = this.currentSubCategory ? Number(this.currentSubCategory.id) : 0
+ if (nextId === curId) return
+ this.currentSubCategory = sub || null
+ this.page = 1
+ this.list = []
+ this.hasMore = true
+ this.fetchPosts()
+ },
+ /**
+ * 切换排序规则(价格项:首次点击升序,再次点击升降序来回切换)
* @param {string} s 排序值 new|hot|nearby|price
*/
changeSort(s) {
- if (this.sort === s) return
+ if (s === 'price') {
+ if (this.sort === 'price') {
+ this.priceOrder = this.priceOrder === 'asc' ? 'desc' : 'asc'
+ } else {
+ this.priceOrder = 'asc'
+ }
+ } else if (this.sort === s) {
+ return
+ }
this.sort = s
this.page = 1
this.list = []
@@ -234,6 +521,172 @@ export default {
this.initLocation()
}
},
+ /**
+ * 拉取服务区域列表(平铺:每条自带省/市/区县),构建省市级联树
+ */
+ async fetchAreas() {
+ try {
+ const rows = await homeApi.areas()
+ this.areaRows = Array.isArray(rows) ? rows : []
+ this.rebuildAreaTree(this.areaRows)
+ } catch (e) {}
+ },
+ /**
+ * 重建级联选择树
+ * @param {Array} rows 平铺区域列表
+ */
+ rebuildAreaTree(rows) {
+ if (!Array.isArray(rows) || !rows.length) return
+ this.areaTree = groupAreaTree(rows)
+ },
+ /**
+ * onShow 时与首页区域选择保持同步(共享同一份缓存)
+ */
+ syncAreaFromStorage() {
+ const saved = safeGetStorage(STORAGE_KEY_SELECTED_AREA, null)
+ const prov = (saved && saved.province) || ''
+ const city = (saved && saved.city) || ''
+ if (prov === this.selectedProvince && city === this.selectedCity) return
+ this.selectedProvince = prov
+ this.selectedCity = city
+ this.manualArea = !!saved
+ this.activeProvince = prov
+ this.activeCity = city
+ this.page = 1
+ this.list = []
+ this.hasMore = true
+ if (this.currentCategory) {
+ this.fetchPosts()
+ }
+ },
+ /**
+ * 打开区域切换半屏面板(与首页同款省/市两列级联)
+ */
+ openLocationModal() {
+ this.showLocModal = true
+ if (!this.activeProvince && this.selectedProvince) {
+ this.activeProvince = this.selectedProvince
+ } else if (!this.activeProvince && this.areaTree.length) {
+ const gz = this.areaTree.find((p) => p.name.indexOf('贵州') !== -1)
+ this.activeProvince = gz ? gz.name : ''
+ }
+ if (!this.activeCity && this.selectedCity) {
+ this.activeCity = this.selectedCity
+ }
+ },
+ /**
+ * 关闭区域切换面板
+ */
+ closeLocationModal() {
+ this.showLocModal = false
+ },
+ /**
+ * 级联第一列:点击全国或省份
+ * @param {string} provName 省份名称(空串代表全国)
+ */
+ onSelectCascadeProvince(provName) {
+ this.activeProvince = provName || ''
+ if (!provName) {
+ this.activeCity = ''
+ this.applyAreaSelection(null, true)
+ this.closeLocationModal()
+ return
+ }
+ const prov = this.areaTree.find((p) => p.name === provName)
+ const firstCity = prov && prov.cities && prov.cities[0] ? prov.cities[0].name : ''
+ this.activeCity = firstCity
+ },
+ /**
+ * 级联第二列:点击全部(全省)或具体城市(全市筛选,只到市级)
+ * @param {string} cityName 城市名称(空串代表全省全部)
+ */
+ onSelectCascadeCity(cityName) {
+ if (!cityName) {
+ this.activeCity = ''
+ if (!this.activeProvince) {
+ this.applyAreaSelection(null, true)
+ } else {
+ this.applyAreaSelection({ province: this.activeProvince, city: '' }, true)
+ }
+ this.closeLocationModal()
+ return
+ }
+ this.activeCity = cityName
+ this.applyAreaSelection({ province: this.activeProvince, city: cityName }, true)
+ this.closeLocationModal()
+ },
+ /**
+ * 统一应用区域选择并持久化(与首页共享缓存,null = 全国)
+ * @param {Object|null} area 区域数据
+ * @param {boolean} isManual 是否为用户主动操作
+ */
+ applyAreaSelection(area, isManual = true) {
+ if (!area) {
+ this.selectedProvince = ''
+ this.selectedCity = ''
+ this.manualArea = isManual
+ if (isManual) {
+ safeSetStorage(STORAGE_KEY_SELECTED_AREA, { areaId: 0, district: '', city: '', province: '' })
+ }
+ } else {
+ this.selectedProvince = area.province || ''
+ this.selectedCity = area.city || ''
+ this.manualArea = isManual
+ if (isManual) {
+ safeSetStorage(STORAGE_KEY_SELECTED_AREA, {
+ areaId: 0,
+ district: '',
+ city: this.selectedCity,
+ province: this.selectedProvince,
+ })
+ }
+ }
+ this.page = 1
+ this.list = []
+ this.hasMore = true
+ this.fetchPosts()
+ },
+ /**
+ * 面板内:重新定位当前位置并切换(清除手动标记,恢复自动匹配)
+ */
+ relocateCurrentPosition() {
+ if (this.isLocating) return
+ this.isLocating = true
+ uni.getLocation({
+ type: 'gcj02',
+ success: async (res) => {
+ this.lat = res.latitude
+ this.lng = res.longitude
+ try {
+ const found = await homeApi.locate({ lat: this.lat, lng: this.lng })
+ if (found && found.areaId) {
+ safeSetStorage(STORAGE_KEY_SELECTED_AREA, null)
+ this.manualArea = false
+ this.selectedProvince = found.province || ''
+ this.selectedCity = found.city || ''
+ this.activeProvince = this.selectedProvince
+ this.activeCity = this.selectedCity
+ this.page = 1
+ this.list = []
+ this.hasMore = true
+ this.fetchPosts()
+ uni.showToast({ title: `已定位到:${found.city || '所在城市'}`, icon: 'none' })
+ this.closeLocationModal()
+ } else {
+ uni.showToast({ title: '已定位,但当前位置暂无开通服务', icon: 'none' })
+ }
+ } catch (err) {
+ uni.showToast({ title: '定位匹配失败,请手动选择', icon: 'none' })
+ } finally {
+ this.isLocating = false
+ }
+ },
+ fail: () => {
+ this.isLocating = false
+ uni.showToast({ title: '获取定位权限失败,请在设置中开启', icon: 'none' })
+ },
+ })
+ },
/**
* 获取当前分类下的信息列表(支持关键字在当前页面直接检索)
*/
@@ -244,7 +697,12 @@ export default {
try {
const params = {
categoryId: this.currentCategory.id,
- sort: this.sort,
+ subCategoryId: this.currentSubCategory ? this.currentSubCategory.id : undefined,
+ // 价格排序带方向:price_asc / price_desc(后端按方向排序)
+ sort: this.sort === 'price' ? `price_${this.priceOrder}` : this.sort,
+ // 区域筛选只到市级(与首页一致)
+ province: !this.selectedCity && this.selectedProvince ? this.selectedProvince : undefined,
+ city: this.selectedCity || undefined,
page: this.page,
size: this.size,
}
@@ -299,7 +757,8 @@ export default {
*/
goPublish() {
const catId = this.currentCategory ? this.currentCategory.id : ''
- uni.navigateTo({ url: `/pages/post/create?categoryId=${catId}` })
+ const subId = this.currentSubCategory ? `&subCategoryId=${this.currentSubCategory.id}` : ''
+ uni.navigateTo({ url: `/pages/post/create?categoryId=${catId}${subId}` })
},
/**
* 查看信息详情
@@ -408,6 +867,8 @@ export default {
flex: 1;
display: flex;
min-height: 0; /* 必须,确保内部滚动条生效 */
+ min-width: 0; /* 防止长文本卡片把整个双栏撑出屏幕 */
+ overflow: hidden;
}
/* 左侧分类栏:图标与标签左右水平排列,扩充宽度彻底杜绝 4 字分类名截断 */
@@ -470,29 +931,113 @@ export default {
/* 右侧内容展示区 */
.cat-content {
- flex: 1;
+ /* 关键修复:flex 子项默认 min-width:auto,会被列表里长标题/长标签卡片的
+ min-content 撑破(间歇性把右栏顶出屏幕)。flex-basis 0% + min-width 0
+ 把宽度死锁在剩余空间内,超宽内容交给 scroll-view 裁剪。 */
+ flex: 1 1 0%;
+ min-width: 0;
+ width: 0; /* 双保险:微信 scroll-view 包装节点不回传内容宽度 */
height: 100%;
padding: 14rpx 14rpx 0;
box-sizing: border-box;
+ overflow: hidden;
}
-/* 排序切换:轻巧微胶囊风格 */
+/* 二级分类实拍宫格卡片 */
+.cat-subcard {
+ background: #ffffff;
+ border-radius: 20rpx;
+ padding: 18rpx 16rpx 10rpx;
+ margin-bottom: 14rpx;
+ box-shadow: 0 2rpx 10rpx rgba(4, 48, 30, 0.04);
+}
+.cat-subcard__head {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ padding: 0 6rpx 14rpx;
+}
+.cat-subcard__title {
+ font-size: 26rpx;
+ font-weight: 700;
+ color: #1e293b;
+}
+.cat-subcard__reset {
+ font-size: 22rpx;
+ color: #00a854;
+ font-weight: 600;
+}
+/* 二级品类宫格:≤9 个自适应高度不滚动;>9 个锁 3 行高度(474rpx)区域内上下滚动 */
+.cat-subgrid-scroll {
+ width: 100%;
+}
+.cat-subgrid {
+ display: flex;
+ flex-wrap: wrap;
+}
+.cat-subgrid__item {
+ width: 33.3333%;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ padding: 8rpx 6rpx 16rpx;
+ box-sizing: border-box;
+ &--active {
+ .cat-subgrid__thumb {
+ border-color: #00d26a;
+ background: #ecfdf5;
+ box-shadow: 0 4rpx 12rpx rgba(0, 210, 106, 0.22);
+ }
+ .cat-subgrid__name {
+ color: #00a854;
+ font-weight: 700;
+ }
+ }
+}
+.cat-subgrid__thumb {
+ width: 96rpx;
+ height: 96rpx;
+ border-radius: 24rpx;
+ background: #f8fafc;
+ border: 2rpx solid transparent;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ padding: 8rpx;
+ box-sizing: border-box;
+ transition: all 0.15s ease;
+}
+.cat-subgrid__img {
+ width: 100%;
+ height: 100%;
+ border-radius: 16rpx;
+}
+.cat-subgrid__name {
+ margin-top: 8rpx;
+ font-size: 23rpx;
+ color: #334155;
+ text-align: center;
+ line-height: 1.25;
+}
+
+/* 排序切换:轻巧微胶囊风格(价格项带升/降序双三角,右侧为区域筛选) */
.cat-sort {
display: flex;
align-items: center;
background: #ffffff;
border-radius: $fc-radius;
- padding: 6rpx 8rpx;
+ padding: 6rpx 10rpx;
margin-bottom: 14rpx;
box-shadow: 0 2rpx 8rpx rgba(4, 48, 30, 0.04);
}
.cat-sort__item {
cursor: pointer;
- flex: 1;
- text-align: center;
+ display: inline-flex;
+ align-items: center;
+ flex-shrink: 0;
font-size: 23rpx;
color: $fc-text-secondary;
- padding: 8rpx 0;
+ padding: 8rpx 10rpx;
border-radius: 999rpx;
transition: all 0.15s ease;
@@ -502,6 +1047,62 @@ export default {
background: $fc-primary-lighter;
}
}
+/* 价格排序双三角指示器(未选中灰、选中主题绿) */
+.cat-sort__caret {
+ display: inline-flex;
+ flex-direction: column;
+ align-items: center;
+ margin-left: 4rpx;
+ gap: 3rpx;
+}
+.cat-sort__caret-up {
+ width: 0;
+ height: 0;
+ border-left: 6rpx solid transparent;
+ border-right: 6rpx solid transparent;
+ border-bottom: 8rpx solid #cbd5e1;
+ &.is-on {
+ border-bottom-color: #00a854;
+ }
+}
+.cat-sort__caret-down {
+ width: 0;
+ height: 0;
+ border-left: 6rpx solid transparent;
+ border-right: 6rpx solid transparent;
+ border-top: 8rpx solid #cbd5e1;
+ &.is-on {
+ border-top-color: #00a854;
+ }
+}
+/* 区域筛选入口:薄荷浅绿胶囊(与首页区域按钮同风格,紧凑适配窄栏) */
+.cat-sort__area {
+ margin-left: auto;
+ display: inline-flex;
+ align-items: center;
+ flex-shrink: 0;
+ padding: 6rpx 14rpx;
+ background: #f2fef7;
+ border: 1rpx solid rgba(0, 168, 84, 0.2);
+ border-radius: 999rpx;
+}
+.cat-sort__area-icon {
+ width: 24rpx;
+ height: 24rpx;
+ margin-right: 6rpx;
+ flex-shrink: 0;
+}
+.cat-sort__area-txt {
+ font-size: 22rpx;
+ color: #00a854;
+ font-weight: 600;
+ max-width: 96rpx;
+}
+.cat-sort__area-arrow {
+ font-size: 18rpx;
+ color: #00a854;
+ margin-left: 2rpx;
+}
/* 信息流列表 */
.cat-list {
@@ -539,4 +1140,263 @@ export default {
.cat-content__space {
height: 140rpx;
}
+
+/* ============================================================
+ 区域筛选半屏面板样式(与首页 Bottom Sheet 同款)
+ ========================================================== */
+.cat-modal-mask {
+ 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: catModalFadeIn 0.22s ease-out;
+}
+.cat-modal-content {
+ background: #ffffff;
+ border-radius: 36rpx 36rpx 0 0;
+ padding: 20rpx 32rpx calc(48rpx + env(safe-area-inset-bottom));
+ animation: catModalSlideUp 0.26s cubic-bezier(0.16, 1, 0.3, 1);
+ box-shadow: 0 -8rpx 36rpx rgba(4, 48, 30, 0.12);
+}
+.cat-modal-handle {
+ width: 72rpx;
+ height: 8rpx;
+ background: #dcece3;
+ border-radius: 999rpx;
+ margin: 0 auto 24rpx;
+}
+.cat-modal-head {
+ display: flex;
+ align-items: flex-start;
+ justify-content: space-between;
+ margin-bottom: 28rpx;
+}
+.cat-modal-title-box {
+ display: flex;
+ flex-direction: column;
+}
+.cat-modal-title {
+ font-size: 34rpx;
+ font-weight: 700;
+ color: #1e293b;
+}
+.cat-modal-subtitle {
+ font-size: 22rpx;
+ color: $fc-text-secondary;
+ margin-top: 6rpx;
+}
+.cat-modal-close {
+ width: 56rpx;
+ height: 56rpx;
+ border-radius: 50%;
+ background: #f1f8f4;
+ color: #608573;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ font-size: 26rpx;
+ font-weight: 700;
+ &:active {
+ opacity: 0.7;
+ }
+}
+
+/* 当前定位状态卡片 */
+.cat-modal-loc-card {
+ background: #f4fbf7;
+ border: 1rpx solid #c9ebd8;
+ border-radius: 20rpx;
+ padding: 24rpx;
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ margin-bottom: 30rpx;
+}
+.cat-modal-loc-info {
+ display: flex;
+ align-items: center;
+ flex: 1;
+ min-width: 0;
+}
+.cat-modal-loc-pin {
+ width: 44rpx;
+ height: 44rpx;
+ flex-shrink: 0;
+ margin-right: 16rpx;
+}
+.cat-modal-loc-texts {
+ display: flex;
+ flex-direction: column;
+ min-width: 0;
+}
+.cat-modal-loc-row {
+ display: flex;
+ align-items: center;
+}
+.cat-modal-loc-label {
+ font-size: 26rpx;
+ color: $fc-text-regular;
+ flex-shrink: 0;
+}
+.cat-modal-loc-val {
+ font-size: 30rpx;
+ font-weight: 700;
+ color: $fc-primary-text;
+ max-width: 200rpx;
+ overflow: hidden;
+ white-space: nowrap;
+ text-overflow: ellipsis;
+}
+.cat-modal-badge {
+ font-size: 20rpx;
+ padding: 2rpx 12rpx;
+ border-radius: 999rpx;
+ margin-left: 12rpx;
+ font-weight: 600;
+ flex-shrink: 0;
+ &--manual {
+ background: #e6f6ee;
+ color: $fc-primary-text;
+ border: 1rpx solid #b5e8cb;
+ }
+ &--gps {
+ background: #00e070;
+ color: $fc-primary-ink;
+ }
+}
+.cat-modal-loc-sub {
+ font-size: 22rpx;
+ color: $fc-text-secondary;
+ margin-top: 6rpx;
+}
+.cat-modal-reloc-btn {
+ flex-shrink: 0;
+ display: inline-flex;
+ align-items: center;
+ padding: 12rpx 24rpx;
+ border-radius: 999rpx;
+ background: #ffffff;
+ border: 1rpx solid #b7e6cc;
+ color: $fc-primary-text;
+ font-size: 24rpx;
+ font-weight: 600;
+ box-shadow: 0 4rpx 12rpx rgba(4, 48, 30, 0.06);
+ transition: all 0.2s ease;
+ &:active {
+ transform: scale(0.96);
+ background: #ebfaf1;
+ }
+ &--loading {
+ opacity: 0.75;
+ }
+}
+.cat-modal-reloc-icon {
+ font-size: 26rpx;
+ margin-right: 6rpx;
+ font-weight: bold;
+ &--spin {
+ display: inline-block;
+ animation: catSpin 1s linear infinite;
+ }
+}
+
+/* 全国省/市 两列级联面板(薄荷容器 + 白色圆角列卡 + 柔绿选中态) */
+.cat-cascade {
+ background: #f2fef7;
+ border-radius: 24rpx;
+ padding: 24rpx 20rpx 20rpx;
+}
+.cat-cascade-head {
+ display: flex;
+ margin-bottom: 16rpx;
+}
+.cat-cascade-head-label {
+ font-size: 22rpx;
+ font-weight: 600;
+ color: $fc-text-muted;
+ padding-left: 24rpx;
+ box-sizing: border-box;
+
+ &--prov {
+ width: 40%;
+ }
+ &--city {
+ width: 60%;
+ }
+}
+.cat-cascade-body {
+ display: flex;
+ height: 560rpx;
+ background: #ffffff;
+ border-radius: 20rpx;
+ overflow: hidden;
+ box-shadow: 0 4rpx 16rpx rgba(4, 48, 30, 0.05);
+}
+.cat-cascade-col {
+ height: 100%;
+ box-sizing: border-box;
+ &--prov {
+ width: 40%;
+ background: #f7fcf9;
+ border-right: 1rpx solid #eef6f1;
+ }
+ &--city {
+ width: 60%;
+ background: #ffffff;
+ }
+}
+.cat-cascade-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));
+
+ .cat-cascade-text {
+ color: #04874a;
+ font-weight: 700;
+ }
+ }
+}
+.cat-cascade-text {
+ font-size: 26rpx;
+ color: $fc-text-regular;
+ flex: 1;
+ line-height: 1.5;
+}
+.cat-cascade-check {
+ font-size: 26rpx;
+ color: #00c566;
+ font-weight: 700;
+ margin-left: 8rpx;
+ flex-shrink: 0;
+}
+
+/* 动效 */
+@keyframes catModalFadeIn {
+ from { opacity: 0; }
+ to { opacity: 1; }
+}
+@keyframes catModalSlideUp {
+ from { transform: translateY(100%); }
+ to { transform: translateY(0); }
+}
+@keyframes catSpin {
+ from { transform: rotate(0deg); }
+ to { transform: rotate(360deg); }
+}
diff --git a/uniapp/pages/detail/detail.vue b/uniapp/pages/detail/detail.vue
index f846d89..550cde6 100644
--- a/uniapp/pages/detail/detail.vue
+++ b/uniapp/pages/detail/detail.vue
@@ -100,7 +100,7 @@
¥
{{ post.price }}
{{ post.priceUnit }}
-
面议
+
{{ post.priceUnit || '面议' }}
@@ -202,6 +202,21 @@
详细描述
+
+
+
+ 种植面积
+ {{ post.plantArea }}
+
+
+ 采摘时间
+ {{ post.harvestTime }}
+
+
+ 预计量产
+ {{ post.outputRange }}
+
+
{{ post.content }}
{{ t }}
@@ -221,55 +236,25 @@
-
+
联系方式
- 已解锁
-
-
-
+
+
联系人
- {{ contact.name }}
+ {{ post.contactName }}
联系电话
- {{ contact.phone }}
-
-
- 微信号
- {{ contact.wechat }}
-
-
-
-
- 拨打电话
-
-
- 复制微信号
-
+ {{ post.phone || '未预留' }}
+ {{ callQuotaText }},点击下方「拨打电话」联系对方
-
-
-
-
- 联系电话
- {{ post.phone || post.contact || '188****5042' }}
-
-
-
- {{ unlockBtnText }}
-
-
- {{ freeViewUnlimited ? '开通会员享无限次免费看 ›' : `开通会员享每日 ${freeViewQuota || 20} 条免费看 ›` }}
-
-
- {{ freeViewUnlimited ? 'VIP尊享无限次免费解锁' : `今日剩余 ${freeViewLeft} 次免费` }}
-
-
+
+ 发布者未预留联系电话,可通过平台消息联系
@@ -338,69 +323,20 @@
-
-
-
-
-
- {{ post.title }}
-
- ¥
- {{ Number(payViewPrice).toFixed(2) }}
-
-
-
-
-
-
- 微信支付
- 微信安全支付
-
-
-
-
-
-
-
-
- 余额支付
- 即时扣款
-
-
-
-
-
-
-
-
-
- {{ freeViewUnlimited ? '开通会员,尊享无限次免费查看' : `开通会员,享每日 ${freeViewQuota || 20} 条免费看` }}
-
- 去开通 ›
-
-
- {{ submitting ? '处理中…' : `立即支付 ¥${payViewPrice} 解锁` }}
-
-
-
-
-
-
+
+
-
+
发表评价
@@ -419,7 +355,7 @@
-
+
-
+
+
+
+ {{ currentCityText }}
+ ▾
@@ -147,95 +157,48 @@
-
-
-
-
-
- 切换服务位置
- 选择您关注的同城生活与分类信息区域
-
- ✕
+
+
+
+ 切换服务位置
+ 选择您关注的同城生活与分类信息区域
-
-
-
-
-
-
-
- 当前位置:
- {{ currentCityText }}
- 手动选择
- 定位匹配
-
- {{ locStatusDesc }}
-
-
-
- ⟳
- {{ isLocating ? '定位中…' : '重新定位' }}
-
-
-
-
-
-
- 常用与同城区县快捷选择
- 点击即刻切换生效
-
-
-
-
- 全部区域
-
-
-
- {{ item.district }}
-
-
-
-
-
-
-
-
-
-
- 选择其他省市或区县
- 浏览所有已开通城市与区县列表
-
-
-
- ›
-
-
-
+ ✕
-
+
+
+
+
+
+
+
+ 当前位置:
+ {{ currentCityText }}
+ 手动选择
+ 定位匹配
+
+ {{ locStatusDesc }}
+
+
+
+ ⟳
+ {{ isLocating ? '定位中…' : '重新定位' }}
+
+
+
@@ -243,7 +206,7 @@
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 FcCityPicker from '@/components/fc-city-picker/fc-city-picker.vue'
import homeApi from '@/common/api/home.js'
import memberApi from '@/common/api/member.js'
import messageApi from '@/common/api/message.js'
@@ -251,7 +214,6 @@ import { useUserStore } from '@/common/store/index.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'
-import { groupAreaTree } from '@/common/utils/area.js'
// 本地离线快照缓存 Key(Stale-While-Revalidate,实现首屏 0ms 秒开)
const STORAGE_KEY_BANNERS = 'fc_cache_home_banners_v2'
@@ -285,7 +247,7 @@ function safeSetStorage(key, value) {
}
export default {
- components: { FcPostCard, FcTabbar, FcEmpty, FcAreaPicker },
+ components: { FcPostCard, FcTabbar, FcEmpty, FcCityPicker },
data() {
// 优先从本地缓存提取首屏数据,达到即开即显零白屏体验
const cachedBanners = safeGetStorage(STORAGE_KEY_BANNERS, [])
@@ -313,9 +275,13 @@ export default {
hasMore: true,
loading: false,
sort: 'new',
- // 服务区域筛选(若用户曾手动选择,直接恢复)
+ // 价格排序方向(asc 升序 / desc 降序),点击已选中的「价格」时切换
+ priceOrder: 'asc',
+ // 服务区域筛选(若用户曾手动选择,直接恢复;否则默认全国 + 定位匹配所在城市)
areaId: savedUserArea ? Number(savedUserArea.areaId || 0) : 0,
areaText: savedUserArea ? (savedUserArea.district || '') : '',
+ selectedProvince: savedUserArea ? (savedUserArea.province || '') : '',
+ selectedCity: savedUserArea ? (savedUserArea.city || '') : '',
manualArea: !!savedUserArea,
lat: null,
lng: null,
@@ -332,12 +298,9 @@ export default {
{ label: '价格', value: 'price' },
{ label: '附近', value: 'nearby' },
],
- // ---------- 位置手动替换弹窗控制 ----------
+ // ---------- 位置手动替换弹窗控制(fc-city-picker 公共组件) ----------
showLocModal: false,
isLocating: false,
- areaTree: [],
- pickerColumns: [[], [], []],
- pickerIndex: [0, 0, 0],
}
},
computed: {
@@ -359,16 +322,14 @@ export default {
return '开通会员 · 享免费发帖看号'
},
/**
- * 顶栏显示的城市或区域文案(优先当前选择区县,其次城市,缺省回退到同城服务)
+ * 顶栏显示的城市文案(优先当前选择城市,其次省份,缺省显示全国)
*/
currentCityText() {
if (this.areaText) return this.areaText
+ if (this.selectedCity) return this.selectedCity
+ if (this.selectedProvince) return this.selectedProvince
if (this.location) return this.location
- const first = (this.areaRows || [])[0]
- if (first && (first.district || first.city)) {
- return first.district || first.city
- }
- return '同城服务'
+ return '全国'
},
/**
* 位置弹窗内的状态描述文案
@@ -378,22 +339,10 @@ export default {
return '当前由您手动锁定展示该区域信息'
}
if (this.lat != null && this.lng != null) {
- return '已基于您的地理位置自动匹配同城区县'
+ return '已基于您的地理位置自动匹配所在城市'
}
return '暂未获取定位,展示平台推荐区域'
},
- /**
- * 快捷区县选择列表:优先展示与当前城市相同的区县,便于快速直达
- */
- quickAreaList() {
- if (!Array.isArray(this.areaRows) || !this.areaRows.length) return []
- const targetCity = this.location || (this.areaRows[0] && this.areaRows[0].city) || ''
- if (targetCity) {
- const filtered = this.areaRows.filter((r) => r.city === targetCity)
- if (filtered.length) return filtered
- }
- return this.areaRows.slice(0, 12)
- },
/**
* 会员引导条副标题
*/
@@ -409,15 +358,6 @@ export default {
return min > 0 ? `超值月卡 ¥${min} 起` : '超值会员权益,立即开通'
},
},
- watch: {
- areaRows: {
- handler(rows) {
- this.rebuildAreaTree(rows)
- },
- deep: true,
- immediate: true,
- },
- },
/**
* 页面初始化:提取布局高度与裂变邀请参数
* @param {Object} query 路由启动参数
@@ -542,10 +482,14 @@ export default {
return `/static/banners/banner-${idx}.png`
},
/**
- * 获取分类图标地址
+ * 获取分类图标/实拍图地址
* @param {Object} c 分类对象
*/
catIcon(c) {
+ if (!c) return categoryIconUrl(1)
+ if (c.image && /^https?:\/\/|^\/uploads\/|^\/static\//i.test(c.image)) {
+ return c.image
+ }
return (c.iconKey && iconUrl(c.iconKey)) || categoryIconUrl(c.id)
},
@@ -596,7 +540,6 @@ export default {
if (Array.isArray(rows)) {
this.areaRows = rows
safeSetStorage(STORAGE_KEY_AREAS, rows)
- this.rebuildAreaTree(rows)
}
} catch (e) {}
},
@@ -652,19 +595,21 @@ export default {
},
/**
- * 将定位坐标匹配为服务区域
+ * 将定位坐标匹配为服务区域(只匹配到市级,展示所在城市全部信息)
*/
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) {
- const oldId = this.areaId
- this.areaId = Number(found.areaId) || 0
- this.areaText = found.district || ''
+ const oldCity = this.selectedCity
+ this.areaId = 0
+ this.areaText = ''
+ this.selectedProvince = found.province || ''
+ this.selectedCity = found.city || ''
this.location = found.city || ''
- // 若匹配出的区域有变动,平滑刷新信息流
- if (oldId !== this.areaId) {
+ // 若匹配出的城市有变动,平滑刷新信息流
+ if (oldCity !== this.selectedCity) {
this.page = 1
this.fetchFeed(true)
}
@@ -673,7 +618,7 @@ export default {
},
/**
- * 信息流拉取(具备请求时序保护与竞态校验)
+ * 信息流拉取(具备请求时序保护与竞态校验,筛选只到市级:全国/省/市)
* @param {boolean} reset 是否重置列表
*/
async fetchFeed(reset = false) {
@@ -685,7 +630,10 @@ export default {
const res = await homeApi.feed({
page: this.page,
size: this.size,
- sort: this.sort,
+ // 价格排序带方向:price_asc / price_desc(后端按方向排序)
+ sort: this.sort === 'price' ? `price_${this.priceOrder}` : this.sort,
+ province: !this.areaId && !this.selectedCity && this.selectedProvince ? this.selectedProvince : undefined,
+ city: !this.areaId && this.selectedCity ? this.selectedCity : undefined,
areaId: this.areaId || undefined,
lat: this.lat != null ? this.lat : undefined,
lng: this.lng != null ? this.lng : undefined,
@@ -712,11 +660,19 @@ export default {
},
/**
- * 切换排序标签
+ * 切换排序标签(价格项:首次点击升序,再次点击升降序来回切换)
* @param {string} v 排序方式
*/
changeSort(v) {
- if (this.sort === v) return
+ if (v === 'price') {
+ if (this.sort === 'price') {
+ this.priceOrder = this.priceOrder === 'asc' ? 'desc' : 'asc'
+ } else {
+ this.priceOrder = 'asc'
+ }
+ } else if (this.sort === v) {
+ return
+ }
this.sort = v
this.page = 1
this.fetchFeed(true)
@@ -727,19 +683,30 @@ export default {
},
/**
- * 中间筛选栏区域变化(与左上角位置双向同步)
- * @param {Object|null} area 选中的区域
- */
- onFilterAreaChange(area) {
- this.applyAreaSelection(area, true)
- },
-
- /**
- * 打开左上角位置手动替换弹窗
+ * 打开左上角位置手动替换弹窗(回显由 fc-city-picker 内部处理)
*/
openLocationModal() {
this.showLocModal = true
- this.syncPickerFromValue()
+ },
+
+ /**
+ * 城市选择抽屉回调(全国 / 全省 / 全市统一入口)
+ * @param {Object} area { province, city },空串表示全国/全省
+ */
+ onCityPickerSelect(area) {
+ const province = (area && area.province) || ''
+ const city = (area && area.city) || ''
+ if (!province && !city) {
+ this.applyAreaSelection(null, true)
+ } else {
+ this.applyAreaSelection({
+ areaId: 0,
+ district: '',
+ city,
+ province,
+ }, true)
+ }
+ this.closeLocationModal()
},
/**
@@ -750,25 +717,7 @@ export default {
},
/**
- * 手动选择具体区域项(来自弹窗快捷标签)
- * @param {Object|null} item 区县对象(null 表示全部区域)
- */
- selectAreaItem(item) {
- if (!item) {
- this.applyAreaSelection(null, true)
- } else {
- this.applyAreaSelection({
- areaId: Number(item.id) || 0,
- district: item.district || '',
- city: item.city || '',
- province: item.province || '',
- }, true)
- }
- this.closeLocationModal()
- },
-
- /**
- * 统一应用区域选择并持久化(供手动选区与筛选栏共享)
+ * 统一应用区域选择并持久化(支持全国 / 全省 / 全市)
* @param {Object|null} area 区域数据
* @param {boolean} isManual 是否为用户主动操作
*/
@@ -776,23 +725,26 @@ export default {
if (!area) {
this.areaId = 0
this.areaText = ''
+ this.selectedProvince = ''
+ this.selectedCity = ''
+ this.location = '全国'
this.manualArea = isManual
if (isManual) {
- safeSetStorage(STORAGE_KEY_SELECTED_AREA, { areaId: 0, district: '', city: this.location || '全部区域' })
+ safeSetStorage(STORAGE_KEY_SELECTED_AREA, { areaId: 0, district: '', city: '', province: '' })
}
} else {
this.areaId = Number(area.areaId) || 0
this.areaText = area.district || ''
- if (area.city) {
- this.location = area.city
- }
+ this.selectedProvince = area.province || ''
+ this.selectedCity = area.city || ''
+ this.location = area.city || area.province || '全国'
this.manualArea = isManual
if (isManual) {
safeSetStorage(STORAGE_KEY_SELECTED_AREA, {
areaId: this.areaId,
district: this.areaText,
- city: this.location,
- province: area.province || '',
+ city: this.selectedCity,
+ province: this.selectedProvince,
})
}
}
@@ -818,15 +770,17 @@ export default {
try {
const found = await homeApi.locate({ lat: this.lat, lng: this.lng })
if (found && found.areaId) {
- // 清除手动选择标记,恢复为自动定位匹配模式
+ // 清除手动选择标记,恢复为自动定位匹配模式(只到市级)
safeSetStorage(STORAGE_KEY_SELECTED_AREA, null)
this.manualArea = false
- this.areaId = Number(found.areaId) || 0
- this.areaText = found.district || ''
+ this.areaId = 0
+ this.areaText = ''
+ this.selectedProvince = found.province || ''
+ this.selectedCity = found.city || ''
this.location = found.city || ''
this.page = 1
this.fetchFeed(true)
- uni.showToast({ title: `已定位到:${found.district || found.city}`, icon: 'none' })
+ uni.showToast({ title: `已定位到:${found.city || '所在城市'}`, icon: 'none' })
this.closeLocationModal()
} else {
uni.showToast({ title: '已定位,但当前位置暂无开通服务', icon: 'none' })
@@ -844,110 +798,6 @@ export default {
})
},
- /**
- * 重建三级级联选择树
- * @param {Array} rows 平铺区域列表
- */
- rebuildAreaTree(rows) {
- if (!Array.isArray(rows) || !rows.length) return
- this.areaTree = groupAreaTree(rows)
- this.buildPickerColumns()
- },
-
- /**
- * 按选中区域同步三级联动索引
- */
- syncPickerFromValue() {
- if (!this.areaTree || !this.areaTree.length) return
- let pi = 0
- let ci = 0
- let di = 0
- if (this.areaId > 0) {
- let matched = false
- for (let p = 0; p < this.areaTree.length && !matched; p++) {
- const cities = this.areaTree[p].cities || []
- for (let c = 0; c < cities.length && !matched; c++) {
- const districts = cities[c].districts || []
- for (let d = 0; d < districts.length; d++) {
- if (Number(districts[d].id) === this.areaId) {
- pi = p
- ci = c
- di = d
- matched = true
- break
- }
- }
- }
- }
- }
- this.pickerIndex = [pi, ci, di]
- this.buildPickerColumns()
- },
-
- /**
- * 构建三级选择器列数据
- */
- buildPickerColumns() {
- if (!this.areaTree || !this.areaTree.length) {
- this.pickerColumns = [[], [], []]
- return
- }
- const pi = Math.max(0, Number(this.pickerIndex[0]) || 0)
- const ci = Math.max(0, Number(this.pickerIndex[1]) || 0)
- const province = this.areaTree[pi] || this.areaTree[0]
- const cities = (province && province.cities) || []
- const city = cities[ci] || cities[0] || {}
- const districts = city.districts || []
-
- this.pickerColumns = [
- this.areaTree.map((p) => ({ label: p.name, value: p.name })),
- cities.map((c) => ({ label: c.name, value: c.name })),
- districts.map((d) => ({ label: d.name, id: d.id, item: d })),
- ]
- },
-
- /**
- * 级联选择器滚动列联动
- * @param {Object} e 事件对象
- */
- onPickerColumnChange(e) {
- const col = Number(e.detail.column)
- const val = Number(e.detail.value)
- const next = [...this.pickerIndex]
- next[col] = val
- if (col === 0) {
- next[1] = 0
- next[2] = 0
- } else if (col === 1) {
- next[2] = 0
- }
- this.pickerIndex = next
- this.buildPickerColumns()
- },
-
- /**
- * 级联选择器确认选中
- * @param {Object} e 事件对象
- */
- onPickerChange(e) {
- const vals = e.detail.value || []
- const pi = Number(vals[0] || 0)
- const ci = Number(vals[1] || 0)
- const di = Number(vals[2] || 0)
- const province = this.areaTree[pi]
- const city = province && province.cities ? province.cities[ci] : null
- const district = city && city.districts ? city.districts[di] : null
- if (district) {
- this.applyAreaSelection({
- areaId: Number(district.id) || 0,
- district: district.name,
- city: city.name,
- province: province.name,
- }, true)
- this.closeLocationModal()
- }
- },
-
/**
* 页面跳转助手
* @param {string} url 目标路径
@@ -1291,13 +1141,66 @@ export default {
font-size: $fc-font;
color: $fc-text-secondary;
transition: color 0.2s ease;
+ display: inline-flex;
+ align-items: center;
&--active {
color: $fc-primary-text;
font-weight: 700;
}
}
-.home__filter-area {
+/* 价格排序双三角指示器(未选中灰、选中主题绿) */
+.home__caret {
+ display: inline-flex;
+ flex-direction: column;
+ align-items: center;
+ margin-left: 6rpx;
+ gap: 3rpx;
+}
+.home__caret-up {
+ width: 0;
+ height: 0;
+ border-left: 7rpx solid transparent;
+ border-right: 7rpx solid transparent;
+ border-bottom: 9rpx solid #cbd5e1;
+ &.is-on {
+ border-bottom-color: #00a854;
+ }
+}
+.home__caret-down {
+ width: 0;
+ height: 0;
+ border-left: 7rpx solid transparent;
+ border-right: 7rpx solid transparent;
+ border-top: 9rpx solid #cbd5e1;
+ &.is-on {
+ border-top-color: #00a854;
+ }
+}
+.home__filter-area-btn {
margin-left: auto;
+ display: inline-flex;
+ align-items: center;
+ padding: 8rpx 20rpx;
+ background: #ffffff;
+ border: 1rpx solid rgba(0, 168, 84, 0.22);
+ border-radius: 999rpx;
+ box-shadow: 0 2rpx 8rpx rgba(0, 168, 84, 0.06);
+}
+.home__filter-area-icon {
+ width: 24rpx;
+ height: 24rpx;
+ margin-right: 6rpx;
+}
+.home__filter-area-txt {
+ font-size: 24rpx;
+ color: #00a854;
+ font-weight: 600;
+ max-width: 180rpx;
+}
+.home__filter-area-arrow {
+ font-size: 20rpx;
+ color: #00a854;
+ margin-left: 6rpx;
}
/* 拟真骨架屏列表 */
@@ -1352,36 +1255,9 @@ export default {
}
/* ============================================================
- 位置手动替换弹窗样式(春绿生态风格 Bottom Sheet)
+ 位置手动替换弹窗:抽屉外壳与级联面板样式已抽至公共组件 fc-city-picker,
+ 此处仅保留标题区与定位状态卡片(通过 header 插槽注入)
========================================================== */
-.home__modal-mask {
- 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: modalFadeIn 0.22s ease-out;
-}
-.home__modal-content {
- background: #ffffff;
- border-radius: 36rpx 36rpx 0 0;
- padding: 20rpx 32rpx calc(48rpx + env(safe-area-inset-bottom));
- animation: modalSlideUp 0.26s cubic-bezier(0.16, 1, 0.3, 1);
- box-shadow: 0 -8rpx 36rpx rgba(4, 48, 30, 0.12);
-}
-.home__modal-handle {
- width: 72rpx;
- height: 8rpx;
- background: #dcece3;
- border-radius: 999rpx;
- margin: 0 auto 24rpx;
-}
.home__modal-head {
display: flex;
align-items: flex-start;
@@ -1515,112 +1391,7 @@ export default {
}
}
-/* 快捷区县网格 */
-.home__modal-section {
- margin-bottom: 28rpx;
-}
-.home__modal-section-title {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 18rpx;
-}
-.home__modal-section-main {
- font-size: 26rpx;
- font-weight: 700;
- color: $fc-text;
-}
-.home__modal-section-tip {
- font-size: 22rpx;
- color: $fc-text-placeholder;
-}
-.home__modal-chip-grid {
- display: flex;
- flex-wrap: wrap;
- gap: 16rpx;
- max-height: 380rpx;
- overflow-y: auto;
-}
-.home__modal-chip {
- padding: 14rpx 26rpx;
- border-radius: 999rpx;
- background: #f4fbf7;
- border: 1rpx solid #d5efe1;
- transition: all 0.15s ease;
- &:active {
- transform: scale(0.96);
- }
- &--active {
- background: #00e070;
- border-color: #00e070;
- box-shadow: 0 4rpx 14rpx rgba(0, 224, 112, 0.35);
- .home__modal-chip-text {
- color: $fc-primary-ink;
- font-weight: 700;
- }
- }
-}
-.home__modal-chip-text {
- font-size: 26rpx;
- color: $fc-text-regular;
-}
-
-/* 三级联动选择器触发入口 */
-.home__modal-picker-trigger {
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 24rpx 24rpx;
- background: #f7fdfa;
- border: 1rpx dashed #a8e5c3;
- border-radius: 20rpx;
- margin-top: 8rpx;
- &:active {
- background: #edfbf3;
- }
-}
-.home__modal-picker-left {
- display: flex;
- align-items: center;
-}
-.home__modal-picker-icon {
- width: 40rpx;
- height: 40rpx;
- margin-right: 16rpx;
-}
-.home__modal-picker-text-wrap {
- display: flex;
- flex-direction: column;
-}
-.home__modal-picker-label {
- font-size: 28rpx;
- font-weight: 600;
- color: $fc-primary-text;
-}
-.home__modal-picker-hint {
- font-size: 22rpx;
- color: $fc-text-secondary;
- margin-top: 4rpx;
-}
-.home__modal-picker-right {
- display: flex;
- align-items: center;
-}
-.home__modal-picker-arrow {
- font-size: 34rpx;
- color: #619a7d;
- font-weight: 600;
-}
-
-/* 动效 */
-@keyframes modalFadeIn {
- from { opacity: 0; }
- to { opacity: 1; }
-}
-@keyframes modalSlideUp {
- from { transform: translateY(100%); }
- to { transform: translateY(0); }
-}
+/* 动效(抽屉淡入/上滑动效已在 fc-city-picker 组件内) */
@keyframes spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
diff --git a/uniapp/pages/member/index.vue b/uniapp/pages/member/index.vue
index 31b99c9..86c1ee6 100644
--- a/uniapp/pages/member/index.vue
+++ b/uniapp/pages/member/index.vue
@@ -214,7 +214,7 @@
-
+
选择优惠券
diff --git a/uniapp/pages/merchant/detail.vue b/uniapp/pages/merchant/detail.vue
index 2ea1f6e..9118446 100644
--- a/uniapp/pages/merchant/detail.vue
+++ b/uniapp/pages/merchant/detail.vue
@@ -84,14 +84,11 @@
-
-
+
+
-
- 联系咨询:{{ merchant.contact }}
-
-
- {{ merchant.unlocked ? '立即拨打 ›' : '受保护 · 去解锁 ›' }}
+
+ 联系咨询:{{ merchant.contact || '未预留' }}
@@ -155,12 +152,24 @@
地图导航
-
+
- {{ merchant.unlocked ? '联系店长' : '联系店长 (受保护)' }}
+ 联系店长
+
+
+
@@ -176,13 +185,14 @@
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 FcCallModal from '@/components/fc-call-modal/fc-call-modal.vue'
import { merchantApi } from '@/common/api/merchant.js'
import { iconUrl, loadUiConfig } from '@/common/store/ui.js'
import { assetUrl } from '@/common/utils/format.js'
import { useUserStore } from '@/common/store/index.js'
export default {
- components: { FcNavbar, FcPostCard, FcEmpty },
+ components: { FcNavbar, FcPostCard, FcEmpty, FcCallModal },
data() {
return {
merchantId: 0,
@@ -198,6 +208,14 @@ export default {
userLat: null,
userLng: null,
postId: 0,
+ // 拨打弹窗与每日额度状态(手机号全程脱敏,仅通过 /merchant/:id/dial 校验额度后拨打)
+ showCallModal: false,
+ dialSubmitting: false,
+ hasPhone: true,
+ dialDisplay: '',
+ callQuotaTotal: 5,
+ callQuotaUsed: 0,
+ callQuotaLeft: 5,
}
},
computed: {
@@ -227,6 +245,22 @@ export default {
}
return ''
},
+ /**
+ * 今日拨打额度是否不限次数(后台配置 0 = 不限)
+ * @returns {boolean}
+ */
+ callQuotaUnlimited() {
+ return Number(this.callQuotaTotal) === 0
+ },
+ /**
+ * 免责弹窗拨打展示文案(联系人姓氏 + 脱敏手机号)
+ * @returns {string}
+ */
+ dialDisplayText() {
+ if (this.dialDisplay) return String(this.dialDisplay)
+ const masked = String((this.merchant && this.merchant.contact) || '')
+ return masked
+ },
},
/**
* 页面加载入参初始化
@@ -348,6 +382,12 @@ export default {
this.hasMore = !!data.hasMorePosts
this.page = 1
this.loaded = true
+ // 同步拨打额度与脱敏号码展示信息
+ if (data.hasPhone != null) this.hasPhone = !!data.hasPhone
+ if (data.dialDisplay) this.dialDisplay = String(data.dialDisplay)
+ if (data.callQuotaTotal != null) this.callQuotaTotal = Number(data.callQuotaTotal)
+ if (data.callQuotaUsed != null) this.callQuotaUsed = Number(data.callQuotaUsed)
+ if (data.callQuotaLeft != null) this.callQuotaLeft = Number(data.callQuotaLeft)
}
} catch (e) {
uni.showToast({ title: (e && e.message) || '店铺信息加载失败', icon: 'none' })
@@ -413,38 +453,70 @@ export default {
}
},
/**
- * 一键拨打商家咨询电话(未解锁/非会员状态下严格执行付费拦截)
+ * 打开免责声明拨打弹窗(号码全程脱敏,游客先引导登录)
*/
- callPhone() {
- const isProtected = !this.merchant || !this.merchant.unlocked || (this.merchant.contact && this.merchant.contact.includes('*'))
- if (isProtected) {
- uni.showModal({
- title: '联系方式受保护',
- content: this.postId ? '该商家门店电话受平台付费保护,请先解锁关联的发布信息或开通会员查看。' : '该商家门店联系方式受平台保护,开通会员即可直接联系全站商家。 ',
- confirmText: this.postId ? '返回去解锁' : '去开通会员',
- cancelText: '知道了',
- confirmColor: '#00E070',
- success: (r) => {
- if (r.confirm) {
- if (this.postId) {
- uni.navigateBack()
- } else {
- uni.navigateTo({ url: '/pages/member/index' })
- }
- }
- }
- })
+ openCallModal() {
+ if (!this.hasPhone || !this.merchant.contact) {
+ uni.showToast({ title: '商家暂未预留联系电话', icon: 'none' })
return
}
- const phone = this.merchant && this.merchant.contact
- if (!phone) {
- uni.showToast({ title: '商家暂未公开联系电话', icon: 'none' })
- return
+ try {
+ const store = useUserStore()
+ const login = store && store.isLogin && (store.isLogin.value != null ? store.isLogin.value : !!store.isLogin)
+ if (!login) {
+ uni.showModal({
+ title: '提示',
+ content: '拨打商家电话需要先登录账号,是否前往?',
+ confirmText: '去登录',
+ cancelText: '取消',
+ confirmColor: '#00E070',
+ success: (r) => {
+ if (r.confirm) uni.navigateTo({ url: '/pages/auth/login' })
+ },
+ })
+ return
+ }
+ } catch (e) {}
+ this.showCallModal = true
+ },
+ /**
+ * 确认拨打:调用 POST /merchant/:id/dial 扣减当日额度并调起系统拨号盘
+ */
+ async confirmDial() {
+ if (this.dialSubmitting) return
+ this.dialSubmitting = true
+ try {
+ const res = await merchantApi.dial(this.merchantId)
+ this.showCallModal = false
+ if (res && res.callQuotaUsed != null) this.callQuotaUsed = Number(res.callQuotaUsed)
+ if (res && res.callQuotaLeft != null) this.callQuotaLeft = Number(res.callQuotaLeft)
+ if (res && res.phoneNumber) {
+ uni.makePhoneCall({
+ phoneNumber: String(res.phoneNumber),
+ fail: () => {},
+ })
+ }
+ } catch (e) {
+ const msg = (e && e.message) || '拨打失败,请稍后重试'
+ // 当日拨打次数超限(后端 403):引导开通 VIP 会员提升每日拨打次数
+ if (/上限/.test(msg)) {
+ this.showCallModal = false
+ uni.showModal({
+ title: '今日拨打次数已用完',
+ content: msg,
+ confirmText: '去开通会员',
+ cancelText: '知道了',
+ confirmColor: '#00E070',
+ success: (r) => {
+ if (r.confirm) uni.navigateTo({ url: '/pages/member/index' })
+ },
+ })
+ return
+ }
+ uni.showToast({ title: msg, icon: 'none' })
+ } finally {
+ this.dialSubmitting = false
}
- uni.makePhoneCall({
- phoneNumber: String(phone).trim(),
- fail: () => {},
- })
},
/**
* 跳转到信息详情页
@@ -689,11 +761,6 @@ export default {
color: #334155;
font-weight: 500;
}
-.shop-detail__call-link {
- font-size: 24rpx;
- font-weight: 600;
- color: #04874a;
-}
.shop-detail__notice-box {
background: #fbfdfc;
border: 1rpx dashed #d1eedc;
diff --git a/uniapp/pages/post/create.vue b/uniapp/pages/post/create.vue
index 0f8001c..df7f8a6 100644
--- a/uniapp/pages/post/create.vue
+++ b/uniapp/pages/post/create.vue
@@ -1,21 +1,13 @@
-
-
-
-
-
- 草稿箱
- {{ draftCount }}
-
-
-
+
+
-
+
-
+
- 所属分类
+ 所属大类
*
@@ -23,7 +15,22 @@
{{ currentCat.name }}
- 请选择信息所属分类
+ 请选择大类(蔬菜 / 水果)
+ ›
+
+
+
+
+
+ 产品品类
+ *
+
+
+
+
+ {{ currentSubCat.name }}
+
+ {{ currentCat ? '请选择品类' : '请先选择大类' }}
›
@@ -33,7 +40,6 @@
发布身份
- 认证商家享专属标识与引流
-
+
标题*
- 详细内容*
-
- {{ (form.content || '').length }}/500
-
- 图片 / 视频(实拍更具可信度)
+
+ 轮播图片 / 视频
+
@@ -114,44 +111,83 @@
媒体上传中,请稍候…
-
+
- 期望价格 / 薪资
-
-
- ✓
-
- 面议 / 无标价
-
+ 销售价格*
-
-
+
+
- ¥
- {{ form.priceUnit || '元' }}
+
+
+
+
+
+
+ 产地规格信息
-
-
-
+
+ 种植面积*
+
+
+
+
+
+ 采摘时间*
+
- {{ u }}
-
+
+
+ {{ form.harvestTime || '选择采摘/上市日期' }}
+
+ ›
+
+
+
+
+
+
+ 预计量产*
+
+
+
+ {{ form.outputRange || '选择预计产量范围' }}
+
+ ›
+
+
@@ -192,7 +228,7 @@
-
+
+
+ 详细内容*
+
+ {{ (form.content || '').length }}/500
+
+
+
联系人
@@ -224,24 +274,12 @@
class="create__input create__input--row"
type="number"
maxlength="11"
- placeholder="请输入11位联系手机号"
+ placeholder="请输入11位手机号"
placeholder-class="create__ph"
@input="onFieldInput"
/>
-
- 微信号
-
-
-
所在位置
@@ -286,7 +324,7 @@
-
+
-
+
-
+
+
-
-
+
+
- {{ c.name }}
- ✓
+
+ {{ c.name }}
+ {{ (c.children && c.children.length) || 0 }} 个品类 ›
+
+
+
+
+
+
+
+
+
+
+
+ 全部{{ currentCat ? currentCat.name : '' }}
+
+ ✓
+
+
+
+
+
+
+ {{ sub.name }}
+
+ ✓
@@ -399,9 +473,12 @@
* 核心优化:
* 1. 分类选择由接口动态返回决定,统一收敛为「所属分类单元格 + 全部分类抽屉」单一入口,
* 避免同一分类在页面内重复出现(已选值只展示一次);
- * 2. 彻底剥离草稿箱列表到独立页面 /pages/post/drafts,发布页右上方提供直通入口与存草稿闭环;
+ * 2. 草稿箱列表独立于 /pages/post/drafts 页面(发布页不提供入口,用户中心访问),发布页仅保留「存草稿」动作;
* 3. 支持个人 / 商家身份二选一(已认证商家可切换为商家身份发布并附带门店信息);
- * 4. 严格遵循春绿规范,大厂级布局与无障碍高对比度。
+ * 4. 表单输入顺序按用户心智模型排布:分类 → 身份 → 标题/图片 → 价格/产地规格 → 详细内容兜底 → 联系方式,
+ * 相关字段逻辑分组(field-grouping),校验顺序与视觉顺序一致;
+ * 5. 价格为自由文本输入(如:1万元 / 2000元/斤 / 面议),提交时拆分为数值 + 单位与后端结构兼容;
+ * 6. 严格遵循春绿规范,大厂级布局与无障碍高对比度。
*/
import FcNavbar from '@/components/fc-navbar/fc-navbar.vue'
import FcAreaPicker from '@/components/fc-area-picker/fc-area-picker.vue'
@@ -420,7 +497,6 @@ export default {
data() {
return {
categories: [],
- draftCount: 0,
currentDraftId: 0, // 当前正在编辑的草稿ID(编辑自某草稿)
// 平铺服务区域(每条自带省/市/区县),交给级联选择器分组
areaRows: [],
@@ -431,21 +507,35 @@ export default {
draftTimer: null,
catDrawerVisible: false,
catDrawerAnim: false,
+ // 分类两步选择:1 = 选一级大类,2 = 选二级品类
+ catDrawerStep: 1,
customTagInput: '',
+ outputRangeOptions: [
+ '1000斤以下',
+ '1000-5000斤',
+ '5000-1万斤',
+ '1万-5万斤',
+ '5万-10万斤',
+ '10万斤以上',
+ ],
form: {
categoryId: 0,
+ subCategoryId: 0,
identityType: 'person', // 'person' | 'merchant'
title: '',
content: '',
media: [],
price: '',
- priceUnit: '元',
isNegotiable: false,
- wechat: '',
+ plantArea: '',
+ harvestTime: '',
+ outputRange: '',
tags: [],
contact: '',
phone: '',
address: '',
+ province: '',
+ city: '',
areaId: 0,
area: '',
lat: null,
@@ -546,12 +636,52 @@ export default {
return '未认证,点击立即前往认证'
},
/**
- * 当前选中的分类对象
+ * 当前选中的一级分类对象
* @returns {Object|null}
*/
currentCat() {
return this.categories.find((c) => Number(c.id) === Number(this.form.categoryId)) || null
},
+ /**
+ * 当前选中的二级分类对象
+ * @returns {Object|null}
+ */
+ currentSubCat() {
+ const children = (this.currentCat && this.currentCat.children) || []
+ return children.find((s) => Number(s.id) === Number(this.form.subCategoryId)) || null
+ },
+ /**
+ * 当前选中分类是否为农产品类(kind=farm):
+ * 决定「种植面积/采摘时间/预计量产」的显隐与必填校验;历史数据无 kind 时按农产品处理
+ * @returns {boolean}
+ */
+ isFarmCategory() {
+ if (!this.currentCat) return true
+ return (this.currentCat.kind || 'farm') === 'farm'
+ },
+ /**
+ * 分类抽屉内当前大类下的二级分类列表
+ * @returns {Array}
+ */
+ drawerSubCategories() {
+ return (this.currentCat && Array.isArray(this.currentCat.children)) ? this.currentCat.children : []
+ },
+ /**
+ * 分类抽屉标题(随打开的输入行切换)
+ * @returns {string}
+ */
+ catDrawerStepTitle() {
+ if (this.catDrawerStep === 1) return '选择所属大类'
+ return `选择${this.currentCat ? this.currentCat.name : ''}品类`
+ },
+ /**
+ * 预计量产下拉框当前选中索引
+ * @returns {number}
+ */
+ outputRangeIndex() {
+ const idx = this.outputRangeOptions.indexOf(this.form.outputRange)
+ return idx >= 0 ? idx : 0
+ },
balance() {
try {
return useUserStore().state.userInfo?.balance ?? 0
@@ -632,39 +762,19 @@ export default {
return plan ? String(plan.price).replace(/[¥元]/g, '') : ''
},
/**
- * 当前分类对应的常用计价单位
- */
- currentUnits() {
- const catId = Number(this.form.categoryId || 0)
- if (catId === 1) return ['元/月', '元/天', '元/小时', '元/次']
- if (catId === 2) return ['元/月', '万元', '元/天', '元/季']
- if (catId === 3) return ['元']
- if (catId === 4) return ['万元', '元']
- if (catId === 5) return ['元起', '元/次', '元/小时', '元/天']
- if (catId === 6) return ['元/课时', '元', '元/月']
- if (catId === 7) return ['元/次', '元/小时', '元/㎡', '元/月']
- return ['元', '元/月', '元/次', '万元']
- },
- /**
- * 当前分类对应的常用同城亮点标签
+ * 当前分类对应的常用农产品亮点标签
*/
recommendTags() {
const catId = Number(this.form.categoryId || 0)
- const map = {
- 1: ['日结', '包吃住', '双休', '五险一金', '经验不限', '就近分配'],
- 2: ['精装修', '近地铁', '随时看房', '押一付一', '家电齐全', '独立卫浴'],
- 3: ['9成新', '支持验机', '同城自提', '急出可刀', '配件齐全', '保修期内'],
- 4: ['一手车', '无事故', '准新车', '支持检测', '省油好开', '带牌转让'],
- 5: ['上门服务', '明码标价', '十年经验', '专业高效', '质保售后', '免费检测'],
- 6: ['体验课', '一对一', '名师授课', '小班教学', '零基础', '包学会'],
- 7: ['自带工具', '持健康证', '深度保洁', '满意付款', '实名认证'],
- 8: ['运动搭子', '周末活动', 'AA制', '新手友好', '同城聚会']
+ if (catId === 2) {
+ return ['产地直供', '现摘现发', '树上熟', '甜度高', '量大从优', '支持代办']
}
- return map[catId] || ['高品质', '值得信赖', '同城便民', '价格透明']
+ return ['基地直发', '高山有机', '现砍现装', '冷链锁鲜', '量大从优', '支持看货']
},
},
onLoad(query) {
if (query && query.categoryId) this.form.categoryId = Number(query.categoryId)
+ if (query && query.subCategoryId) this.form.subCategoryId = Number(query.subCategoryId)
if (query && query.title) this.form.title = decodeURIComponent(query.title)
if (query && query.draftId) {
this.loadDraftPost(Number(query.draftId))
@@ -675,11 +785,10 @@ export default {
this.init()
},
/**
- * 页面每次显示时触发:刷新发布额度、草稿数并同步最新用户资料(如从会员中心开通返回后立即刷新额度)
+ * 页面每次显示时触发:刷新发布额度并同步最新用户资料(如从会员中心开通返回后立即刷新额度)
*/
async onShow() {
this.loadPublish()
- this.updateDraftCount()
try {
const userStore = useUserStore()
if (userStore.isLogin.value) {
@@ -699,24 +808,34 @@ export default {
},
catIcon(c) {
if (!c) return ''
+ if (c.image && /^https?:\/\/|^\/uploads\/|^\/static\//i.test(c.image)) {
+ return c.image
+ }
return (c.iconKey && iconUrl(c.iconKey)) || categoryIconUrl(c.id)
},
/**
- * 页面基础数据初始化
+ * 页面基础数据初始化(自动加载一二级分类树,并根据定位默认选中当前区域)
*/
async init() {
try {
const cats = await homeApi.categories()
this.categories = Array.isArray(cats) ? cats : []
- // 若未指定分类且已有分类列表,默认选中第一个
+ // 若路由传入的 categoryId 是二级分类,自动反查父级
+ if (this.form.categoryId && this.categories.length) {
+ const isTop = this.categories.some((c) => Number(c.id) === Number(this.form.categoryId))
+ if (!isTop) {
+ for (const p of this.categories) {
+ const foundSub = (p.children || []).find((s) => Number(s.id) === Number(this.form.categoryId))
+ if (foundSub) {
+ this.form.categoryId = Number(p.id)
+ this.form.subCategoryId = Number(foundSub.id)
+ break
+ }
+ }
+ }
+ }
if (!this.form.categoryId && this.categories.length) {
this.form.categoryId = Number(this.categories[0].id)
- } else if (this.form.categoryId) {
- this.form.categoryId = Number(this.form.categoryId)
- }
- // 联动初始化当前分类的首选计价单位
- if (this.currentUnits && this.currentUnits.length && (!this.form.priceUnit || this.form.priceUnit === '元')) {
- this.form.priceUnit = this.currentUnits[0]
}
} catch (e) {
uni.showToast({ title: '分类数据加载失败', icon: 'none' })
@@ -727,27 +846,20 @@ export default {
this.areaRows = Array.isArray(rows) ? rows : []
} catch (e) {}
- this.loadPublish()
- this.updateDraftCount()
- },
- /**
- * 刷新草稿箱数量统计
- */
- async updateDraftCount() {
- try {
- const drafts = await postApi.drafts()
- this.draftCount = Array.isArray(drafts) ? drafts.length : 0
- } catch (e) {
- this.draftCount = 0
+ // 默认根据定位匹配当前服务区域
+ if (!this.form.areaId && typeof uni !== 'undefined' && uni.getLocation) {
+ uni.getLocation({
+ type: 'gcj02',
+ success: (res) => {
+ if (!this.form.lat) this.form.lat = res.latitude
+ if (!this.form.lng) this.form.lng = res.longitude
+ this.matchRegionByLocation(res.latitude, res.longitude)
+ },
+ fail: () => {},
+ })
}
- },
- /**
- * 跳转独立草稿箱页面
- */
- goDraftsPage() {
- uni.navigateTo({
- url: '/pages/post/drafts',
- })
+
+ this.loadPublish()
},
/**
* 从草稿中还原数据
@@ -760,25 +872,28 @@ export default {
if (target) {
this.currentDraftId = draftId
if (target.categoryId) this.form.categoryId = target.categoryId
+ if (target.subCategoryId) this.form.subCategoryId = target.subCategoryId
this.form.title = target.title || ''
this.form.content = target.content || ''
this.form.contact = target.contact || ''
this.form.phone = target.phone || ''
- this.form.wechat = target.wechat || ''
this.form.address = target.address || ''
+ this.form.province = target.province || ''
+ this.form.city = target.city || ''
this.form.areaId = target.areaId || 0
this.form.area = target.area || ''
+ this.form.plantArea = target.plantArea || ''
+ this.form.harvestTime = target.harvestTime || ''
+ this.form.outputRange = target.outputRange || ''
this.form.lat = target.lat || null
this.form.lng = target.lng || null
if (target.identityType) this.form.identityType = target.identityType
if (target.price != null && target.price > 0) {
- this.form.price = String(target.price)
- this.form.isNegotiable = false
- } else if (target.priceUnit === '面议') {
- this.form.price = ''
- this.form.isNegotiable = true
+ // 数值 + 单位还原为自由文本(如:2000 + 元/斤 → 2000元/斤)
+ this.form.price = String(target.price) + (target.priceUnit && target.priceUnit !== '面议' ? target.priceUnit : '')
+ } else if (target.priceUnit) {
+ this.form.price = target.priceUnit
}
- if (target.priceUnit) this.form.priceUnit = target.priceUnit
if (Array.isArray(target.tags)) this.form.tags = [...target.tags]
if (Array.isArray(target.media)) this.form.media = [...target.media]
uni.showToast({ title: '已载入草稿内容', icon: 'none' })
@@ -794,25 +909,28 @@ export default {
const p = await postApi.detail(id)
if (p) {
if (p.categoryId) this.form.categoryId = p.categoryId
+ if (p.subCategoryId) this.form.subCategoryId = p.subCategoryId
this.form.title = p.title || ''
this.form.content = p.content || ''
- this.form.contact = p.contact || ''
- this.form.phone = p.phone || ''
- this.form.wechat = p.wechat || ''
+ this.form.contact = p.contactName || ''
+ this.form.phone = (p.phone && !String(p.phone).includes('*')) ? p.phone : ''
this.form.address = p.address || ''
+ this.form.province = p.province || ''
+ this.form.city = p.city || ''
this.form.areaId = p.areaId || 0
this.form.area = p.area || ''
+ this.form.plantArea = p.plantArea || ''
+ this.form.harvestTime = p.harvestTime || ''
+ this.form.outputRange = p.outputRange || ''
this.form.lat = p.lat || null
this.form.lng = p.lng || null
if (p.identityType) this.form.identityType = p.identityType
if (p.price != null && p.price > 0) {
- this.form.price = String(p.price)
- this.form.isNegotiable = false
- } else if (p.priceUnit === '面议' || p.price === 0) {
- this.form.price = ''
- this.form.isNegotiable = true
+ // 数值 + 单位还原为自由文本(如:2000 + 元/斤 → 2000元/斤)
+ this.form.price = String(p.price) + (p.priceUnit && p.priceUnit !== '面议' ? p.priceUnit : '')
+ } else if (p.priceUnit) {
+ this.form.price = p.priceUnit
}
- if (p.priceUnit) this.form.priceUnit = p.priceUnit
if (Array.isArray(p.tags)) this.form.tags = [...p.tags]
if (Array.isArray(p.media)) this.form.media = [...p.media]
uni.showToast({ title: '已载入待修改内容', icon: 'none' })
@@ -820,29 +938,35 @@ export default {
} catch (e) {}
},
/**
- * 切换期望价格面议状态
+ * 选择采摘日期
+ * @param {Object} e
*/
- toggleNegotiable() {
- this.form.isNegotiable = !this.form.isNegotiable
- if (this.form.isNegotiable) {
- this.form.price = ''
- this.form.priceUnit = '面议'
- } else {
- this.form.priceUnit = (this.currentUnits && this.currentUnits[0]) || '元'
- }
+ onHarvestTimeChange(e) {
+ this.form.harvestTime = (e && e.detail && e.detail.value) || ''
this.triggerAutoSave()
},
/**
- * 快速选择计价单位
- * @param {string} u 计价单位
+ * 选择预计量产范围
+ * @param {Object} e
*/
- selectPriceUnit(u) {
- this.form.priceUnit = u
- if (this.form.isNegotiable) {
- this.form.isNegotiable = false
- }
+ onOutputRangeChange(e) {
+ const idx = Number((e && e.detail && e.detail.value) || 0)
+ this.form.outputRange = this.outputRangeOptions[idx] || ''
this.triggerAutoSave()
},
+ /**
+ * 解析自由输入的价格文本(如:1万元 / 2000元/斤 / 面议)
+ * 数值部分写入 price 字段,其余文本作为计价单位写入 priceUnit,与后端存储结构兼容
+ * @returns {{num:number, unit:string}} num 为数值部分(无数字时为 0),unit 为单位/备注文本
+ */
+ parsePriceInput() {
+ const raw = String(this.form.price || '').trim()
+ if (!raw) return { num: 0, unit: '' }
+ const m = raw.match(/^([0-9]+(?:\.[0-9]+)?)\s*(.*)$/)
+ if (m) return { num: parseFloat(m[1]) || 0, unit: (m[2] || '').trim() }
+ // 纯文本写法(如:面议):数值为 0,整段作为单位展示
+ return { num: 0, unit: raw }
+ },
/**
* 点击添加分类推荐亮点标签
* @param {string} rt 推荐标签
@@ -981,9 +1105,15 @@ export default {
}
},
/**
- * 打开全部分类弹窗抽屉
+ * 打开分类抽屉(step=1 选大类,step=2 选品类;选品类前须已选大类)
+ * @param {number} step 抽屉步骤
*/
- openCatDrawer() {
+ openCatStep(step) {
+ if (Number(step) === 2 && !this.form.categoryId) {
+ uni.showToast({ title: '请先选择大类', icon: 'none' })
+ return
+ }
+ this.catDrawerStep = Number(step) === 2 ? 2 : 1
this.catDrawerVisible = true
setTimeout(() => {
this.catDrawerAnim = true
@@ -999,26 +1129,40 @@ export default {
}, 200)
},
/**
- * 在抽屉中点选分类
- * @param {Object} c 分类项
+ * 选择一级大类(蔬菜 / 水果),选中即回填并关闭
+ * @param {Object} c 一级大类对象
*/
- onSelectDrawerCat(c) {
- this.selectCat(c)
+ onSelectDrawerParentCat(c) {
+ if (!c) return
+ this.form.categoryId = Number(c.id)
+ this.form.subCategoryId = 0
+ this.triggerAutoSave()
this.closeCatDrawer()
},
/**
- * 选中分类
- * @param {Object} c 分类项
+ * 第二步:仅按一级大类发布(不选具体二级品类)
*/
- selectCat(c) {
- if (!c) return
- const prevCat = this.form.categoryId
- this.form.categoryId = c.id
- if (prevCat !== c.id && !this.form.isNegotiable) {
- this.form.priceUnit = (this.currentUnits && this.currentUnits[0]) || '元'
- }
+ onSelectDrawerParentOnly() {
+ this.form.subCategoryId = 0
this.triggerAutoSave()
+ this.closeCatDrawer()
},
+ /**
+ * 第二步:选中二级分类(如:花菜、白菜、紫甘蓝、青甘蓝、青菜等)并完成选择
+ * @param {Object} sub 二级分类对象
+ */
+ onSelectDrawerSubCat(sub) {
+ if (!sub) return
+ if (sub.pid) {
+ this.form.categoryId = Number(sub.pid)
+ }
+ this.form.subCategoryId = Number(sub.id)
+ this.triggerAutoSave()
+ this.closeCatDrawer()
+ },
+ /**
+ * 金额展示格式化(整数不带小数,其余保留两位)
+ */
money(v) {
const n = Number(v || 0)
return Number.isInteger(n) ? String(n) : n.toFixed(2)
@@ -1026,17 +1170,102 @@ export default {
isVideo(url) {
return /\.(mp4|mov|m4v|avi|webm|mkv)(\?|$)/i.test(String(url || ''))
},
+ /**
+ * 校验上传图片的宽高比与文件大小(用于详情页顶部轮播展示,限制宽高比 0.75~2.2,单张 ≤ 5MB)
+ * @param {string} filePath 本地临时路径
+ * @param {Object} fileObj chooseImage 返回的 tempFiles[i]
+ * @returns {Promise<{ok:boolean, message?:string}>}
+ */
+ validateImageForCarousel(filePath, fileObj = null) {
+ if (fileObj && fileObj.size && Number(fileObj.size) > 5 * 1024 * 1024) {
+ return Promise.resolve({ ok: false, message: '单张图片大小不能超过 5MB' })
+ }
+ if (typeof uni === 'undefined' || !uni.getImageInfo) {
+ return Promise.resolve({ ok: true })
+ }
+ return new Promise((resolve) => {
+ uni.getImageInfo({
+ src: filePath,
+ success: (info) => {
+ const w = Number(info && info.width) || 0
+ const h = Number(info && info.height) || 0
+ if (w >= 50 && h >= 50) {
+ const ratio = w / h
+ if (ratio < 0.75 || ratio > 2.2) {
+ resolve({
+ ok: false,
+ message: '为保证轮播展示效果,请上传宽高比在 3:4 ~ 16:9 之间的横图或方图',
+ })
+ return
+ }
+ }
+ resolve({ ok: true })
+ },
+ fail: () => resolve({ ok: true }),
+ })
+ })
+ },
chooseImage() {
if (this.uploading) return
const remain = 6 - this.imageCount
if (remain <= 0) return uni.showToast({ title: '最多上传 6 张图片', icon: 'none' })
+ // 直接从相册选择(拍照功能已移除)
+ this.pickFromAlbum(remain)
+ },
+ /** 相册选图:压缩(>1MB 阶梯降质)→ 宽高比与大小校验 → 上传 */
+ pickFromAlbum(remain) {
uni.chooseImage({
count: remain,
+ sizeType: ['original', 'compressed'],
success: async (res) => {
- await this.uploadFiles(res.tempFilePaths || [], 'image')
+ const paths = res.tempFilePaths || []
+ const files = res.tempFiles || []
+ const validPaths = []
+ for (let i = 0; i < paths.length; i++) {
+ const compressed = await this.compressImageForUpload(paths[i], files[i])
+ const check = await this.validateImageForCarousel(compressed.path, { size: compressed.size })
+ if (!check.ok) {
+ uni.showToast({ title: check.message, icon: 'none', duration: 2600 })
+ } else {
+ validPaths.push(compressed.path)
+ }
+ }
+ if (validPaths.length) {
+ await this.uploadFiles(validPaths, 'image')
+ }
},
})
},
+ /**
+ * 上传前压缩:>1MB 才压缩,按 80/60/45 质量阶梯降质直到 ≤5MB(后端硬限制)
+ * gif 不支持压缩接口,直接原样返回
+ * @param {string} path 本地临时路径
+ * @param {Object} fileObj chooseImage 返回的 tempFiles[i]
+ * @returns {Promise<{path:string, size:number}>}
+ */
+ async compressImageForUpload(path, fileObj) {
+ const fileSize = Number(fileObj && fileObj.size) || 0
+ if (/\.gif$/i.test(path)) return { path, size: fileSize }
+ if (fileSize > 0 && fileSize <= 1024 * 1024) return { path, size: fileSize }
+ if (typeof uni === 'undefined' || !uni.compressImage) return { path, size: fileSize }
+ let cur = { path, size: fileSize }
+ for (const q of [80, 60, 45]) {
+ try {
+ const res = await new Promise((resolve, reject) => {
+ uni.compressImage({ src: cur.path, quality: q, success: resolve, fail: reject })
+ })
+ if (!res || !res.tempFilePath) break
+ const info = await new Promise((resolve) => {
+ uni.getFileInfo({ filePath: res.tempFilePath, success: resolve, fail: () => resolve(null) })
+ })
+ cur = { path: res.tempFilePath, size: Number(info && info.size) || 0 }
+ if (cur.size > 0 && cur.size <= 5 * 1024 * 1024) return cur
+ } catch (e) {
+ break
+ }
+ }
+ return cur
+ },
chooseVideo() {
if (this.uploading) return
if (this.videoCount >= 1) return uni.showToast({ title: '最多上传 1 个视频', icon: 'none' })
@@ -1089,6 +1318,8 @@ export default {
onRegionPicked(area) {
this.form.areaId = area ? Number(area.areaId) || 0 : 0
this.form.area = area ? area.district || '' : ''
+ this.form.province = area ? area.province || '' : ''
+ this.form.city = area ? area.city || '' : ''
this.triggerAutoSave()
},
/**
@@ -1103,6 +1334,8 @@ export default {
if (!found || !found.areaId) return
this.form.areaId = Number(found.areaId) || 0
this.form.area = found.district || ''
+ this.form.province = found.province || ''
+ this.form.city = found.city || ''
} catch (e) {}
},
onFieldInput() {
@@ -1132,10 +1365,11 @@ export default {
*/
async executeSaveDraft(silent = false) {
try {
+ const parsedPrice = this.parsePriceInput()
const payload = {
...this.form,
- price: this.form.isNegotiable ? 0 : (Number(this.form.price) || 0),
- priceUnit: this.form.isNegotiable ? '面议' : (this.form.priceUnit || '元'),
+ price: parsedPrice.num,
+ priceUnit: parsedPrice.unit,
tags: this.form.tags,
draftId: this.currentDraftId || 0,
}
@@ -1143,7 +1377,6 @@ export default {
if (res && res.draftId) {
this.currentDraftId = res.draftId
}
- this.updateDraftCount()
if (!silent) {
uni.showToast({ title: '已存入草稿箱', icon: 'success' })
}
@@ -1159,9 +1392,17 @@ export default {
*/
validate() {
if (!this.form.categoryId) return '请选择所属分类'
- if (this.form.identityType === 'merchant' && !this.isMerchantUser) return '请先完成商家资质认证'
+ if (!this.form.subCategoryId && this.drawerSubCategories.length) return '请选择二级品类'
if (!this.form.title || !this.form.title.trim()) return '请填写标题'
if (!this.form.content || !this.form.content.trim()) return '请填写详细内容'
+ // 校验顺序与表单视觉顺序一致(价格 → 产地规格 → 区域 → 手机号),报错时用户可自上而下定位
+ if (this.isFarmCategory && !(this.parsePriceInput().num > 0)) return '请填写销售价格'
+ if (this.isFarmCategory) {
+ if (!this.form.plantArea || !this.form.plantArea.trim()) return '请填写种植面积'
+ if (!this.form.harvestTime) return '请选择采摘时间'
+ if (!this.form.outputRange) return '请选择预计量产范围'
+ }
+ if (this.form.identityType === 'merchant' && !this.isMerchantUser) return '请先完成商家资质认证'
if (!this.form.areaId) return '请选择所属区域'
if (this.form.phone && !/^1\d{10}$/.test(this.form.phone)) return '请输入正确的11位手机号'
return ''
@@ -1244,10 +1485,11 @@ export default {
try {
// 订阅消息授权(审核结果);未配置模板时静默跳过
await requestSubscribe('audit')
+ const parsedPrice = this.parsePriceInput()
const payload = {
...this.form,
- price: this.form.isNegotiable ? 0 : (Number(this.form.price) || 0),
- priceUnit: this.form.isNegotiable ? '面议' : (this.form.priceUnit || '元'),
+ price: parsedPrice.num,
+ priceUnit: parsedPrice.unit,
tags: this.form.tags,
plan: this.form.plan === 'quota' ? 'free' : this.form.plan,
payPassword,
@@ -1296,53 +1538,6 @@ export default {
padding-bottom: calc(160rpx + env(safe-area-inset-bottom));
}
-/* 顶部独立草稿箱入口按钮 */
-.create__draft-entry {
- display: flex;
- align-items: center;
- background: rgba(255, 255, 255, 0.18);
- border: 1rpx solid rgba(255, 255, 255, 0.35);
- border-radius: 28rpx;
- padding: 8rpx 18rpx;
- position: relative;
- cursor: pointer;
- transition: opacity 0.15s ease;
-
- &:active {
- opacity: 0.8;
- }
-}
-
-.create__draft-icon {
- width: 28rpx;
- height: 28rpx;
- margin-right: 8rpx;
-}
-
-.create__draft-text {
- font-size: 24rpx;
- font-weight: 600;
- color: #ffffff;
-}
-
-.create__draft-badge {
- position: absolute;
- top: -10rpx;
- right: -10rpx;
- background: #ff5252;
- color: #ffffff;
- font-size: 18rpx;
- font-weight: 700;
- min-width: 28rpx;
- height: 28rpx;
- border-radius: 14rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 0 6rpx;
- box-shadow: 0 2rpx 6rpx rgba(0, 0, 0, 0.2);
-}
-
/* 表单卡片区域 */
.create__section {
margin: 20rpx 28rpx 0;
@@ -1378,7 +1573,7 @@ export default {
margin-bottom: 20rpx;
}
-/* 分类选择单元格(唯一入口) */
+/* 分类选择单元格(大类 / 品类两行独立输入) */
.create__cell {
display: flex;
align-items: center;
@@ -1388,6 +1583,16 @@ export default {
cursor: pointer;
}
+/* 品类行与大类行之间的分隔线 */
+.create__cell--sub {
+ border-top: 2rpx solid #f0f4f2;
+}
+
+/* 未选大类时品类行置灰不可点 */
+.create__cell--disabled {
+ opacity: 0.55;
+}
+
.create__cell-left {
display: flex;
align-items: center;
@@ -1431,14 +1636,7 @@ export default {
color: #04874a;
}
-.create__label-tip {
- font-size: 22rpx;
- color: $fc-text-placeholder;
- font-weight: 400;
- margin-left: auto;
-}
-
-/* 2. 身份切换组 */
+/* 联系卡内身份切换组 */
.create__identity-group {
display: grid;
grid-template-columns: 1fr 1fr;
@@ -1721,54 +1919,14 @@ export default {
}
}
-.create__price-symbol {
- font-size: 34rpx;
- font-weight: 800;
- color: #f5a623; /* 阳光金强调价值 */
- margin-right: 12rpx;
-}
-
.create__price-input {
flex: 1;
height: 88rpx;
- font-size: 36rpx;
+ font-size: 32rpx;
font-weight: 700;
color: #f5a623;
}
-.create__price-unit-text {
- font-size: 26rpx;
- font-weight: 600;
- color: $fc-text-sub;
- margin-left: 12rpx;
-}
-
-/* 计价单位快捷胶囊 */
-.create__unit-chips {
- display: flex;
- flex-wrap: wrap;
- gap: 14rpx;
- margin-top: 18rpx;
-}
-
-.create__unit-chip {
- padding: 10rpx 24rpx;
- border-radius: 28rpx;
- font-size: 24rpx;
- color: $fc-text;
- background: #f4f8f5;
- border: 1rpx solid #dcece1;
- cursor: pointer;
- transition: all 0.15s ease;
-
- &--active {
- background: rgba(0, 224, 112, 0.16);
- border-color: #00e070;
- color: #04874a;
- font-weight: 700;
- }
-}
-
/* 特色亮点标签 */
.create__tags-wrapper {
display: flex;
@@ -2159,6 +2317,7 @@ export default {
}
.cat-drawer__title {
+ flex: 1;
font-size: 32rpx;
font-weight: 700;
color: $fc-text;
@@ -2193,58 +2352,82 @@ export default {
gap: 20rpx;
}
+/* 第一步:一级大类大卡(双列,大图识物) */
+.cat-drawer__grid--parent {
+ grid-template-columns: repeat(2, 1fr);
+ gap: 24rpx;
+}
+
.cat-drawer__item {
- background: #f7faf8;
- border: 2rpx solid #e7efe9;
+ background: #ffffff;
+ border: 3rpx solid #e7efe9;
border-radius: 20rpx;
- padding: 24rpx 16rpx;
- display: flex;
- flex-direction: column;
- align-items: center;
- justify-content: center;
+ overflow: hidden;
position: relative;
transition: all 0.15s ease;
cursor: pointer;
&--active {
- border-color: #00e070;
- background: #ebfaf0;
- box-shadow: 0 4rpx 16rpx rgba(0, 224, 112, 0.2);
-
- .cat-drawer__name {
- color: #04874a;
- font-weight: 700;
- }
+ border-color: #00d26a;
+ box-shadow: 0 6rpx 20rpx rgba(0, 224, 112, 0.22);
}
}
-.cat-drawer__icon-box {
- width: 72rpx;
- height: 72rpx;
+/* 大图封面区(浅绿底衬托透明插画,图片为主体便于不识字用户识物) */
+.cat-drawer__cover-box {
+ height: 170rpx;
+ background: linear-gradient(180deg, #f2fef7, #eafaf1);
display: flex;
align-items: center;
justify-content: center;
- margin-bottom: 12rpx;
+
+ &--parent {
+ height: 210rpx;
+ }
}
-.cat-drawer__icon {
- width: 60rpx;
- height: 60rpx;
+.cat-drawer__cover {
+ width: 78%;
+ height: 78%;
+}
+
+/* 底部名称条(文字仅作辅助) */
+.cat-drawer__caption {
+ padding: 14rpx 12rpx 16rpx;
+ display: flex;
+ flex-direction: column;
+ align-items: center;
+ background: #ffffff;
}
.cat-drawer__name {
- font-size: 26rpx;
+ font-size: 28rpx;
+ font-weight: 600;
color: $fc-text;
text-align: center;
}
+.cat-drawer__count {
+ margin-top: 4rpx;
+ font-size: 20rpx;
+ color: $fc-text-muted;
+}
+
.cat-drawer__check {
position: absolute;
- top: 8rpx;
+ top: 12rpx;
right: 12rpx;
- font-size: 22rpx;
+ width: 40rpx;
+ height: 40rpx;
+ border-radius: 50%;
+ background: #00d26a;
+ color: #ffffff;
+ font-size: 24rpx;
font-weight: 900;
- color: #04874a;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ box-shadow: 0 4rpx 10rpx rgba(0, 210, 106, 0.4);
}
.cat-drawer__space {
@@ -2424,4 +2607,24 @@ export default {
opacity: 0.6;
}
}
+
+/* 产地规格选择器样式 */
+.create__picker-flex {
+ flex: 1;
+}
+.create__picker-inner {
+ display: flex;
+ align-items: center;
+ justify-content: flex-end;
+ min-height: 60rpx;
+}
+.create__picker-val {
+ font-size: 28rpx;
+ color: #1e293b;
+ font-weight: 500;
+}
+.create__picker-ph {
+ font-size: 28rpx;
+ color: $fc-text-placeholder;
+}
diff --git a/uniapp/static/categories/cat-fruit.png b/uniapp/static/categories/cat-fruit.png
new file mode 100644
index 0000000..7fce115
Binary files /dev/null and b/uniapp/static/categories/cat-fruit.png differ
diff --git a/uniapp/static/categories/cat-veg.png b/uniapp/static/categories/cat-veg.png
new file mode 100644
index 0000000..019fe17
Binary files /dev/null and b/uniapp/static/categories/cat-veg.png differ
diff --git a/uniapp/static/categories/fruit-apple.png b/uniapp/static/categories/fruit-apple.png
new file mode 100644
index 0000000..31f03f3
Binary files /dev/null and b/uniapp/static/categories/fruit-apple.png differ
diff --git a/uniapp/static/categories/fruit-grape.png b/uniapp/static/categories/fruit-grape.png
new file mode 100644
index 0000000..a48391d
Binary files /dev/null and b/uniapp/static/categories/fruit-grape.png differ
diff --git a/uniapp/static/categories/fruit-kiwi.png b/uniapp/static/categories/fruit-kiwi.png
new file mode 100644
index 0000000..d0e7df8
Binary files /dev/null and b/uniapp/static/categories/fruit-kiwi.png differ
diff --git a/uniapp/static/categories/fruit-orange.png b/uniapp/static/categories/fruit-orange.png
new file mode 100644
index 0000000..0603e1a
Binary files /dev/null and b/uniapp/static/categories/fruit-orange.png differ
diff --git a/uniapp/static/categories/fruit-passion.png b/uniapp/static/categories/fruit-passion.png
new file mode 100644
index 0000000..f58d88c
Binary files /dev/null and b/uniapp/static/categories/fruit-passion.png differ
diff --git a/uniapp/static/categories/fruit-peach.png b/uniapp/static/categories/fruit-peach.png
new file mode 100644
index 0000000..03b4480
Binary files /dev/null and b/uniapp/static/categories/fruit-peach.png differ
diff --git a/uniapp/static/categories/fruit-strawberry.png b/uniapp/static/categories/fruit-strawberry.png
new file mode 100644
index 0000000..52b1a0d
Binary files /dev/null and b/uniapp/static/categories/fruit-strawberry.png differ
diff --git a/uniapp/static/categories/fruit-watermelon.png b/uniapp/static/categories/fruit-watermelon.png
new file mode 100644
index 0000000..5d7ac3c
Binary files /dev/null and b/uniapp/static/categories/fruit-watermelon.png differ
diff --git a/uniapp/static/categories/veg-cabbage.png b/uniapp/static/categories/veg-cabbage.png
new file mode 100644
index 0000000..f286997
Binary files /dev/null and b/uniapp/static/categories/veg-cabbage.png differ
diff --git a/uniapp/static/categories/veg-cauliflower.png b/uniapp/static/categories/veg-cauliflower.png
new file mode 100644
index 0000000..dbecc61
Binary files /dev/null and b/uniapp/static/categories/veg-cauliflower.png differ
diff --git a/uniapp/static/categories/veg-chili.png b/uniapp/static/categories/veg-chili.png
new file mode 100644
index 0000000..2b20d25
Binary files /dev/null and b/uniapp/static/categories/veg-chili.png differ
diff --git a/uniapp/static/categories/veg-green-cabbage.png b/uniapp/static/categories/veg-green-cabbage.png
new file mode 100644
index 0000000..b457763
Binary files /dev/null and b/uniapp/static/categories/veg-green-cabbage.png differ
diff --git a/uniapp/static/categories/veg-greens.png b/uniapp/static/categories/veg-greens.png
new file mode 100644
index 0000000..85d2aaa
Binary files /dev/null and b/uniapp/static/categories/veg-greens.png differ
diff --git a/uniapp/static/categories/veg-purple-cabbage.png b/uniapp/static/categories/veg-purple-cabbage.png
new file mode 100644
index 0000000..a7d9d08
Binary files /dev/null and b/uniapp/static/categories/veg-purple-cabbage.png differ
diff --git a/uniapp/static/categories/veg-radish.png b/uniapp/static/categories/veg-radish.png
new file mode 100644
index 0000000..85e13e1
Binary files /dev/null and b/uniapp/static/categories/veg-radish.png differ
diff --git a/uniapp/static/categories/veg-tomato.png b/uniapp/static/categories/veg-tomato.png
new file mode 100644
index 0000000..31b7bb6
Binary files /dev/null and b/uniapp/static/categories/veg-tomato.png differ
diff --git a/uniapp/static/icons/cat-fruit.png b/uniapp/static/icons/cat-fruit.png
new file mode 100644
index 0000000..7fce115
Binary files /dev/null and b/uniapp/static/icons/cat-fruit.png differ
diff --git a/uniapp/static/icons/cat-veg.png b/uniapp/static/icons/cat-veg.png
new file mode 100644
index 0000000..019fe17
Binary files /dev/null and b/uniapp/static/icons/cat-veg.png differ