mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-08-06 10:57:25 +08:00
refactor: 移动端升级 Vue3 + uView Plus
将 lilishop-uniapp 从 Vue2/uView 1.6 迁移到 Vue3/uview-plus,优先支持 H5/微商城与微信小程序;移除 vendored uview-ui,改用 npm 依赖、Vuex4 与迁移脚本/补丁,并补充 VUE3_MIGRATION.md 回归清单。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -229,6 +229,38 @@ function navigationToBack(type) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析商品相册/图片项,兼容上传组件的 JSON 字符串与纯 URL。
|
||||
* 后端 goodsGalleryList 可能同时存在两种格式:
|
||||
* - '{"url":"https://...jpg","name":"x.jpg","status":"finished"}'
|
||||
* - 'https://...jpg'
|
||||
* @param {String} item 单个相册项
|
||||
* @returns {String} 解析出的图片地址,无法解析时返回空字符串
|
||||
*/
|
||||
export function parseGoodsImageUrl(item) {
|
||||
if (item === null || item === undefined) return "";
|
||||
if (typeof item !== "string") return "";
|
||||
const trimmed = item.trim();
|
||||
if (!trimmed) return "";
|
||||
// 纯 URL 直接返回
|
||||
if (/^https?:\/\//.test(trimmed)) return trimmed;
|
||||
// JSON 字符串,尝试解析取 url 字段
|
||||
if (trimmed.charAt(0) === "{") {
|
||||
try {
|
||||
const parsed = JSON.parse(trimmed);
|
||||
const url = parsed && (parsed.url || parsed.path || parsed.link);
|
||||
if (typeof url === "string" && /^https?:\/\//.test(url.trim())) {
|
||||
return url.trim();
|
||||
}
|
||||
} catch (e) {
|
||||
// 解析失败时退化为正则提取
|
||||
}
|
||||
const match = trimmed.match(/https?:\/\/[^\s"'\\}]+/);
|
||||
if (match) return match[0];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算当前时间到第二天0点的倒计时[秒]
|
||||
* @returns {number}
|
||||
@@ -246,7 +278,7 @@ export function theNextDayTime() {
|
||||
).getTime() - nowDate.getTime();
|
||||
return parseInt(time / 1000);
|
||||
}
|
||||
module.exports = {
|
||||
export default {
|
||||
unixToDate,
|
||||
dateToUnix,
|
||||
formatPrice,
|
||||
@@ -256,4 +288,5 @@ module.exports = {
|
||||
theNextDayTime,
|
||||
whetherNavigate,
|
||||
checkBankno,
|
||||
parseGoodsImageUrl,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user