Bläddra i källkod

调整AI页面UI&生成逻辑

zjs_project 1 år sedan
förälder
incheckning
776f71245b

+ 26 - 28
src/components/newBottomCom/viewMask/viewMask.html

@@ -1,5 +1,5 @@
 <!-- 覆盖层操作视图 -->
-<div class="mask-view" @touchmove.stop.prevent="catchTapEvent" @click.stop="catchTapEvent">
+<div class="mask-view" @touchmove.stop="catchTapEvent" @click.stop="catchTapEvent">
 	<!-- AI图片-轮播图 -->
 	<el-carousel v-if="aiImagesList && aiImagesList.length>0" v-show="showAIImage" class="swiper" 
 	:autoplay="false" :loop="false" ref="carousel"
@@ -22,9 +22,6 @@
 		<img class="loading_img"
 			src="https://dm.static2.elab-plus.com/aiBeauty/aiBeauty3/icon_loading_Img.png"
 			mode="aspectFit"></image>
-		<!-- <img class="loading_text"
-			src="https://dm.static2.elab-plus.com/aiBeauty/aiBeauty3/icon_loading_text.png"
-			mode="heightFix"></image> -->
 			自动生成更多图片中{{random+'%'}}...
 	</div>
 	<div class="btn-view columns" v-if="showAIImage==false">
@@ -66,37 +63,38 @@
 		<!-- <div class="signscoll-block"></div> -->
 		<!-- 精装修 -->
 		<div class="aiEdit">
-			<div class="aiStyleList grid" :style="{'height':disableAble?'20rpx':'240rpx'}">
-				<div class="scrollViewItem" v-for="(item, idx) in styleList" :key="idx" :id="'styleItem'+idx"
-					@click.stop="selectStyle(idx)">
-					<div class="styleItem" :class="{'styleItemSelected':curStyleIndex==idx}">
-						<img class="styleIcon" :src="item.imgUrl+'?imageMogr2/auto-orient/thumbnail/200x200/blur/1x0/quality/75'" mode="aspectFill"></image>
-						<span class="styleTitle">{{item.styleName}}</span>
-					</div>
-				</div>
+			<!-- tab视图 -->
+			<div class="tab-view rows">
+				<div class='left btn rows justify-center' :class="{active:modelType==2}" @click="changeModel(2)">精准设计</div>
+				<div class='right btn rows justify-center' :class="{active:modelType==1}" @click="changeModel(1)">创意设计</div>
 			</div>
-			<!-- <div class="aiTool">
-				<div class="changeBtn" v-if="showAIFlag" @click.stop="changeAIImg">
-					<span v-if="checked==false" class="iconfont icon-xingzhuang-tuoyuanxing" style="margin-right:10rpx;font-size:36rpx;"></span>
-					<span v-else class="iconfont icon-ziyuan" style="margin-right:10rpx;font-size:36rpx;color:#FAB060"></span>
-					{{checked?'已选定图片':'选定图片'}}
-				</div>
-				<div v-if="showAIFlag" class="submitBtn continue rows justify-center" @click.stop="aiSubmit(2)"
-				 :class="{disable:disableAble}">
-					继续生成
+			<div class="aiStyleList rows">
+				<div class="styleItem" v-for="(item, idx) in styleList" :key="idx" :id="'styleItem'+idx"
+				@click.stop="selectStyle(idx)" :class="{'styleItemSelected':curStyleIndex==idx}">
+					<img class="styleIcon" :src="item.imgUrl+'?imageMogr2/auto-orient/thumbnail/200x200/blur/1x0/quality/75'" mode="aspectFill"></image>
+					<span class="styleTitle">{{item.styleName}}</span>
 				</div>
