电子商城测试版v4

This commit is contained in:
czm 2022-07-05 10:43:47 +08:00
parent 0a77473193
commit 29090350ef
4 changed files with 32 additions and 13 deletions

View File

@ -36,6 +36,8 @@ export default ({show = false, onClose}: param) => {
setSelectStatus(true)
}, [selectIndex])
//重置勾选数据
const resetList = () => {
list?.map(item => {
@ -56,16 +58,25 @@ export default ({show = false, onClose}: param) => {
const {data} = await fetchData()
let color_list = data.color_list||[]
initList(color_list)
setList(color_list)
setLoading(false)
}
//初始化勾选数据
const [selectData, setSelectData] = useState<{id: number, checked: true|false}[]>([])
const initSelectData = (data:{id:number}[] = []) => {
let res = data?.map(item => {
return {id: item.id, checked: true}
})
setSelectData(() => res)
}
//初始化全部数据
const initList = (color_list) => {
color_list?.map(item => {
if(selectIndex == item.sale_mode) item.select = true
item.count = formatCount(item)
})
setList(color_list)
}
//显示是展示数据

View File

@ -23,9 +23,7 @@ const PictureItem:FC<ImageParam> = memo(({onChange, defaultList}) => {
const uploadImage = async () => {
let list:any = await getWxPhoto('after-sale', 5)
let images:any[] = []
console.log('item22:::', list.length)
list?.map(item => {
console.log('item:::', item)
images.push(item.url)
})
setImageLise([...imageList, ...images])

View File

@ -167,8 +167,8 @@ export default memo(({order, comfirm = false}:Param) => {
<View className={styles.order_list_item_des}>
<View className={styles.order_list_item_title}>
{colorItem.code + ' ' + colorItem.name}
{colorItem?.return_roll&&<Text>{`已退${colorItem?.return_roll}`}</Text>}
{colorItem?.apply_return_roll&&<Text>{`待退${colorItem?.apply_return_roll}`}</Text>}
{(colorItem?.return_roll > 0)&&<Text>{`已退${colorItem?.return_roll}`}</Text>}
{(colorItem?.apply_return_roll > 0)&&<Text>{`待退${colorItem?.apply_return_roll}`}</Text>}
</View>
<View className={styles.order_list_item_price}>
¥{standardPrice(colorItem.sale_price)}

View File

@ -114,15 +114,18 @@ export default () => {
})
}
/**
*
* @param cdn_upload_type //CDN 文件上传场景值
*/
// product 产品相关,图片、纹理图等 全平台
// after-sale 售后(申请退货、退款)相关的、图片、视频 全平台
// mall 电子商城相关的 全平台
// logistics 物流(发货、提货)相关的、图片、视频 全平台
type cdn_upload_type_Param = 'product'|'after-sale'|'mall'|'logistics'
/**
*
* @param cdn_upload_type
* @param count // 1时返回一张图片信息 大于1时返回图片数组
* @returns
*/
const getWxPhoto = (cdn_upload_type: cdn_upload_type_Param, count: number = 1) => {
return new Promise((resolve, reject) => {
let list:any[] = []
@ -132,11 +135,18 @@ export default () => {
sourceType: ['album', 'camera'],
success: async function (res) {
try {
if(count > 1) {
for(let i = 0; i < res.tempFiles.length; i++) {
let data = await uploadCDNImg(res.tempFiles[i], cdn_upload_type, cdn_upload_type)
list.push(data)
}
resolve(list)
} else {
//兼容以前上传一张的情况
let data = await uploadCDNImg(res.tempFiles[0], cdn_upload_type, cdn_upload_type)
resolve(data)
}
} catch(res) {
reject(res)
}