商城测试版v8_1

This commit is contained in:
2022-07-29 20:48:15 +08:00
parent 4a7bbf774f
commit e2b0b0c52b
18 changed files with 1821 additions and 1722 deletions
+9 -5
View File
@@ -21,19 +21,23 @@ export const UPLOAD_CDN_URL = `https://v0.api.upyun.com/`
// cdn
// export const IMG_CND_Prefix = CURRENT_ENV.includes('development')? "https://test.cdn.zzfzyc.com":"https://cdn.zzfzyc.com"
export const IMG_CND_Prefix = CURRENT_ENV.includes('development')? "https://test.cdn.zzfzyc.com":"https://test.cdn.zzfzyc.com"
export const IMG_CND_Prefix = CURRENT_ENV.includes('development')
? 'https://test.cdn.zzfzyc.com'
: 'https://test.cdn.zzfzyc.com'
//在线支付图片baseUrl
// export const CAP_HTML_TO_IMAGE_BASE_URL = CURRENT_ENV.includes('development')? "https://test.zzfzyc.com":"https://www.zzfzyc.com"
export const CAP_HTML_TO_IMAGE_BASE_URL = CURRENT_ENV.includes('development')? "https://test.zzfzyc.com":"https://test.zzfzyc.com"
export const CAP_HTML_TO_IMAGE_BASE_URL = CURRENT_ENV.includes('development')
? 'https://test.zzfzyc.com'
: 'https://test.zzfzyc.com'
// 上传图片视频
export const CDN_UPLOAD_IMG = `${UPLOAD_CDN_URL || ''}`;
export const CDN_UPLOAD_IMG = `${UPLOAD_CDN_URL || ''}`
//appid
export const WX_APPID = 'wx68d92d7cbf0b6963'
//场景值
export const SCENE = {
SearchScene : 0 //商城面料搜索
}
SearchScene: 0, //商城面料搜索
}
+80 -59
View File
@@ -1,56 +1,60 @@
import { formatImgUrl } from "./fotmat";
import { analysisShortCodeApi } from "./shortCode";
import { formatImgUrl } from './fotmat'
import { analysisShortCodeApi } from './shortCode'
import Taro from '@tarojs/taro'
/**
* 防抖
* @param {*} fn
* @param {*} delay
* @returns
* @param {*} fn
* @param {*} delay
* @returns
*/
export const debounce = (fn, delay) => {
let timer:any = null;
let timer: any = null
return (...param) => {
if (timer) clearTimeout(timer);
if (timer) clearTimeout(timer)
timer = setTimeout(() => {
fn(...param);
}, delay);
};
fn(...param)
}, delay)
}
}
/**
* 节流
* @param {*} fn
* @param {*} delay
* @returns
* @param {*} fn
* @param {*} delay
* @returns
*/
export const throttle = (fn, delay) => {
let pre = 0;
let pre = 0
return (...params) => {
let now = new Date().getTime();
let now = new Date().getTime()
if (now - pre > delay) {
fn(...params);
pre = now;
fn(...params)
pre = now
}
};
}
}
/**
* 批量过滤对象值为空的属性
* @param {Object} val 需要过滤的对象
* @param {Array} arr 排除过滤的属性
* @returns
* @returns
*/
export const getFilterData = (val = {}, arr: string[] = []) => {
export const getFilterData = (val = {}, arr: string[] = []) => {
let res = {}
for(let key in val) {
if(val[key]!==undefined&&val[key]!==null&&val[key]!==''&&(!arr.includes(key))){
if(typeof val[key] == 'number'){
if(!isNaN(val[key])) {
for (let key in val) {
if (
val[key] !== undefined &&
val[key] !== null &&
val[key] !== '' &&
!arr.includes(key)
) {
if (typeof val[key] == 'number') {
if (!isNaN(val[key])) {
res[key] = val[key]
}
} else{
} else {
res[key] = val[key]
}
}
@@ -59,23 +63,23 @@ export const throttle = (fn, delay) => {
}
/**
* 对象深拷贝
* @param {*} object
* @returns
* @param {*} object
* @returns
*/
export const copyObject = (object)=>{
if(object.constructor==Object){
let keys = Object.keys(object);
let newObject = {};
keys.map(key=>{
newObject[key]= copyObject(object[key]);
})
return newObject;
}else if(object.constructor==Array){
return object.map(item=>{
return copyObject(item);
})
}else{
return object;
export const copyObject = (object) => {
if (object.constructor == Object) {
let keys = Object.keys(object)
let newObject = {}
keys.map((key) => {
newObject[key] = copyObject(object[key])
})
return newObject
} else if (object.constructor == Array) {
return object.map((item) => {
return copyObject(item)
})
} else {
return object
}
}
@@ -91,13 +95,21 @@ export const throttle = (fn, delay) => {
!wh400
!w600
*/
export const screenshot = (url, suffix="!w200")=>{
return url+suffix;
}
export const screenshot = (url, suffix = '!w200') => {
return url + suffix
}
//获取数据加载状态 //0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
export const dataLoadingStatus = ({list = [], total = 0, status = false}:{list:any[], total:number, status:true|false}) => {
if(list.length == 0 && status) {
//获取数据加载状态 //0:数据从无到有加载数据,1,没有任何数据, 2:下拉加载,3:下拉没有数据
export const dataLoadingStatus = ({
list = [],
total = 0,
status = false,
}: {
list: any[]
total: number
status: true | false
}) => {
if (list.length == 0 && status) {
return 0
} else if (list.length == 0 && !status) {
return 1
@@ -106,30 +118,39 @@ export const throttle = (fn, delay) => {
} else {
return 3
}
}
}
//全局分享监听
export const shareShop = () => {
//全局分享监听
export const shareShop = () => {
const page = Taro.getCurrentInstance().page
//当有分享参数时,绑定上下级
if(page && page.options?.share) {
if (page && page.options?.share) {
analysisShortCodeApi(page.options.share)
}
if(page && page.onShareAppMessage) {
if (page && page.onShareAppMessage) {
page.onShareAppMessage = (res) => {
let path = ''
let title = ''
let imageUrl = ''
let sortCode = Taro.getStorageSync('sort_code')?JSON.parse(Taro.getStorageSync('sort_code')):''
let pageInfo:any = page
if(res.from === 'button') {
let sortCode = Taro.getStorageSync('sort_code')
? JSON.parse(Taro.getStorageSync('sort_code'))
: ''
let pageInfo: any = page
//商品详情分享
if (pageInfo.route === 'pages/details/index') {
path = `/pages/details/index?share=${sortCode.shareShortDetail.code}`
title = sortCode.shareShortDetail.title
imageUrl = sortCode.shareShortDetail.img
} else {
path = (pageInfo.route === 'pages/user/index')?`/pages/user/index?share=${sortCode.shareShortPage.code}`:`/pages/index/index?share=${sortCode.shareShortPage.code}`
path =
pageInfo.route === 'pages/user/index'
? `/pages/user/index?share=${sortCode.shareShortPage.code}`
: `/pages/index/index?share=${sortCode.shareShortPage.code}`
title = sortCode.shareShortPage.title
imageUrl = (pageInfo.route === 'pages/user/index')?formatImgUrl('/mall/share_img_02.png') : sortCode.shareShortPage.img
imageUrl =
pageInfo.route === 'pages/user/index'
? sortCode.shareShortPage.img
: formatImgUrl('/mall/share_img_02.png')
}
return {
title,
@@ -138,4 +159,4 @@ export const throttle = (fn, delay) => {
}
}
}
}
}