viewPlot.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template src="./viewPlot.html">
  2. </template>
  3. <script>
  4. const util = require('@/utils/util.js').default;
  5. const config = require('@/services/urlConfig.js');
  6. import spaceTypes from '@/static/spaceTypesIE.js';
  7. import {
  8. Toast
  9. } from 'mint-ui';
  10. import {
  11. getStorage,
  12. } from '@/utils/localStorage';
  13. // import Bus from '@/common/bus';
  14. // import commonMethod from '@/common/commonMethod.js';
  15. // import requestConfig from '@/static/lib/requestConfig';
  16. // import bgLoading from "@/components/bgLoading/bgLoading.vue"
  17. // import { nextTick } from "vue";
  18. // const app = getApp(); //获取应用实例
  19. export default {
  20. data: function() {
  21. return {
  22. selectItem:null,
  23. selectIndex:0,
  24. tabIndex:0,
  25. lastTabIndex:0,
  26. plotList:[],//布局数据
  27. curHouseObj:null,
  28. spaceList:[],
  29. }
  30. },
  31. props:{
  32. overChange: {//当前页面是否处在忙碌状态
  33. type: Boolean,
  34. default: false,
  35. },
  36. },
  37. watch: {
  38. curSpaceId: {
  39. handler(newVal,oldVal) {
  40. if (newVal) {
  41. console.warn("***curSpaceId-CHANGE-viewPlot***", newVal,oldVal)
  42. // this.initData();
  43. }
  44. },
  45. },
  46. },
  47. computed: {
  48. curSpaceId() {
  49. return this.$store.state.curSpaceId;
  50. },
  51. },
  52. mixins: [],
  53. async mounted() {//组件挂载时事件
  54. this.curHouseObj = JSON.parse(getStorage('curHouseObj'));
  55. let spaceDetail = this.curHouseObj;
  56. let spaceList = JSON.parse(spaceDetail.houseJson);
  57. this.spaceList = spaceList;
  58. // this.initData();
  59. // var currPage = getCurrentPages()[getCurrentPages().length - 1] ? getCurrentPages()[getCurrentPages().length - 1].$vm : null;
  60. // this.$parent.$parent.updateCareFul = this.initData;//页面注册变更方法
  61. },
  62. // 页面被展示时执行
  63. onPageShow: function() {
  64. },
  65. //页面被隐藏时执行
  66. onPageHide: function() {
  67. },
  68. methods:{
  69. //初始化数据
  70. initData(){
  71. // var currPage = getCurrentPages()[getCurrentPages().length - 1] ? getCurrentPages()[getCurrentPages().length - 1].$vm : null;
  72. console.warn("***initData***",this.spaceList)
  73. const spaceDetail = this.spaceList.find(it=>it.spaceId == this.curSpaceId);
  74. this.selectSpace = spaceDetail;
  75. if(spaceDetail.layouts){
  76. this.getOverallArrangementDetailsList(spaceDetail.layouts);
  77. }
  78. // console.warn("***viewCareful-change***", this.carefulList)
  79. },
  80. async getOverallArrangementDetailsList(layouts) {
  81. // 设置空间数组的墙体信息
  82. // this.setSpaceListWallInfo();
  83. let arr = layouts.map(it => it.layoutId).filter(it => it != 0);
  84. let parmas = {
  85. ids: arr,
  86. };
  87. // 获取布局信息
  88. let res = await requestConfig("getOverallArrangementDetailsList", parmas);
  89. if (!res.success || !res.list || res.list.length == 0) {
  90. return false;
  91. }
  92. this.tabIndex = 0;
  93. this.plotList = [];
  94. let list = res.list;
  95. list.forEach(item=>{
  96. //布局列表当中不存在当前布局的类型
  97. let data = this.plotList.find(it=>it.type==item.type);
  98. if(!data){
  99. let _d0 = {
  100. type:item.type,
  101. name:spaceTypes[item.type - 1],
  102. count:1,
  103. dataList:[item],
  104. }
  105. this.plotList.push(_d0);
  106. }else{
  107. data.count ++;
  108. data.dataList.push(item);
  109. }
  110. if(item.id==this.selectSpace.layoutId){
  111. this.tabIndex = this.plotList.length - 1;
  112. this.selectIndex = this.plotList[this.tabIndex].dataList.length - 1;
  113. this.lastTabIndex = this.tabIndex;
  114. }
  115. });
  116. console.warn("***viewPlot***", this.plotList)
  117. },
  118. //切换选项
  119. changeOption(id) {
  120. if (id == this.selectIndex) {
  121. return false;
  122. }
  123. this.selectIndex = id;
  124. // this.plotList[this.tabIndex].checkedIndex = this.optionIndex;
  125. // if (this.tabIndex == 0) { //当前为角色时,则需要同步变更上面的
  126. // this.currImgIdx = id;
  127. // this.$refs.carousel.setActiveItem(this.currImgIdx);
  128. // }
  129. console.warn("***changeOption***", this.plotList,this.selectIndex)
  130. },
  131. closeHandle(){
  132. this.$parent.rebackLast();//告知页面,关闭当前弹窗
  133. },
  134. confirm(){
  135. if(!this.plotList || this.plotList.length==0){
  136. Toast({
  137. message: '没有布局,不能切换',
  138. });
  139. return false
  140. }
  141. if(this.selectIndex<0 || this.tabIndex<0){
  142. Toast({
  143. message: '请选择具体的布局',
  144. });
  145. return false
  146. }
  147. let plot = this.plotList[this.tabIndex].dataList[this.selectIndex];
  148. if(!plot){
  149. Toast({
  150. message: '请选择具体的布局',
  151. });
  152. return false
  153. }
  154. let typeName = this.plotList[this.lastTabIndex].name;
  155. let newTypeName = this.plotList[this.tabIndex].name;
  156. let optionName = this.plotList[this.tabIndex].dataList[this.selectIndex].name;
  157. let param = {
  158. type: 'CLK', //埋点类型
  159. clkId: 'clk_2cmina_24012302', //点击ID
  160. clkName: 'option_clk', //点击前往的页面名称
  161. clkParams: {
  162. locusName: this.curHouseObj.houseType + "·" + this.curHouseObj.houseArea + " " + this.curHouseObj.note,
  163. locusValue: typeName + "调整为" + newTypeName + "-" + optionName,
  164. }
  165. };
  166. util.trackRequest(param);
  167. this.$parent.$parent.userSelectPlot(plot,this.selectSpace);//告知页面,用户选择的布局id
  168. this.lastTabIndex = this.tabIndex;
  169. },
  170. //去往详情页面
  171. goRoam(){
  172. let item = this.lastCareList[this.selectIndex];
  173. this.$parent.$parent.goRoam1(item.spaceId);
  174. },
  175. callBack(type){
  176. console.warn("***callBack***",type)
  177. this.initData();
  178. this.$parent.$parent.callBackFun = null;//注销父页面的通知回调函数
  179. }
  180. }
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. @import "./viewPlot.scss";
  185. /* @import "@/common/css/common.css"; */
  186. </style>