webgl_rxdz_text_customize.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  1. <template src="./webgl_rxdz_text_customize.html">
  2. </template>
  3. <script>
  4. const util = require('@/utils/util.js').default;
  5. const config = require('@/services/urlConfig.js');
  6. import {
  7. Toast
  8. } from 'mint-ui';
  9. import router from "@/router";
  10. import touchHandle from '@/mixins/touchHandle.js';
  11. import commonPageMethod from '@/mixins/commonPageMethod.js';
  12. import spaceTypes from '@/static/spaceTypesIE.js';
  13. // const app = getApp(); //获取应用实例
  14. // import requestConfig from '@/static/lib/requestConfig.js';
  15. // import commonPageMethod from '@/common/commonPageMethod.js';
  16. // import commonMethod from '@/common/commonMethod.js';
  17. export default {
  18. mixins: [touchHandle,commonPageMethod],
  19. /**
  20. * 页面的初始数据
  21. */
  22. data() {
  23. return {
  24. pvId: 'p_2cmina_23080403',
  25. locusBehaviorName: "我的定制",
  26. locusValue: "",
  27. locusName: "",
  28. pvCurPageName: "submit_ret",
  29. pvCurPageParams: null,
  30. navbar: {
  31. showCapsule: 1,
  32. title: '我的定制',
  33. titleColor: '#fff',
  34. navPadding: 0,
  35. navPaddingBg:'transparent',
  36. navBarColor: 'transparent',
  37. navBackColor: 'transparent',
  38. haveCallback: false, // 如果是 true 会接手 navbarBackClk
  39. fromShare: false,
  40. fromProject: 0,
  41. shareToken: "",
  42. pageName: this.pvCurPageName,
  43. },
  44. houseId: $config.houseIdHs,
  45. shareUserId: null, // 分享者ID
  46. id: '',//方案库id
  47. currImgIdx:0,
  48. tabIndex: 0,
  49. // featureImgList: [],
  50. hardboundEffect: [],//当前swiper数据列表对象
  51. form: {},
  52. tabData:[],
  53. number: '',
  54. plotHeadDeafultImg: 'https://dm.static.elab-plus.com/mini-program/plotHeadDeafultImg.png', // 地块人物默认头像
  55. showPhoneModel:false,
  56. gsImage:'',
  57. layoutStruct:null,
  58. expand:null,
  59. likeCount:0,//喜欢的人数
  60. unlikedCount:0,//不喜欢人数
  61. total:0,//总人数
  62. typeStatus:0,//显示是否喜欢的视图 ,1 显示 0 不显示
  63. proportion:50, //显式比例
  64. headList:[],
  65. showUserInput:false, //是否显示手机号留电弹窗
  66. repeatFlag:false, //防止重复请求
  67. name:'', //用户称呼
  68. tel:'', //手机号
  69. verifyCode:'',//验证码
  70. verifyText:'', //验证码提示
  71. isSend:false,
  72. showPopup:false,
  73. isIOS:false,
  74. }
  75. },
  76. /**
  77. * 生命周期函数--监听页面加载
  78. */
  79. mounted(options) {
  80. console.log("***onLoad-webgl_rxdz_text_customize***", this.$route.query)
  81. const that = this;
  82. this.houseId = this.$route.query.houseId?this.$route.query.houseId:'';
  83. this.id = this.$route.query.id?this.$route.query.id:'';
  84. this.typeStatus = this.$route.query.typeStatus?this.$route.query.typeStatus:0;
  85. let isIOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
  86. this.isIOS = isIOS;
  87. if(!this.id){
  88. Toast({
  89. message: '没有数据!',
  90. });
  91. return false;
  92. }else{
  93. this.getIdData();
  94. setTimeout(()=>{
  95. this.likeOrView()
  96. },500)
  97. }
  98. },
  99. computed: {
  100. userId() {
  101. return this.$store.state.userId;
  102. },
  103. landDataId() {
  104. return this.$store.state.landDataId;
  105. },
  106. },
  107. methods: {
  108. showPop() {
  109. this.showUserInput = true;
  110. },
  111. hidePop() {
  112. this.showUserInput = false;
  113. },
  114. getVerifyCode: function () { //验证码
  115. if (this.isSend) {
  116. return
  117. }
  118. this.isSend = true;
  119. if (!/^1\d{10}$/.test(this.tel)) {
  120. Toast({
  121. message: '输入的手机号不合法',
  122. });
  123. this.isSend = false
  124. return;
  125. }
  126. this.querySendCode(); //发送验证码接口
  127. },
  128. // 发送验证码接口
  129. async querySendCode() {
  130. let time = 60;
  131. let time1 = setInterval(() => {
  132. if (time > 0) {
  133. time = time - 1;
  134. this.verifyText = time + 's'
  135. } else {
  136. this.isSend = false;
  137. this.verifyText = '重新发送';
  138. clearInterval(time1)
  139. }
  140. }, 1000)
  141. const res = await requestConfig('send', {
  142. phoneNumber: this.tel,
  143. "sign": "Elab未来人居",
  144. "verifyType": 1,
  145. houseId: this.houseId || ''
  146. });
  147. if (res && res.success) {
  148. } else {
  149. this.isSend = false;
  150. Toast({
  151. message: '系统提示:网络错误',
  152. });
  153. }
  154. },
  155. async sendPhone() {
  156. console.log("sendPhone", this.verifyCode)
  157. if (!/^1\d{10}$/.test(this.tel)) {
  158. Toast({
  159. message: '输入的手机号不合法',
  160. });
  161. return;
  162. }
  163. if (!this.verifyCode) {
  164. Toast({
  165. message: '没有验证码',
  166. });
  167. return;
  168. }
  169. let codeData = {
  170. mobile: this.tel,
  171. code: this.verifyCode,
  172. verifyType: 1,
  173. // mobile: this.tel,
  174. // type: 'verification.code',
  175. // verifycode: this.verifyCode
  176. // mobile: this.tel,
  177. // leavePhoneCustomerId:this.userId || '',
  178. // code: this.verifyCode,
  179. // houseId:this.houseId,
  180. // source:2,
  181. // fromPlatform:'前测',
  182. // terminal:'7',
  183. };
  184. const validateCodeRes = await requestConfig('validate', codeData);
  185. if (validateCodeRes && !validateCodeRes.success) { //成功
  186. Toast({
  187. message: '验证码输入错误',
  188. });
  189. return
  190. } else {
  191. this.fakeLeavePhone()
  192. }
  193. this.isSend = false;
  194. },
  195. async fakeLeavePhone(){
  196. let signParam = {
  197. brandCustomerId: this.userId || '',
  198. brandId: $config.brandId,
  199. mobile: this.tel || '',
  200. houseId: this.houseId || '',
  201. source: 2,
  202. type: 2,
  203. terminal: 7
  204. };
  205. // 获取登录用户的shareToken
  206. const signres = await requestConfig('leavephone', signParam, true);
  207. if (signres && signres.success) {
  208. // let shareToken = signres.single;
  209. // console.log('刷新分享秘钥,当前为:', shareToken)
  210. // let parm = {
  211. // houseId: this.houseId || '',
  212. // scene: "",
  213. // brandCustomerId: this.userId || '',
  214. // brandId: $config.brandId,
  215. // mobile: this.tel || '',
  216. // shareSign: shareToken,
  217. // gdt_vid: "",
  218. // url: window.location.href,
  219. // };
  220. // let result = await requestConfig('authorizedMobile', parm, true);
  221. // if(result && result.success){
  222. // Toast({
  223. // message: '留电成功',
  224. // });
  225. // }
  226. Toast({
  227. message: '留电成功',
  228. });
  229. this.showUserInput = false;
  230. }
  231. },
  232. blurInput(e) {
  233. this.tel = e.detail.value || ''
  234. },
  235. blurCode(e) {
  236. this.verifyCode = e.detail.value || ''
  237. },
  238. swiperChangeImg(e){
  239. console.log("***swiperChangeImg***",e);
  240. this.currImgIdx = e.detail ? e.detail.current : e;
  241. this.gsImage = this.hardboundEffect[this.currImgIdx];//获取高斯模糊的图片
  242. },
  243. rightScroll(){//右滑
  244. if(this.currImgIdx <= (this.hardboundEffect.length - 1) && this.currImgIdx > 0){
  245. this.$refs.carousel.prev();
  246. }
  247. },
  248. leftScroll(){//继续生成
  249. if(this.currImgIdx != this.hardboundEffect.length - 1){
  250. if(this.currImgIdx<this.hardboundEffect.length - 1){
  251. this.$refs.carousel.next();
  252. }
  253. }
  254. },
  255. //去往首页
  256. toIndex(){
  257. if(window.__wxjs_environment === 'miniprogram'){
  258. this.pvCloseHandle();//小程序跳转会主动杀死关闭当前页面-不经过页面框架跳转关闭逻辑-所以需要主动触发关闭埋点
  259. wx.miniProgram.redirectTo({url: '/pages/index/index?houseId='+this.houseId})
  260. }else{
  261. let url = $config.min_uri + "pages/index/index?houseId=" + this.houseId
  262. // window.location.href = shottingImg;
  263. window.open(url)
  264. }
  265. },
  266. //联系我们
  267. conectUS(){
  268. if(window.__wxjs_environment === 'miniprogram'){
  269. this.pvCloseHandle();//小程序跳转会主动杀死关闭当前页面-不经过vue跳转关闭逻辑-所以需要主动触发关闭埋点
  270. wx.miniProgram.navigateTo({url: '/pages/transfer/transfer?event=openCustomerServiceChat&houseId='+this.houseId})
  271. }else{
  272. // this.$message.warning("敬请期待");
  273. this.showPop();
  274. }
  275. },
  276. async share(){
  277. if(window.__wxjs_environment === 'miniprogram'){
  278. // Toast({
  279. // message: '请点击右上角发起分享',
  280. // });
  281. this.showPopup = true;
  282. // wx.miniProgram.navigateTo({url: '/pages/transfer/transfer?event=openCustomerServiceChat&houseId='+this.houseId})
  283. }else{
  284. // window.location.href = shottingImg;
  285. let ind = window.location.href.indexOf('?');
  286. let webUrl = window.location.href.substr(0,ind) + "?houseId=" + this.houseId +"&id=" + this.id + "&typeStatus=1"+ "&brandId=" + $config.brandId;
  287. let url = '';
  288. if (window.self !== window.top) {
  289. url = $config.min_uri + "pages/webView/webView?view=" + encodeURIComponent(webUrl) + "&title=梦想设计";
  290. } else {
  291. url = webUrl;
  292. }
  293. console.warn("***复制***",url);
  294. if(this.isIOS){
  295. navigator.clipboard.writeText(url);
  296. // const permission = await navigator.permissions.query({ name: 'clipboard-write' });
  297. // if (permission.state === 'denied') {
  298. // return console.error("Damn, we don't have permissions to do this")
  299. // }
  300. // try{
  301. // await navigator.clipboard.writeText(url) // 写入文本
  302. // }catch(e){
  303. // console.error("Error while copying text!",e)
  304. // }
  305. }else{
  306. var textArea = document.createElement("textarea");
  307. textArea.value = url;
  308. document.body.appendChild(textArea);
  309. textArea.select();
  310. document.execCommand('copy');
  311. document.body.removeChild(textArea);
  312. }
  313. Toast({
  314. message: '链接已复制',
  315. });
  316. }
  317. },
  318. async likeOrView(type){
  319. let userId = this.userId || '';
  320. let params = {
  321. busId: this.id,
  322. brandId: $config.brandId,
  323. houseId:this.houseId,
  324. userId,
  325. type:1,
  326. };
  327. if(type==1){//喜欢
  328. params.likeed = 1
  329. }else if(type==2){//不喜欢
  330. params.likeed = 0
  331. }
  332. if(this.repeatFlag){
  333. return false
  334. }
  335. this.repeatFlag = true;
  336. // params.userId = this.userId;
  337. const res = await requestConfig('add', params);
  338. if (res.success && type) {
  339. this.layoutStruct.clickLike = params.likeed;
  340. if(this.total){
  341. if(type==1){
  342. this.likeCount = this.likeCount + 1
  343. }else{
  344. this.unlikedCount = this.unlikedCount + 1
  345. }
  346. // if(userId != this.layoutStruct.userId){
  347. // this.total ++;
  348. // }
  349. this.proportion = parseInt((this.likeCount / (this.likeCount + this.unlikedCount))*100);
  350. }
  351. }
  352. // this.getIdData();
  353. this.repeatFlag = false;
  354. },
  355. async getIdData(){
  356. let userId = this.userId || '';
  357. let params = {
  358. id: this.id,
  359. brandId: $config.brandId,
  360. houseId:this.houseId,
  361. userId,
  362. type:'QIANCE',
  363. };
  364. if(this.shareUserId){//分享时 不带用户id
  365. delete params.userId
  366. }
  367. if(this.landDataId){
  368. params.landDataId = this.landDataId;
  369. }
  370. // params.userId = this.userId;
  371. const res = await requestConfig('getCustomizedRecord', params);
  372. if (res.success && res.list && res.list[0]) {
  373. let single = res.list[0];
  374. this.tabIndex = 0;//表明是户型首图
  375. this.tabData = [];
  376. if(single.expand){
  377. let list = JSON.parse(single.expand);
  378. let ind = list.findIndex(it=>it.name == '户型偏好');
  379. this.expand = list.slice(ind);
  380. }
  381. this.layoutStruct = JSON.parse(JSON.stringify(single));
  382. this.likeCount = this.layoutStruct.liked;//喜欢的人数
  383. this.unlikedCount = this.layoutStruct.unliked;//不喜欢人数
  384. this.total = this.layoutStruct.total;//总人数
  385. if((this.likeCount + this.unlikedCount)>0){
  386. this.proportion = parseInt((this.likeCount / (this.likeCount + this.unlikedCount))*100);
  387. }
  388. // this.number = single.landCode
  389. this.form = single.layoutStruct[0];
  390. this.headList = this.layoutStruct.heads || [];
  391. this.hardboundEffect = this.form.layoutImgCustomized? [this.form.layoutImgCustomized] : [];//赋值轮播图
  392. let data = {
  393. name : this.form.layoutName,
  394. imgUrl : this.form.layoutImgCustomized,
  395. hardboundEffect:[this.form.layoutImgCustomized],
  396. gsImage:this.form.layoutImgCustomized,
  397. area:this.form.layoutArea,
  398. }
  399. this.tabData.push(data);
  400. this.form.houseJson = this.form.houseJson.filter((item)=>{
  401. return item.spaceName && item.spaceName.length>0 && item.spaceType!=11 && item.hardboundEffect && item.hardboundEffect[0]
  402. })
  403. this.form.houseJson.sort(function(a,b){return parseFloat((b.spaceWidth * b.spaceHeight) / 10000) -parseFloat((a.spaceWidth * a.spaceHeight) / 10000)});
  404. this.form.houseJson.forEach((item,index)=>{
  405. //获取面积
  406. let curSpaceArea = parseFloat((item.spaceWidth * item.spaceHeight) / 10000).toFixed(1);
  407. let text = item.spaceName;
  408. if(item.spaceId && item.spaceType){
  409. text = spaceTypes[item.spaceType - 1];
  410. if(item.spaceType==15 && item.layoutSpaceType){
  411. text = spaceTypes[item.layoutSpaceType - 1];
  412. }
  413. }
  414. let data = {
  415. name : text,
  416. imgUrl : item.hardboundEffect[0],
  417. hardboundEffect:item.hardboundEffect,
  418. gsImage:item.hardboundEffect[0],
  419. area:item.spaceId?curSpaceArea:'',
  420. }
  421. this.tabData.push(data);
  422. })
  423. this.gsImage = this.form.layoutImgCustomized;//获取高斯模糊的图片
  424. }else{
  425. Toast({
  426. message: '作品未找到!',
  427. });
  428. }
  429. },
  430. changeTab(id){
  431. if(id == this.tabIndex){
  432. return
  433. }
  434. this.tabIndex = id;
  435. this.currImgIdx = 0;
  436. this.hardboundEffect = this.tabData[id].hardboundEffect? this.tabData[id].hardboundEffect : [];//赋值轮播图
  437. this.gsImage = this.tabData[id].gsImage;//获取高斯模糊的图片
  438. let param = {
  439. type: 'CLK', //埋点类型
  440. clkId: 'clk_2cmina_23080421', //点击ID
  441. clkName: 'roomretpic_clk', //点击前往的页面名称
  442. clkParams: {
  443. type: this.tabData[this.tabIndex].name,
  444. locusName: "房间名称",
  445. // locusValue: this.tabData[this.tabIndex].name,
  446. }
  447. };
  448. util.trackRequest(param);
  449. },
  450. catchTouchMove: function() {
  451. return false;
  452. },
  453. toMode(){
  454. let data = {
  455. houseId:this.houseId,
  456. id:this.id,
  457. }
  458. router.push({
  459. name: "webgl_rxdz_test_look",
  460. query:data
  461. });
  462. let param = {
  463. type: 'CLK', //埋点类型
  464. clkId: 'clk_2cmina_23080420', //点击ID
  465. clkName: 'checkroom_clk', //点击前往的页面名称
  466. clkParams: {
  467. locusName: "查看户型",
  468. }
  469. };
  470. util.trackRequest(param);
  471. },
  472. }
  473. }
  474. </script>
  475. <style lang="scss" scoped>
  476. @import "./webgl_rxdz_text_customize.scss";
  477. </style>
  478. <style lang="css" scoped>
  479. /* @import "@/common/css/common.css"; */
  480. </style>