webgl_rxdz_env.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template src="./webgl_rxdz_env.html">
  2. </template>
  3. <script>
  4. const util = require('@/utils/util.js').default;
  5. const config = require('@/services/urlConfig.js');
  6. import router from "@/router";
  7. import {
  8. setStorage,
  9. getStorage,
  10. } from '@/utils/localStorage';
  11. import {
  12. Toast
  13. } from 'mint-ui';
  14. import touchHandle from '@/mixins/touchHandle.js';
  15. import createImgHandle from '@/mixins/createImgHandle.js';
  16. import commonPageMethod from '@/mixins/commonPageMethod.js';
  17. // const app = getApp(); //获取应用实例
  18. // import requestConfig from '@/static/lib/requestConfig.js';
  19. // import commonPageMethod from '@/common/commonPageMethod.js';
  20. // import commonMethod from '@/common/commonMethod.js';
  21. export default {
  22. mixins: [touchHandle, commonPageMethod,createImgHandle],
  23. /**
  24. * 页面的初始数据
  25. */
  26. data() {
  27. return {
  28. pvId: 'p_2cmina_21012501',
  29. locusBehaviorName: "环境偏好",
  30. locusValue: "",
  31. locusName: "",
  32. pvCurPageName: "role_set",
  33. pvCurPageParams: null,
  34. navbar: {
  35. showCapsule: 1,
  36. title: '环境偏好',
  37. titleColor: '#fff',
  38. navPadding: 0,
  39. navPaddingBg: 'transparent',
  40. navBarColor: 'transparent',
  41. navBackColor: 'transparent',
  42. haveCallback: false, // 如果是 true 会接手 navbarBackClk
  43. fromShare: false,
  44. fromProject: 0,
  45. shareToken: "",
  46. pageName: this.pvCurPageName,
  47. },
  48. houseId: $config.houseIdHs,
  49. id: '', //题目
  50. allSelect:false,//是否所有大类都选择了
  51. currentIndex: 0,
  52. // featureImgList: [],
  53. showPhoneModel: false,
  54. tabIndex: 0, //当前在第几个tab
  55. optionIndex: -1, //选项选中的序号
  56. options: [], //选项数据
  57. aiImagesList: [], //角色数据,单独
  58. AIImg:'', //AI生成所需要的垫图
  59. tabData: [],
  60. checked:false, //是否喜欢
  61. subDataList:[], //提交的数据对象
  62. }
  63. },
  64. /**
  65. * 生命周期函数--监听页面加载
  66. */
  67. mounted(options) {
  68. console.log("***onLoad-webgl_rxdz_customize***", this.$route.query)
  69. const that = this;
  70. this.houseId = this.$route.query.houseId ? this.$route.query.houseId : '';
  71. // this.spaceId = this.$route.query.spaceId?this.$route.query.spaceId:'';
  72. this.id = this.$route.query.id ? this.$route.query.id : '111';
  73. this.queryTestcaseSingle();
  74. },
  75. computed: {
  76. userId() {
  77. return this.$store.state.userId;
  78. },
  79. },
  80. methods: {
  81. swiperChangeImg(e) {
  82. console.log("***swiperChangeImg***", e);
  83. this.currentIndex = e.detail ? e.detail.current : e;
  84. this.checked = this.aiImagesList[this.currentIndex].checked;
  85. // this.optionIndex = this.currentIndex;
  86. // this.tabData[0].checkedIndex = this.currentIndex;
  87. },
  88. rightScroll() { //右滑
  89. if (this.currentIndex <= (this.aiImagesList.length - 1) && this.currentIndex > 0) {
  90. this.$refs.carousel.prev();
  91. }
  92. },
  93. leftScroll() { //继续生成
  94. console.log("***leftScroll***", this.currentIndex,this.aiImagesList.length);
  95. if (this.currentIndex != this.aiImagesList.length - 1) {
  96. if (this.currentIndex < this.aiImagesList.length - 1) {
  97. this.$refs.carousel.next();
  98. }
  99. return false;
  100. }
  101. // console.log("***leftScroll***",this.currentIndex,this.aiImagesList.length)
  102. let obj = {
  103. imgUrl:this.AIImg,
  104. prompt:this.options[this.optionIndex].remark,
  105. negativePrompt:this.options[this.optionIndex].tips,
  106. tabIndex:this.tabIndex,
  107. optionIndex:this.optionIndex,
  108. }
  109. this.startServer(obj);//继续生成下一张
  110. },
  111. //点赞喜欢
  112. changeAIImg() {
  113. // let lastPage = getCurrentPages()[getCurrentPages().length - 2] ? getCurrentPages()[getCurrentPages().length - 2].$vm : null;
  114. this.checked = !this.checked;//变更选项
  115. this.aiImagesList[this.currentIndex].checked = this.checked;
  116. console.warn("***changeAIImg***",this.checked)
  117. let img = this.aiImagesList[this.currentIndex].imageUrl;
  118. let obj = this.options[this.optionIndex].hardboundEffect.find(it=>it.imageUrl==img);
  119. if(obj){
  120. obj.checked = this.checked;
  121. }
  122. },
  123. //查询题目数据
  124. async queryTestcaseSingle() {
  125. let userId = this.userId || '';
  126. let params = {
  127. id: this.id,
  128. brandId: $config.brandId,
  129. houseId: this.houseId,
  130. userId,
  131. };
  132. // params.userId = this.userId;
  133. const res = await requestConfig('queryTestcaseSingle', params);
  134. if (res.success) {
  135. let list = res.list;
  136. list.forEach(it => {
  137. it.checkedIndex = -1;////增加当前题目用户选择的需要,默认不选中
  138. it.options.forEach(option=>{
  139. option.hardboundEffect = [
  140. {
  141. imageUrl :option.imageUrl,
  142. type:'system',//人为添加的
  143. }
  144. ];//AI生成图存放对象
  145. })
  146. });
  147. // this.tabIndex = 0;
  148. this.tabData = list;
  149. this.tabData[0].checkedIndex = 0;
  150. this.optionIndex = 0;
  151. this.options = this.tabData[0].options; //选项数据
  152. this.AIImg = this.tabData[0].options[0].imageUrl;//AI生成所需的垫图
  153. this.aiImagesList = this.tabData[0].options[0].hardboundEffect;
  154. this.submitAnswer()
  155. //初始化待提交的数据对象
  156. // list.forEach(it=>{
  157. // let obj = {
  158. // fatherContent:it.fatherContent,
  159. // name:it.fatherContent,
  160. // houseId:it.houseId,
  161. // houseName:it.houseName,
  162. // id:it.id,
  163. // hardboundEffect:[]
  164. // }
  165. // this.subDataList.push(obj);
  166. // });
  167. }
  168. },
  169. //切换大类
  170. changeTab(id) {
  171. if (id == this.tabIndex) {
  172. return
  173. }
  174. this.tabIndex = id;
  175. this.options = this.tabData[this.tabIndex].options; //选项数据
  176. this.optionIndex = this.tabData[this.tabIndex].checkedIndex; //获取用户已经选中的选项
  177. let param = {
  178. type: 'CLK', //埋点类型
  179. clkId: 'clk_2cmina_24012601', //点击ID
  180. clkName: 'tab_clk', //点击前往的页面名称
  181. clkParams: {
  182. type: this.tabData[this.tabIndex].fatherContent,
  183. locusName: "大类选择",
  184. }
  185. };
  186. util.trackRequest(param);
  187. },
  188. //切换选项
  189. changeOption(id) {
  190. if (id == this.optionIndex) {
  191. return false;
  192. }
  193. this.optionIndex = id;
  194. this.tabData[this.tabIndex].checkedIndex = this.optionIndex;
  195. // if (this.tabIndex == 0) { //当前为角色时,则需要同步变更上面的
  196. // this.currentIndex = id;
  197. // this.$refs.carousel.setActiveItem(this.currentIndex);
  198. // }
  199. this.allSelect = !this.tabData.some(it=>it.checkedIndex==-1);
  200. this.AIImg = this.options[this.optionIndex].imageUrl;//AI生成图的垫图
  201. //替换对应的队列为选中的选项的数组对象
  202. this.aiImagesList = this.options[this.optionIndex].hardboundEffect;
  203. console.warn("***changeOption***", this.tabData,this.AIImg,this.subDataList)
  204. // let param = {
  205. // type: 'CLK', //埋点类型
  206. // clkId: 'clk_2cmina_24012602', //点击ID
  207. // clkName: 'option_clk', //点击前往的页面名称
  208. // clkParams: {
  209. // type: this.options[this.optionIndex].content,
  210. // locusName: "选项选择",
  211. // }
  212. // };
  213. // util.trackRequest(param);
  214. this.submitAnswer()
  215. },
  216. submitAnswer(){
  217. let userId = this.userId || '';
  218. let params = {
  219. "answerContent": [
  220. {
  221. "optionTitle": this.options[this.optionIndex].content,
  222. "questionTitle": this.tabData[this.tabIndex].subContent,//问题标题
  223. "subOptionId": this.options[this.optionIndex].id,
  224. "subQuestionId": this.tabData[this.tabIndex].id,
  225. }
  226. ],
  227. brandId: $config.brandId,
  228. houseId: this.houseId,
  229. channel:this.$route.query.channel || '',
  230. city:this.$route.query.city || '',
  231. district:this.$route.query.district || '',
  232. province:this.$route.query.province || '',
  233. paperTitle:'',//试卷id
  234. testThemeId:'',
  235. testcaseId:this.id,
  236. uuid:userId,
  237. xcxCustomerId:userId,
  238. };
  239. requestConfig('submitAnswer', params,true);
  240. },
  241. catchTouchMove: function() {
  242. return false;
  243. },
  244. //提交结果数据处理
  245. async resultDataHandle(){
  246. let firstData = JSON.parse(getStorage('firstData'));
  247. let secondData = JSON.parse(getStorage('secondData'));
  248. let curHouseObj = JSON.parse(getStorage('curHouseObj'));
  249. let spaceList = JSON.parse(getStorage('spaceList'));
  250. let shottingImg = getStorage('shottingImg');
  251. let expand = [];//扩展数据
  252. let otherlist = [];
  253. let userId = this.userId ? this.userId : '';
  254. let houseData = {
  255. "layoutId": curHouseObj.id,
  256. "layoutName": curHouseObj.name,
  257. "layoutArea": curHouseObj.houseArea,
  258. "floor": 1,
  259. "layoutImgCustomized": shottingImg,
  260. "style": "",
  261. "houseJson": []
  262. }
  263. secondData.forEach(it=>{
  264. let _dt = {
  265. name:it.name,
  266. value:it.selectOptionName,
  267. }
  268. expand.push(_dt);
  269. })
  270. this.tabData.forEach(tab=>{
  271. let list = tab.options[tab.checkedIndex].hardboundEffect.filter(it=>it.checked==true);//过滤选中的
  272. list = list.map(it=>{
  273. return it.imageUrl
  274. })
  275. let obj = tab.options[tab.checkedIndex];
  276. let data = {
  277. spaceName:tab.fatherName,
  278. spaceId:'',
  279. hardboundEffect:(list && list.length>0)?list:[obj.imageUrl],
  280. }
  281. otherlist.push(data);
  282. expand.push({
  283. name:tab.fatherName,
  284. value:obj.content,
  285. });
  286. })
  287. houseData.houseJson = spaceList.concat(otherlist);
  288. // houseData.expand = expand;
  289. let param = {
  290. "brandId": $config.brandId,
  291. "houseId": curHouseObj.houseId,
  292. "userId": userId,
  293. "floot": 1,
  294. "spaceName": curHouseObj.name,
  295. "spaceStructure": '',
  296. "curFloor":1,
  297. layoutStruct:[houseData],
  298. type:'QIANCE',
  299. expand:JSON.stringify(expand),
  300. }
  301. console.warn("submitHouse-param: ", param);
  302. const loading = this.$loading({
  303. lock: true,
  304. text: '提交中...',
  305. spinner: 'el-icon-loading',
  306. background: 'rgba(0, 0, 0, 0.7)'
  307. });
  308. let res = await requestConfig("saveCustomizedRecord", param);
  309. loading.close();
  310. if(res && res.success && res.single){//提交成功
  311. let data = {
  312. houseId:this.houseId,
  313. id:res.single,
  314. }
  315. router.push({
  316. name: "webgl_rxdz_text_customize",
  317. query:data
  318. });
  319. }
  320. },
  321. submit() {
  322. let index = this.tabData.findIndex(it=>it.checkedIndex==-1);
  323. if(index>-1){
  324. Toast({
  325. message: this.tabData[index].fatherContent + '选项不能为空',
  326. });
  327. return false;
  328. }
  329. this.resultDataHandle();
  330. // console.log("进入订制户型: ", this.curHouseObj);
  331. // setStorage('curHouseObj', this.curHouseObj);
  332. // this.$store.dispatch('setCurHouseObj', this.curHouseObj);
  333. // let data = {
  334. // houseId:this.houseId,
  335. // }
  336. // router.push({
  337. // name: "webgl_rxdz_houseList",
  338. // query:data
  339. // });
  340. // let param = {
  341. // type: 'CLK', //埋点类型
  342. // clkId: 'clk_2cmina_24012303', //点击ID
  343. // clkName: 'confirm_clk', //点击前往的页面名称
  344. // clkParams: {
  345. // locusName: "确定个人偏好",
  346. // }
  347. // };
  348. // util.trackRequest(param);
  349. },
  350. }
  351. }
  352. </script>
  353. <style lang="scss" scoped>
  354. @import "./webgl_rxdz_env.scss";
  355. </style>