PixelAI-mobile/pages/mobile_web/workshops/common/imgDeal.js

46 lines
1.0 KiB
JavaScript
Raw Normal View History

2024-12-03 09:34:24 +08:00
import configService from "@/common/config.service";
// 处理选择器
const selectDealFunction = (vm,model,params,success) => {
switch(model){
2024-12-06 23:58:58 +08:00
case 0 :
diagramOfTheSketch(vm,params,success);
2024-12-03 09:34:24 +08:00
break;
};
return;
}
2024-12-06 23:58:58 +08:00
// 图生图
const diagramOfTheSketch = async (vm,params,success) => {
commonUpload(vm,params,success);
2024-12-03 09:34:24 +08:00
}
// 通用上传方法
2024-12-06 23:58:58 +08:00
const commonUpload = (vm,params,success) =>{
const image = params.filePath;
delete params.filePath;
2024-12-03 09:34:24 +08:00
uni.uploadFile({
2024-12-06 23:58:58 +08:00
url: configService.apiUrl+'/AiPicture/GenerateImages',
filePath: image,
2024-12-03 09:34:24 +08:00
name: 'image',
2024-12-06 23:58:58 +08:00
formData: params,
2024-12-03 09:34:24 +08:00
header:{'token':vm.$store.state.vuex_token},
success: (res) => {
2024-12-05 11:46:54 +08:00
if(res.data){
2024-12-06 23:58:58 +08:00
success(encodeURI(JSON.parse(res.data).data.path));
2024-12-05 11:46:54 +08:00
} else {
vm.$refs.uToast.show({type: 'error',title: "余额不足,请充值!"});
vm.dotLoading = false;
return;
}
2024-12-03 09:34:24 +08:00
},
fail: function (res) {
2024-12-05 11:46:54 +08:00
vm.$refs.uToast.show({type: 'error',title: "处理失败!"});
2024-12-06 23:58:58 +08:00
vm.dotLoading = false;
2024-12-03 09:34:24 +08:00
}
});
}
export {
selectDealFunction
};