mirror of
https://gitee.com/beijing_hongye_huicheng/lilishop-uniapp.git
synced 2026-08-06 10:57:25 +08:00
feat: 更新项目配置与组件使用
- 在入口文件中引入uview-plus的配置,优化字体加载逻辑 - 移除manifest.json中不必要的权限描述 - 更新package.json和package-lock.json,添加开发依赖 - 调整多个组件的样式和结构,提升用户体验 - 修复部分组件的逻辑和样式问题,确保兼容性
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,
|
||||
};
|
||||
|
||||
@@ -3,6 +3,15 @@ import { getUserInfo } from "@/api/members";
|
||||
import storage from "@/utils/storage.js";
|
||||
import config from "@/config/config";
|
||||
import Foundation from "./Foundation.js";
|
||||
|
||||
/**
|
||||
* 解析商品图片地址,兼容上传 JSON 与纯 URL,非法时返回占位图
|
||||
*/
|
||||
export function parseGoodsImageUrl(item, fallback = config.logo) {
|
||||
const url = Foundation.parseGoodsImageUrl(item);
|
||||
return url || fallback || "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 金钱单位置换 2999 --> 2,999.00
|
||||
* @param val
|
||||
@@ -426,7 +435,7 @@ export function tipsToLogin (type) {
|
||||
/**
|
||||
* 获取用户信息并重新添加到缓存里面
|
||||
*/
|
||||
export async function userInfo () {
|
||||
export async function refreshUserInfo () {
|
||||
let res = await getUserInfo();
|
||||
if (res.data.success) {
|
||||
storage.setUserInfo(res.data.result);
|
||||
|
||||
@@ -216,8 +216,9 @@ function b64MD5w(str) {
|
||||
/* Backward compatibility */
|
||||
function calcMD5(str) {
|
||||
return binl2hex(coreMD5(str2binl(str)))
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
export const md5 = hexMD5
|
||||
export default {
|
||||
md5: hexMD5
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
// MIT License - http://opensource.org/licenses/mit-license.php
|
||||
|
||||
/*global window, require, define */
|
||||
(function(_window) {
|
||||
var uuid = (function(_window) {
|
||||
'use strict';
|
||||
|
||||
|
||||
@@ -241,22 +241,7 @@
|
||||
uuid._whatwgRNG = _whatwgRNG;
|
||||
|
||||
|
||||
if (('undefined' !== typeof module) && module.exports) {
|
||||
// Publish as node.js module
|
||||
module.exports = uuid;
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
// Publish as AMD module
|
||||
define(function() { return uuid; });
|
||||
} else {
|
||||
// Publish as global (in browsers)
|
||||
_previousRoot = _window.uuid;
|
||||
return uuid;
|
||||
})('undefined' !== typeof window ? window : (typeof globalThis !== 'undefined' ? globalThis : {}));
|
||||
|
||||
// **`noConflict()` - (browser only) to reset global 'uuid' var**
|
||||
uuid.noConflict = function() {
|
||||
_window.uuid = _previousRoot;
|
||||
return uuid;
|
||||
};
|
||||
|
||||
_window.uuid = uuid;
|
||||
}
|
||||
})('undefined' !== typeof window ? window : null);
|
||||
export default uuid;
|
||||
Reference in New Issue
Block a user