webgl_rxdz_text_customize.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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. },
  104. methods: {
  105. showPop() {
  106. this.showUserInput = true;
  107. },
  108. hidePop() {
  109. this.showUserInput = false;
  110. },
  111. getVerifyCode: function () { //验证码
  112. if (this.isSend) {
  113. return
  114. }
  115. this.isSend = true;
  116. if (!/^1\d{10}$/.test(this.tel)) {
  117. Toast({
  118. message: '输入的手机号不合法',
  119. });
  120. this.isSend = false
  121. return;
  122. }
  123. this.querySendCode(); //发送验证码接口
  124. },
  125. // 发送验证码接口
  126. async querySendCode() {
  127. let time = 60;
  128. let time1 = setInterval(() => {
  129. if (time > 0) {
  130. time = time - 1;
  131. this.verifyText = time + 's'
  132. } else {
  133. this.isSend = false;
  134. this.verifyText = '重新发送';
  135. clearInterval(time1)
  136. }
  137. }, 1000)
  138. const res = await requestConfig('send', {
  139. phoneNumber: this.tel,
  140. "sign": "Elab未来人居",
  141. "verifyType": 1,
  142. houseId: this.houseId || ''
  143. });
  144. if (res && res.success) {
  145. } else {
  146. this.isSend = false;
  147. Toast({
  148. message: '系统提示:网络错误',
  149. });
  150. }
  151. },
  152. async sendPhone() {
  153. console.log("sendPhone", this.verifyCode)
  154. if (!/^1\d{10}$/.test(this.tel)) {
  155. Toast({
  156. message: '输入的手机号不合法',
  157. });
  158. return;
  159. }
  160. if (!this.verifyCode) {
  161. Toast({
  162. message: '没有验证码',
  163. });
  164. return;
  165. }
  166. let codeData = {
  167. mobile: this.tel,
  168. code: this.verifyCode,
  169. verifyType: 1,
  170. // mobile: this.tel,
  171. // type: 'verification.code',
  172. // verifycode: this.verifyCode
  173. // mobile: this.tel,
  174. // leavePhoneCustomerId:this.userId || '',
  175. // code: this.verifyCode,
  176. // houseId:this.houseId,
  177. // source:2,
  178. // fromPlatform:'前测',
  179. // terminal:'7',
  180. };
  181. const validateCodeRes = await requestConfig('validate', codeData);
  182. if (validateCodeRes && !validateCodeRes.success) { //成功
  183. Toast({
  184. message: '验证码输入错误',
  185. });
  186. return
  187. } else {
  188. this.fakeLeavePhone()
  189. }
  190. this.isSend = false;
  191. },
  192. async fakeLeavePhone(){
  193. let signParam = {
  194. brandCustomerId: this.userId || '',
  195. brandId: $config.brandId,
  196. mobile: this.tel || '',
  197. houseId: this.houseId || '',
  198. source: 2,
  199. type: 2,
  200. terminal: 7
  201. };
  202. // 获取登录用户的shareToken
  203. const signres = await requestConfig('leavephone', signParam, true);
  204. if (signres && signres.success) {
  205. // let shareToken = signres.single;
  206. // console.log('刷新分享秘钥,当前为:', shareToken)
  207. // let parm = {
  208. // houseId: this.houseId || '',
  209. // scene: "",
  210. // brandCustomerId: this.userId || '',
  211. // brandId: $config.brandId,
  212. // mobile: this.tel || '',
  213. // shareSign: shareToken,
  214. // gdt_vid: "",
  215. // url: window.location.href,
  216. // };
  217. // let result = await requestConfig('authorizedMobile', parm, true);
  218. // if(result && result.success){
  219. // Toast({
  220. // message: '留电成功',
  221. // });
  222. // }
  223. Toast({
  224. message: '留电成功',
  225. });
  226. this.showUserInput = false;
  227. }
  228. },
  229. blurInput(e) {
  230. this.tel = e.detail.value || ''
  231. },
  232. blurCode(e) {
  233. this.verifyCode = e.detail.value || ''
  234. },
  235. swiperChangeImg(e){
  236. console.log("***swiperChangeImg***",e);
  237. this.currImgIdx = e.detail ? e.detail.current : e;
  238. this.gsImage = this.hardboundEffect[this.currImgIdx];//获取高斯模糊的图片
  239. },
  240. rightScroll(){//右滑
  241. if(this.currImgIdx <= (this.hardboundEffect.length - 1) && this.currImgIdx > 0){
  242. this.$refs.carousel.prev();
  243. }
  244. },
  245. leftScroll(){//继续生成
  246. if(this.currImgIdx != this.hardboundEffect.length - 1){
  247. if(this.currImgIdx<this.hardboundEffect.length - 1){
  248. this.$refs.carousel.next();
  249. }
  250. }
  251. },
  252. //去往首页
  253. toIndex(){
  254. if(window.__wxjs_environment === 'miniprogram'){
  255. this.pvCloseHandle();//小程序跳转会主动杀死关闭当前页面-不经过页面框架跳转关闭逻辑-所以需要主动触发关闭埋点
  256. wx.miniProgram.redirectTo({url: '/pages/index/index?houseId='+this.houseId})
  257. }else{
  258. let url = $config.min_uri + "pages/index/index?houseId=" + this.houseId
  259. // window.location.href = shottingImg;
  260. window.open(url)
  261. }
  262. },
  263. //联系我们
  264. conectUS(){
  265. if(window.__wxjs_environment === 'miniprogram'){
  266. this.pvCloseHandle();//小程序跳转会主动杀死关闭当前页面-不经过vue跳转关闭逻辑-所以需要主动触发关闭埋点
  267. wx.miniProgram.navigateTo({url: '/pages/transfer/transfer?event=openCustomerServiceChat&houseId='+this.houseId})
  268. }else{
  269. // this.$message.warning("敬请期待");
  270. this.showPop();
  271. }
  272. },
  273. async share(){
  274. if(window.__wxjs_environment === 'miniprogram'){
  275. // Toast({
  276. // message: '请点击右上角发起分享',
  277. // });
  278. this.showPopup = true;
  279. // wx.miniProgram.navigateTo({url: '/pages/transfer/transfer?event=openCustomerServiceChat&houseId='+this.houseId})
  280. }else{
  281. // window.location.href = shottingImg;
  282. let ind = window.location.href.indexOf('?');
  283. let webUrl = window.location.href.substr(0,ind) + "?houseId=" + this.houseId +"&id=" + this.id + "&typeStatus=1"+ "&brandId=" + $config.brandId;
  284. let url = '';
  285. if (window.self !== window.top) {
  286. url = $config.min_uri + "pages/webView/webView?view=" + encodeURIComponent(webUrl) + "&title=梦想设计";
  287. } else {
  288. url = webUrl;
  289. }
  290. console.warn("***复制***",url);
  291. if(this.isIOS){
  292. navigator.clipboard.writeText(url);
  293. // const permission = await navigator.permissions.query({ name: 'clipboard-write' });
  294. // if (permission.state === 'denied') {
  295. // return console.error("Damn, we don't have permissions to do this")
  296. // }
  297. // try{
  298. // await navigator.clipboard.writeText(url) // 写入文本
  299. // }catch(e){
  300. // console.error("Error while copying text!",e)
  301. // }
  302. }else{
  303. var textArea = document.createElement("textarea");
  304. textArea.value = url;
  305. document.body.appendChild(textArea);
  306. textArea.select();
  307. document.execCommand('copy');
  308. document.body.removeChild(textArea);
  309. }
  310. Toast({
  311. message: '链接已复制',
  312. });
  313. }
  314. },
  315. async likeOrView(type){
  316. let userId = this.userId || '';
  317. let params = {
  318. busId: this.id,
  319. brandId: $config.brandId,
  320. houseId:this.houseId,
  321. userId,
  322. type:1,
  323. };
  324. if(type==1){//喜欢
  325. params.likeed = 1
  326. }else if(type==2){//不喜欢
  327. params.likeed = 0
  328. }
  329. if(this.repeatFlag){
  330. return false
  331. }
  332. this.repeatFlag = true;
  333. // params.userId = this.userId;
  334. const res = await requestConfig('add', params);
  335. if (res.success && type) {
  336. this.layoutStruct.clickLike = params.likeed;
  337. if(this.total){
  338. if(type==1){
  339. this.likeCount = this.likeCount + 1
  340. }else{
  341. this.unlikedCount = this.unlikedCount + 1
  342. }
  343. // if(userId != this.layoutStruct.userId){
  344. // this.total ++;
  345. // }
  346. this.proportion = parseInt((this.likeCount / (this.likeCount + this.unlikedCount))*100);
  347. }
  348. }
  349. // this.getIdData();
  350. this.repeatFlag = false;
  351. },
  352. async getIdData(){
  353. let userId = this.userId || '';
  354. let params = {
  355. id: this.id,
  356. brandId: $config.brandId,
  357. houseId:this.houseId,
  358. userId,
  359. type:'QIANCE',
  360. };
  361. if(this.shareUserId){//分享时 不带用户id
  362. delete params.userId
  363. }
  364. // params.userId = this.userId;
  365. const res = await requestConfig('getCustomizedRecord', params);
  366. if (res.success && res.list && res.list[0]) {
  367. let single = res.list[0];
  368. this.tabIndex = 0;//表明是户型首图
  369. this.tabData = [];
  370. if(single.expand){
  371. let list = JSON.parse(single.expand);
  372. let ind = list.findIndex(it=>it.name == '户型偏好');
  373. this.expand = list.slice(ind);
  374. }
  375. this.layoutStruct = JSON.parse(JSON.stringify(single));
  376. this.likeCount = this.layoutStruct.liked;//喜欢的人数
  377. this.unlikedCount = this.layoutStruct.unliked;//不喜欢人数
  378. this.total = this.layoutStruct.total;//总人数
  379. if((this.likeCount + this.unlikedCount)>0){
  380. this.proportion = parseInt((this.likeCount / (this.likeCount + this.unlikedCount))*100);
  381. }
  382. // this.number = single.landCode
  383. this.form = single.layoutStruct[0];
  384. this.headList = this.layoutStruct.heads || [];
  385. this.hardboundEffect = this.form.layoutImgCustomized? [this.form.layoutImgCustomized] : [];//赋值轮播图
  386. let data = {
  387. name : this.form.layoutName,
  388. imgUrl : this.form.layoutImgCustomized,
  389. hardboundEffect:[this.form.layoutImgCustomized],
  390. gsImage:this.form.layoutImgCustomized,
  391. area:this.form.layoutArea,
  392. }
  393. this.tabData.push(data);
  394. this.form.houseJson = this.form.houseJson.filter((item)=>{
  395. return item.spaceName && item.spaceName.length>0 && item.spaceType!=11 && item.hardboundEffect && item.hardboundEffect[0]
  396. })
  397. this.form.houseJson.sort(function(a,b){return parseFloat((b.spaceWidth * b.spaceHeight) / 10000) -parseFloat((a.spaceWidth * a.spaceHeight) / 10000)});
  398. this.form.houseJson.forEach((item,index)=>{
  399. //获取面积
  400. let curSpaceArea = parseFloat((item.spaceWidth * item.spaceHeight) / 10000).toFixed(1);
  401. let text = item.spaceName;
  402. if(item.spaceId && item.spaceType){
  403. text = spaceTypes[item.spaceType - 1];
  404. if(item.spaceType==15 && item.layoutSpaceType){
  405. text = spaceTypes[item.layoutSpaceType - 1];
  406. }
  407. }
  408. let data = {
  409. name : text,
  410. imgUrl : item.hardboundEffect[0],
  411. hardboundEffect:item.hardboundEffect,
  412. gsImage:item.hardboundEffect[0],
  413. area:item.spaceId?curSpaceArea:'',
  414. }
  415. this.tabData.push(data);
  416. })
  417. this.gsImage = this.form.layoutImgCustomized;//获取高斯模糊的图片
  418. }else{
  419. Toast({
  420. message: '作品未找到!',
  421. });
  422. }
  423. },
  424. changeTab(id){
  425. if(id == this.tabIndex){
  426. return
  427. }
  428. this.tabIndex = id;
  429. this.currImgIdx = 0;
  430. this.hardboundEffect = this.tabData[id].hardboundEffect? this.tabData[id].hardboundEffect : [];//赋值轮播图
  431. this.gsImage = this.tabData[id].gsImage;//获取高斯模糊的图片
  432. let param = {
  433. type: 'CLK', //埋点类型
  434. clkId: 'clk_2cmina_23080421', //点击ID
  435. clkName: 'roomretpic_clk', //点击前往的页面名称
  436. clkParams: {
  437. type: this.tabData[this.tabIndex].name,
  438. locusName: "房间名称",
  439. // locusValue: this.tabData[this.tabIndex].name,
  440. }
  441. };
  442. util.trackRequest(param);
  443. },
  444. catchTouchMove: function() {
  445. return false;
  446. },
  447. toMode(){
  448. let data = {
  449. houseId:this.houseId,
  450. id:this.id,
  451. }
  452. router.push({
  453. name: "webgl_rxdz_look",
  454. query:data
  455. });
  456. let param = {
  457. type: 'CLK', //埋点类型
  458. clkId: 'clk_2cmina_23080420', //点击ID
  459. clkName: 'checkroom_clk', //点击前往的页面名称
  460. clkParams: {
  461. locusName: "查看户型",
  462. }
  463. };
  464. util.trackRequest(param);
  465. },
  466. }
  467. }
  468. </script>
  469. <style lang="scss" scoped>
  470. @import "./webgl_rxdz_text_customize.scss";
  471. </style>
  472. <style lang="css" scoped>
  473. /* @import "@/common/css/common.css"; */
  474. </style>