webgl_rxdz_houseList.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <template src="./webgl_rxdz_houseList.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 houseList from "../../components/houseList/houseList.vue";
  15. // import houseList2 from "../../components/houseList/houseList2.vue";
  16. export default {
  17. name: 'webgl_rxdz_houseList',
  18. data() {
  19. return {
  20. pvId: 'p_2cmina_24012401',
  21. locusBehaviorName: "空间偏好",
  22. locusValue: "",
  23. locusName: "",
  24. pvCurPageName: "space_set",
  25. pvCurPageParams: null,
  26. navbar: {
  27. showCapsule: 1,
  28. title: '空间偏好',
  29. titleColor: '#fff',
  30. navPadding: 0,
  31. navPaddingBg: 'transparent',
  32. navBarColor: 'transparent',
  33. navBackColor: 'transparent',
  34. haveCallback: false, // 如果是 true 会接手 navbarBackClk
  35. fromShare: false,
  36. fromProject: 0,
  37. shareToken: "",
  38. pageName: this.pvCurPageName,
  39. },
  40. id:'', //题目id
  41. houseId: 100296,
  42. houseList:[], //户型列表
  43. optionIndex: -1, //选项选中的序号
  44. tabData: [], //
  45. curHouseObj:null, //用户选择的户型
  46. selectIndex:-1, //用户选择的户型序号
  47. }
  48. },
  49. // components: {
  50. // houseList,
  51. // },
  52. watch: {},
  53. mounted(options) {
  54. console.log("***onLoad-webgl_rxdz_houseList***", this.$route.query)
  55. let queryObj = getStorage('queryObj') ? JSON.parse(getStorage('queryObj')) : null;
  56. this.id = this.$route.query.id2 ? this.$route.query.id2 : (queryObj && queryObj.id2?queryObj.id2:'110');
  57. this.findHouseTypeSpaceList();
  58. this.queryTestcaseSingle();
  59. document.title = this.navbar.title;
  60. },
  61. methods: {
  62. backFun() {
  63. uni.navigateBack({
  64. url: 'pages/groupIndex2/groupIndex2'
  65. })
  66. },
  67. // selectHouseObj(obj) {
  68. // console.log("户型", obj);
  69. // this.enterAction(obj, 0, 0);
  70. // },
  71. //切换选项
  72. changeOption(idx, idx1) {
  73. if (idx1 == this.tabData[idx].checkedIndex) {
  74. return false;
  75. }
  76. this.tabData[idx].checkedIndex = idx1;
  77. // console.warn("***changeOption***", this.tabData,this.allSelect)
  78. // let param = {
  79. // type: 'CLK', //埋点类型
  80. // clkId: 'clk_2cmina_24012401', //点击ID
  81. // clkName: 'option_clk', //点击前往的页面名称
  82. // clkParams: {
  83. // type: this.tabData[idx].options[idx1].content,
  84. // locusName: "选项选择",
  85. // }
  86. // };
  87. // util.trackRequest(param);
  88. this.submitAnswer(idx,idx1);
  89. },
  90. submitAnswer(tabIndex,optionIndex){
  91. let userId = this.userId || '';
  92. let params = {
  93. "answerContent": [
  94. {
  95. "optionTitle": this.tabData[tabIndex].options[optionIndex].content,
  96. "questionTitle": this.tabData[tabIndex].subContent,//问题标题
  97. "subOptionId": this.tabData[tabIndex].options[optionIndex].id,
  98. "subQuestionId": this.tabData[tabIndex].id,
  99. }
  100. ],
  101. brandId: $config.brandId,
  102. houseId: this.houseId,
  103. channel:this.$route.query.channel || '',
  104. city:this.$route.query.city || '',
  105. district:this.$route.query.district || '',
  106. province:this.$route.query.province || '',
  107. paperTitle:'',//试卷id
  108. testThemeId:'',
  109. testcaseId:this.id,
  110. uuid:userId,
  111. xcxCustomerId:userId,
  112. };
  113. requestConfig('submitAnswer', params,true);
  114. },
  115. changeHouse(item,index){
  116. this.curHouseObj = item;
  117. this.selectIndex = index;
  118. console.log("changeHouse: ", this.curHouseObj,this.selectIndex);
  119. let param = {
  120. type: 'CLK', //埋点类型
  121. clkId: 'clk_2cmina_24012401', //点击ID
  122. clkName: 'option_clk', //点击前往的页面名称
  123. clkParams: {
  124. houseType: item.houseType,
  125. name: item.name,
  126. note: item.note,
  127. area: item.houseArea,
  128. id: item.id,
  129. locusName: "空间选择",
  130. }
  131. };
  132. util.trackRequest(param);
  133. },
  134. //查询题目数据
  135. async queryTestcaseSingle() {
  136. let params = {
  137. id: this.id,
  138. brandId: $config.brandId,
  139. houseId: this.houseId,
  140. };
  141. const res = await requestConfig('queryTestcaseSingle', params);
  142. if (res.success) {
  143. let list = res.list;
  144. list.forEach(it => it.checkedIndex = -1); //增加当前题目用户选择的需要,默认不选中
  145. this.tabData = list;
  146. }
  147. },
  148. // 查询户型列表
  149. async findHouseTypeSpaceList() {
  150. // const { houseId, brandId } = getApp().globalData;
  151. var parmas = {
  152. brandId: 94,
  153. houseId: this.houseId,
  154. pageNo: 1,
  155. pageSize: 2000,
  156. isCloud: 1,
  157. };
  158. let res = await requestConfig("findHouseTypeSpaceList",parmas);
  159. if (res.success && res.pageModel) {
  160. let list = res.pageModel.resultSet || [];
  161. list && list.forEach((item,index)=>{
  162. if(item.houseJson){
  163. let spaceList = JSON.parse(item.houseJson);
  164. // 交换centerX, centerY
  165. for (let index = 0; index < spaceList.length; index++) {
  166. var element = spaceList[index];
  167. const {centerX, centerY} = element;
  168. element.centerX = centerY;
  169. element.centerY = centerX;
  170. }
  171. item.houseJson = JSON.stringify(spaceList);
  172. console.log("户型详情列表: ", spaceList);
  173. }
  174. })
  175. this.houseList = res.pageModel.resultSet || [];
  176. }
  177. },
  178. //进入下一步
  179. enterAction() {
  180. let index = this.tabData.findIndex(it=>it.checkedIndex==-1);
  181. if(index>-1){
  182. Toast({
  183. message: this.tabData[index].fatherContent + '选项不能为空',
  184. });
  185. return false;
  186. }
  187. if(!this.curHouseObj){
  188. Toast({
  189. message: '请选择喜欢的空间',
  190. });
  191. return false;
  192. }
  193. console.log("进入订制户型: ", this.curHouseObj);
  194. setStorage('curHouseObj', this.curHouseObj);
  195. this.$store.dispatch('setCurHouseObj', this.curHouseObj);
  196. let dataList = [
  197. {
  198. name:'户型偏好',
  199. selectOptionName:this.houseList[this.selectIndex].houseType || '',
  200. selectOptionImageUrl:'',
  201. }
  202. ];
  203. this.tabData.forEach(tab=>{
  204. let _dt = {
  205. name:tab.fatherContent,
  206. selectOptionName:tab.options[tab.checkedIndex].content || '',
  207. selectOptionImageUrl:tab.options[tab.checkedIndex].imageUrl || '',
  208. }
  209. dataList.push(_dt);
  210. })
  211. setStorage('secondData', dataList);//把第一步选择的数据存入本地缓存里面,方便后续使用
  212. let data = {
  213. houseId:this.houseId,
  214. }
  215. router.push({
  216. name: "webgl_rxdz_test",
  217. query:data
  218. });
  219. },
  220. }
  221. }
  222. </script>
  223. <style lang="scss" scoped>
  224. @import "./webgl_rxdz_houseList.scss";
  225. </style>