|
|
@ -1,3 +1,5 @@ |
|
|
|
|
|
import {img_domian} from "./config"; |
|
|
|
|
|
|
|
|
function formatTime(time) { |
|
|
function formatTime(time) { |
|
|
if (typeof time !== 'number' || time < 0) { |
|
|
if (typeof time !== 'number' || time < 0) { |
|
|
return time |
|
|
return time |
|
|
@ -94,10 +96,56 @@ const hexToRgba = (hex, opacity) => { //16进制颜色转rgba |
|
|
return "rgba(" + parseInt("0x" + hex.slice(1, 3)) + "," + parseInt("0x" + hex.slice(3, 5)) + "," + parseInt("0x" + hex.slice(5, 7)) + "," + opacity + ")" |
|
|
return "rgba(" + parseInt("0x" + hex.slice(1, 3)) + "," + parseInt("0x" + hex.slice(3, 5)) + "," + parseInt("0x" + hex.slice(5, 7)) + "," + opacity + ")" |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 图片路径转换 |
|
|
|
|
|
* @param {String} img_path 图片地址 |
|
|
|
|
|
* @param {Object} params 参数,针对商品、相册里面的图片区分大中小,size: big、mid、small |
|
|
|
|
|
*/ |
|
|
|
|
|
function img(img_path, params) { |
|
|
|
|
|
var path = ""; |
|
|
|
|
|
if (img_path != undefined && img_path != "") { |
|
|
|
|
|
if (img_path.split(',').length > 1) { |
|
|
|
|
|
img_path = img_path.split(',')[0]; |
|
|
|
|
|
} |
|
|
|
|
|
if (params && img_path != getDefaultImage().goods) { |
|
|
|
|
|
// 过滤默认图
|
|
|
|
|
|
let arr = img_path.split("."); |
|
|
|
|
|
let suffix = arr[arr.length - 1]; |
|
|
|
|
|
arr.pop(); |
|
|
|
|
|
arr[arr.length - 1] = arr[arr.length - 1] + "_" + params.size.toUpperCase(); |
|
|
|
|
|
arr.push(suffix); |
|
|
|
|
|
img_path = arr.join("."); |
|
|
|
|
|
} |
|
|
|
|
|
if (img_path.indexOf("http://") == -1 && img_path.indexOf("https://") == -1) { |
|
|
|
|
|
path = img_domian + "/" + img_path; |
|
|
|
|
|
} else { |
|
|
|
|
|
path = img_path; |
|
|
|
|
|
} |
|
|
|
|
|
if(img_domian.indexOf('https://') != -1){ |
|
|
|
|
|
path = path.replace('http://', 'https://'); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// path += '?t=' + parseInt(new Date().getTime() / 1000);
|
|
|
|
|
|
return path; |
|
|
|
|
|
} |
|
|
|
|
|
/** |
|
|
|
|
|
* 获取默认图 |
|
|
|
|
|
*/ |
|
|
|
|
|
function getDefaultImage() { |
|
|
|
|
|
let defaultImg = store.state.defaultImg; |
|
|
|
|
|
defaultImg.goods = img(defaultImg.goods); |
|
|
|
|
|
defaultImg.head = img(defaultImg.head); |
|
|
|
|
|
defaultImg.store = img(defaultImg.store); |
|
|
|
|
|
defaultImg.article = img(defaultImg.article); |
|
|
|
|
|
return defaultImg; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = { |
|
|
module.exports = { |
|
|
formatTime, |
|
|
formatTime, |
|
|
formatDateTime, |
|
|
formatDateTime, |
|
|
formatLocation, |
|
|
formatLocation, |
|
|
dateUtils, |
|
|
dateUtils, |
|
|
hexToRgba |
|
|
hexToRgba, |
|
|
|
|
|
img |
|
|
} |
|
|
} |
|
|
|