viewMask.vue 44 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389
  1. <template src="./viewMask.html">
  2. </template>
  3. <script>
  4. const util = require('@/utils/util.js').default;
  5. import router from "@/router";
  6. import { MessageBox } from 'mint-ui';
  7. import spaceTypes from '@/static/spaceTypesIE.js';
  8. // const config = require('@/services/url$config.js');
  9. import touchHandle from '@/mixins/touchHandle.js';
  10. import {
  11. setStorage,
  12. getStorage,
  13. } from '@/utils/localStorage';
  14. import Replicate from "replicate";
  15. const replicate = new Replicate({
  16. auth: "Token r8_VvWR3EJobLn1G4FNlyEqBZaXxWY4X4E3Yjyfy",
  17. });
  18. // import requestConfig from '@/static/lib/requestConfig';
  19. // const app = getApp(); //获取应用实例
  20. export default {
  21. mixins: [touchHandle],
  22. data: function() {
  23. return {
  24. currentIndex:0, //当前看到的图片序号
  25. showAIImage: false,//是否显示当前AI结果集合 默认不显示,因为没有
  26. aiImagesList:[
  27. ],//AI生成的图片列表
  28. styleList: [], //风格列表数据
  29. curStyleIndex: 0, //当前选中的风格序号
  30. aiFlag:false,
  31. aiImage: "",
  32. inputBase64Url: "",
  33. aiPicId: "", // 图生图任务ID
  34. randomTimer:null,
  35. timer: null,
  36. outTimer: null,
  37. imageWidth: 750,
  38. imageHeight: 448,
  39. showAIFlag:false,//继续生成状态切换标志
  40. checked:false,
  41. shottingImg:'',
  42. count:0,
  43. random:1,
  44. // disableAble:false,
  45. myloading:false,
  46. loadingMsg:'',
  47. screenWidth:0,
  48. screenHeight:0,
  49. modelType:2, //当前模型类型,1指创意设计 2指精准设计 默认2
  50. themeIndex:0,
  51. themeList:[
  52. {
  53. id:1,
  54. text:'默认',
  55. prot:'',
  56. },
  57. {
  58. id:2,
  59. leftColor:'#F4EBDE',
  60. rightColor:'#C1C9B4',
  61. text:'莫兰素雅',
  62. prot:'Soft grays, warm earth tones, subtle blues, soft pinks,',
  63. },
  64. {
  65. id:3,
  66. leftColor:'#1F1F1F',
  67. rightColor:'#FFFFFF',
  68. text:'经典黑白',
  69. prot:'Classic black and pure white,',
  70. },
  71. {
  72. id:4,
  73. leftColor:'#6FA5BE',
  74. rightColor:'#E2CCC5',
  75. text:'海岸珊瑚',
  76. prot:'Deep ocean blue paired with vibrant coral red,',
  77. },
  78. {
  79. id:5,
  80. leftColor:'#849059',
  81. rightColor:'#E6CEB4',
  82. text:'森林璀璨',
  83. prot:'Deep forest green paired with luxurious gold,'
  84. },
  85. {
  86. id:6,
  87. leftColor:'#A1BACB',
  88. rightColor:'#E6DFD8',
  89. text:'梦幻静谧',
  90. prot:'Dreamy powder blue paired with neutral gray,'
  91. },
  92. {
  93. id:7,
  94. leftColor:'#303B2B',
  95. rightColor:'#D8C8A6',
  96. text:'自然和谐',
  97. prot:'Natural olive green paired with warm beige,'
  98. },
  99. {
  100. id:8,
  101. leftColor:'#652C30',
  102. rightColor:'#D5C3B0',
  103. text:'醇酒乳香',
  104. prot:'Rich burgundy paired with soft cream,'
  105. },
  106. {
  107. id:9,
  108. leftColor:'#E3C7C5',
  109. rightColor:'#EDE4DB',
  110. text:'雅致浪漫',
  111. prot:'Understated taupe paired with romantic pink,'
  112. },
  113. {
  114. id:10,
  115. leftColor:'#2C3C6E',
  116. rightColor:'#F0DBBD',
  117. text:'夜空璀璨',
  118. prot:'Elegant navy blue paired with glamorous gold,'
  119. },
  120. {
  121. id:11,
  122. leftColor:'#ACC9A1',
  123. rightColor:'#E6DCC6',
  124. text:'复古翠绿',
  125. prot:'Vintage tan paired with vibrant green,'
  126. },
  127. {
  128. id:12,
  129. leftColor:'#AAA8A7',
  130. rightColor:'#D8A176',
  131. text:'暖阳灰影',
  132. prot:'Warm orange paired with cool gray,'
  133. },
  134. {
  135. id:13,
  136. leftColor:'#413D41',
  137. rightColor:'#D1B687',
  138. text:'耀眼黑金',
  139. prot:'black and gold,'
  140. },
  141. ],
  142. timeOut:20000, //超时时间
  143. subType:0,
  144. currentImg:null,
  145. reqList:[
  146. {
  147. model:'batouresearch/sdxl-controlnet-lora',
  148. level:'5',
  149. aiPicId:'',
  150. resultImg:'',
  151. }
  152. ],
  153. reqListReset:[
  154. {
  155. model:'deployments/elabgroup/elab-sdxl-controlnet-lora',
  156. level:'3',
  157. aiPicId:'',
  158. resultImg:'',
  159. },{
  160. model:'batouresearch/sdxl-controlnet-lora',
  161. level:'5',
  162. aiPicId:'',
  163. resultImg:'',
  164. }
  165. ],
  166. // dialogVisible: false,
  167. // dialogAIVisible: false,
  168. datalist:[],
  169. connectUsImg:'',
  170. curSpaceId:'',
  171. queryObj:null,
  172. form:null,
  173. }
  174. },
  175. props:{
  176. spaceObj: {
  177. type: Object,
  178. default: null,
  179. },
  180. spaceList: {
  181. type: [Array ,Object],
  182. default: [],
  183. },
  184. layoutList:{
  185. type: [Array ,Object],
  186. default: [],
  187. }
  188. },
  189. watch: {
  190. spaceObj(newVal, oldVal) {
  191. if (newVal == null) {
  192. return;
  193. }
  194. console.log("当前空间数据view-mark-watch:", newVal,newVal.layoutSpaceName,newVal.layoutSpaceType);
  195. this.getAiBeautyFamily();
  196. // this.curSpaceArea = parseFloat(
  197. // (newVal.spaceWidth * newVal.spaceHeight) / 10000
  198. // ).toFixed(2);
  199. // this.getOverallArrangementDetailsList();
  200. },
  201. spaceList(newVal, oldVal) {
  202. if (newVal == null) {
  203. return;
  204. }
  205. console.log("当前空间数据spaceList-watch:", newVal);
  206. if(newVal && newVal.length>0){
  207. this.datalist = [];
  208. newVal.forEach(it=>{
  209. if(it.spaceName && !it.isSizeLock){
  210. this.datalist.push(it);
  211. }
  212. })
  213. }
  214. },
  215. layoutList(newVal, oldVal) {
  216. if (newVal == null) {
  217. return;
  218. }
  219. this.updataLable();
  220. },
  221. customizedRecordId: {
  222. handler(newVal) {
  223. console.warn("***watch-customizedRecordId***", newVal);
  224. if (newVal != null) {
  225. this.getIdData();
  226. }
  227. },
  228. immediate: true,
  229. },
  230. },
  231. filters:{
  232. // spaceTypeFilter(type){
  233. // let name = spaceTypes[type - 1];
  234. // return name || '-'
  235. // },
  236. },
  237. mounted() {//组件挂载时事件
  238. // console.warn("***mounted-nav***",this.seedItem)
  239. // if(this.seedItem){
  240. // this.title = this.seedItem.seedText;
  241. // }
  242. // wx.checkJsApi({
  243. // jsApiList: ['previewImage'], // 需要检测的JS接口列表,所有JS接口列表见附录2,
  244. // success: function(res) {
  245. // // 以键值对的形式返回,可用的api值true,不可用为false
  246. // // 如:{"checkResult":{"chooseImage":true},"errMsg":"checkJsApi:ok"}
  247. // console.warn("checkJsApi",res)
  248. // // alert('su'+ JSON.stringify(res))
  249. // },
  250. // fail:(err)=>{
  251. // console.warn("checkJsApi-err",err)
  252. // // alert('err'+ JSON.stringify(err) )
  253. // }
  254. // })
  255. this.screenWidth = window.screen.width;
  256. this.screenHeight = window.screen.height;
  257. if(window.innerWidth && window.screen.width){
  258. this.screenWidth = Math.min(window.innerWidth,window.screen.width)
  259. }
  260. if(window.innerHeight && window.screen.height){
  261. this.screenHeight = Math.min(window.innerHeight,window.screen.height)
  262. }
  263. this.connectUsImg = 'https://dm.static.elab-plus.com/miniProgram/conentUs.png';
  264. let firstData = JSON.parse(getStorage('firstData'));
  265. if(firstData && firstData[0]){
  266. this.connectUsImg = firstData[0].selectOptionImageUrl;
  267. }
  268. let queryObj = getStorage('queryObj') ? JSON.parse(getStorage('queryObj')) : null;
  269. this.queryObj = queryObj;
  270. },
  271. beforeDestroy:function(){
  272. console.warn("***beforeDestroy***");//更新到页面上的数据
  273. this.stopInterval();
  274. },
  275. computed: {
  276. aiData() {
  277. return this.$store.state.aiData;
  278. },
  279. landDataId() {
  280. return this.$store.state.landDataId;
  281. },
  282. houseName() {
  283. return this.$store.state.houseName;
  284. },
  285. curHouseObj() {
  286. return this.$store.state.curHouseObj;
  287. },
  288. userId() {
  289. return this.$store.state.userId;
  290. },
  291. customizedRecordId() {
  292. return this.$store.state.customizedRecordId;
  293. },
  294. },
  295. methods:{
  296. //更改空间显示名称 X空间 类型 根据布局所属类型来显示
  297. updataLable(){
  298. let list = this.layoutList;
  299. this.datalist.forEach(lable=>{
  300. if(lable.spaceType==15){
  301. let layoutId = lable.layoutId;
  302. let layout = list.find(it=>it.id == layoutId);
  303. if(layout){
  304. let name = spaceTypes[layout.type - 1];
  305. lable.text = name;
  306. }
  307. }else{
  308. let name = spaceTypes[lable.spaceType - 1];
  309. lable.text = name;
  310. }
  311. })
  312. this.$forceUpdate()
  313. console.warn("***updataLable***",this.datalist)
  314. },
  315. swiperChangeImg(e){
  316. this.currentIndex = e.detail?e.detail.current:e;
  317. this.checked = this.aiImagesList[this.currentIndex].checked;
  318. console.warn("***swiperChangeImg***",this.checked);//更新到页面上的数据
  319. },
  320. //切换空间
  321. changeSpace(item){
  322. this.$parent.changeSpace(item.spaceId);
  323. let param = {
  324. type: 'CLK', //埋点类型
  325. clkId: 'clk_2cmina_23080417', //点击ID
  326. clkName: 'changeangle_clk', //点击前往的页面名称
  327. clkParams: {
  328. locusName: "空间切换",
  329. locusValue:item.text,
  330. spaceId:item.spaceId,
  331. type:item.text,
  332. }
  333. };
  334. util.trackRequest(param);
  335. },
  336. //视角切换
  337. switchActor(){
  338. // this.$parent.clearHandle()
  339. this.$emit('switchActor');
  340. this.showAIImage = false;//隐藏AI结果集合-执行切换视角
  341. let index = this.$parent.currentActor.userIndex;//当前视角的序号
  342. let nextIndex = (index + 1) % this.$parent.actors.length;
  343. let param = {
  344. type: 'CLK', //埋点类型
  345. clkId: 'clk_2cmina_23080417', //点击ID
  346. clkName: 'changeangle_clk', //点击前往的页面名称
  347. clkParams: {
  348. locusName: "视角切换",
  349. type:this.$parent.actors[nextIndex].actorEum
  350. }
  351. };
  352. util.trackRequest(param);
  353. },
  354. showOrHideWebGl(){
  355. // this.$parent.clearHandle()
  356. this.showAIImage = !this.showAIImage;
  357. let param = {
  358. type: 'CLK', //埋点类型
  359. clkId: 'clk_2cmina_23080415', //点击ID
  360. clkName: 'contrast_clk', //点击前往的页面名称
  361. clkParams: {
  362. locusName: "对比",
  363. }
  364. };
  365. util.trackRequest(param);
  366. },
  367. //空间或者风格切换
  368. selectAction(selItem,type,index) {
  369. console.log('点击动作111:', selItem,type,index)
  370. var self = this;
  371. if(this.themeIndex == index){
  372. return false
  373. }
  374. this.themeIndex = index;
  375. let param = {
  376. type: 'CLK', //埋点类型
  377. clkId: 'clk_2cmina_23112701', //点击ID
  378. clkName: 'AIstyle_theme_clk', //点击前往的页面名称
  379. clkParams: {
  380. locusName: "AI 主题",
  381. type:this.themeList[this.themeIndex].text
  382. }
  383. };
  384. util.trackRequest(param);
  385. },
  386. //切换模式
  387. changeModel(){
  388. this.modelType = (this.modelType + 1) >2 ? 1 : 2;
  389. },
  390. //保存到相册
  391. save() {
  392. //表示canvas正在绘制,不能进行保存
  393. if (!this.aiImagesList || this.aiImagesList.length==0) {
  394. return false;
  395. }
  396. var _resultImg = this.aiImagesList[this.currentIndex].image;
  397. //正在选择照片,不能生效
  398. if (!_resultImg || _resultImg.length==0) {
  399. this.showToast("请选中图片后再试!");
  400. return false;
  401. }
  402. var para = {
  403. type: 'CLK', //埋点类型
  404. clkId: 'clk_2cmina_56', //点击ID,固定
  405. clkName: "share-savepic", //点击名称
  406. expand: {
  407. "resultImg": (_resultImg || ""),
  408. },
  409. }
  410. util.trackRequest(para);
  411. if(navigator.userAgent.toLocaleLowerCase().includes('micromessenger')){
  412. this.$message("请长按图片保存!");
  413. }else{
  414. this.saveImageHandle(_resultImg);
  415. }
  416. },
  417. downloadIamge(imgsrc) { //下载图片地址和图片名
  418. var fileName = "4DImage" + util.formatDate(new Date(), "yyyyMMddhhmmss") + '.jpg';
  419. const image = new Image();
  420. // 解决跨域 Canvas 污染问题
  421. image.setAttribute("crossOrigin", "anonymous");
  422. image.onload = ()=> {
  423. // let canvas = document.createElement("canvas");
  424. // canvas.width = image.width;
  425. // canvas.height = image.height;
  426. // const context = canvas.getContext("2d");
  427. // context.drawImage(image, 0, 0, image.width, image.height);
  428. // const url = canvas.toDataURL("image/jpg"); //得到图片的base64编码数据
  429. const a = document.createElement("a"); // 生成一个a元素
  430. const event = new MouseEvent("click"); // 创建一个单击事件
  431. a.download = fileName || "photo"; // 设置图片名称
  432. a.href = imgsrc; // 将生成的URL设置为a.href属性
  433. a.dispatchEvent(event); // 触发a的单击事件
  434. this.showToast("保存成功!");
  435. };
  436. image.src = imgsrc;
  437. },
  438. saveImageHandle(_resultImg){
  439. let param = {
  440. type: 'CLK', //埋点类型
  441. clkId: 'clk_2cmina_23080414', //点击ID
  442. clkName: 'download_clk', //点击前往的页面名称
  443. clkParams: {
  444. locusName: "下载",
  445. img:_resultImg
  446. }
  447. };
  448. util.trackRequest(param);
  449. this.downloadIamge(_resultImg);
  450. },
  451. //点赞喜欢
  452. changeAIImg() {
  453. // let lastPage = getCurrentPages()[getCurrentPages().length - 2] ? getCurrentPages()[getCurrentPages().length - 2].$vm : null;
  454. this.checked = !this.checked;//变更选项
  455. this.aiImagesList[this.currentIndex].checked = this.checked;
  456. console.warn("***changeAIImg***",this.checked,this.aiData)
  457. // if(this.aiData){//给上一个页面回传生成的数据
  458. // let space = this.aiData.find(it=>{
  459. // return it.spaceId == this.spaceObj.spaceId
  460. // })
  461. // if(space){
  462. // space.aiImagesList[this.currentIndex].checked = this.checked;
  463. // }
  464. // }
  465. if(this.checked){
  466. let param = {
  467. type: 'CLK', //埋点类型
  468. clkId: 'clk_2cmina_23080418', //点击ID
  469. clkName: 'chooseprogramme_clk', //点击前往的页面名称
  470. clkParams: {
  471. locusName: "选定风格/视角",
  472. style:this.styleList[this.curStyleIndex].styleName,
  473. img:this.aiImagesList[this.currentIndex].image,
  474. }
  475. };
  476. util.trackRequest(param);
  477. }
  478. },
  479. rightScroll(){//右滑
  480. if(this.currentIndex <= (this.aiImagesList.length - 1) && this.currentIndex > 0){
  481. // this.currentIndex --;
  482. this.$refs.carousel.prev();
  483. }
  484. },
  485. leftScroll(){//继续生成
  486. if(this.currentIndex != this.aiImagesList.length - 1){
  487. if(this.currentIndex<this.aiImagesList.length - 1){
  488. // this.currentIndex ++;
  489. this.$refs.carousel.next();
  490. }
  491. return false;
  492. }
  493. console.log("***leftScroll***",this.currentIndex,this.aiImagesList.length)
  494. this.aiSubmit(2);//继续生成下一张
  495. },
  496. //预览图片-使用微信自带的预览功能,即H5中不可用
  497. previewAction() {
  498. if(wx && typeof(wx.previewImage)=='function'){
  499. let imglist = this.aiImagesList.map(it=>it.image);
  500. wx.previewImage({
  501. current: this.currentIndex,
  502. urls: imglist,
  503. success: (res) => {
  504. console.log('图片预览:', res);
  505. },
  506. fail:(err)=>{
  507. console.warn('图片预览-err:', res);
  508. }
  509. })
  510. }
  511. },
  512. mynavigateFuc(e) {
  513. if (e) {
  514. // this.$parent.clearHandle();
  515. let param = {
  516. type: 'CLK', //埋点类型
  517. clkId: 'clk_2cmina_23080408', //点击ID
  518. clkName: 'WeCom_clk', //点击前往的页面名称
  519. clkParams: {
  520. locusName: "联系定制",
  521. }
  522. };
  523. util.trackRequest(param);
  524. if(window.__wxjs_environment === 'miniprogram'){
  525. wx.miniProgram.navigateTo({url: '/pages/transfer/transfer?event=openCustomerServiceChat&houseId='+this.$store.state.houseId})
  526. }else{
  527. this.$message.warning("敬请期待");
  528. }
  529. }
  530. },
  531. catchTapEvent:function(){
  532. return false;
  533. },
  534. //获取AI风格列表
  535. async getAiBeautyFamily() {
  536. // const spaceName = this.spaceTypes[this.spaceObj.spaceType - 1].title;
  537. let res = await requestConfig("getHardboundEffects", {
  538. // "houseId": this.$route.query.houseId || this.$store.state.houseId,
  539. "spaceType": this.spaceObj.layoutSpaceType || this.spaceObj.spaceType,
  540. "spaceName": this.spaceObj.layoutSpaceName || this.spaceObj.spaceName,
  541. });
  542. this.styleList = [];
  543. // alert("***getAiBeautyFamily-res***"+JSON.stringify(res))
  544. if (res.success) {
  545. let list = res.list;
  546. this.styleList = list;
  547. }
  548. },
  549. //风格选择
  550. selectStyle(idx){
  551. if(this.curStyleIndex == idx){
  552. return false
  553. }
  554. this.curStyleIndex = idx;
  555. let param = {
  556. type: 'CLK', //埋点类型
  557. clkId: 'clk_2cmina_23080416', //点击ID
  558. clkName: 'AIstyle_ret_clk', //点击前往的页面名称
  559. clkParams: {
  560. locusName: "AI 风格",
  561. type:this.styleList[this.curStyleIndex].styleName
  562. }
  563. };
  564. util.trackRequest(param);
  565. },
  566. // AI渲染
  567. async aiSubmit(type) {
  568. if(!this.styleList || this.styleList.length==0 || this.curStyleIndex==-1
  569. || !this.styleList[this.curStyleIndex].prompt || !this.styleList[this.curStyleIndex].negativePrompt){
  570. return false;
  571. }
  572. // 防止连续点击处理
  573. if (this.aiFlag) {
  574. return
  575. }
  576. this.aiFlag = true;
  577. this.aiImage = "";//清空AI结果图
  578. this.stopInterval();
  579. // if(!this.showAIImage){
  580. this.myloading = true;
  581. this.loadingMsg = "启动中";
  582. // }
  583. // this.inputBase64Url = await this.shottingAction(2);//开始截图-返回的是base64的数据
  584. // this.startServer();
  585. // let base64 = await this.$parent.shottingAction(2);//开始截图-返回的是base64
  586. let shottingImg = await this.$parent.shottingAction();//开始截图-返回的是图片地址
  587. if(!shottingImg){
  588. this.showToast("渲染失败,请重试");
  589. return false;
  590. }
  591. // ?x-oss-process=image/auto-orient,1/quality,Q_46/format,jpg //阿里OSS
  592. // "?imageMogr2/auto-orient/format/webp/blur/1x0/quality/75";//七牛云压缩图片
  593. shottingImg += "?x-oss-process=image/auto-orient,1/quality,Q_46/format,jpg";//压缩图片
  594. this.shottingImg = shottingImg;
  595. this.changeImg2Base64(this.shottingImg, false);
  596. console.warn("***shottingImg***",this.shottingImg)
  597. if(type==1){
  598. let param = {
  599. type: 'CLK', //埋点类型
  600. clkId: 'clk_2cmina_23080413', //点击ID
  601. clkName: 'AIcreate_clk', //点击前往的页面名称
  602. clkParams: {
  603. locusName: "AI生成",
  604. userparamter:{
  605. shottingImg:this.shottingImg,
  606. style:this.styleList[this.curStyleIndex].styleName
  607. }
  608. }
  609. };
  610. util.trackRequest(param);
  611. }else{
  612. let param = {
  613. type: 'CLK', //埋点类型
  614. clkId: 'clk_2cmina_23080419', //点击ID
  615. clkName: 'continueAIcreate_clk', //点击前往的页面名称
  616. clkParams: {
  617. locusName: "继续生成",
  618. userparamter:{
  619. shottingImg:this.shottingImg,
  620. style:this.styleList[this.curStyleIndex].styleName
  621. }
  622. }
  623. };
  624. util.trackRequest(param);
  625. }
  626. },
  627. image2Base64(imgUrl) {//导入的图片路径
  628. var toBase64= new Promise(function(resolve, reject){
  629. window.URL = window.URL || window.webkitURL;
  630. var xhr = new XMLHttpRequest();
  631. xhr.open("get", imgUrl, true);
  632. // 至关重要
  633. xhr.responseType = "blob";//文件流
  634. xhr.onload = function (res) {
  635. if (res.currentTarget.status == 200) {
  636. //得到一个blob对象
  637. var blob = res.currentTarget.response;
  638. // 至关重要
  639. let oFileReader = new FileReader();
  640. oFileReader.onloadend = function (e) {
  641. let base64 = e.target.result;//base64
  642. resolve(base64)
  643. };
  644. oFileReader.readAsDataURL(blob);
  645. }
  646. }
  647. xhr.send();
  648. });
  649. return toBase64;
  650. },
  651. changeImg2Base64(url, isRepeat) {
  652. var self = this;
  653. if(isRepeat && self.inputBase64Url){//重复使用
  654. self.startServer();
  655. }else{
  656. self.startServer();
  657. }
  658. },
  659. //前置逻辑
  660. async prevHandle(parmas){
  661. //不是首次请求,则无需前置判断 用户上传的也不需要前置处理
  662. if(this.subType!=0){
  663. return '';
  664. }
  665. return new Promise(async (resolve, reject) => {
  666. let _data = JSON.parse(JSON.stringify(parmas))
  667. delete _data.webhook;
  668. let res = await requestConfig("img2img_local", _data);
  669. if (res && res.success) {
  670. if (res.success && res.single) {
  671. let resultImg = res.single;
  672. resolve(resultImg);
  673. }else{
  674. resolve('');
  675. }
  676. }else{
  677. resolve('');
  678. }
  679. })
  680. },
  681. //直接调接口测试
  682. async test() {
  683. if(!this.styleList || this.curStyleIndex < 0 || !this.styleList[this.curStyleIndex].imgUrl){
  684. return false
  685. }
  686. if(this.$parent.pvCurPageName!="room_show"){//说明用户切换页面了
  687. console.warn("***用户已经退出页面***")
  688. return false;
  689. }
  690. const output = await replicate.run(
  691. "batouresearch/sdxl-controlnet-lora:3bb13fe1c33c35987b33792b01b71ed6529d03f165d1c2416375859f09ca9fef",
  692. {
  693. input: {
  694. seed: null,
  695. image: "https://replicate.delivery/pbxt/JiOTMCHj4oGrTTf8Pg2r7vyI8YdXc5jL2IDyC2SfhuggjYe6/out-0%20(1).png",
  696. prompt: "shot in the style of sksfer, a woman in alaska",
  697. refine: "base_image_refiner",
  698. strength: 0.8,
  699. scheduler: "K_EULER",
  700. lora_scale: 0.95,
  701. num_outputs: 1,
  702. lora_weights: "https://pbxt.replicate.delivery/mwN3AFyYZyouOB03Uhw8ubKW9rpqMgdtL9zYV9GF2WGDiwbE/trained_model.tar",
  703. refine_steps: 20,
  704. guidance_scale: 7.5,
  705. apply_watermark: true,
  706. condition_scale: 0.5,
  707. negative_prompt: "",
  708. num_inference_steps: 40
  709. }
  710. }
  711. );
  712. console.log(output);
  713. // let imgUrl = this.styleList[this.curStyleIndex].imgUrl;
  714. // let subType = this.subType;
  715. // let session_hash = Date.now();
  716. // let theme = this.themeList[this.themeIndex];//主题数据
  717. // let prompt = this.styleList[this.curStyleIndex].prompt + theme.prot;
  718. // let noPromot = this.styleList[this.curStyleIndex].negativePrompt;
  719. // let unit = 768 / this.screenWidth;
  720. // this.imageWidth = parseInt((this.screenWidth * unit).toFixed());
  721. // this.imageHeight = parseInt((this.$parent.canvasHeight * unit).toFixed());
  722. // this.timeOut = this.modelType==1 ? 20000: 120000;
  723. // var parmas = {
  724. // negativePrompt: noPromot,
  725. // prompt: prompt,
  726. // "batchSize": 1,
  727. // brandId: $config.brandId,
  728. // height: this.imageHeight,
  729. // width: this.imageWidth,
  730. // "moduleType": "AI_Biography",
  731. // "steps":20,
  732. // "sampler":"DDIM",
  733. // "controlNetSessionHash":session_hash,
  734. // "cfgScale":12,
  735. // "denoising":0.9,
  736. // image:this.shottingImg,
  737. // styleImage:imgUrl,
  738. // keyword: "replicate",
  739. // model: this.modelType==1? "lucataco/ssd-1b" : 'catio-apps/controlnet-interior-design',
  740. // };
  741. // if(this.modelType==2){//精准设计
  742. // if(subType == 0){//首次
  743. // parmas.model = this.reqList[0].model;
  744. // }else{//重试
  745. // parmas.model = this.reqListReset[0].model;
  746. // }
  747. // }else{//创意设计
  748. // if(subType == 0){//首次
  749. // parmas.model = "lucataco/ssd-1b";
  750. // }else{//重试
  751. // parmas.model = "deployments/elabgroup/elab-ssd-1b";
  752. // }
  753. // }
  754. // this.curSpaceId = this.spaceObj.spaceId;//生成时的空间id
  755. // // let result = await this.prevHandle(parmas);
  756. // // console.warn("***prevHandle***",result)
  757. // let res = await requestConfig("https://replicate.com/batouresearch/sdxl-controlnet-lora?input=nodejs", parmas);
  758. // if (res && res.success) {
  759. // }else{
  760. // }
  761. },
  762. //开始图生图流程
  763. async startServer() {
  764. if(!this.styleList || this.curStyleIndex < 0 || !this.styleList[this.curStyleIndex].imgUrl){
  765. return false
  766. }
  767. if(this.$parent.pvCurPageName!="room_show"){//说明用户切换页面了
  768. console.warn("***用户已经退出页面***")
  769. return false;
  770. }
  771. let imgUrl = this.styleList[this.curStyleIndex].imgUrl;
  772. let subType = this.subType;
  773. let session_hash = Date.now();
  774. let theme = this.themeList[this.themeIndex];//主题数据
  775. let prompt = this.styleList[this.curStyleIndex].prompt + theme.prot;
  776. let noPromot = this.styleList[this.curStyleIndex].negativePrompt;
  777. let unit = 768 / this.screenWidth;
  778. this.imageWidth = parseInt((this.screenWidth * unit).toFixed());
  779. this.imageHeight = parseInt((this.$parent.canvasHeight * unit).toFixed());
  780. this.timeOut = this.modelType==1 ? 20000: 120000;
  781. var parmas = {
  782. negativePrompt: noPromot,
  783. prompt: prompt,
  784. "batchSize": 1,
  785. brandId: $config.brandId,
  786. height: this.imageHeight,
  787. width: this.imageWidth,
  788. "moduleType": "AI_Biography",
  789. "steps":20,
  790. "sampler":"DDIM",
  791. "controlNetSessionHash":session_hash,
  792. "cfgScale":12,
  793. "denoising":0.9,
  794. image:this.shottingImg,
  795. styleImage:imgUrl,
  796. keyword: "replicate",
  797. model: this.modelType==1? "lucataco/ssd-1b" : 'catio-apps/controlnet-interior-design',
  798. };
  799. if(this.modelType==2){//精准设计
  800. if(subType == 0){//首次
  801. parmas.model = this.reqList[0].model;
  802. }else{//重试
  803. parmas.model = this.reqListReset[0].model;
  804. }
  805. }else{//创意设计
  806. if(subType == 0){//首次
  807. parmas.model = "lucataco/ssd-1b";
  808. }else{//重试
  809. parmas.model = "deployments/elabgroup/elab-ssd-1b";
  810. }
  811. }
  812. this.curSpaceId = this.spaceObj.spaceId;//生成时的空间id
  813. let result = await this.prevHandle(parmas);
  814. console.warn("***prevHandle***",result)
  815. if(result && result.length>0){
  816. this.randomHandle(result)
  817. return false;
  818. }else{
  819. if(this.modelType==2){//精准设计
  820. this.otherHandle(parmas);//发送其他AI请求
  821. }
  822. let res = await requestConfig("generateTaskImgToImgForAliyun", parmas);
  823. console.log("图生图结果:", res);
  824. let that = this;
  825. if (res && res.success && res.single) {
  826. this.aiPicId = res.single;
  827. if(this.modelType==2){//精准设计
  828. if(subType == 0){//首次
  829. this.reqList[0].aiPicId = this.aiPicId;
  830. }else{//重试
  831. this.reqListReset[0].aiPicId = this.aiPicId;
  832. }
  833. }
  834. if (this.aiPicId) {
  835. this.startInterval();//开始轮询AI生成图的结果
  836. }else{
  837. this.stopInterval()
  838. }
  839. }else{
  840. this.stopInterval()
  841. this.showToast("渲染失败,请重试")
  842. }
  843. }
  844. },
  845. stopInterval() {
  846. if (this.randomTimer) {
  847. clearInterval(this.randomTimer);
  848. this.randomTimer = null;
  849. }
  850. if (this.timer) {
  851. // clearInterval(this.timer);
  852. this.timer = null;
  853. }
  854. if (this.outTimer) {
  855. clearTimeout(this.outTimer)
  856. this.outTimer = null
  857. }
  858. this.subType = 0;
  859. this.reqList.forEach(it=>{
  860. it.aiPicId = '';
  861. it.resultImg = '';
  862. })
  863. this.reqListReset.forEach(it=>{
  864. it.aiPicId = '';
  865. it.resultImg = '';
  866. })
  867. // this.random = 1;
  868. this.myloading = false;
  869. this.aiFlag = false;
  870. },
  871. //随机处理
  872. randomHandle(resultImg){
  873. if(this.timer || !resultImg){
  874. return false;
  875. }
  876. let self = this;
  877. var count = 1;
  878. var process = 0;//进度
  879. var randomNum = Math.floor(Math.random() * 4 + 5);//5-8随机数
  880. this.randomTimer = setInterval(function() {
  881. process = parseInt(count * 100/(randomNum));
  882. if(process>=100){
  883. process = 99;
  884. }
  885. if (count < randomNum) {//没有到上限
  886. // if(!self.showAIImage){
  887. self.myloading = true;
  888. self.loadingMsg = '生成中…' + process + '%';
  889. // }
  890. }else{
  891. self.myloading = false;
  892. self.resultHandle(resultImg);
  893. }
  894. count = count + 1;
  895. }, 1000);
  896. },
  897. otherHandle(parmas){
  898. let reqList = [];
  899. if(this.subType == 0){//首次
  900. reqList = this.reqList;
  901. }else{//重试
  902. reqList = this.reqListReset;
  903. }
  904. reqList.forEach(async (it,index)=>{
  905. let _data = JSON.parse(JSON.stringify(parmas));
  906. if(index>0){
  907. _data.model = it.model;
  908. let res = await requestConfig("generateTaskImgToImgForAliyun", _data);
  909. if (res.success) {
  910. console.log('生成结果123:', res);
  911. it.aiPicId = res.single || '';
  912. }
  913. }
  914. })
  915. },
  916. //开始生成AI图的轮询,每隔1s轮询一次
  917. startInterval() {
  918. if(this.timer){
  919. return false;
  920. }
  921. let self = this;
  922. this.count = 1;//轮询次数
  923. var random = 0;
  924. this.currentImg = false;//当次生成图还没有结果
  925. this.timer = 1;
  926. this.getOutPicture();//不在轮询,而是等结果
  927. this.setOutTimer();//设置超时逻辑
  928. },
  929. //设置一个超时逻辑,到底指定时间后停止轮询,当前是90s
  930. setOutTimer() {
  931. if (this.outTimer) {
  932. clearTimeout(this.outTimer)
  933. this.outTimer = null
  934. }
  935. var self = this;
  936. this.outTimer = setTimeout(function() {
  937. if (self.timer) {
  938. let hasResult = false;
  939. if(self.modelType==2){//精准设计
  940. let reqList = [];
  941. if(self.subType == 0){//首次
  942. reqList = self.reqList;
  943. }else{//重试
  944. reqList = self.reqListReset;
  945. }
  946. reqList.some((item,index) => {
  947. if(item.resultImg){
  948. hasResult = true;
  949. self.resultHandle(item.resultImg)
  950. }
  951. });
  952. }
  953. console.warn("***hasResult***",hasResult)
  954. if(!hasResult){//没有结果
  955. self.stopInterval();//停止轮询
  956. // self.$message.warning("AI开了个小差,请稍后再试");
  957. // self.dialogVisible = true;//弹出超时提示
  958. MessageBox.confirm('',{
  959. title: '提示',
  960. message: '当前AI使用火爆,请继续尝试?',
  961. showCancelButton: true,
  962. confirmButtonText:'继续尝试',
  963. cancelButtonText:'取消等待',
  964. }).then(action => {
  965. console.warn("***MessageBox-action***",action)
  966. if(action == 'confirm'){
  967. self.confirmHandle(1);
  968. }
  969. }).catch(err=>{
  970. console.warn("***MessageBox-err***",err)
  971. if(err == 'cancel'){
  972. self.cancelHandle();
  973. }
  974. });
  975. // MessageBox.confirm('确定执行此操作?')
  976. }
  977. }
  978. clearTimeout(self.outTimer);
  979. self.outTimer = null
  980. }, this.timeOut);
  981. },
  982. confirmHandle(type){
  983. console.log('用户点击确定')
  984. this.subType = type || 0;
  985. this.startServer();
  986. },
  987. cancelHandle(){
  988. console.log('用户点击取消')
  989. this.subType = 0;
  990. },
  991. //获取生成图结果
  992. getOutPicture() {
  993. if(this.timer==null){
  994. console.warn("***当前轮询已经结束了1***")
  995. return false;
  996. }
  997. if(this.modelType==2){//精准设计
  998. let reqList = [];
  999. if(this.subType == 0){//首次
  1000. reqList = this.reqList;
  1001. }else{//重试
  1002. reqList = this.reqListReset;
  1003. }
  1004. reqList.forEach((item,index) => {
  1005. this.singleHandle(item)
  1006. });
  1007. }
  1008. else{
  1009. this.singleHandle({aiPicId:this.aiPicId})
  1010. }
  1011. },
  1012. //发出获取结果请求获取AI生成结果
  1013. async singleHandle(model){
  1014. if(!model || !model.aiPicId){
  1015. return false;
  1016. }
  1017. var parmas = {
  1018. id: model.aiPicId,
  1019. };
  1020. let res = await requestConfig("getPredictions", parmas);
  1021. if (res && res.success && res.single) {
  1022. if(this.currentImg){//当前已经有生成图了
  1023. console.warn("***当前已经有最高级生成图了***")
  1024. return false;
  1025. }
  1026. if(this.timer==null){
  1027. console.warn("***当前轮询已经结束了***")
  1028. return false;
  1029. }
  1030. if (res.single.status == 'succeeded' && res.single.output) {
  1031. if(this.modelType==2){//精准设计
  1032. model.resultImg = res.single.output;
  1033. if(model.level=='5'){//最高级了
  1034. this.currentImg = true;
  1035. setTimeout(()=>{
  1036. this.resultHandle(res.single.output)
  1037. },1500)
  1038. }
  1039. }else{
  1040. this.currentImg = true;
  1041. setTimeout(()=>{
  1042. this.resultHandle(res.single.output)
  1043. },1500)
  1044. }
  1045. console.warn("***有生成图了***",model)
  1046. }
  1047. if(this.modelType==2){//最高优先级返回没有图片,则处理进度条事宜
  1048. if(model.level=='5'){
  1049. this.processHandle(res.single);
  1050. }
  1051. }else{//普通设计
  1052. this.processHandle(res.single);
  1053. }
  1054. } else {
  1055. this.stopInterval();//停止轮询
  1056. this.showToast("渲染失败,请重试")
  1057. }
  1058. },
  1059. //进度处理
  1060. processHandle(single){
  1061. console.warn("***single***",single.status,single.progress,this.count,single);
  1062. let self = this;
  1063. if(single.status=='starting'){//启动中的逻辑
  1064. if(this.count>=20){
  1065. this.stopInterval();//停止轮询
  1066. // this.dialogAIVisible = true;
  1067. MessageBox.confirm('',{
  1068. title: '提示',
  1069. message: 'AI开了小差,是否重新生成?',
  1070. showCancelButton: true,
  1071. confirmButtonText:'继续生成',
  1072. cancelButtonText:'放弃生成',
  1073. }).then(action => {
  1074. console.warn("***MessageBox-action***",action)
  1075. if(action == 'confirm'){
  1076. this.confirmHandle(0);
  1077. }
  1078. }).catch(err=>{
  1079. if(err == 'cancel'){
  1080. this.cancelHandle();
  1081. }
  1082. });
  1083. }else{
  1084. this.myloading = true;
  1085. this.loadingMsg = '启动中';
  1086. }
  1087. this.count = this.count + 1;
  1088. this.getOutPicture();//进行下一轮查询
  1089. }else if(single.status=='processing'){
  1090. let random = single.progress || 0;
  1091. if(random >= 100){
  1092. random = 99;
  1093. }
  1094. this.myloading = true;
  1095. this.loadingMsg = '生成中…' + parseInt(random) + '%';
  1096. this.getOutPicture();//进行下一轮查询
  1097. }else if(single.status=='succeeded'){
  1098. if(single.output){//实际有结果了
  1099. this.myloading = true;
  1100. this.loadingMsg = '生成中…100%';
  1101. }else{//还没有结果,继续请求
  1102. this.myloading = true;
  1103. this.loadingMsg = '生成中…99%';
  1104. this.getOutPicture();//进行下一轮查询
  1105. }
  1106. }
  1107. },
  1108. //返回结果处理
  1109. resultHandle(resultImg){
  1110. this.currentImg = true;
  1111. // this.random = 100;
  1112. this.aiImage = resultImg;
  1113. this.showAIFlag = true;
  1114. let newImage = resultImg;
  1115. let aiStyleName = this.styleList[this.curStyleIndex].styleName;
  1116. let _data = {
  1117. image:newImage,
  1118. checked:false,
  1119. list:[newImage],
  1120. spaceId:this.curSpaceId,//记录下当前生成的AI图是哪个空间的,因为会切换空间
  1121. }
  1122. this.aiImagesList.push(_data);
  1123. this.showAIImage = true;//显示AI结果集合-因为生成了AI图片
  1124. if(this.$parent && typeof(this.$parent.clearHandle)=="function" ){
  1125. this.$parent.clearHandle();
  1126. }
  1127. this.stopInterval();
  1128. if(this.aiImagesList.length>1){
  1129. setTimeout(()=>{
  1130. this.$refs.carousel.setActiveItem(this.aiImagesList.length-1);//切换到最后一张
  1131. }, 1000);
  1132. }
  1133. },
  1134. //空间数据整理
  1135. spaceAIHandle(){
  1136. let curHouseObj = this.$parent.curHouseObj;//当前户型数据对象
  1137. let aiImagesList = this.aiImagesList;//AI生成图数据对象
  1138. let wallList = this.$parent.wallList;//当前户型墙体数据列表对象
  1139. let spaceList = JSON.parse(curHouseObj.houseJson);
  1140. //遍历当前户型下的每一个空间
  1141. spaceList.forEach((item)=>{
  1142. let space = item;
  1143. let list = aiImagesList.filter(it=>it.spaceId==space.spaceId);//找到AI生成图中的当前空间
  1144. if(list && list.length>0){
  1145. list = list.filter(it=>it.checked==true);//过滤选中的
  1146. list = list.map(it=>{
  1147. return it.image
  1148. })
  1149. space.hardboundEffect = list;
  1150. console.warn("submitHouse: ", list,space);
  1151. }
  1152. let wall = wallList.find(it=>it.id==space.wallId);
  1153. if(wall){//找到当前空间的墙体数据
  1154. space.wallList = JSON.stringify(wall);
  1155. }
  1156. })
  1157. setStorage('spaceList', spaceList);//把空间选择的数据存入本地缓存里面,方便后续使用
  1158. console.warn("**spaceList**",spaceList)
  1159. },
  1160. //进入下一步
  1161. gonext(){
  1162. this.spaceAIHandle()
  1163. router.push({
  1164. name: "webgl_rxdz_test_env",
  1165. query:{
  1166. houseId:this.$route.query.houseId || this.$store.state.houseId,
  1167. }
  1168. });
  1169. },
  1170. submit() {
  1171. this.spaceAIHandle();
  1172. setTimeout(()=>{
  1173. if(this.customizedRecordId){//修改
  1174. this.updateHandle();
  1175. }else{//完全新增
  1176. this.resultDataHandle();
  1177. }
  1178. },200)
  1179. },
  1180. //获取作品信息
  1181. async getIdData(){
  1182. let userId = this.userId || '';
  1183. let params = {
  1184. id: this.customizedRecordId,
  1185. brandId: $config.brandId,
  1186. houseId: this.houseId,
  1187. userId,
  1188. type:'QIANCE',
  1189. };
  1190. const res = await requestConfig('getCustomizedRecord', params);
  1191. if (res.success && res.list && res.list[0]) {
  1192. let single = res.list[0];
  1193. this.form = single;
  1194. // this.hardboundEffect = this.form.layoutImgCustomized? [this.form.layoutImgCustomized] : [];//赋值轮播图
  1195. }
  1196. },
  1197. //提交结果数据处理
  1198. async resultDataHandle(){
  1199. // let firstData = JSON.parse(getStorage('firstData'));
  1200. let secondData = JSON.parse(getStorage('secondData'));
  1201. let thirdData = JSON.parse(getStorage('thirdData'));
  1202. let curHouseObj = JSON.parse(getStorage('curHouseObj'));
  1203. let spaceList = JSON.parse(getStorage('spaceList'));
  1204. let shottingImg = getStorage('shottingImg');
  1205. let expand = [];//扩展数据
  1206. let checkIndexList = [];
  1207. let otherlist = [];
  1208. let userId = this.userId ? this.userId : '';
  1209. let houseData = {
  1210. "layoutId": curHouseObj.id,
  1211. "layoutName": curHouseObj.name,
  1212. "layoutArea": curHouseObj.houseArea,
  1213. "floor": 1,
  1214. "layoutImgCustomized": shottingImg,
  1215. "style": "",
  1216. "houseJson": []
  1217. }
  1218. // firstData.forEach(it=>{
  1219. // let _dt = {
  1220. // name:it.name,
  1221. // value:it.selectOptionImageUrl,
  1222. // }
  1223. // expand.push(_dt);
  1224. // })
  1225. if(secondData){
  1226. secondData.forEach(it=>{
  1227. let _dt = {
  1228. name:it.name,
  1229. value:it.selectOptionName,
  1230. }
  1231. expand.push(_dt);
  1232. })
  1233. }
  1234. if(thirdData){
  1235. thirdData.forEach(it=>{
  1236. let _dt = {
  1237. name:it.spaceName,
  1238. value:it.selectOptionName,
  1239. }
  1240. expand.push(_dt);
  1241. })
  1242. }
  1243. let mainImage = '';
  1244. if(thirdData && thirdData.length>0){
  1245. mainImage = thirdData[1] ? thirdData[1].hardboundEffect[0] : thirdData[0].hardboundEffect[0];
  1246. }
  1247. houseData.houseJson = thirdData ? spaceList.concat(thirdData) : spaceList;
  1248. // houseData.expand = expand;
  1249. let param = {
  1250. "brandId": $config.brandId,
  1251. "houseId": this.houseId || curHouseObj.houseId,
  1252. "userId": userId,
  1253. "floot": 1,
  1254. "spaceName": curHouseObj.name,
  1255. "spaceStructure": '',
  1256. "curFloor":1,
  1257. layoutStruct:[houseData],
  1258. type:'QIANCE',
  1259. expand:JSON.stringify(expand),
  1260. mainImage:mainImage,
  1261. }
  1262. if(this.landDataId){
  1263. param.landDataId = this.landDataId;
  1264. }
  1265. if(this.houseName){
  1266. param.houseName = this.houseName;
  1267. }
  1268. console.warn("submitHouse-param: ", param);
  1269. // setStorage('envData',checkIndexList);
  1270. const loading = this.$loading({
  1271. lock: true,
  1272. text: '提交中...',
  1273. spinner: 'el-icon-loading',
  1274. background: 'rgba(0, 0, 0, 0.7)'
  1275. });
  1276. let res = await requestConfig("saveCustomizedRecord", param);
  1277. loading.close();
  1278. if(res && res.success && res.single){//提交成功
  1279. let data = {
  1280. houseId:this.houseId || curHouseObj.houseId,
  1281. id:res.single,
  1282. }
  1283. router.push({
  1284. name: "webgl_rxdz_text_customize",
  1285. query:data
  1286. });
  1287. }
  1288. },
  1289. //修改结果数据处理
  1290. async updateHandle(){
  1291. // let firstData = JSON.parse(getStorage('firstData'));
  1292. // let secondData = JSON.parse(getStorage('secondData'));
  1293. // let thirdData = JSON.parse(getStorage('thirdData'));
  1294. let curHouseObj = JSON.parse(getStorage('curHouseObj'));
  1295. let spaceList = JSON.parse(getStorage('spaceList'));
  1296. let shottingImg = getStorage('shottingImg');
  1297. let expand = [];//扩展数据
  1298. let checkIndexList = [];
  1299. let otherlist = [];
  1300. let userId = this.userId ? this.userId : '';
  1301. let houseData = {
  1302. "layoutId": curHouseObj.id,
  1303. "layoutName": curHouseObj.name,
  1304. "layoutArea": curHouseObj.houseArea,
  1305. "floor": 1,
  1306. "layoutImgCustomized": shottingImg,
  1307. "style": "",
  1308. "houseJson": []
  1309. }
  1310. // let mainImage = '';
  1311. // if(thirdData && thirdData.length>0){
  1312. // mainImage = thirdData[1] ? thirdData[1].hardboundEffect[0] : thirdData[0].hardboundEffect[0];
  1313. // }
  1314. houseData.houseJson = spaceList.concat(this.form.layoutStruct[0].houseJson);
  1315. // houseData.expand = expand;
  1316. let param = {
  1317. id:this.customizedRecordId,
  1318. "brandId": $config.brandId,
  1319. "houseId": this.houseId || curHouseObj.houseId,
  1320. "userId": userId,
  1321. "floot": 1,
  1322. "spaceName": curHouseObj.name,
  1323. "spaceStructure": '',
  1324. "curFloor":1,
  1325. layoutStruct:[houseData],
  1326. type:'QIANCE',
  1327. expand:this.form.expand,
  1328. // mainImage:this.form.mainImage,
  1329. }
  1330. if(this.landDataId){
  1331. param.landDataId = this.landDataId;
  1332. }
  1333. if(this.houseName){
  1334. param.houseName = this.houseName;
  1335. }
  1336. console.warn("submitHouse-update-param: ", param);
  1337. // setStorage('envData',checkIndexList);
  1338. const loading = this.$loading({
  1339. lock: true,
  1340. text: '提交中...',
  1341. spinner: 'el-icon-loading',
  1342. background: 'rgba(0, 0, 0, 0.7)'
  1343. });
  1344. let res = await requestConfig("saveCustomizedRecord", param);
  1345. loading.close();
  1346. if(res && res.success && res.single){//提交成功
  1347. let data = {
  1348. houseId:this.houseId || curHouseObj.houseId,
  1349. id:res.single,
  1350. }
  1351. wx.miniProgram.redirectTo({url: '/webgl/pages/webgl_rxdz_text_customize/webgl_rxdz_text_customize?id='+data.id+"&houseId="+this.houseId})
  1352. // router.push({
  1353. // name: "webgl_rxdz_text_customize",
  1354. // query:data
  1355. // });
  1356. }
  1357. },
  1358. showToast(title,time=3000){
  1359. this.myloading = false;
  1360. this.$store.state.loading = true;
  1361. this.$store.state.loadingMsg = title || "";
  1362. setTimeout(()=>{
  1363. this.$store.state.loading = false;
  1364. }, time);
  1365. }
  1366. }
  1367. }
  1368. </script>
  1369. <style lang="scss" scoped>
  1370. @import "./viewMask.scss";
  1371. </style>
  1372. <style lang="css" scoped>
  1373. /* @import "@/common/css/common.css"; */
  1374. </style>