-				<div v-else class="submitBtn rows justify-center" @click.stop="aiSubmit(1)" 
-				:class="{disable:disableAble}" >
-					<img class="magic-icon" src="https://dm.static.elab-plus.com/miniProgram/iconfont/magic.png" mode="widthFix"/>
-					AI生成精软装风格
+			</div>
+			<!-- 主题 -->
+			<div class="section4">
+				<div class="items">
+					<div :class="['item', themeIndex==idx ? 'item_sel columns': 'columns']" v-for="(item, idx) in themeList"
+						:key="idx" @click="selectAction(item,'theme',idx)">
+						<div class="def-view" v-if="idx==0"></div>
+						<div class="color-view rows" v-else>
+							<div class="left" :style="{'background':item.leftColor}"></div>
+							<div class="right" :style="{'background':item.rightColor}"></div>
+						</div>
+						<div>{{item.text}}</div>
+					</div>
 				</div>
-			</div> -->
+			</div>
 			<div class="btn-list rows rows-between" >
 				<div class="btn houseType rows justify-center up1" @click.stop="goback">
-					<div class="iconfont icon-huxingjianshang style1"></div>户型空间
+					<div class="iconfont icon-huxingjianshang style1"></div>返回户型
 				</div>
 				<div class="btn AiBtn rows justify-center up2" @click.stop="aiSubmit(1)">
-					<div class="iconfont icon-a-lujing35039 style1"></div>{{aiImagesList && aiImagesList.length>0?'继续生成':'AI精软装'}}
+					<div class="iconfont icon-a-lujing35039 style1"></div>{{aiImagesList && aiImagesList.length>0?'继续设计':'开始设计'}}
 				</div>
 			</div>
 		</div>

+ 86 - 82
src/components/newBottomCom/viewMask/viewMask.scss

@@ -112,7 +112,7 @@
 	background: #fff;
 	box-shadow: 0 -6px 12px rgba(0, 0, 0, 0.12);
 	z-index: 15;
