diff --git a/server/application/admin/view/common/meta.html b/server/application/admin/view/common/meta.html
index 2a669f2..7b0b170 100755
--- a/server/application/admin/view/common/meta.html
+++ b/server/application/admin/view/common/meta.html
@@ -19,6 +19,28 @@
+
+
-
-
+
+
{{ locBarText }}
-
-
- {{ locBarActionText }}
@@ -128,7 +121,7 @@
/>
-
+
工单大厅加载失败
{{ loadError }}
@@ -150,8 +143,8 @@
急单
-
- {{ o.service_type_tag || '安装' }}
+
+ {{ o.service_type_tag }}
{{ o.service_name }}
@@ -274,11 +267,12 @@
当前筛选下暂无待接工单
- 可尝试切换订单类型、刷新列表或扩展接单技能范围
+ {{ activeFilterChips.length ? '可清除筛选条件后查看其他订单' : '可尝试切换订单类型、刷新列表或扩展接单技能范围' }}
+ 清除筛选
查看全部订单 ({{ formatCount(counts.all) }})
@@ -289,6 +283,37 @@
+
+
+
+ 订单筛选
+
+
+
+
+ 排序方式
+ {{ item.name }}
+
+
+ 订单距离
+ 只显示所选距离内的订单;与推荐范围分别设置
+ {{ item.label }}
+
+
+ 服务类型
+ 根据订单中的服务明细筛选
+ 全部{{ item.name }}
+ {{ showAllServiceTypes ? '收起服务类型' : '展开全部服务类型' }}
+
+
+ 服务品类
+ 全部{{ item.name }}
+
+
+
+
+
+
@@ -323,12 +348,12 @@
import api from '@/utils/api.js';
import { isLogin, toLogin } from '@/utils/request.js';
import { setRole } from '@/utils/role.js';
+ import { savePickedLocation } from '@/utils/masterHallLocation.mjs';
import {
checkLocationPermissionStatus,
getCurrentCoordinates,
getSavedManualLocation,
- saveManualLocation,
- openMiniProgramLocationSettingSync
+ saveManualLocation
} from '@/utils/location.js';
import YjyfNavBar from '@/components/YjyfNavBar.vue';
import YjyfRefreshScroll from '@/components/YjyfRefreshScroll.vue';
@@ -347,7 +372,6 @@
const locationStatus = ref('prompt');
const locationCity = ref('');
const locationLabel = ref('');
- const serveRadius = ref(15);
const serverLocationSource = ref('none');
const requestingLocation = ref(false);
const initializingLocation = ref(false);
@@ -357,20 +381,26 @@
const locBarText = computed(() => {
if (hasCoords.value) {
const name = locationLabel.value || locationCity.value || '已开启实时定位';
- return `当前位置:${name}(${serveRadius.value}km内)`;
+ return `接单位置:${name}`;
}
if (serverLocationSource.value === 'saved') {
- return `已按历史位置(${locationCity.value || '常驻城市'} · ${serveRadius.value}km内)为您推荐`;
+ return `接单位置:${locationCity.value || '已保存位置'}`;
}
- return '未获取当前位置,开启或设置位置后可精准推荐附近订单';
- });
- const locBarActionText = computed(() => {
- if (hasCoords.value) return '切换位置';
- if (serverLocationSource.value === 'saved') return '设置位置';
- return '选择位置';
+ return '选择接单位置';
});
const type = ref('all');
const sort = ref('recommend');
+ const filterOptions = ref({ categories: [], service_types: [] });
+ const distance = ref(0);
+ const category = ref(0);
+ const serviceType = ref('');
+ const filtersOpen = ref(false);
+ const draftSort = ref('recommend');
+ const draftDistance = ref(0);
+ const draftCategory = ref(0);
+ const draftServiceType = ref('');
+ const showAllServiceTypes = ref(false);
+ const visibleServiceTypes = computed(() => showAllServiceTypes.value ? filterOptions.value.service_types : filterOptions.value.service_types.slice(0, 5));
const selectedOrder = ref(null);
const grabbing = ref(false);
const togglingWork = ref(false);
@@ -390,9 +420,27 @@
{ key: 'recommend', name: '智能推荐' },
{ key: 'distance', name: '离我最近' },
{ key: 'new', name: '最新发布' },
- { key: 'amount', name: '报酬最高' },
+ { key: 'amount', name: '实付最高' },
{ key: 'urgent', name: '急单优先' }
];
+ const distanceOptions = [
+ { value: 0, label: '不限' }, { value: 5, label: '5km内' },
+ { value: 15, label: '15km内' }, { value: 30, label: '30km内' }, { value: 50, label: '50km内' }
+ ];
+ const activeFilterChips = computed(() => {
+ const chips = [];
+ if (sort.value === 'amount' || sort.value === 'urgent') chips.push({ key: 'sort', label: sortTabs.find(s => s.key === sort.value).name });
+ if (distance.value) chips.push({ key: 'distance', label: `${distance.value}km内` });
+ if (serviceType.value) {
+ const item = filterOptions.value.service_types.find(s => s.code === serviceType.value);
+ if (item) chips.push({ key: 'serviceType', label: item.name });
+ }
+ if (category.value) {
+ const item = filterOptions.value.categories.find(c => Number(c.id) === category.value);
+ if (item) chips.push({ key: 'category', label: item.name });
+ }
+ return chips;
+ });
// 基于真实待接工单生成可点击直达详情的实时广播条
const broadcastList = computed(() => {
@@ -438,9 +486,50 @@
if (locationCity.value) {
params.city = locationCity.value;
}
+ if (distance.value) params.distance_km = distance.value;
+ if (category.value) params.cat_id = category.value;
+ if (serviceType.value) params.service_type = serviceType.value;
return params;
}
+ function openFilters() {
+ draftSort.value = sort.value;
+ draftDistance.value = distance.value;
+ draftCategory.value = category.value;
+ draftServiceType.value = serviceType.value;
+ showAllServiceTypes.value = Boolean(serviceType.value && !filterOptions.value.service_types.slice(0, 5).some(item => item.code === serviceType.value));
+ filtersOpen.value = true;
+ }
+ function resetDraftFilters() {
+ draftSort.value = 'recommend';
+ draftDistance.value = 0;
+ draftCategory.value = 0;
+ draftServiceType.value = '';
+ }
+ function applyFilters() {
+ if ((draftDistance.value || draftSort.value === 'distance') && !hasCoords.value && serverLocationSource.value === 'none') {
+ uni.showToast({ title: '请先选择接单位置', icon: 'none' });
+ return;
+ }
+ sort.value = draftSort.value;
+ distance.value = draftDistance.value;
+ category.value = draftCategory.value;
+ serviceType.value = draftServiceType.value;
+ filtersOpen.value = false;
+ fetchHallList();
+ }
+ function clearFilter(key) {
+ if (key === 'sort') sort.value = 'recommend';
+ if (key === 'distance') distance.value = 0;
+ if (key === 'category') category.value = 0;
+ if (key === 'serviceType') serviceType.value = '';
+ fetchHallList();
+ }
+ function clearAllFilters() {
+ sort.value = 'recommend'; distance.value = 0; category.value = 0; serviceType.value = '';
+ fetchHallList();
+ }
+
function switchType(k) {
if (type.value === k) return;
type.value = k;
@@ -449,7 +538,8 @@
function switchSort(k) {
if (k === 'distance' && !hasCoords.value && serverLocationSource.value === 'none') {
- handleRequestLocation();
+ handleLocationBarTap();
+ return;
}
if (sort.value === k) return;
sort.value = k;
@@ -539,106 +629,49 @@
}
}
- function openLocationPage() {
- const query = [];
- if (coords.value.lat && coords.value.lng) {
- query.push(`lat=${encodeURIComponent(coords.value.lat)}`);
- query.push(`lng=${encodeURIComponent(coords.value.lng)}`);
- }
- if (locationCity.value) {
- query.push(`city=${encodeURIComponent(locationCity.value)}`);
- }
- if (locationLabel.value) {
- query.push(`label=${encodeURIComponent(locationLabel.value)}`);
- }
- if (serveRadius.value) {
- query.push(`radius=${encodeURIComponent(serveRadius.value)}`);
- }
- const qs = query.length ? `?${query.join('&')}` : '';
- uni.navigateTo({ url: `/pages/master/location${qs}` });
- }
-
function handleLocationBarTap() {
- if (hasCoords.value) {
- openLocationPage();
- return;
- }
- handleRequestLocation();
- }
-
- function handleRequestLocation() {
- // #ifdef MP-WEIXIN
- // 已被微信拒绝过权限时,必须在点击同步手势周期内直接唤起微信原生设置页
- if (locationStatus.value === 'denied') {
- requestingLocation.value = true;
- openMiniProgramLocationSettingSync().then(async (res) => {
- requestingLocation.value = false;
- if (res && res.ok && res.lat && res.lng) {
- locationStatus.value = 'granted';
- await applyVerifiedLocation(res.lat, res.lng);
- uni.showToast({ title: '定位已开启,已更新附近推荐', icon: 'none' });
- } else {
- openLocationPage();
- }
- });
- return;
- }
- requestDeviceLocationInteractive();
- return;
- // #endif
-
- // #ifndef MP-WEIXIN
- openLocationPage();
- // #endif
- }
-
- async function applyVerifiedLocation(lat, lng, customLabel = '', customCity = '') {
- coords.value = { lat, lng };
- if (customCity) locationCity.value = customCity;
- if (customLabel) locationLabel.value = customLabel;
- const res = await syncMasterLocation(lat, lng, customCity, customLabel);
- const finalCity = customCity || (res && res.location_city) || locationCity.value || '';
- const finalLabel = customLabel || (res && res.location_label) || finalCity || '已定位';
- const finalRadius = (res && res.serve_radius) || serveRadius.value;
- locationCity.value = finalCity;
- locationLabel.value = finalLabel;
- serveRadius.value = finalRadius;
- saveManualLocation({ lat, lng, label: finalLabel, city: finalCity, serveRadius: finalRadius });
- await fetchHallList();
- }
-
- async function requestDeviceLocationInteractive() {
- if (requestingLocation.value) return;
+ if (requestingLocation.value || initializingLocation.value) return;
requestingLocation.value = true;
- try {
- const res = await getCurrentCoordinates({ timeout: 4500 });
- if (res && res.ok && res.lat && res.lng) {
- locationStatus.value = 'granted';
- await applyVerifiedLocation(res.lat, res.lng);
- uni.showToast({ title: '定位成功,已为您推荐附近工单', icon: 'none' });
- } else {
- if (res && res.reason === 'denied') {
- locationStatus.value = 'denied';
+ const options = {
+ success: async (selection) => {
+ try {
+ ++loadSeq;
+ const saved = await savePickedLocation(selection, api.masterUpdateLocation);
+ coords.value = { lat: saved.lat, lng: saved.lng };
+ locationCity.value = saved.city;
+ locationLabel.value = saved.label;
+ saveManualLocation({ ...saved, manual: true });
+ await fetchHallList();
+ uni.showToast({ title: '接单位置已更新', icon: 'none' });
+ } catch (e) {
+ loading.value = false;
+ uni.showToast({ title: e?.msg || e?.message || '保存位置失败,请重试', icon: 'none' });
+ } finally {
+ requestingLocation.value = false;
+ }
+ },
+ fail: (err) => {
+ requestingLocation.value = false;
+ if (!String(err?.errMsg || '').toLowerCase().includes('cancel')) {
+ uni.showToast({ title: '无法打开位置选择,请检查定位权限', icon: 'none' });
}
- openLocationPage();
}
- } finally {
- requestingLocation.value = false;
+ };
+ if (hasCoords.value) {
+ options.latitude = Number(coords.value.lat);
+ options.longitude = Number(coords.value.lng);
}
- }
-
- function onLocationPageUpdated(payload) {
- if (!payload) return;
- if (payload.lat && payload.lng) {
- coords.value = { lat: payload.lat, lng: payload.lng };
- }
- if (payload.city) locationCity.value = payload.city;
- if (payload.label) locationLabel.value = payload.label;
- if (payload.serveRadius) serveRadius.value = Number(payload.serveRadius) || serveRadius.value;
- fetchHallList();
+ uni.chooseLocation(options);
}
async function resolveLocationSilent(timeoutMs = 3500) {
+ const saved = getSavedManualLocation();
+ if (saved && saved.manual) {
+ coords.value = { lat: saved.lat, lng: saved.lng };
+ locationCity.value = saved.city;
+ locationLabel.value = saved.label;
+ return true;
+ }
const status = await checkLocationPermissionStatus();
locationStatus.value = status;
@@ -675,7 +708,6 @@
}
// 若实时设备定位未获取,回读近期手动校准过的真实地点缓存
- const saved = getSavedManualLocation();
if (saved) {
coords.value = { lat: saved.lat, lng: saved.lng };
if (saved.city) locationCity.value = saved.city;
@@ -704,7 +736,7 @@
toLogin('/pages/master/hall');
return;
}
- if (initializingLocation.value) {
+ if (initializingLocation.value || requestingLocation.value) {
return;
}
const saved = getSavedManualLocation();
@@ -712,7 +744,6 @@
coords.value = { lat: saved.lat, lng: saved.lng };
if (saved.city) locationCity.value = saved.city;
if (saved.label) locationLabel.value = saved.label;
- if (saved.serveRadius) serveRadius.value = saved.serveRadius;
} else if (!hasCoords.value) {
await resolveLocationSilent(3000);
}
@@ -760,12 +791,10 @@
if (hallRes.counts) {
counts.value = hallRes.counts;
}
+ if (hallRes.filter_options) filterOptions.value = hallRes.filter_options;
if (hallRes.location_city) {
locationCity.value = hallRes.location_city;
}
- if (hallRes.serve_radius) {
- serveRadius.value = Number(hallRes.serve_radius) || serveRadius.value;
- }
serverLocationSource.value = hallRes.location_source || 'none';
} else if (hallResult.status === 'rejected') {
const err = hallResult.reason;
@@ -845,12 +874,10 @@
}
onMounted(() => {
- uni.$on('masterLocationUpdated', onLocationPageUpdated);
initLocationAndLoad();
});
onBeforeUnmount(() => {
- uni.$off('masterLocationUpdated', onLocationPageUpdated);
while (timers.length) {
clearTimeout(timers.pop());
}
@@ -1674,11 +1701,37 @@
}
}
.sort-tabs-inner {
- display: inline-flex;
+ display: flex;
+ flex: 1;
+ min-width: 0;
align-items: center;
- gap: 10rpx;
+ gap: 6rpx;
padding-right: $yjyf-space-xs;
}
+ .sort-tabs-inner .s-tab { flex: 1; min-width: 0; padding: 0 8rpx; }
+ .filter-trigger { flex-shrink: 0; min-height: 88rpx; display: flex; align-items: center; gap: 6rpx; color: $yjyf-primary; font-size: $yjyf-font-sub; font-weight: 600; }
+ .filter-icon { width: 26rpx; height: 26rpx; }
+ .active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8rpx; padding: 0 $yjyf-space-md $yjyf-space-sm; }
+ .active-filter { display: inline-flex; align-items: center; gap: 6rpx; min-height: 52rpx; padding: 0 16rpx; border-radius: $yjyf-radius-pill; background: $yjyf-primary-bg; color: $yjyf-primary; font-size: $yjyf-font-micro; }
+ .active-filter-close { width: 18rpx; height: 18rpx; }
+ .clear-filters { display: flex; align-items: center; min-height: 52rpx; padding: 0 12rpx; color: $yjyf-text-secondary; font-size: $yjyf-font-sub; }
+ .filter-mask { position: fixed; inset: 0; z-index: 1005; background: rgba(0, 0, 0, 0.48); display: flex; align-items: flex-end; }
+ .filter-panel { width: 100%; height: 78vh; display: flex; flex-direction: column; background: $yjyf-bg-card; border-radius: $yjyf-radius-lg $yjyf-radius-lg 0 0; overflow: hidden; }
+ .filter-heading { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; padding: 0 $yjyf-space-md; height: 96rpx; font-size: 32rpx; font-weight: 700; color: $yjyf-text-main; border-bottom: 1rpx solid $yjyf-border-color; }
+ .filter-close { width: 88rpx; height: 88rpx; display: flex; align-items: center; justify-content: center; }
+ .filter-close-icon { width: 28rpx; height: 28rpx; }
+ .filter-content { flex: 1; min-height: 0; height: 0; box-sizing: border-box; padding: 0 $yjyf-space-md; }
+ .filter-group { padding: 24rpx 0; border-bottom: 1rpx solid $yjyf-border-color; }
+ .filter-title { display: block; color: $yjyf-text-main; font-size: $yjyf-font-body; font-weight: 700; }
+ .filter-hint { display: block; margin-top: 8rpx; color: $yjyf-text-secondary; font-size: $yjyf-font-micro; line-height: 1.4; }
+ .filter-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12rpx; margin-top: 16rpx; }
+ .filter-option { min-height: 76rpx; display: flex; align-items: center; justify-content: center; text-align: center; padding: 8rpx; box-sizing: border-box; border-radius: $yjyf-radius-sm; border: 1rpx solid transparent; background: $yjyf-bg-page; color: $yjyf-text-regular; font-size: $yjyf-font-sub; }
+ .filter-option.selected { color: $yjyf-primary; border-color: $yjyf-primary; background: $yjyf-primary-bg; font-weight: 600; }
+ .filter-expand { display: flex; align-items: center; min-height: 72rpx; color: $yjyf-primary; font-size: $yjyf-font-sub; }
+ .filter-footer { flex-shrink: 0; display: flex; gap: 16rpx; padding: 16rpx $yjyf-space-md calc(16rpx + env(safe-area-inset-bottom)); border-top: 1rpx solid $yjyf-border-color; background: $yjyf-bg-card; }
+ .filter-reset, .filter-confirm { flex: 1; height: 80rpx; display: flex; align-items: center; justify-content: center; border-radius: $yjyf-radius-pill; font-size: $yjyf-font-body; font-weight: 600; }
+ .filter-reset { background: $yjyf-bg-page; color: $yjyf-text-regular; }
+ .filter-confirm { background: $yjyf-gradient-primary; color: $yjyf-text-inverse; }
/* 位置状态与引导条(紧贴控制台下方,不阻挡主列表) */
.loc-status-bar {
@@ -1697,6 +1750,7 @@
.loc-bar-left {
flex: 1;
min-width: 0;
+ min-height: 88rpx;
display: flex;
align-items: center;
gap: 10rpx;
@@ -1719,18 +1773,6 @@
.loc-status-bar.warn .loc-bar-txt {
color: $yjyf-text-regular;
}
- .loc-bar-action {
- flex-shrink: 0;
- display: inline-flex;
- align-items: center;
- padding: 4rpx 0;
- }
- .loc-bar-action-txt {
- font-size: $yjyf-font-sub;
- font-weight: 600;
- color: $yjyf-primary;
- line-height: 1;
- }
.loc-bar-arrow {
width: 22rpx;
height: 22rpx;
diff --git a/yjyf-app/utils/location.js b/yjyf-app/utils/location.js
index 975786d..1421c45 100644
--- a/yjyf-app/utils/location.js
+++ b/yjyf-app/utils/location.js
@@ -28,7 +28,7 @@ export function getSavedManualLocation() {
if (!Number.isFinite(lat) || !Number.isFinite(lng) || (Math.abs(lat) < 0.0001 && Math.abs(lng) < 0.0001)) {
return null;
}
- if (updatedAt > 0 && Date.now() - updatedAt > MANUAL_LOC_TTL_MS) {
+ if (!raw.manual && updatedAt > 0 && Date.now() - updatedAt > MANUAL_LOC_TTL_MS) {
return null;
}
return {
@@ -38,6 +38,7 @@ export function getSavedManualLocation() {
city: String(raw.city || ''),
district: String(raw.district || ''),
serveRadius: Number(raw.serveRadius) || 0,
+ manual: Boolean(raw.manual),
updatedAt
};
} catch (e) {
@@ -48,7 +49,7 @@ export function getSavedManualLocation() {
/**
* 保存用户主动定位或选定的真实经纬度坐标
*/
-export function saveManualLocation({ lat, lng, label = '', city = '', district = '', serveRadius = 0 }) {
+export function saveManualLocation({ lat, lng, label = '', city = '', district = '', serveRadius = 0, manual = false }) {
const latNum = Number(lat);
const lngNum = Number(lng);
if (!Number.isFinite(latNum) || !Number.isFinite(lngNum)) return;
@@ -60,6 +61,7 @@ export function saveManualLocation({ lat, lng, label = '', city = '', district =
city: String(city || ''),
district: String(district || ''),
serveRadius: Number(serveRadius) || 0,
+ manual: Boolean(manual),
updatedAt: Date.now()
});
} catch (e) {}
diff --git a/yjyf-app/utils/masterHallLocation.mjs b/yjyf-app/utils/masterHallLocation.mjs
new file mode 100644
index 0000000..e97f0f1
--- /dev/null
+++ b/yjyf-app/utils/masterHallLocation.mjs
@@ -0,0 +1,17 @@
+export async function savePickedLocation(selection, updateLocation) {
+ const lat = Number(selection?.latitude);
+ const lng = Number(selection?.longitude);
+ if (!Number.isFinite(lat) || !Number.isFinite(lng) || Math.abs(lat) > 90 || Math.abs(lng) > 180 || (!lat && !lng)) {
+ throw new Error('所选位置坐标无效,请重新选择');
+ }
+ const label = selection.name || selection.address || '';
+ const result = await updateLocation({ lat, lng, label });
+ return {
+ lat,
+ lng,
+ label: label || result?.location_label || '',
+ city: result?.location_city || '',
+ district: result?.location_district || '',
+ serveRadius: Number(result?.serve_radius) || 0
+ };
+}