viewCareful.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. <template src="./viewCareful.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 Bus from '@/common/bus';
  8. // import commonMethod from '@/common/commonMethod.js';
  9. // import requestConfig from '@/static/lib/requestConfig';
  10. // import bgLoading from "@/components/bgLoading/bgLoading.vue"
  11. // import { nextTick } from "vue";
  12. // const app = getApp(); //获取应用实例
  13. export default {
  14. data: function() {
  15. return {
  16. selectItem:null,
  17. carefulList:[],
  18. lastCareList:[],//上一次的滑块值
  19. selectIndex:0,
  20. }
  21. },
  22. props:{
  23. overChange: {//当前页面是否处在忙碌状态
  24. type: Boolean,
  25. default: false,
  26. },
  27. curHouseObj: {//当前展示的户型
  28. type: Object,
  29. default: () => {
  30. return null
  31. }
  32. },
  33. },
  34. watch: {
  35. curHouseObj: {
  36. handler(newVal,oldVal) {
  37. if (newVal) {
  38. console.warn("***curHouseObj-CHANGE-viewCareful***", newVal,oldVal)
  39. if(!oldVal || (oldVal && oldVal.id != newVal.id)){
  40. this.initData();
  41. }
  42. }
  43. },
  44. deep:true,
  45. },
  46. },
  47. mixins: [],
  48. async mounted() {//组件挂载时事件
  49. // this.initData();
  50. // var currPage = getCurrentPages()[getCurrentPages().length - 1] ? getCurrentPages()[getCurrentPages().length - 1].$vm : null;
  51. this.$parent.$parent.updateCareFul = this.initData;//页面注册变更方法
  52. },
  53. // 页面被展示时执行
  54. onPageShow: function() {
  55. },
  56. //页面被隐藏时执行
  57. onPageHide: function() {
  58. },
  59. methods:{
  60. //初始化数据
  61. initData(){
  62. // var currPage = getCurrentPages()[getCurrentPages().length - 1] ? getCurrentPages()[getCurrentPages().length - 1].$vm : null;
  63. this.carefulList = [];
  64. this.lastCareList = [];
  65. const spaceDetail = this.curHouseObj;
  66. const spaceList = JSON.parse(spaceDetail.houseJson);
  67. let result = 0;
  68. spaceList && spaceList.forEach((item,index)=>{
  69. let minArea = 0;
  70. let maxArea = 100;
  71. if(item.hasOwnProperty('spaceWidthMin') && item.hasOwnProperty('spaceHeightMin')){
  72. minArea = parseFloat((item.spaceWidthMin * item.spaceHeightMin) / 10000).toFixed(1);
  73. }
  74. if(item.hasOwnProperty('spaceWidthMax') && item.hasOwnProperty('spaceHeightMax')){
  75. maxArea = parseFloat((item.spaceWidthMax * item.spaceHeightMax) / 10000).toFixed(1);
  76. }
  77. //修改为显示空间类型名称
  78. let text = spaceTypes[item.spaceType - 1] || item.spaceName;
  79. if(item.spaceType==15 && item.layoutSpaceType){
  80. text = spaceTypes[item.layoutSpaceType - 1];
  81. }
  82. if(item.spaceName && !item.isSizeLock){//楼梯不显示
  83. let curSpaceArea = Number(parseFloat(
  84. (item.spaceWidth * item.spaceHeight) / 10000
  85. ).toFixed(1));
  86. let data = {
  87. spaceId:item.spaceId,
  88. index:this.carefulList.length,
  89. name:text,
  90. area:curSpaceArea,
  91. percent:0,
  92. minArea:parseFloat(minArea), //最小面积
  93. maxArea:parseFloat(maxArea), //最大面积
  94. }
  95. result = result + curSpaceArea;
  96. this.carefulList.push(data);
  97. this.lastCareList.push({
  98. spaceId:item.spaceId,
  99. index:this.carefulList.length,
  100. area:curSpaceArea,
  101. })
  102. }
  103. })
  104. // let result = this.carefulList.reduce((prev, cur)=>{
  105. //     return prev + parseFloat(cur.area);
  106. // },0);
  107. this.carefulList.forEach(it=>{
  108. if(!result){
  109. it.percent = 100;
  110. }else{
  111. it.percent = (parseFloat(it.area) / parseFloat(result)*100).toFixed(0);
  112. }
  113. // console.warn("***carefulList-change1***", it.area,it)
  114. })
  115. console.warn("***viewCareful-change***", this.carefulList)
  116. },
  117. updataData(spaceId,layoutObj){
  118. let lable = this.carefulList.find(it=>it.spaceId == spaceId);
  119. let name = spaceTypes[layoutObj.type - 1];
  120. lable.name = name;
  121. console.warn("***updataData***",lable)
  122. },
  123. sliderChanging(e,item) {
  124. // const wallValue = e.detail.value;
  125. // item.percent = 60;
  126. // console.warn("***sliderChanging***",item)
  127. // this.curWallMoveValue = Math.abs(this.curWallValue - wallValue);
  128. },
  129. sliderChange(e,index) {
  130. let value = e.detail?e.detail.value:e;
  131. let item = this.lastCareList[index];
  132. console.log("滑块值:", value,item);
  133. if(this.overChange){
  134. this.$message.warning("请慢一点!");
  135. return false;
  136. }
  137. this.selectIndex = index;
  138. this.$parent.$parent.selectSpaceId = item.spaceId;
  139. let _area = value - parseFloat(item.area);
  140. if(_area==0){
  141. return false;
  142. }
  143. let data = {
  144. spaceId:item.spaceId,
  145. area:Math.abs(_area),
  146. isZoomIn:_area>0?true:false,
  147. }
  148. let param = {
  149. type: 'CLK', //埋点类型
  150. clkId: 'clk_2cmina_23080405', //点击ID
  151. clkName: 'zoomin_clk', //点击前往的页面名称
  152. clkParams: {
  153. locusName: this.curHouseObj.houseType + "·" + this.curHouseObj.houseArea,
  154. locusValue:this.carefulList[index].name + "面积由" + parseFloat(item.area).toFixed(1)
  155. + "㎡调整为"+ value + "㎡",
  156. }
  157. };
  158. util.trackRequest(param);
  159. console.log("发送消息-空间变化: ",data, JSON.stringify(item));
  160. // this.selectItem = item;
  161. item.area = value;
  162. // var currPage = getCurrentPages()[getCurrentPages().length - 1] ? getCurrentPages()[getCurrentPages().length - 1].$vm : null;
  163. // this.sendMessageAction(JSON.stringify(parmas));
  164. this.$parent.$parent.callBackFun = this.callBack;//向父页面注册通知回调函数
  165. this.$emit("curSpaceChange",data);//通知父组件-空间面积变化
  166. },
  167. //去往详情页面
  168. goRoam(){
  169. let item = this.lastCareList[this.selectIndex];
  170. this.$parent.$parent.goRoam1(item.spaceId);
  171. let param = {
  172. type: 'CLK', //埋点类型
  173. clkId: 'clk_2cmina_24012901', //点击ID
  174. clkName: 'AI_clk', //点击前往的页面名称
  175. clkParams: {
  176. locusName: "AI精软装",
  177. carefulList:this.carefulList
  178. }
  179. };
  180. util.trackRequest(param);
  181. },
  182. callBack(type){
  183. console.warn("***callBack***",type)
  184. this.initData();
  185. this.$parent.$parent.callBackFun = null;//注销父页面的通知回调函数
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss" scoped>
  191. @import "./viewCareful.scss";
  192. /* @import "@/common/css/common.css"; */
  193. </style>