-	padding:0px 60px;
+	padding:0px 30px;
 	box-sizing: border-box;
 	pointer-events: auto;
 	.signscoll-block{
@@ -137,33 +137,42 @@
 	width: 100%;
 	display: flex;
 	flex-direction: column;
-	align-items: center;
-	margin-top:60px;
-	.aiStyleList {
-		width: 100%;
-		// height: 220px;
-		/* background: #333; */
-		flex-shrink: 0;
-		// white-space: nowrap;
-
-		.scrollViewItem {
-			width: 120px;
-			height: 168px;
-			// display: inline-block;
-			// margin: 0px 10px;
+	// align-items: center;
+	margin-top:30px;
+	.tab-view{
+		margin-bottom: 30px;
+		.btn{
+			width: 148px;
+			height: 56px;
+			border-radius: 16px;
+			background: transparent;
+			font-family: "Verdana";
+			font-weight: 400;
+			font-size: 30px;
+			color: #4e4e4e;
+			margin-right:40px;
 		}
-
-		.scrollViewItem:first-child {
+		.btn.active{
+			background: #343434;
+			color: #fff;
+		}
+	}
+	.aiStyleList {
+		width: 720px;
+		margin-bottom: 30px;
+		overflow-x: auto;
+		.styleItem:first-child {
 			// margin-left: 30px;
 		}
 
-		.scrollViewItem:last-child {
-			// margin-right: 30px;
+		.styleItem:last-child {
+			margin-right: 0px;
 		}
 
 		.styleItem {
-			position: absolute;
 			width: 120px;
+			height: 168px;
+			margin-right: 30px;
 			// height: 100%;
 			display: flex;
 			flex-direction: column;
@@ -201,82 +210,77 @@
 			}
 		}
 	}
-
-	.aiStyleList ::-webkit-scrollbar {
+	::-webkit-scrollbar {
 		width: 0;
 		height: 0;
 		background-color: transparent;
 	}
-
-	.aiTool {
-		width: 100%;
-		height: 100px;
+	.section4 {
+		width: 720px;
 		display: flex;
-		flex-direction: row;
 		align-items: center;
-		justify-content: center;
-		/* background: red; */
-		// margin: 0px 30px;
-		margin-top: 10px;
-		padding: 0px 30px;
-		box-sizing: border-box;
-		.changeBtn {
-			width: 320px;
-			height: 100px;
-			border-radius: 50px;
-			background: rgba(255, 156, 56, 0.15);
-			margin-right: 30px;
-			line-height: 100px;
-			text-align: center;
-			font-family: "DIN Alternate Bold";
-			font-weight: 700;
-			font-size: 32px;
-			color: #ff9f36;
-		}
-
-		.submitBtn {
-			width: 460px;
-			border-radius: 50px;
-			background: rgba(255, 156, 56, 0.15);
-			text-align: center;
-			height: 100%;
-			line-height: 100px;
-			font-family: "DIN Alternate Bold";
-			font-weight: 700;
-			font-size: 28px;
-			color: #fff;
-			box-shadow: 0 6px 20px rgba(242, 152, 2, 0.2);
-			backdrop-filter: blur(40px);
-			background-color: rgba(255, 255, 255, 0.15);
-			background-image:linear-gradient(124deg, rgba(245, 201, 82, 1) 0%, rgba(239, 149, 57, 1) 100%);
-		}
-		.disable{
-			background-color: #ccc;
-			background-image: unset;
-		}
-		.continue{
-			width: 330px;
-			background: #fab060;
-		}
-		.right-icon{
-			width: 34px;
-			height: 34px;
-			margin-right:10px;
-		}
-		.magic-icon{
-			width: 40.6px;
-			height: 40.56px;
-			margin-right:10px;
+		overflow-x: auto;
+		.items {
+			display: flex;
+			align-items: center;
+	
+			.item {
+				width: 140px;
+				height: 100px;
+				border-radius: 12px;
+				background: rgba(243, 243, 243, 1);
+				font-family: "Verdana";
+				font-weight: 400;
+				font-size: 24px;
+				text-align: center;
+				color: #4e4e4e;
+				// margin-right: 10px;
+				margin-right: 16px;
+	
+				padding: 10px 20px;
+				border: 2px solid transparent;
+				box-sizing: border-box;
+				white-space: nowrap;
+				.def-view{
+					width: 40px;
+					height: 40px;
+					border-radius: 50%;
+					background: conic-gradient(from 90.00deg at 50.00% 50.00%, #ea3333 0%, #ffc350 13.54%, #eded5e 29.06%, #8ad960 45.32%, #72b3a7 59.55%, #4f7aed 75%, #9f5bed 88.67%, #ef6d6d 100%);
+				}
+				.color-view{
+					margin-bottom: 6px;
+					.left{
+						width: 50px;
+						height: 40px;
+						border-radius: 8px 0 0 8px;
+					}
+					.right{
+						width: 50px;
+						height: 40px;
+						border-radius: 0 8px 8px 0;
+					}
+				}
+			}
+	
+			.item_sel {
+				background: rgba(247, 211, 116, 0.15);
+				border-color: #FDAD56;
+				color: #fcac56;
+			}
+			.item:last-child {
+				margin-right: 0px;
+			}
 		}
 	}
+	
 }
 .btn-list{
 	position: relative;
 	width: 100%;
 	box-sizing: border-box;
-	margin-top:26px;
+	margin-top:30px;
 	.btn{
-		height: 100px;
+		height: 88px;
 		border-radius: 50px;
 		backdrop-filter:blur(40px);
 		--webkit-backdrop-filter: blur(40px);

+ 145 - 99
src/components/newBottomCom/viewMask/viewMask.vue

@@ -23,6 +23,7 @@
 				inputBase64Url: "",
 				taskId: "", // 图生图任务ID
 				img2imgTimer: null,
+				outTimer: null,
 				imageWidth: 750,
 				imageHeight: 448,
 				showAIFlag:false,//继续生成状态切换标志
@@ -30,7 +31,7 @@
 				shottingImg:'',
 				count:0,
 				random:1,
-				disableAble:false,
+				// disableAble:false,
 				spaceTypes: [{
 						icon: "",
 						title: "卧室",
@@ -108,6 +109,100 @@
 				loadingMsg:'',
 				screenWidth:0,
 				screenHeight:0,
+				modelType:2,	//当前模型类型,1指创意设计 2指精准设计 默认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,		//超时时间
 			}
 		},
 		props:{
@@ -198,13 +293,29 @@
 					}
 				};
 				util.trackRequest(param);
-				// setTimeout(()=> {
-				// 	if(this.showAIImage==true){
-				// 		this.$parent.clearHandle()
-				// 	}else{
-				// 		this.$parent.attendEvent()
-				// 	}
-				// }, 100);
+			},
+			//空间或者风格切换
+			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', //点击ID
+					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() {
@@ -268,7 +379,7 @@
 				this.downloadIamge(_resultImg);
 			},
 		
-			//选项变更
+			//点赞喜欢
 			changeAIImg() {
 				// let lastPage = getCurrentPages()[getCurrentPages().length - 2] ? getCurrentPages()[getCurrentPages().length - 2].$vm : null;
 				this.checked = !this.checked;//变更选项
@@ -334,13 +445,6 @@
 					}else{
 						this.$message.warning("敬请期待");
 					}
-					// setTimeout(()=> {
-					// 	if(this.showAIImage==true){
-					// 		this.$parent.clearHandle()
-					// 	}else{
-					// 		this.$parent.attendEvent()
-					// 	}
-					// }, 100);
 				}
 			},
 			catchTapEvent:function(){
@@ -360,14 +464,14 @@
 					this.styleList = list;
 				}
 				if(!this.styleList || this.styleList.length==0){
-					this.disableAble = true;//不能点击-没有风格
+					// this.disableAble = true;//不能点击-没有风格
 					let unit = this.screenWidth / 750;//单位rpm 对应 px 的值
 					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{
-					this.disableAble = false;//可以点击
+					// this.disableAble = false;//可以点击
 				}
 			},
 			clearInterval() {
@@ -492,26 +596,7 @@
 				if(isRepeat && self.inputBase64Url){//重复使用
 					self.startServer();
 				}else{
-					// self.inputBase64Url = Base64Url;
-					// console.log("生成inputBase64Url");
 					self.startServer();
-					// this.image2Base64(url).then(base64 => {
-					// 	self.inputBase64Url = base64;
-					// 	self.startServer();
-					// })
-					// uni.request({
-					// 	url: url,
-					// 	method: "GET",
-					// 	responseType: "arraybuffer",
-					// 	success: async (res) => {
-					// 		let base64 = wx.arrayBufferToBase64(res.data);
-					// 		let Base64Url = "data:image/jpeg;base64," + base64;
-					// 		// console.log('base64:', Base64Url);
-					// 		self.inputBase64Url = Base64Url;
-					// 		console.log("生成inputBase64Url");
-					// 		self.startServer();
-					// 	},
-					// });
 				}
 			},
 			//开始图生图流程
@@ -520,68 +605,11 @@
 					return false
 				}
 				let imgUrl = this.styleList[this.curStyleIndex].imgUrl;
-				// let base64Url = await this.image2Base64(imgUrl);
-				// let data = {
-				// 	"configType": "AI_Biography",
-				// 	"keyvalue": "ControlNet_IpAdapter",
-				// 	"model": "ip-adapter_xl [4209e9f7]",
-				// 	"cpu": "ip-adapter_clip_sdxl",
-				// 	"session_hash": Date.now(),
-				// 	"weight": 1.5,
-				// 	"number1": -1,
-				// 	"number2": -1,
-				// 	"number3": 0,
-				// 	"number4": 1,
-				// 	// "imageBase64": base64Url,
-				// 	"imageUrl":imgUrl,
-				// }
-				// let res1 = await requestConfig("AIuploadImgControlNet", data);
-				// if(!res1 || !res1.single){
-				// 	this.showToast("渲染失败,请重试");
-				// 	this.aiFlag = false;
-				// 	this.aiImage = "";
-				// 	this.myloading = false;
-				// 	return false;
-				// }
-				// let session_hash = data.session_hash;
-				// data.model = "sai_xl_canny_256lora [566f20af]";
-				// data.keyvalue =  "ControlNet_Canny";
-				// data.cpu =  "canny";
-				// data.weight =  0.8;
-				// data.number1 =  100;
-				// data.number2 =  200;
-				// data.number3 =  0;
-				// data.number4 =  1;
-				// data.imageBase64 = this.inputBase64Url;
 				
-				// let res2 = await requestConfig("AIuploadImgControlNet", data);
-				// if(!res2 || !res2.success){
-				// 	this.showToast("渲染失败,请重试");
-				// 	this.aiFlag = false;
-				// 	this.aiImage = "";
-				// 	this.myloading = false;
-				// 	return false;
-				// }
-				// data.model = "t2iadapter_seg_sd14v1 [6387afb5]";
-				// data.keyvalue =  "ControlNet_Seg";
-				// data.cpu =  "seg_ofade20k";
-				// data.weight =  0.8;
-				// data.number1 =  -1;
-				// data.number2 =  -1;
-				// data.number3 =  0;
-				// data.number4 =  1;
-				// data.imageBase64 = this.inputBase64Url;
-				// let res3 = await requestConfig("AIuploadImgControlNet", data);
-				// if(!res3 || !res3.success){
-				// 	this.showToast("渲染失败,请重试");
-				// 	this.aiFlag = false;
-				// 	this.aiImage = "";
-				// 	this.myloading = false;
-				// 	return false;
-				// }
 				let session_hash = Date.now();
-				const prompt = this.styleList[this.curStyleIndex].prompt;
-				const noPromot = this.styleList[this.curStyleIndex].negativePrompt;
+				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());
@@ -601,8 +629,9 @@
 					image:this.shottingImg,
 					styleImage:imgUrl,
 					keyword: "replicate",
-					model: "lucataco/ssd-1b",
+					model: this.modelType==1? "lucataco/ssd-1b" : 'catio-apps/controlnet-interior-design',
 				};
+				this.timeOut = this.modelType==1? 20000: 40000;
 				let res = await requestConfig("generateTaskImgToImgForAliyun", parmas);
 				console.log("图生图结果:", res);
 				if(this.$parent.pvCurPageName!="room_show"){//说明用户切换页面了
@@ -612,7 +641,6 @@
 				let that = this;
 				if (res.success && res.single) {
 					if(typeof(res.single)=="object"){
-					// if(true){
 						let cot = res.single.queueCount || 1;
 						this.showToast("正有"+cot+"人排队,预计等待"+cot*25+"秒",10000);
 						this.aiImage = "";
@@ -628,13 +656,31 @@
 							this.count ++;
 							this.getResultForImgToImg();
 						}, 1000);
+						this.setOutTimer();
 					}
 				}else{
+					this.clearInterval()
 					this.aiFlag = false;
 					this.aiImage = "";
 					this.showToast("渲染失败,请重试")
 				}
 			},
+			//设置一个超时逻辑,到底指定时间后停止轮询,当前是90s
+			setOutTimer() {
+				if (this.outTimer) {
+					clearTimeout(this.outTimer)
+					this.outTimer = null
+				}
+				var self = this;
+				this.outTimer = setTimeout(function() {
+					if (self.img2imgTimer) {
+						self.clearInterval();//停止轮询
+						self.$message.warning("AI开了个小差,请稍后再试");
+					}
+					clearTimeout(self.outTimer);
+					self.outTimer = null
+				}, this.timeOut);
+			},
 			// 轮询获取图片结果
 			async getResultForImgToImg() {
 				var parmas = {

+ 1 - 1
src/main.js

@@ -40,7 +40,7 @@ window.echarts = echarts
 
 console.log('***process.env***production', process.env);
 window.env = process.env.NODE_ENV;
-env = env == 'development' ? 'production' : env;
+env = env == 'development' ? 'test2' : env;
 window.$config = api(env);
 console.log("window.$config", window.$config);