feat: 新增阿里云OSS适配器及分类图标优化
- 新增阿里云OSS SDK核心类库文件 - 新增OSS插件配置文件及钩子监听 - 新增分类图标SVG资源并优化为轻量化格式 - 替换定位接口为天地图逆地理编码接口 - 新增OSS图片缩略处理工具方法
这个提交包含在:
@@ -302,17 +302,16 @@ 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.selectedProvince = found.province || ''
|
||||
this.selectedCity = found.city || ''
|
||||
}
|
||||
} catch (e) {}
|
||||
let found = null
|
||||
try { found = await homeApi.geocode(this.lat, this.lng) } catch (e) { return }
|
||||
if (found && found.areaId) {
|
||||
this.selectedProvince = found.province || ''
|
||||
this.selectedCity = found.city || ''
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 分页获取分类信息列表
|
||||
|
||||
@@ -575,27 +575,25 @@ 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 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.hasMore = true
|
||||
// 平滑重载:保持原页面展示,等新数据回来再做原子替换,杜绝白屏与空状态跳动
|
||||
this.fetchPosts(false)
|
||||
}
|
||||
let found = null
|
||||
try { found = await homeApi.geocode(this.lat, this.lng) } catch (e) { return }
|
||||
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.hasMore = true
|
||||
this.fetchPosts(false)
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 拉取全部分类数据(快照缓存秒开 + 后台静默对齐,避免重复 fetchPosts 竞态)
|
||||
@@ -862,29 +860,25 @@ export default {
|
||||
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
|
||||
let found = null
|
||||
try { found = await homeApi.geocode(this.lat, this.lng) } catch (e) {}
|
||||
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' })
|
||||
}
|
||||
this.isLocating = false
|
||||
},
|
||||
fail: () => {
|
||||
this.isLocating = false
|
||||
|
||||
@@ -213,7 +213,7 @@ import memberApi from '@/common/api/member.js'
|
||||
import messageApi from '@/common/api/message.js'
|
||||
import { useUserStore } from '@/common/store/index.js'
|
||||
import { iconUrl, logoUrl, categoryIconUrl, loadUiConfig, uiState } from '@/common/store/ui.js'
|
||||
import { assetUrl } from '@/common/utils/format.js'
|
||||
import { assetUrl, ossThumb } from '@/common/utils/format.js'
|
||||
import { bannerArtUrl, bannerHasValue, bannerBg } from '@/common/assets/banners.js'
|
||||
import { getNavMetrics } from '@/common/utils/navbar.js'
|
||||
import { safeNavigateTo, safeRedirectTo } from '@/common/utils/nav.js'
|
||||
@@ -527,8 +527,7 @@ export default {
|
||||
const img = b.image.trim()
|
||||
if (img.startsWith('http://') || img.startsWith('https://')) return img
|
||||
if (img.startsWith('/static/')) return img
|
||||
if (img.startsWith('/uploads/')) return img
|
||||
return img
|
||||
return assetUrl(img)
|
||||
}
|
||||
const idx = (Math.abs(i) % 3) + 1
|
||||
return `/static/banners/banner-${idx}.png`
|
||||
@@ -539,9 +538,10 @@ export default {
|
||||
*/
|
||||
catIcon(c) {
|
||||
if (!c) return categoryIconUrl(1)
|
||||
if (c.image && /^https?:\/\/|^\/uploads\/|^\/static\//i.test(c.image)) {
|
||||
const img = (c.image || c.icon || '').trim()
|
||||
if (img && /^https?:\/\/|^\/uploads\/|^\/static\//i.test(img)) {
|
||||
// 包内自带图标(categories/icons 插画)直接用包内路径;其余拼后端域名,否则裂图
|
||||
return /^\/static\/(categories|icons)\//i.test(c.image) ? c.image : assetUrl(c.image)
|
||||
return /^\/static\/(categories|icons)\//i.test(img) ? img : ossThumb(assetUrl(img))
|
||||
}
|
||||
return (c.iconKey && iconUrl(c.iconKey)) || categoryIconUrl(c.id)
|
||||
},
|
||||
@@ -655,26 +655,26 @@ export default {
|
||||
},
|
||||
|
||||
/**
|
||||
* 将定位坐标匹配为服务区域(只匹配到市级,展示所在城市全部信息)
|
||||
* 天地图逆地理编码 → 精确匹配 fa_fc_area 服务区域(市级)
|
||||
*/
|
||||
async applyLocationArea() {
|
||||
if (this.manualArea || this.lat == null || this.lng == null) return
|
||||
let found = null
|
||||
try {
|
||||
const found = await homeApi.locate({ lat: this.lat, lng: this.lng })
|
||||
if (found && found.areaId) {
|
||||
const oldCity = this.selectedCity
|
||||
this.areaId = 0
|
||||
this.areaText = ''
|
||||
this.selectedProvince = found.province || ''
|
||||
this.selectedCity = found.city || ''
|
||||
this.location = found.city || ''
|
||||
// 若匹配出的城市有变动,平滑刷新信息流
|
||||
if (oldCity !== this.selectedCity) {
|
||||
this.page = 1
|
||||
this.fetchFeed(true)
|
||||
}
|
||||
found = await homeApi.geocode(this.lat, this.lng)
|
||||
} catch (e) { return }
|
||||
if (found && found.areaId) {
|
||||
const oldCity = this.selectedCity
|
||||
this.areaId = found.areaId
|
||||
this.areaText = found.district || ''
|
||||
this.selectedProvince = found.province || ''
|
||||
this.selectedCity = found.city || ''
|
||||
this.location = found.city || ''
|
||||
if (oldCity !== this.selectedCity) {
|
||||
this.page = 1
|
||||
this.fetchFeed(true)
|
||||
}
|
||||
} catch (e) {}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -827,29 +827,24 @@ export default {
|
||||
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.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.city || '所在城市'}`, icon: 'none' })
|
||||
this.closeLocationModal()
|
||||
} else {
|
||||
uni.showToast({ title: '已定位,但当前位置暂无开通服务', icon: 'none' })
|
||||
}
|
||||
} catch (err) {
|
||||
uni.showToast({ title: '定位匹配失败,请手动选择', icon: 'none' })
|
||||
} finally {
|
||||
this.isLocating = false
|
||||
let found = null
|
||||
try { found = await homeApi.geocode(this.lat, this.lng) } catch (e) {}
|
||||
if (found && found.areaId) {
|
||||
safeSetStorage(STORAGE_KEY_SELECTED_AREA, null)
|
||||
this.manualArea = false
|
||||
this.areaId = found.areaId
|
||||
this.areaText = found.district || ''
|
||||
this.selectedProvince = found.province || ''
|
||||
this.selectedCity = found.city || ''
|
||||
this.location = found.city || ''
|
||||
this.page = 1
|
||||
this.fetchFeed(true)
|
||||
uni.showToast({ title: `已定位到:${found.city || '所在城市'}`, icon: 'none' })
|
||||
this.closeLocationModal()
|
||||
} else {
|
||||
uni.showToast({ title: '已定位,但当前位置暂无开通服务', icon: 'none' })
|
||||
}
|
||||
this.isLocating = false
|
||||
},
|
||||
fail: () => {
|
||||
this.isLocating = false
|
||||
|
||||
@@ -1787,20 +1787,19 @@ export default {
|
||||
this.triggerAutoSave()
|
||||
},
|
||||
/**
|
||||
* 按经纬度匹配服务区域(后端 /home/locate)
|
||||
* 按经纬度匹配服务区域(前端本地计算,不再请求后端)
|
||||
* @param {number|null} lat
|
||||
* @param {number|null} lng
|
||||
*/
|
||||
async matchRegionByLocation(lat, lng) {
|
||||
if (lat == null || lng == null) return
|
||||
try {
|
||||
const found = await homeApi.locate({ lat, lng })
|
||||
if (!found || !found.areaId) return
|
||||
this.form.areaId = Number(found.areaId) || 0
|
||||
this.form.area = found.district || ''
|
||||
this.form.province = found.province || ''
|
||||
this.form.city = found.city || ''
|
||||
} catch (e) {}
|
||||
let found = null
|
||||
try { found = await homeApi.geocode(lat, lng) } catch (e) { return }
|
||||
if (!found || !found.areaId) return
|
||||
this.form.areaId = found.areaId
|
||||
this.form.area = found.district || ''
|
||||
this.form.province = found.province || ''
|
||||
this.form.city = found.city || ''
|
||||
},
|
||||
onFieldInput() {
|
||||
this.triggerAutoSave()
|
||||
|
||||
在新工单中引用
屏蔽一个用户