viewAI.vue 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. <template src="./viewAI.html">
  2. </template>
  3. <script>
  4. const util = require('@/utils/util.js').default;
  5. import {
  6. MessageBox
  7. } from 'mint-ui';
  8. import {
  9. Indicator
  10. } from 'mint-ui';
  11. import {
  12. Toast
  13. } from 'mint-ui';
  14. import lottie from "lottie-web"; //lottie
  15. // import commonMethod from '@/common/commonMethod.js';
  16. // import touchHandle from '@/mixins/touchHandle.js';
  17. // import requestConfig from '@/static/lib/requestConfig';
  18. export default {
  19. data: function() {
  20. return {
  21. leftList: [],
  22. rightList: [],
  23. musicList: [], //音乐列表
  24. dataList: [],
  25. tabIndex: 0, //当前选中的tab序号
  26. selectIndex: -1,
  27. peopleIndex: -1,
  28. petIndex: -1,
  29. musicIndex: -1,
  30. specialIndex: 1,
  31. specialList:[
  32. {
  33. id:1,
  34. url:'https://dm.static.elab-plus.com/miniProgram/lottieJson/gold.json',
  35. title:'金光闪闪',
  36. },
  37. {
  38. id:2,
  39. url:'https://dm.static.elab-plus.com/miniProgram/lottieJson/fireworks.json',
  40. title:'烟花',
  41. },
  42. {
  43. id:3,
  44. url:'https://dm.static.elab-plus.com/miniProgram/lottieJson/coloreRibbon.json',
  45. title:'彩带',
  46. },
  47. ],
  48. hasRedBox:false, //是否添加了红包
  49. limit:20,
  50. videoId:'', //上传视频的id
  51. videoUrl:'', //处理好的视频地址
  52. progress:0, //进度条
  53. ktProgress:0, //抠图进度条
  54. showPersonView:false, //是否显示个人形象提示弹窗
  55. showPopView:false, //是否显示确认取消框
  56. uploadStatus:0, //视频处理的状态 0 未开始,1 上传中,2绿幕抠图中-服务端处理中,3处理成功 4 处理失败
  57. count:0, //结果请求次数
  58. timeOut:90000, //超时时间
  59. outTimer:null, //延时处理对象
  60. timer:null, //轮询对象
  61. widthHeight:'', //用户上传视频尺寸
  62. stopFlag:false, //停止上传动作
  63. cancelTokenSource:null, //取消上传的操作对象
  64. repeartFlag:false, //防止重复点击
  65. }
  66. },
  67. props: {
  68. relationId: {
  69. type: String,
  70. default: '',
  71. },
  72. amount: {
  73. type: String,
  74. default: '',
  75. },
  76. },
  77. watch: {
  78. relationId(newVal, oldVal) {
  79. if (newVal == null) {
  80. return;
  81. }
  82. console.log("当前空间数据relationId:", newVal);
  83. this.tabIndex = 2;//有红包时默认切换为红包
  84. if(!this.hasRedBox){
  85. setTimeout(()=>{
  86. this.addRedBox();//添加红包
  87. },500)
  88. this.$nextTick(() => {
  89. // 播放lottie动画
  90. lottie.destroy("markLoading");
  91. var element = document.getElementById("special-img");
  92. this.anim = lottie.loadAnimation({
  93. container: element,
  94. name: "markLoading",
  95. renderer: "svg",
  96. loop: true,
  97. autoplay: true,
  98. path: this.specialList[this.specialIndex].url, //动画json
  99. });
  100. });
  101. }
  102. // this.curSpaceArea = parseFloat(
  103. // (newVal.spaceWidth * newVal.spaceHeight) / 10000
  104. // ).toFixed(2);
  105. // this.getOverallArrangementDetailsList();
  106. },
  107. },
  108. // mixins: [touchHandle],
  109. async mounted() {
  110. // await this.getCityHouseList();
  111. console.warn("***viewAI***")
  112. Indicator.open('加载中...');
  113. this.getDatalist(0);
  114. this.getDatalist(1);
  115. this.getDatalist(3);
  116. // this.getRelationInfo();//获取场景信息
  117. },
  118. computed: {
  119. userId() {
  120. return this.$store.state.userId;
  121. },
  122. },
  123. // 页面被展示时执行
  124. onPageShow: function() {
  125. },
  126. //页面被隐藏时执行
  127. onPageHide: function() {
  128. // console.warn("***detached-hide***")
  129. },
  130. methods: {
  131. format(percentage) {
  132. let text = "上传中";
  133. if(this.uploadStatus==1){
  134. text = "上传中";
  135. }else if(this.uploadStatus==2){
  136. text = "抠图中";
  137. }
  138. return `${text}\n${percentage}%`;
  139. },
  140. resolveIndex(index) {
  141. this.selectIndex = index || 0;
  142. },
  143. catchTapEvent:function(){
  144. return false;
  145. },
  146. specialChange(index) {
  147. if (this.specialIndex == index) {
  148. return false;
  149. }
  150. this.specialIndex = index;
  151. this.$nextTick(() => {
  152. // 播放lottie动画
  153. lottie.destroy("markLoading");
  154. var element = document.getElementById("special-img");
  155. this.anim = lottie.loadAnimation({
  156. container: element,
  157. name: "markLoading",
  158. renderer: "svg",
  159. loop: true,
  160. autoplay: true,
  161. path: this.specialList[this.specialIndex].url, //动画json
  162. });
  163. });
  164. },
  165. tabChange(index) {
  166. if (this.tabIndex == index) {
  167. return false;
  168. }
  169. if (this.$parent.repeatFlag == true) {
  170. Toast({
  171. message: '加载中...请稍后再试',
  172. });
  173. return false
  174. }
  175. this.tabIndex = index;
  176. this.$emit("tabChange", this.tabIndex); //通知页面,户型大类发生了变更
  177. if(this.tabIndex==2 && this.specialIndex>-1){
  178. if(!this.hasRedBox){
  179. this.addRedBox();//添加红包
  180. }
  181. this.$nextTick(() => {
  182. // 播放lottie动画
  183. lottie.destroy("markLoading");
  184. var element = document.getElementById("special-img");
  185. this.anim = lottie.loadAnimation({
  186. container: element,
  187. name: "markLoading",
  188. renderer: "svg",
  189. loop: true,
  190. autoplay: true,
  191. path: this.specialList[this.specialIndex].url, //动画json
  192. });
  193. });
  194. }
  195. },
  196. initStatus(){
  197. this.progress = 0;
  198. this.ktProgress = 0;
  199. this.count = 0;
  200. this.videoUrl = '';
  201. this.widthHeight = '';
  202. this.leftList[0].icon = '';
  203. this.leftList[0].url = '';
  204. this.uploadStatus = 0;//处理完毕
  205. },
  206. uploadImgObj(e,form,type=1){
  207. this.stopFlag = false;//上传开始时,开启上传
  208. if(type==2){
  209. this.initStatus();//重置上传状态到初始值
  210. }
  211. //上传图片
  212. var file = e.target.files[0];
  213. var fileSize = file.size / 1024 / 1024;
  214. // alert('**文件**' + e.target.value + "-fileName=" + file.name);
  215. if (!/\.(MP4|mp4|MOV|mov)$/.test(e.target.value)) {
  216. this.$message.warning('文件类型必须是mp4或者mov');
  217. var videoForm = document.getElementById(form); //获取表单对象
  218. videoForm && videoForm.reset(); // 重置表单
  219. return false
  220. }
  221. if (fileSize > this.limit) {
  222. this.$message.warning('您的上传的视频过大,请低于' + this.limit + 'MB');
  223. var videoForm = document.getElementById(form); //获取表单对象
  224. videoForm && videoForm.reset(); // 重置表单
  225. return false
  226. }
  227. if (file.name.length > 100) {
  228. this.$message.warning('文件名过长,请不要超过100个字符');
  229. var videoForm = document.getElementById(form); //获取表单对象
  230. videoForm && videoForm.reset(); // 重置表单
  231. return false;
  232. }
  233. if(this.$parent.isIOS){//IOS则直接上传
  234. // let reader = new FileReader();
  235. // reader.onload = (event) => {
  236. // alert("onloadedmetadata0")
  237. // let video = document.getElementById('videoPlayer');
  238. // video.setAttribute("crossOrigin", "Anonymous");
  239. // video.src = event.target.result;
  240. // video.controls = false;
  241. // video.autoplay = true;
  242. // video.preload = 'auto';
  243. // video.setAttribute('webkit-playsinline', true);
  244. // video.setAttribute('playsinline', true);
  245. // video.load();
  246. // // video.play();
  247. // video.onloadedmetadata = (event) => {
  248. // alert("onloadedmetadata1")
  249. // if(!this.stopFlag){
  250. // var item = {};
  251. // item.file = file;
  252. // console.warn("***uploadImgObj***",file)
  253. // this.uploadMaterielFile(item, form); //正常上传图片
  254. // }
  255. // }
  256. // };
  257. // reader.readAsDataURL(file);
  258. if(!this.stopFlag){
  259. var item = {};
  260. item.file = file;
  261. console.warn("***uploadImgObj***",file)
  262. this.uploadMaterielFile(item, form); //正常上传图片
  263. }
  264. }else{//安卓
  265. let reader = new FileReader();
  266. reader.onload = (event) => {
  267. let video = document.createElement('video');
  268. video.onloadedmetadata = (event) => {
  269. let duration = video.duration;
  270. let width = video.videoWidth;
  271. let height = video.videoHeight;
  272. // this.videoWidth = width;
  273. // this.videoHeight = height;
  274. console.warn('视频时长:', duration,this.stopFlag);
  275. console.warn('视频尺寸:x:', width, 'y:', height);
  276. if (duration > 20) {
  277. this.$message.warning('您的上传的视频过长,请低于20s');
  278. var videoForm = document.getElementById(form); //获取表单对象
  279. videoForm && videoForm.reset(); // 重置表单
  280. return false
  281. }else{
  282. if(!this.stopFlag){
  283. var item = {};
  284. item.file = file;
  285. console.warn("***uploadImgObj***",file)
  286. this.uploadMaterielFile(item, form); //正常上传图片
  287. }
  288. }
  289. };
  290. video.src = event.target.result;
  291. };
  292. reader.readAsDataURL(file);
  293. }
  294. },
  295. //视频上传进度处理
  296. uploadProgress(e){
  297. this.progress = Math.round((e.loaded / e.total) * 100);//loaded已经加载的
  298. console.warn("***uploadProgress***",this.progress)
  299. },
  300. //显示弹窗提示框
  301. showPopViewHandle(){
  302. this.showPopView = true;//弹出确认框;
  303. },
  304. //取消上传
  305. cancel(cancelTokenSource){
  306. this.cancelTokenSource = cancelTokenSource;
  307. console.warn("***取消上传函数定义***")
  308. },
  309. //停止上传
  310. stopUpload(){
  311. this.showPopView = false;//弹出确认框;
  312. this.stopFlag = true;//停止上传标志打开
  313. if(this.uploadStatus == 1){
  314. this.cancelTokenSource.cancel('上传已取消');//通知取消上传
  315. Toast({
  316. message: '上传已取消',
  317. });
  318. }
  319. else if(this.uploadStatus==2 || this.uploadStatus==3){//绿幕抠图中 或者已经完成
  320. let data = {
  321. userId:this.userId,
  322. brandId: $config.brandId,
  323. processStatus:'canceled',
  324. virtualNo:this.videoId,
  325. }
  326. requestConfig('addUserVirtural', data);//停止该绿幕视频的使用
  327. this.initStatus();//还原初始状态
  328. }
  329. let data = {
  330. url:'https://dm.static.elab-plus.com/miniProgram/silhouette1.mp4',
  331. value:'个人形象',
  332. width:'',
  333. height:'',
  334. }
  335. this.aiPeopleChange(data, 'canel')
  336. this.peopleIndex = -1;
  337. },
  338. //获取用户上传的个人形象
  339. async getUserVirtural() {
  340. let data = {
  341. userId:this.userId,
  342. brandId: $config.brandId,
  343. processStatus:'completed',
  344. }
  345. let res = await requestConfig('getUserVirtural', data);//停止该绿幕视频的使用
  346. if (res.success && res.list && res.list[0]) {
  347. let data = res.list[res.list.length - 1];//获取最新的一个用户的个人形象数据
  348. this.leftList[0].icon = data.virtualBg;
  349. this.leftList[0].url = data.virtualUrl;
  350. this.videoUrl = data.virtualUrl;
  351. if(data.widthHeight){
  352. this.leftList[0].width = data.widthHeight.split('x')[0];
  353. this.leftList[0].height = data.widthHeight.split('x')[1];
  354. }
  355. }
  356. },
  357. async uploadMaterielFile(item, form) {
  358. this.uploadStatus = 0;
  359. this.peopleIndex = 0; //选中第一个
  360. if(this.stopFlag){
  361. return false;
  362. }
  363. var self = this;
  364. let formData = new FormData();
  365. formData.append('file', item.file);
  366. formData.append('brandId', $config.brandId);
  367. formData.append('userId', this.userId);
  368. console.warn("***uploadMaterielFile***");
  369. this.uploadStatus = 1;//上传中
  370. this.showPersonView = false;
  371. this.addSilhouette();//添加剪影视频
  372. let res = await requestConfig('robust_video', formData, true, false,'post',this.uploadProgress,this.cancel)
  373. if (axios.isCancel(res)) {//取消上传处理
  374. this.initStatus();//还原初始状态
  375. }else if (res.success && res.single) {
  376. this.videoId = res.single;//根据Id查询结果
  377. this.startInterval();//开始轮询获取结果
  378. }
  379. var videoForm = document.getElementById(form); //获取表单对象
  380. videoForm && videoForm.reset(); // 重置表单
  381. },
  382. async getVideoUrl() {
  383. if(this.stopFlag){
  384. this.stopInterval();
  385. }
  386. if(!this.videoId){
  387. Toast({
  388. message: '请先上传视频',
  389. });
  390. return false;
  391. }
  392. this.count = this.count + 1;
  393. let res = await requestConfig('get_result', {id:this.videoId,userId:this.userId}, true, false,'get')
  394. if(this.stopFlag){
  395. this.stopInterval();
  396. }
  397. if (res.success && res.single) {
  398. this.resultHandle(res.single)
  399. }else{
  400. this.videoUrl = "https://test.static.elab-plus.com/digital_human/f4c16cffae9711ee9853845cf3fb2826.mp4";//视频地址
  401. this.leftList[0].icon = this.videoUrl + "?vframe/jpg/offset/0";
  402. this.leftList[0].url = this.videoUrl;
  403. this.uploadStatus = 4;//处理失败
  404. }
  405. },
  406. //添加剪影视频
  407. addSilhouette(){
  408. let data = {
  409. url:'https://dm.static.elab-plus.com/miniProgram/silhouette1.mp4',
  410. value:'个人形象',
  411. width:'',
  412. height:'',
  413. }
  414. this.aiPeopleChange(data, 'add')
  415. },
  416. //添加用户绿幕视频
  417. addRealVideo(){
  418. let data = {
  419. url:this.videoUrl,
  420. value:'个人形象',
  421. width:this.widthHeight.split('x')[0],
  422. height:this.widthHeight.split('x')[1],
  423. }
  424. this.aiPeopleChange(data, 'add')
  425. },
  426. //上传结果处理
  427. resultHandle(single){
  428. if(!single){
  429. return false;
  430. }
  431. if(single.status=='completed' && single.output){//有结果
  432. this.ktProgress = 100;//抠图进度100%
  433. this.videoUrl = single.output;//视频地址
  434. // this.leftList[0].icon = this.videoUrl + "?vframe/jpg/offset/5";
  435. this.widthHeight = single.widthHeight; //"856x480"
  436. this.leftList[0].icon = single.virtualBg;
  437. this.leftList[0].url = this.videoUrl;
  438. this.leftList[0].width = single.widthHeight.split('x')[0],
  439. this.leftList[0].height = single.widthHeight.split('x')[1],
  440. this.uploadStatus = 3;//处理完毕
  441. // alert("***virtualBg***"+single.virtualBg);
  442. this.stopInterval();//停止轮询
  443. if(this.peopleIndex==0 && this.tabIndex==0){//如果当前在个人形象上,则替换视频
  444. this.addRealVideo();
  445. }
  446. }else{//没有结果
  447. let progress = single.progress;
  448. progress = progress.replace(this.videoId + ':','');
  449. let index = progress.indexOf("|");
  450. progress = progress.substr(0,index);
  451. console.warn("***抠图进度条***",progress);
  452. this.ktProgress = parseFloat(progress);//提取出来的进度条
  453. if(this.ktProgress>99){
  454. this.ktProgress = 99;
  455. }
  456. }
  457. },
  458. //开始生成AI图的轮询,每隔1s轮询一次
  459. startInterval() {
  460. if(this.timer){
  461. return false;
  462. }
  463. let self = this;
  464. this.count = 0;//轮询次数
  465. this.uploadStatus = 2;//绿幕抠图中
  466. this.getVideoUrl();//获取结果
  467. this.timer = setInterval(()=>{
  468. this.getVideoUrl();//获取结果
  469. },1000);//1秒轮询一次
  470. this.setOutTimer();//设置超时逻辑
  471. },
  472. //设置一个超时逻辑,到底指定时间后停止轮询,当前是90s
  473. setOutTimer() {
  474. var self = this;
  475. if (this.outTimer) {
  476. clearTimeout(this.outTimer)
  477. this.outTimer = null
  478. }
  479. this.outTimer = setTimeout(function() {
  480. if(!self.videoUrl){//没有结果
  481. MessageBox.confirm('',{
  482. title: '提示',
  483. message: '当前AI使用火爆,请继续尝试?',
  484. showCancelButton: true,
  485. confirmButtonText:'继续尝试',
  486. cancelButtonText:'取消等待',
  487. }).then(action => {
  488. console.warn("***MessageBox-action***",action)
  489. if(action == 'confirm'){
  490. // self.confirmHandle(1);
  491. }
  492. }).catch(err=>{
  493. console.warn("***MessageBox-err***",err)
  494. if(err == 'cancel'){
  495. // self.cancelHandle();
  496. }
  497. });
  498. // MessageBox.confirm('确定执行此操作?')
  499. }
  500. self.stopInterval();//停止轮询
  501. }, this.timeOut);
  502. },
  503. //停止轮询
  504. stopInterval() {
  505. if (this.timer) {
  506. clearInterval(this.timer);
  507. this.timer = null;
  508. }
  509. if (this.outTimer) {
  510. clearTimeout(this.outTimer)
  511. this.outTimer = null
  512. }
  513. // this.uploadStatus = 0;//回到初始上传状态
  514. },
  515. showMask(){
  516. //上传过程中,不允许再次上传
  517. if(this.uploadStatus==1 || this.uploadStatus == 2){
  518. return false;
  519. }
  520. this.showPersonView = true;
  521. console.warn("***showMask***",this.showPersonView)
  522. },
  523. //AI数字人切换
  524. selectAction(selItem, index) {
  525. console.log('点击动作111:', selItem, index,this.leftList)
  526. if (this.tabIndex == 0) {
  527. if(!this.leftList[index].url){
  528. return false
  529. }
  530. if (this.peopleIndex == index) { //取消选中
  531. this.aiPeopleChange(this.leftList[this.peopleIndex], 'canel')
  532. this.peopleIndex = -1;
  533. return false
  534. }
  535. } else if (this.tabIndex == 1) {
  536. if (this.petIndex == index) { //取消选中
  537. this.aiPeopleChange(this.rightList[this.petIndex], 'canel')
  538. this.petIndex = -1;
  539. return false
  540. }
  541. } else if (this.tabIndex == 3) {
  542. if (this.musicIndex == index) { //取消选中
  543. this.aiPeopleChange(this.musicList[this.musicIndex], 'canel')
  544. this.musicIndex = -1;
  545. return false
  546. }
  547. }
  548. if (this.$parent.repeatFlag == true) {
  549. Toast({
  550. message: '加载中...请稍后再试',
  551. });
  552. return false
  553. }
  554. if (this.tabIndex == 0) {
  555. this.peopleIndex = index;
  556. this.aiPeopleChange(this.leftList[this.peopleIndex], 'add')
  557. } else if (this.tabIndex == 1) {
  558. this.petIndex = index;
  559. this.aiPeopleChange(this.rightList[this.petIndex], 'add')
  560. } else if (this.tabIndex == 3) {
  561. this.musicIndex = index;
  562. this.aiPeopleChange(this.musicList[this.musicIndex], 'add')
  563. }
  564. },
  565. // // 获取场景信息
  566. // async getRelationInfo() {
  567. // if(!this.$parent.relationId){
  568. // return false;
  569. // }
  570. // var parmas = {
  571. // "relationId": this.$parent.relationId,
  572. // "brandId": $config.brandId,
  573. // }
  574. // let res = await requestConfig('getRelationInfo', parmas)
  575. // this.selectIndex = 0;
  576. // if (res && res.success) {
  577. // this.count = res.single.count;
  578. // }
  579. // },
  580. // 获取瀑布流数据
  581. async getDatalist(type) {
  582. let typeName = "Virtual_Human";
  583. if (type == 0) {
  584. typeName = "Virtual_Human";
  585. } else if (type == 1) {
  586. typeName = "Virtual_Pet";
  587. } else if (type == 3) {
  588. typeName = "Virtual_Music";
  589. Indicator.close();
  590. }
  591. var parmas = {
  592. "type": typeName,
  593. // "brandId": $config.brandId,
  594. }
  595. let res = await requestConfig('queryEnumList', parmas)
  596. this.selectIndex = 0;
  597. if (res && res.success && res.list) {
  598. let list = res.list;
  599. if (type == 0) {
  600. this.leftList.push({
  601. icon:'',
  602. userUpload:true,
  603. value:'',
  604. url:'',
  605. width:'',
  606. height:'',
  607. })
  608. this.leftList = this.leftList.concat(list);
  609. this.getUserVirtural();
  610. } else if (type == 1) {
  611. this.rightList = list;
  612. } else if (type == 3) {
  613. this.musicList = list;
  614. }
  615. }
  616. },
  617. catchTouchMove: function() {
  618. return false;
  619. },
  620. addRedBox(){//添加红包
  621. console.warn("***添加红包***")
  622. this.$emit("redBox",'add');
  623. this.hasRedBox = true;
  624. },
  625. removeRedBox(){//去除红包
  626. this.$emit("redBox",'canel');
  627. this.hasRedBox = false;
  628. },
  629. setRedBox(){
  630. this.$emit("setRedBox");
  631. },
  632. //AI数字人切换
  633. aiPeopleChange(item, type) {
  634. this.$emit("aiPeopleChange", item, type, this.tabIndex); //通知页面,AI数字人切换了
  635. },
  636. //发布全景
  637. mynavigateFuc(e) {
  638. if (e) {
  639. // if(this.hasRedBox){
  640. // if(!this.$parent.redBoxData.count){
  641. // Toast({
  642. // message: '请输入红包个数!',
  643. // });
  644. // return false;
  645. // }
  646. // if(!this.$parent.redBoxData.money){
  647. // Toast({
  648. // message: '请输入充值金额!',
  649. // });
  650. // return false;
  651. // }
  652. // }
  653. if(this.peopleIndex==0 && (this.uploadStatus ==1 || this.uploadStatus ==2)){
  654. Toast({
  655. message: '请在个人形象上传完成后发布!',
  656. });
  657. return false;
  658. }
  659. if(this.repeartFlag){
  660. return false;
  661. }
  662. this.repeartFlag = true;
  663. let param = {
  664. type: 'CLK', //埋点类型
  665. clkId: 'clk_2cmina_23121301', //点击ID
  666. clkName: 'webgl_public_clk', //点击前往的页面名称
  667. clkParams: {
  668. locusName: "720发布",
  669. }
  670. };
  671. util.trackRequest(param);
  672. let _ps = this.$parent.getPosition();
  673. if (window.__wxjs_environment === 'miniprogram') {
  674. let url = '/extraPackage/pages/aiPublishPage/aiPublishPage?houseId=' + (this.$route.query.houseId || '')
  675. url += '&bgUrl=' + encodeURIComponent(this.$parent.bgUrl)
  676. if(this.peopleIndex>-1){
  677. let people = {
  678. url:this.leftList[this.peopleIndex].url,
  679. ath:_ps.peopleAth,
  680. atv:_ps.peopleAtv,
  681. width:this.leftList[this.peopleIndex].width || '',
  682. height:this.leftList[this.peopleIndex].height || '',
  683. scale:this.$parent.peopleScale,
  684. userUpload:this.peopleIndex==0?true:false,//是否使用了个人形象
  685. }
  686. url += '&AIPeople=' + encodeURIComponent(JSON.stringify(people))
  687. }
  688. if(this.petIndex>-1){
  689. let pet = {
  690. url:this.rightList[this.petIndex].url,
  691. ath:_ps.petAth,
  692. atv:_ps.petAtv,
  693. scale:this.$parent.petScale,
  694. }
  695. url += '&AIPet=' + encodeURIComponent(JSON.stringify(pet))
  696. }
  697. if(this.musicIndex>-1){
  698. let music = {
  699. url:this.musicList[this.musicIndex].url,
  700. title:this.musicList[this.musicIndex].value
  701. };
  702. url += '&bgMusic=' + encodeURIComponent(JSON.stringify(music))
  703. }
  704. if(this.hasRedBox){
  705. let redBox = {
  706. url:'https://dm.static.elab-plus.com/miniProgram/redbox.mp4',
  707. ath:_ps.redBoxAth,
  708. atv:_ps.redBoxAtv,
  709. scale:1,
  710. lottieIndex:this.specialIndex,
  711. // count:this.$parent.redBoxData.count,
  712. // money:this.$parent.redBoxData.money,
  713. // message:this.$parent.redBoxData.message,
  714. }
  715. url += '&redBox=' + encodeURIComponent(JSON.stringify(redBox))
  716. }
  717. console.warn("data:", _ps, url);
  718. wx.miniProgram.navigateTo({
  719. url: url,
  720. complete:(e)=>{
  721. this.repeartFlag = false;
  722. }
  723. })
  724. } else {
  725. console.warn("data:", _ps)
  726. Toast({
  727. message: '敬请期待',
  728. });
  729. }
  730. }
  731. },
  732. }
  733. }
  734. </script>
  735. <style lang="scss" scoped>
  736. @import "./viewAI.scss";
  737. /* @import "@/common/css/common.css"; */
  738. </style>