viewPlot.vue 6.1 KB

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