viewlayout.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template src="./viewlayout.html">
  2. </template>
  3. <script>
  4. // const util = require('@/static/utils/util.js');
  5. const config = require('@/services/urlConfig.js');
  6. import {
  7. Toast
  8. } from 'mint-ui';
  9. // import Bus from '@/common/bus';
  10. // import commonMethod from '@/common/commonMethod.js';
  11. // import requestConfig from '@/static/lib/requestConfig';
  12. // import { language } from '@/static/utils/conf.js'
  13. // const plugin = requirePlugin("WechatSI");
  14. // 获取**全局唯一**的语音识别管理器**recordRecoManager**
  15. // const manager = plugin.getRecordRecognitionManager()
  16. // import bgLoading from "@/components/bgLoading/bgLoading.vue"
  17. // import { nextTick } from "vue";
  18. // const app = getApp(); //获取应用实例
  19. // let positions = new Set();
  20. export default {
  21. data: function() {
  22. return {
  23. seedLayoutList: [],
  24. selectSeedId: null, //当前选中的种子户型id
  25. currentTranslate: {
  26. // 当前语音输入内容
  27. create: '04/27 15:37',
  28. text: '等待说话',
  29. },
  30. recording: false, // 正在录音
  31. startX:0,
  32. startY:0,
  33. clientX:0,
  34. clientY:0,
  35. defaultIndex:0,//默认选中的户型大类
  36. carefulList:[],
  37. lastSpace:null, //上一个语音操作的空间对象
  38. bigWord:"变大,放大,大一点,变宽",
  39. bigWordPY:"bianda,fangda,dayidian,biankuan",
  40. smaillWord:"变小,缩放,小一点,变窄",
  41. smaillWordPY:"bianxiao,suofang,xiaoyidian,bianzhai",
  42. changeRate:0.05, //每次变化的比例
  43. spaceList:[],
  44. showX:false,
  45. }
  46. },
  47. props: {
  48. // houseList: {//当前户型所有的户型详情,可以切换
  49. // type: Array,
  50. // default: () => {
  51. // return []
  52. // }
  53. // },
  54. curHouseObj: {//当前展示的户型
  55. type: Object,
  56. default: () => {
  57. return null
  58. }
  59. },
  60. overChange: {//当前选中的户型类型
  61. type: Boolean,
  62. default: false,
  63. },
  64. styleType:{
  65. type: [String, Number],
  66. default: '',
  67. }
  68. },
  69. watch: {
  70. // houseList: {
  71. // handler(newVal) {
  72. // if (newVal) {
  73. // console.warn("***houseList-change***", newVal)
  74. // this.initData(newVal);
  75. // }
  76. // },
  77. // },
  78. curHouseObj: {
  79. handler(newVal,oldVal) {
  80. if (newVal) {
  81. console.warn("***curHouseObj-CHANGE-layout***", newVal)
  82. // if((oldVal && oldVal.id != newVal.id) || !oldVal){
  83. // this.initSpanceData();
  84. // }
  85. const spaceDetail = newVal;
  86. this.spaceList = JSON.parse(spaceDetail.houseJson);
  87. }
  88. },
  89. },
  90. curSpaceId: {
  91. handler(newVal,oldVal) {
  92. if (newVal) {
  93. console.warn("***curSpaceId-CHANGE-layout***", newVal)
  94. let space = this.spaceList.find(it=>it.spaceId==this.curSpaceId);
  95. if(space && space.spaceType==15){//X空间
  96. this.showX = true;
  97. }else{
  98. this.showX = false;
  99. }
  100. }
  101. },
  102. },
  103. },
  104. computed: {
  105. curSpaceId() {
  106. return this.$store.state.curSpaceId;
  107. },
  108. },
  109. async mounted() {
  110. // this.getRecordAuth();//获取录音权限
  111. // this.initRecord();
  112. // var currPage = getCurrentPages()[getCurrentPages().length - 1] ? getCurrentPages()[getCurrentPages().length - 1].$vm : null;
  113. // currPage.updateSpanceData = this.initSpanceData;//页面注册变更方法
  114. },
  115. // 页面被展示时执行
  116. onPageShow: function() {
  117. },
  118. //页面被隐藏时执行
  119. onPageHide: function() {
  120. console.warn("***detached-hide***")
  121. },
  122. methods: {
  123. initSpanceData(){
  124. this.carefulList = [];
  125. // var currPage = getCurrentPages()[getCurrentPages().length - 1] ? getCurrentPages()[getCurrentPages().length - 1].$vm : null;
  126. const spaceDetail = this.curHouseObj;
  127. const spaceList = JSON.parse(spaceDetail.houseJson);
  128. spaceList && spaceList.forEach(async (item,index)=>{
  129. let curSpaceArea = parseFloat(
  130. (item.spaceWidth * item.spaceHeight) / 10000
  131. ).toFixed(1);
  132. let minArea = 0;
  133. let maxArea = 100;
  134. if(item.hasOwnProperty('spaceWidthMin') && item.hasOwnProperty('spaceHeightMin')){
  135. minArea = parseFloat((item.spaceWidthMin * item.spaceHeightMin) / 10000).toFixed(1);
  136. }
  137. if(item.hasOwnProperty('spaceWidthMax') && item.hasOwnProperty('spaceHeightMax')){
  138. maxArea = parseFloat((item.spaceWidthMax * item.spaceHeightMax) / 10000).toFixed(1);
  139. }
  140. let text = item.spaceName;
  141. if(text && !item.isSizeLock){
  142. // let res = await requestConfig("chineseToPinyin", {chinese:text},true);
  143. // let pinyin = res.single;
  144. let data = {
  145. spaceId:item.spaceId,
  146. index:this.carefulList.length,
  147. name:text,
  148. namePY:'',
  149. area:curSpaceArea,
  150. percent:null,
  151. minArea:minArea, //最小面积
  152. maxArea:maxArea, //最大面积
  153. }
  154. this.carefulList.push(data)
  155. }
  156. })
  157. console.warn("***viewlayout-init***", this.carefulList)
  158. },
  159. initData(houseList){
  160. this.seedLayoutList = [];
  161. houseList && houseList.forEach(item=>{
  162. let data = {
  163. spaceStructure: item.spaceStructure,
  164. spaceName: item.spaceName,
  165. set: false, //是否已经设置过
  166. };
  167. this.seedLayoutList.push(data);
  168. })
  169. // var currPage = getCurrentPages()[getCurrentPages().length - 1] ? getCurrentPages()[getCurrentPages().length - 1].$vm : null;
  170. // if(currPage.curHouseType){//获取当前页面选中的户型类型
  171. // this.selectSeedId = currPage.curHouseType
  172. // } else if(this.seedLayoutList && this.seedLayoutList[this.defaultIndex]){//默认选中第一个
  173. // this.selectSeedId = this.seedLayoutList[this.defaultIndex].spaceStructure;
  174. // }
  175. this.selectSeedId = this.seedLayoutList[this.defaultIndex].spaceStructure;
  176. let keyWord = this.$route.query.layer;
  177. if(keyWord){//如果存在结构特征,则定位到该模型大类下
  178. let item = this.seedLayoutList.find(it=>keyWord.includes(it.spaceName));
  179. if(item){
  180. this.selectSeedId = item.spaceStructure;
  181. }
  182. }
  183. if(this.selectSeedId){
  184. let item = this.seedLayoutList.find(it=>{
  185. return it.spaceStructure == this.selectSeedId
  186. })
  187. this.$emit("seedChange", item);//通知父组件-当前已经选中了户型大类
  188. let param = {
  189. type: 'CLK', //埋点类型
  190. clkId: 'clk_2cmina_23080402', //点击ID
  191. clkName: 'seedroom_clk', //点击前往的页面名称
  192. clkParams: {
  193. type: item.spaceName,
  194. locusValue: item.spaceStructure,
  195. locusName: "切换种子户型",
  196. }
  197. };
  198. // util.trackRequest(param);
  199. }
  200. console.warn("***curHouseType-init***",this.seedLayoutList)
  201. },
  202. //打开布局
  203. openLayout(style) {
  204. console.warn("***openLayout***",style,this.curSpaceId)
  205. let space = this.spaceList.find(it=>it.spaceId==this.curSpaceId);
  206. if(space && space.spaceType==15){//X空间
  207. this.showX = true;
  208. }else{
  209. this.showX = false;
  210. }
  211. if(style==3){
  212. if(this.showX){//X空间
  213. this.$emit("changeStyle",style);
  214. }else{
  215. Toast({
  216. message: '此空间无法更改功能',
  217. });
  218. return false
  219. }
  220. }else{
  221. this.$emit("changeStyle",style);
  222. }
  223. // util.trackRequest(param);
  224. },
  225. goRoam(){
  226. this.$parent.$refs.viewCareful.goRoam();
  227. },
  228. }
  229. }
  230. </script>
  231. <style lang="scss" scoped>
  232. @import "./viewlayout.scss";
  233. /* @import "@/common/css/common.css"; */
  234. </style>