123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029 |
- <template src="./viewMask.html">
- </template>
- <script>
- const util = require('@/utils/util.js').default;
-
- import touchHandle from '@/mixins/touchHandle.js';
-
-
- export default {
- mixins: [touchHandle],
- data: function() {
- return {
- currentIndex:0,
- showAIImage: false,
- aiImagesList:[
- ],
-
- styleList: [],
- curStyleIndex: 0,
- aiFlag:false,
- aiImage: "",
- inputBase64Url: "",
- aiPicId: "",
- randomTimer:null,
- timer: null,
- outTimer: null,
- imageWidth: 750,
- imageHeight: 448,
- showAIFlag:false,
- checked:false,
- shottingImg:'',
- count:0,
- random:1,
-
- spaceTypes: [{
- icon: "",
- title: "卧室",
- subtitle: "0个布局",
- englishRemark: "bedroom",
- },
- {
- icon: "",
- title: "客厅",
- subtitle: "0个布局",
- englishRemark: "living room",
- },
- {
- icon: "",
- title: "餐厅",
- subtitle: "0个布局",
- englishRemark: "dinning room",
- },
- {
- icon: "",
- title: "厨房",
- subtitle: "0个个布局",
- englishRemark: "kitchen",
- },
- {
- icon: "",
- title: "玄关",
- subtitle: "0个布局",
- englishRemark: "hallway",
- },
- {
- icon: "",
- title: "卫生间",
- subtitle: "0个布局",
- englishRemark: "bathroom",
- },
- {
- icon: "",
- title: "衣帽间",
- subtitle: "0个布局",
- englishRemark: "walkin closet",
- },
- {
- icon: "",
- title: "收纳",
- subtitle: "0个布局",
- englishRemark: "storage room",
- },
- {
- icon: "",
- title: "阳台",
- subtitle: "0个布局",
- englishRemark: "balcony",
- },
- {
- icon: "",
- title: "飘窗",
- subtitle: "0个布局",
- englishRemark: "bay window",
- },
- {
- icon: "",
- title: "链接空间",
- subtitle: "0个布局",
- englishRemark: "connecting space between two rooms",
- },
- {
- icon: "",
- title: "自定义",
- subtitle: "0个布局",
- englishRemark: "room",
- },
- ],
- myloading:false,
- loadingMsg:'',
- screenWidth:0,
- screenHeight:0,
- modelType:2,
- themeIndex:0,
- themeList:[
- {
- id:1,
- text:'默认',
- prot:'',
- },
- {
- id:2,
- leftColor:'#F4EBDE',
- rightColor:'#C1C9B4',
- text:'莫兰素雅',
- prot:'Soft grays, warm earth tones, subtle blues, soft pinks,',
- },
- {
- id:3,
- leftColor:'#1F1F1F',
- rightColor:'#FFFFFF',
- text:'经典黑白',
- prot:'Classic black and pure white,',
- },
- {
- id:4,
- leftColor:'#6FA5BE',
- rightColor:'#E2CCC5',
- text:'海岸珊瑚',
- prot:'Deep ocean blue paired with vibrant coral red,',
- },
- {
- id:5,
- leftColor:'#849059',
- rightColor:'#E6CEB4',
- text:'森林璀璨',
- prot:'Deep forest green paired with luxurious gold,'
- },
- {
- id:6,
- leftColor:'#A1BACB',
- rightColor:'#E6DFD8',
- text:'梦幻静谧',
- prot:'Dreamy powder blue paired with neutral gray,'
- },
- {
- id:7,
- leftColor:'#303B2B',
- rightColor:'#D8C8A6',
- text:'自然和谐',
- prot:'Natural olive green paired with warm beige,'
- },
- {
- id:8,
- leftColor:'#652C30',
- rightColor:'#D5C3B0',
- text:'醇酒乳香',
- prot:'Rich burgundy paired with soft cream,'
- },
- {
- id:9,
- leftColor:'#E3C7C5',
- rightColor:'#EDE4DB',
- text:'雅致浪漫',
- prot:'Understated taupe paired with romantic pink,'
- },
- {
- id:10,
- leftColor:'#2C3C6E',
- rightColor:'#F0DBBD',
- text:'夜空璀璨',
- prot:'Elegant navy blue paired with glamorous gold,'
- },
- {
- id:11,
- leftColor:'#ACC9A1',
- rightColor:'#E6DCC6',
- text:'复古翠绿',
- prot:'Vintage tan paired with vibrant green,'
- },
- {
- id:12,
- leftColor:'#AAA8A7',
- rightColor:'#D8A176',
- text:'暖阳灰影',
- prot:'Warm orange paired with cool gray,'
- },
- {
- id:13,
- leftColor:'#413D41',
- rightColor:'#D1B687',
- text:'耀眼黑金',
- prot:'black and gold,'
- },
- ],
- timeOut:20000,
- subType:0,
- currentImg:null,
- reqList:[
- {
- model:'batouresearch/sdxl-controlnet-lora',
- level:'5',
- aiPicId:'',
- resultImg:'',
- }
- ],
- reqListReset:[
- {
- model:'deployments/elabgroup/elab-sdxl-controlnet-lora',
- level:'3',
- aiPicId:'',
- resultImg:'',
- },{
- model:'batouresearch/sdxl-controlnet-lora',
- level:'5',
- aiPicId:'',
- resultImg:'',
- }
- ],
- dialogVisible: false,
- dialogAIVisible: false,
- }
- },
- props:{
- spaceObj: {
- type: Object,
- default: null,
- },
- },
- watch: {
- spaceObj(newVal, oldVal) {
- if (newVal == null) {
- return;
- }
- console.log("当前空间数据view-mark-watch:", newVal);
- this.getAiBeautyFamily();
-
-
-
-
- },
- },
- mounted() {
-
-
-
-
- this.screenWidth = window.screen.width;
- this.screenHeight = window.screen.height;
- if(window.innerWidth && window.screen.width){
- this.screenWidth = Math.min(window.innerWidth,window.screen.width)
- }
- if(window.innerHeight && window.screen.height){
- this.screenHeight = Math.min(window.innerHeight,window.screen.height)
- }
- },
-
- onPageShow: function() {
-
- },
-
- onPageHide: function() {
- },
- beforeDestroy:function(){
- console.warn("***beforeDestroy***");
- this.stopInterval();
- },
- computed: {
- aiData() {
- return this.$store.state.aiData;
- },
- curHouseObj() {
- return this.$store.state.curHouseObj;
- },
- },
- methods:{
- swiperChangeImg(e){
- this.currentIndex = e.detail?e.detail.current:e;
- this.checked = this.aiImagesList[this.currentIndex].checked;
- console.warn("***swiperChangeImg***",this.checked);
- },
-
- switchActor(){
-
- this.$emit('switchActor');
- this.showAIImage = false;
- let index = this.$parent.currentActor.userIndex;
- let nextIndex = (index + 1) % this.$parent.actors.length;
- let param = {
- type: 'CLK',
- clkId: 'clk_2cmina_23080417',
- clkName: 'changeangle_clk',
- clkParams: {
- locusName: "视角切换",
- type:this.$parent.actors[nextIndex].actorEum
- }
- };
- util.trackRequest(param);
- },
- showOrHideWebGl(){
-
- this.showAIImage = !this.showAIImage;
- let param = {
- type: 'CLK',
- clkId: 'clk_2cmina_23080415',
- clkName: 'contrast_clk',
- clkParams: {
- locusName: "对比",
- }
- };
- util.trackRequest(param);
- },
-
- selectAction(selItem,type,index) {
- console.log('点击动作111:', selItem,type,index)
- var self = this;
- if(this.themeIndex == index){
- return false
- }
- this.themeIndex = index;
- let param = {
- type: 'CLK',
- clkId: 'clk_2cmina_23112701',
- clkName: 'AIstyle_theme_clk',
- clkParams: {
- locusName: "AI 主题",
- type:this.themeList[this.themeIndex].text
- }
- };
- util.trackRequest(param);
- },
-
- changeModel(){
- this.modelType = (this.modelType + 1) >2 ? 1 : 2;
- },
-
- save() {
-
- if (!this.aiImagesList || this.aiImagesList.length==0) {
- return false;
- }
- var _resultImg = this.aiImagesList[this.currentIndex].image;
-
- if (!_resultImg || _resultImg.length==0) {
- this.showToast("请选中图片后再试!");
- return false;
- }
- var para = {
- type: 'CLK',
- clkId: 'clk_2cmina_56',
- clkName: "share-savepic",
- expand: {
- "resultImg": (_resultImg || ""),
- },
- }
- util.trackRequest(para);
- if(navigator.userAgent.toLocaleLowerCase().includes('micromessenger')){
- this.$message("请长按图片保存!");
- }else{
- this.saveImageHandle(_resultImg);
- }
- },
- downloadIamge(imgsrc) {
- var fileName = "4DImage" + util.formatDate(new Date(), "yyyyMMddhhmmss") + '.jpg';
- const image = new Image();
-
- image.setAttribute("crossOrigin", "anonymous");
- image.onload = ()=> {
-
-
-
-
-
-
- const a = document.createElement("a");
- const event = new MouseEvent("click");
- a.download = fileName || "photo";
- a.href = imgsrc;
- a.dispatchEvent(event);
- this.showToast("保存成功!");
- };
- image.src = imgsrc;
- },
- saveImageHandle(_resultImg){
- let param = {
- type: 'CLK',
- clkId: 'clk_2cmina_23080414',
- clkName: 'download_clk',
- clkParams: {
- locusName: "下载",
- img:_resultImg
- }
- };
- util.trackRequest(param);
- this.downloadIamge(_resultImg);
- },
-
-
- changeAIImg() {
-
- this.checked = !this.checked;
- this.aiImagesList[this.currentIndex].checked = this.checked;
- console.warn("***changeAIImg***",this.checked,this.aiData)
- if(this.aiData){
- let space = this.aiData.find(it=>{
- return it.spaceId == this.spaceObj.spaceId
- })
- if(space){
- space.aiImagesList[this.currentIndex].checked = this.checked;
- }
- }
- if(this.checked){
- let param = {
- type: 'CLK',
- clkId: 'clk_2cmina_23080418',
- clkName: 'chooseprogramme_clk',
- clkParams: {
- locusName: "选定风格/视角",
- style:this.styleList[this.curStyleIndex].styleName,
- img:this.aiImagesList[this.currentIndex].image,
- }
- };
- util.trackRequest(param);
- }
- },
- rightScroll(){
- if(this.currentIndex <= (this.aiImagesList.length - 1) && this.currentIndex > 0){
-
- this.$refs.carousel.prev();
- }
- },
- leftScroll(){
- if(this.currentIndex != this.aiImagesList.length - 1){
- if(this.currentIndex<this.aiImagesList.length - 1){
-
- this.$refs.carousel.next();
- }
- return false;
- }
- console.log("***leftScroll***",this.currentIndex,this.aiImagesList.length)
- this.aiSubmit(2);
- },
-
- goback(){
- this.$router.go(-1);
- },
- mynavigateFuc(e) {
- if (e) {
-
- let param = {
- type: 'CLK',
- clkId: 'clk_2cmina_23080408',
- clkName: 'WeCom_clk',
- clkParams: {
- locusName: "联系定制",
- }
- };
- util.trackRequest(param);
- if(window.__wxjs_environment === 'miniprogram'){
- wx.miniProgram.navigateTo({url: '/pages/transfer/transfer?event=openCustomerServiceChat&houseId='+this.$store.state.houseId})
- }else{
- this.$message.warning("敬请期待");
- }
- }
- },
- catchTapEvent:function(){
- return false;
- },
-
- async getAiBeautyFamily() {
-
- let res = await requestConfig("getHardboundEffects", {
- "houseId": this.$route.query.houseId,
- "spaceType": this.spaceObj.spaceType,
- "spaceName": this.spaceObj.spaceName,
- });
- this.styleList = [];
- if (res.success) {
- let list = res.list;
- this.styleList = list;
- }
- if(!this.styleList || this.styleList.length==0){
-
- let unit = this.screenWidth / 750;
- this.$parent.canvasHeight = this.screenHeight - (208 * unit);
- this.$parent.camera.aspect = this.screenWidth / this.$parent.canvasHeight;
- this.$parent.camera.updateProjectionMatrix();
- this.$parent.renderer.setSize(this.screenWidth, this.$parent.canvasHeight);
- }else{
-
- }
- },
-
- selectStyle(idx){
- if(this.curStyleIndex == idx){
- return false
- }
- this.curStyleIndex = idx;
- let param = {
- type: 'CLK',
- clkId: 'clk_2cmina_23080416',
- clkName: 'AIstyle_ret_clk',
- clkParams: {
- locusName: "AI 风格",
- type:this.styleList[this.curStyleIndex].styleName
- }
- };
- util.trackRequest(param);
- },
-
- async aiSubmit(type) {
- if(!this.styleList || this.styleList.length==0 || this.curStyleIndex==-1
- || !this.styleList[this.curStyleIndex].prompt || !this.styleList[this.curStyleIndex].negativePrompt){
- return false;
- }
-
- if (this.aiFlag) {
- return
- }
- this.aiFlag = true;
- this.aiImage = "";
- this.stopInterval();
-
- this.myloading = true;
- this.loadingMsg = "启动中";
-
-
-
-
-
- let shottingImg = await this.$parent.shottingAction();
- if(!shottingImg){
- this.showToast("渲染失败,请重试");
- return false;
- }
-
-
- shottingImg += "?x-oss-process=image/auto-orient,1/quality,Q_46/format,jpg";
- this.shottingImg = shottingImg;
- this.changeImg2Base64(this.shottingImg, false);
- console.warn("***shottingImg***",this.shottingImg)
- if(type==1){
- let param = {
- type: 'CLK',
- clkId: 'clk_2cmina_23080413',
- clkName: 'AIcreate_clk',
- clkParams: {
- locusName: "AI生成",
- userparamter:{
- shottingImg:this.shottingImg,
- style:this.styleList[this.curStyleIndex].styleName
- }
- }
- };
- util.trackRequest(param);
- }else{
- let param = {
- type: 'CLK',
- clkId: 'clk_2cmina_23080419',
- clkName: 'continueAIcreate_clk',
- clkParams: {
- locusName: "继续生成",
- userparamter:{
- shottingImg:this.shottingImg,
- style:this.styleList[this.curStyleIndex].styleName
- }
- }
- };
- util.trackRequest(param);
- }
- },
- image2Base64(imgUrl) {
- var toBase64= new Promise(function(resolve, reject){
- window.URL = window.URL || window.webkitURL;
- var xhr = new XMLHttpRequest();
- xhr.open("get", imgUrl, true);
-
- xhr.responseType = "blob";
- xhr.onload = function (res) {
- if (res.currentTarget.status == 200) {
-
- var blob = res.currentTarget.response;
-
- let oFileReader = new FileReader();
- oFileReader.onloadend = function (e) {
- let base64 = e.target.result;
- resolve(base64)
- };
- oFileReader.readAsDataURL(blob);
- }
- }
- xhr.send();
- });
- return toBase64;
- },
- changeImg2Base64(url, isRepeat) {
- var self = this;
- if(isRepeat && self.inputBase64Url){
- self.startServer();
- }else{
- self.startServer();
- }
- },
-
- async prevHandle(parmas){
-
- if(this.subType!=0){
- return '';
- }
- return new Promise(async (resolve, reject) => {
- let _data = JSON.parse(JSON.stringify(parmas))
- delete _data.webhook;
- let res = await requestConfig("img2img_local", _data);
- if (res.success) {
- if (res.success && res.single) {
- let resultImg = res.single;
- resolve(resultImg);
- }else{
- resolve('');
- }
- }else{
- resolve('');
- }
- })
- },
-
- async startServer() {
- if(!this.styleList || this.curStyleIndex < 0 || !this.styleList[this.curStyleIndex].imgUrl){
- return false
- }
- if(this.$parent.pvCurPageName!="room_show"){
- console.warn("***用户已经退出页面***")
- return false;
- }
- let imgUrl = this.styleList[this.curStyleIndex].imgUrl;
- let subType = this.subType;
- let session_hash = Date.now();
- let theme = this.themeList[this.themeIndex];
- let prompt = this.styleList[this.curStyleIndex].prompt + theme.prot;
- let noPromot = this.styleList[this.curStyleIndex].negativePrompt;
- let unit = 768 / this.screenWidth;
- this.imageWidth = parseInt((this.screenWidth * unit).toFixed());
- this.imageHeight = parseInt((this.$parent.canvasHeight * unit).toFixed());
- this.timeOut = this.modelType==1? 20000: 50000;
- var parmas = {
- negativePrompt: noPromot,
- prompt: prompt,
- "batchSize": 1,
- brandId: $config.brandId,
- height: this.imageHeight,
- width: this.imageWidth,
- "moduleType": "AI_Biography",
- "steps":20,
- "sampler":"DDIM",
- "controlNetSessionHash":session_hash,
- "cfgScale":12,
- "denoising":0.9,
- image:this.shottingImg,
- styleImage:imgUrl,
- keyword: "replicate",
- model: this.modelType==1? "lucataco/ssd-1b" : 'catio-apps/controlnet-interior-design',
- };
- if(this.modelType==2){
- if(subType == 0){
- parmas.model = this.reqList[0].model;
- }else{
- parmas.model = this.reqListReset[0].model;
- }
- }else{
- if(subType == 0){
- parmas.model = "lucataco/ssd-1b";
- }else{
- parmas.model = "deployments/elabgroup/elab-ssd-1b";
- }
- }
- let result = await this.prevHandle(parmas);
- console.warn("***prevHandle***",result)
- if(result && result.length>0){
- this.randomHandle(result)
- return false;
- }else{
- if(this.modelType==2){
- this.otherHandle(parmas);
- }
- let res = await requestConfig("generateTaskImgToImgForAliyun", parmas);
- console.log("图生图结果:", res);
- let that = this;
- if (res.success && res.single) {
- this.aiPicId = res.single;
- if(this.modelType==2){
- if(subType == 0){
- this.reqList[0].aiPicId = this.aiPicId;
- }else{
- this.reqListReset[0].aiPicId = this.aiPicId;
- }
- }
- if (this.aiPicId) {
- this.startInterval();
- }else{
- this.stopInterval()
- }
- }else{
- this.stopInterval()
- this.showToast("渲染失败,请重试")
- }
- }
- },
- stopInterval() {
- if (this.randomTimer) {
- clearInterval(this.randomTimer);
- this.randomTimer = null;
- }
- if (this.timer) {
-
- this.timer = null;
- }
- if (this.outTimer) {
- clearTimeout(this.outTimer)
- this.outTimer = null
- }
- this.subType = 0;
- this.reqList.forEach(it=>{
- it.aiPicId = '';
- it.resultImg = '';
- })
- this.reqListReset.forEach(it=>{
- it.aiPicId = '';
- it.resultImg = '';
- })
-
- this.myloading = false;
- this.aiFlag = false;
- },
-
- randomHandle(resultImg){
- if(this.timer || !resultImg){
- return false;
- }
- let self = this;
- var count = 1;
- var process = 0;
- var randomNum = Math.floor(Math.random() * 4 + 5);
- this.randomTimer = setInterval(function() {
- process = parseInt(count * 100/(randomNum));
- if(process>=100){
- process = 99;
- }
- if (count < randomNum) {
-
- self.myloading = true;
- self.loadingMsg = '生成中…' + process + '%';
-
- }else{
- self.myloading = false;
- self.resultHandle(resultImg);
- }
- count = count + 1;
- }, 1000);
- },
-
- otherHandle(parmas){
- let reqList = [];
- if(this.subType == 0){
- reqList = this.reqList;
- }else{
- reqList = this.reqListReset;
- }
- reqList.forEach(async (it,index)=>{
- let _data = JSON.parse(JSON.stringify(parmas));
- if(index>0){
- _data.model = it.model;
- let res = await requestConfig("generateTaskImgToImgForAliyun", _data);
- if (res.success) {
- console.log('生成结果123:', res);
- it.aiPicId = res.single || '';
- }
- }
- })
- },
-
- startInterval() {
- if(this.timer){
- return false;
- }
- let self = this;
- this.count = 1;
- var random = 0;
- this.currentImg = false;
- this.timer = 1;
- this.getOutPicture();
- this.setOutTimer();
- },
-
- setOutTimer() {
- if (this.outTimer) {
- clearTimeout(this.outTimer)
- this.outTimer = null
- }
- var self = this;
- this.outTimer = setTimeout(function() {
- if (self.timer) {
- let hasResult = false;
- if(self.modelType==2){
- let reqList = [];
- if(self.subType == 0){
- reqList = self.reqList;
- }else{
- reqList = self.reqListReset;
- }
- reqList.some((item,index) => {
- if(item.resultImg){
- hasResult = true;
- self.resultHandle(item.resultImg)
- }
- });
- }
- console.warn("***hasResult***",hasResult)
- if(!hasResult){
- self.stopInterval();
-
- self.dialogVisible = true;
- }
- }
- clearTimeout(self.outTimer);
- self.outTimer = null
- }, this.timeOut);
- },
- confirmHandle(type){
- console.log('用户点击确定')
- this.dialogVisible = false;
- this.dialogAIVisible = false;
- this.subType = type || 0;
- this.startServer();
- },
- cancelHandle(){
- console.log('用户点击取消')
- this.dialogVisible = false;
- this.dialogAIVisible = false;
- this.subType = 0;
- },
-
- getOutPicture() {
- if(this.timer==null){
- console.warn("***当前轮询已经结束了1***")
- return false;
- }
- if(this.modelType==2){
- let reqList = [];
- if(this.subType == 0){
- reqList = this.reqList;
- }else{
- reqList = this.reqListReset;
- }
- reqList.forEach((item,index) => {
- this.singleHandle(item)
- });
- }
- else{
- this.singleHandle({aiPicId:this.aiPicId})
- }
- },
-
- async singleHandle(model){
- if(!model || !model.aiPicId){
- return false;
- }
- var parmas = {
- id: model.aiPicId,
- };
- let res = await requestConfig("getPredictions", parmas);
- if (res.success && res.single) {
- if(this.currentImg){
- console.warn("***当前已经有最高级生成图了***")
- return false;
- }
- if(this.timer==null){
- console.warn("***当前轮询已经结束了***")
- return false;
- }
- if (res.single.status == 'succeeded' && res.single.output) {
- if(this.modelType==2){
- model.resultImg = res.single.output;
- if(model.level=='5'){
- this.currentImg = true;
- setTimeout(()=>{
- this.resultHandle(res.single.output)
- },1500)
- }
- }else{
- this.currentImg = true;
- setTimeout(()=>{
- this.resultHandle(res.single.output)
- },1500)
- }
- console.warn("***有生成图了***",model)
- }
- if(this.modelType==2){
- if(model.level=='5'){
- this.processHandle(res.single);
- }
- }else{
- this.processHandle(res.single);
- }
- } else if (!res.success) {
- this.stopInterval();
- this.showToast("渲染失败,请重试")
- }
- },
-
- processHandle(single){
- console.warn("***single***",single.status,single.progress,this.count,single);
- let self = this;
- if(single.status=='starting'){
- if(this.count>=20){
- this.stopInterval();
- this.dialogAIVisible = true;
- }else{
- this.myloading = true;
- this.loadingMsg = '启动中';
- }
- this.count = this.count + 1;
- this.getOutPicture();
- }else if(single.status=='processing'){
- let random = single.progress || 0;
- if(random >= 100){
- random = 99;
- }
-
-
-
-
-
- this.myloading = true;
- this.loadingMsg = '生成中…' + parseInt(random) + '%';
-
- this.getOutPicture();
- }else if(single.status=='succeeded'){
-
-
-
-
-
-
- this.myloading = true;
- this.loadingMsg = '生成中…100%';
-
- }
- },
-
- resultHandle(resultImg){
- this.currentImg = true;
-
- this.aiImage = resultImg;
- this.showAIFlag = true;
- let newImage = resultImg;
- let aiStyleName = this.styleList[this.curStyleIndex].styleName;
- let _data = {
- image:newImage,
- checked:false,
- list:[newImage],
- }
- this.aiImagesList.push(_data);
- this.showAIImage = true;
- if(this.$parent && typeof(this.$parent.clearHandle)=="function" ){
- this.$parent.clearHandle();
- }
- let cpAiData = JSON.parse(JSON.stringify(this.aiData)) || []
- if(cpAiData && this.curHouseObj && this.curHouseObj.houseFloor){
- let space = cpAiData.find(it=>{
- return it.houseFloor == this.curHouseObj.houseFloor && it.spaceId == this.spaceObj.spaceId
- })
- if(space){
- let data ={
- aiStyleName:aiStyleName,
- image:newImage,
- checked:false,
- }
- space.aiImagesList.push(data);
- }else{
- let data = {
- houseFloor:this.curHouseObj.houseFloor,
- spaceId:this.spaceObj.spaceId,
- aiImagesList:[
- {
- aiStyleName:aiStyleName,
- image:newImage,
- checked:false,
- }
- ]
- }
- cpAiData.push(data)
- }
- this.$store.dispatch('setAiData', cpAiData)
- }
- this.stopInterval();
- if(this.aiImagesList.length>1){
- setTimeout(()=>{
-
- this.$refs.carousel.setActiveItem(this.aiImagesList.length-1);
- }, 1000);
- }
- },
- showToast(title,time=3000){
- this.myloading = false;
- this.$store.state.loading = true;
- this.$store.state.loadingMsg = title || "";
- setTimeout(()=>{
- this.$store.state.loading = false;
- }, time);
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- @import "./viewMask.scss";
- </style>
- <style lang="css" scoped>
-
- </style>
|