webgl_rxdz_role.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. <template src="./webgl_rxdz_role.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 commonPageMethod from '@/mixins/commonPageMethod.js';
  16. // const app = getApp(); //获取应用实例
  17. // import requestConfig from '@/static/lib/requestConfig.js';
  18. // import commonPageMethod from '@/common/commonPageMethod.js';
  19. // import commonMethod from '@/common/commonMethod.js';
  20. export default {
  21. mixins: [touchHandle, commonPageMethod],
  22. /**
  23. * 页面的初始数据
  24. */
  25. data() {
  26. return {
  27. pvId: 'p_2cmina_21012301',
  28. locusBehaviorName: "角色偏好",
  29. locusValue: "",
  30. locusName: "",
  31. pvCurPageName: "role_set",
  32. pvCurPageParams: null,
  33. navbar: {
  34. showCapsule: 1,
  35. title: '角色偏好',
  36. titleColor: '#fff',
  37. navPadding: 0,
  38. navPaddingBg: 'transparent',
  39. navBarColor: 'transparent',
  40. navBackColor: 'transparent',
  41. haveCallback: false, // 如果是 true 会接手 navbarBackClk
  42. fromShare: false,
  43. fromProject: 0,
  44. shareToken: "",
  45. pageName: this.pvCurPageName,
  46. },
  47. houseId: $config.houseIdHs,
  48. id: '', //方案库id
  49. allSelect:false,//是否所有大类都选择了
  50. currImgIdx: 0,
  51. // featureImgList: [],
  52. showPhoneModel: false,
  53. tabIndex: 0, //当前在第几个tab
  54. optionIndex: -1, //选项选中的序号
  55. options: [], //选项数据
  56. roleList: [], //角色数据,单独
  57. tabData: [
  58. // {
  59. // id: 1,
  60. // fatherContent: '选择角色',
  61. // checkedIndex: -1, //当前选中的序号
  62. // subName: '选择你的人物角色',
  63. // options: [{
  64. // id: 1,
  65. // text: '- 爱生活 -',
  66. // content: '角色',
  67. // imageUrl: 'https://dm.static.elab-plus.com/miniProgram/role/timg17.png',
  68. // },
  69. // {
  70. // id: 2,
  71. // text: '- 爱时尚 -',
  72. // content: '角色',
  73. // imageUrl: 'https://dm.static.elab-plus.com/miniProgram/role/demo2.jpg',
  74. // }
  75. // ],
  76. // },
  77. ],
  78. }
  79. },
  80. /**
  81. * 生命周期函数--监听页面加载
  82. */
  83. mounted(options) {
  84. console.log("***onLoad-webgl_rxdz_customize***", this.$route.query)
  85. const that = this;
  86. this.houseId = this.$route.query.houseId ? this.$route.query.houseId : '';
  87. // this.spaceId = this.$route.query.spaceId?this.$route.query.spaceId:'';
  88. this.id = this.$route.query.id ? this.$route.query.id : '109';
  89. this.queryTestcaseSingle();
  90. },
  91. computed: {
  92. userId() {
  93. return this.$store.state.userId;
  94. },
  95. },
  96. methods: {
  97. swiperChangeImg(e) {
  98. console.log("***swiperChangeImg***", e);
  99. this.currImgIdx = e.detail ? e.detail.current : e;
  100. // this.optionIndex = this.currImgIdx;
  101. // this.tabData[0].checkedIndex = this.currImgIdx;
  102. },
  103. rightScroll() { //右滑
  104. if (this.currImgIdx <= (this.roleList.length - 1) && this.currImgIdx > 0) {
  105. this.$refs.carousel.prev();
  106. }
  107. },
  108. leftScroll() { //继续生成
  109. if (this.currImgIdx != this.roleList.length - 1) {
  110. if (this.currImgIdx < this.roleList.length - 1) {
  111. this.$refs.carousel.next();
  112. }
  113. }
  114. },
  115. //查询题目数据
  116. async queryTestcaseSingle() {
  117. let userId = this.userId || '';
  118. let params = {
  119. id: this.id,
  120. brandId: $config.brandId,
  121. houseId: this.houseId,
  122. userId,
  123. };
  124. // params.userId = this.userId;
  125. const res = await requestConfig('queryTestcaseSingle', params);
  126. if (res.success) {
  127. let list = res.list;
  128. list.forEach(it => it.checkedIndex = -1); //增加当前题目用户选择的需要,默认不选中
  129. this.tabIndex = 0;
  130. this.tabData = list;
  131. this.options = this.tabData[0].options; //选项数据
  132. this.roleList = this.tabData[0].options; //单独获取角色数据
  133. }
  134. },
  135. //切换大类
  136. changeTab(id) {
  137. if (id == this.tabIndex) {
  138. return
  139. }
  140. this.tabIndex = id;
  141. this.options = this.tabData[this.tabIndex].options; //选项数据
  142. this.optionIndex = this.tabData[this.tabIndex].checkedIndex; //获取用户已经选中的选项
  143. let param = {
  144. type: 'CLK', //埋点类型
  145. clkId: 'clk_2cmina_24012301', //点击ID
  146. clkName: 'tab_clk', //点击前往的页面名称
  147. clkParams: {
  148. type: this.tabData[this.tabIndex].fatherContent,
  149. locusName: "大类选择",
  150. }
  151. };
  152. util.trackRequest(param);
  153. },
  154. //切换选项
  155. changeOption(id) {
  156. if (id == this.optionIndex) {
  157. return false;
  158. }
  159. this.optionIndex = id;
  160. this.tabData[this.tabIndex].checkedIndex = this.optionIndex;
  161. if (this.tabIndex == 0) { //当前为角色时,则需要同步变更上面的
  162. this.currImgIdx = id;
  163. this.$refs.carousel.setActiveItem(this.currImgIdx);
  164. }
  165. this.allSelect = !this.tabData.some(it=>it.checkedIndex==-1);
  166. console.warn("***changeOption***", this.tabData,this.allSelect)
  167. let param = {
  168. type: 'CLK', //埋点类型
  169. clkId: 'clk_2cmina_24012302', //点击ID
  170. clkName: 'option_clk', //点击前往的页面名称
  171. clkParams: {
  172. type: this.options[this.optionIndex].content,
  173. locusName: "选项选择",
  174. }
  175. };
  176. util.trackRequest(param);
  177. },
  178. catchTouchMove: function() {
  179. return false;
  180. },
  181. toMode() {
  182. let index = this.tabData.findIndex(it=>it.checkedIndex==-1);
  183. if(index>-1){
  184. Toast({
  185. message: this.tabData[index].fatherContent + '选项不能为空',
  186. });
  187. return false;
  188. }
  189. // console.log("进入订制户型: ", this.curHouseObj);
  190. // setStorage('curHouseObj', this.curHouseObj);
  191. // this.$store.dispatch('setCurHouseObj', this.curHouseObj);
  192. let data = {
  193. houseId:this.houseId,
  194. }
  195. router.push({
  196. name: "webgl_rxdz_houseList",
  197. query:data
  198. });
  199. // let data = {
  200. // houseId:this.houseId,
  201. // id:this.id,
  202. // }
  203. // router.push({
  204. // name: "webgl_rxdz_look",
  205. // query:data
  206. // });
  207. let param = {
  208. type: 'CLK', //埋点类型
  209. clkId: 'clk_2cmina_24012303', //点击ID
  210. clkName: 'confirm_clk', //点击前往的页面名称
  211. clkParams: {
  212. locusName: "确定个人偏好",
  213. }
  214. };
  215. util.trackRequest(param);
  216. },
  217. }
  218. }
  219. </script>
  220. <style lang="scss" scoped>
  221. @import "./webgl_rxdz_role.scss";
  222. </style>