电子商城测试版v4

This commit is contained in:
2022-07-05 10:43:47 +08:00
parent 0a77473193
commit 29090350ef
4 changed files with 32 additions and 13 deletions
+18 -8
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 {
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)
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)
}
resolve(list)
} catch(res) {
reject(res)
}