PixelAI-mobile/pages/mobile_web/workshops/common/imgDeal.js
2024-12-29 16:09:08 +08:00

52 lines
1.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 由于换了阿里云oss存储该文件方法弃用-2024/12/19
import configService from "@/common/config.service";
// 处理选择器
const selectDealFunction = (vm,model,params,success) => {
switch(model){
case 0 :
case 1 :
case 2 :
case 3 :
case 4 :
diagramOfTheSketch(vm,params,success);
break;
};
return;
}
// 图生图
const diagramOfTheSketch = async (vm,params,success) => {
commonUpload(vm,params,success);
}
// 通用上传方法
const commonUpload = (vm,params,success) =>{
const image = params.filePath;
delete params.filePath;
uni.uploadFile({
url: configService.apiUrl+'/AiPicture/GenerateImages',
filePath: image,
name: 'image',
formData: params,
header:{'token':vm.$store.state.vuex_token},
success: (res) => {
let result = JSON.parse(res.data);
if(result.success){
success(encodeURI(result.data.path));
} else {
vm.$refs.uToast.show({type: 'error',title: "处理失败,请检查余额是否充足!"});
vm.dotLoading = false;
return;
}
},
fail: function (res) {
vm.$refs.uToast.show({type: 'error',title: "处理失败!"});
vm.dotLoading = false;
}
});
}
export {
selectDealFunction,
};