zjs_project 1 rok temu
rodzic
commit
4e88ae09ce

+ 36 - 10
src/App.vue

@@ -44,12 +44,13 @@
 			};
 		},
 		created() {
-			let userId = this.$route.query.leavePhoneCustomerId ? this.$route.query.leavePhoneCustomerId : '';
-			let xcxHouseId = this.$route.query.xcxHouseId ? this.$route.query.xcxHouseId : $config.xcxHouseId;
+			let userInfo = getStorage('userInfo') ? JSON.parse(getStorage('userInfo')) : null;
+			let userId = this.$route.query.leavePhoneCustomerId ? this.$route.query.leavePhoneCustomerId : (userInfo?userInfo.userId:'');
+			let xcxHouseId = this.$route.query.xcxHouseId ? this.$route.query.xcxHouseId : (this.$route.query.houseId || $config.xcxHouseId);
 			let query = this.$route.query;
-			// let xcxHouseId = '100296';
-			if (userId) { //如果存在用户id
-				this.$store.dispatch('setUserId', userId);
+			let brandId = this.$route.query.brandId || this.$route.query.special_ID;
+			if (brandId) { //如果存在集团id
+				$config.brandId = brandId;
 			}
 			if (xcxHouseId) { //如果存在houseid
 				this.$store.dispatch('setHouseId', xcxHouseId);
@@ -57,6 +58,13 @@
 			if (query) { //如果存在入参
 				setStorage('queryObj', query);
 			}
+			if (userId) { //如果存在用户id
+				this.$store.dispatch('setUserId', userId);
+				// 开启websocket连接
+				util.initWebsocket();
+			}else{
+				this.webLogin()
+			}
 			let isIOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
 			this.isIOS = isIOS;
 			window.addEventListener('error', (error) => {
@@ -64,12 +72,9 @@
 				// 区分是否是js错误
 				if (error.message) {
 					console.warn("error" + error.message)
-				} else {
-					console.warn('监测到E1004错误' + error);
 				}
 			}, true)
-			// 开启websocket连接
-			util.initWebsocket();
+			
 			// window.onerror = function(message,source,line,column,error) {
 			// };
 		},
@@ -104,7 +109,28 @@
 			});
 		},
 		methods: {
-
+			async webLogin(){
+				let xcxHouseId = this.$route.query.xcxHouseId ? this.$route.query.xcxHouseId : (this.$route.query.houseId || $config.xcxHouseId);
+				let param = {
+				    "terminal": 7,
+				    "brandId": $config.brandId,
+				    "houseId": xcxHouseId,
+				    "shareToken": '',
+				};
+				let res = await requestConfig('webXcxLogin', param, true);
+				if (res && res.single && res.single.id) { //如果存在用户id
+					let userId = res.single.id;
+					let userInfo = {
+						userId:userId,
+						openId:res.single.openId,
+						token:res.single.token,
+					}
+					this.$store.dispatch('setUserId', userId);
+					setStorage('userInfo', userInfo);
+					// 开启websocket连接
+					util.initWebsocket();
+				}
+			}
 		},
 	};
 </script>

+ 2 - 1
src/pages/webgl_rxdz_env/webgl_rxdz_env.scss

@@ -131,7 +131,8 @@ page {
 		overflow-x: auto;
 		overflow-y: hidden;
 		margin-bottom: 40px;
-		z-index: 9;
+		z-index: 10;
+		background-color: #fff;
 		.tab-content{
 			position: absolute;
 		}

+ 27 - 15
src/pages/webgl_rxdz_env/webgl_rxdz_env.vue

@@ -62,6 +62,7 @@
 				tabData: [],
 				checked:false,	//是否喜欢
 				subDataList:[],	//提交的数据对象
+				queryObj:null,
 			}
 		},
 		/**
@@ -72,7 +73,8 @@
 			const that = this;
 			this.houseId = this.$route.query.houseId ? this.$route.query.houseId : (this.$store.state.houseId || '');
 			let queryObj = getStorage('queryObj') ? JSON.parse(getStorage('queryObj')) : null;
-			this.id = this.$route.query.id3 ? this.$route.query.id3 : (queryObj && queryObj.id3?queryObj.id3:'111');;
+			this.id = this.$route.query.id3 ? this.$route.query.id3 : (queryObj && queryObj.id3?queryObj.id3:'111');
+			this.queryObj = queryObj;
 			this.queryTestcaseSingle();
 		},
 		computed: {
@@ -183,16 +185,16 @@
 				this.tabIndex = id;
 				this.options = this.tabData[this.tabIndex].options; //选项数据
 				this.optionIndex = this.tabData[this.tabIndex].checkedIndex; //获取用户已经选中的选项
-				let param = {
-					type: 'CLK', //埋点类型
-					clkId: 'clk_2cmina_24012601', //点击ID
-					clkName: 'tab_clk', //点击前往的页面名称
-					clkParams: {
-						type: this.tabData[this.tabIndex].fatherContent,
-						locusName: "大类选择",
-					}
-				};
-				util.trackRequest(param);
+				// let param = {
+				// 	type: 'CLK', //埋点类型
+				// 	clkId: 'clk_2cmina_24012601', //点击ID
+				// 	clkName: 'tab_clk', //点击前往的页面名称
+				// 	clkParams: {
+				// 		type: this.tabData[this.tabIndex].fatherContent,
+				// 		locusName: "大类选择",
+				// 	}
+				// };
+				// util.trackRequest(param);
 			},
 			//切换选项
 			changeOption(id) {
@@ -236,10 +238,10 @@
 					],
 					brandId: $config.brandId,
 					houseId: this.houseId,
-					channel:this.$route.query.channel || '',
-					city:this.$route.query.city || '',
-					district:this.$route.query.district || '',
-					province:this.$route.query.province || '',
+					channel:this.queryObj ? this.queryObj.channel : '',
+					city:this.queryObj ? this.queryObj.city : '',
+					district:this.queryObj ? this.queryObj.district : '',
+					province:this.queryObj ? this.queryObj.province : '',
 					paperTitle:'',//试卷id
 					testThemeId:'',
 					testcaseId:this.id,
@@ -247,6 +249,16 @@
 					xcxCustomerId:userId,
 				};
 				requestConfig('submitAnswer', params,true);
+				let param = {
+					type: 'CLK', //埋点类型
+					clkId: 'clk_2cmina_24022003', //点击ID
+					clkName: 'option_clk', //点击前往的页面名称
+					clkParams: {
+						locusValue: this.options[this.optionIndex].content,
+						locusName: "选项选择",
+					}
+				};
+				util.trackRequest(param);
 			},
 			catchTouchMove: function() {
 				return false;

+ 21 - 7
src/pages/webgl_rxdz_houseList/webgl_rxdz_houseList.vue

@@ -14,7 +14,9 @@
 	} from 'mint-ui';
 	// import houseList from "../../components/houseList/houseList.vue";
 	// import houseList2 from "../../components/houseList/houseList2.vue";
+	import commonPageMethod from '@/mixins/commonPageMethod.js';
 	export default {
+		mixins: [commonPageMethod],
 		name: 'webgl_rxdz_houseList',
 		data() {
 			return {
@@ -45,6 +47,7 @@
 				tabData: [],	//
 				curHouseObj:null,	//用户选择的户型
 				selectIndex:-1,	//用户选择的户型序号
+				queryObj:null,//页面参数
 			}
 		},
 		// components: {
@@ -58,9 +61,9 @@
 		},
 		mounted(options) {
 			console.log("***onLoad-webgl_rxdz_houseList***", this.$route.query)
-			let queryObj = getStorage('queryObj') ? JSON.parse(getStorage('queryObj')) : null;
+			this.queryObj = getStorage('queryObj') ? JSON.parse(getStorage('queryObj')) : null;
 			this.houseId = this.$route.query.houseId ? this.$route.query.houseId : (this.$store.state.houseId || '');
-			this.id = this.$route.query.id2 ? this.$route.query.id2 : (queryObj && queryObj.id2?queryObj.id2:'110');
+			this.id = this.$route.query.id2 ? this.$route.query.id2 : (this.queryObj && this.queryObj.id2?this.queryObj.id2:'110');
 			this.findHouseTypeSpaceList();
 			this.queryTestcaseSingle();
 			document.title = this.navbar.title;
@@ -107,10 +110,10 @@
 					],
 					brandId: $config.brandId,
 					houseId: this.houseId,
-					channel:this.$route.query.channel || '',
-					city:this.$route.query.city || '',
-					district:this.$route.query.district || '',
-					province:this.$route.query.province || '',
+					channel:this.queryObj ? this.queryObj.channel : '',
+					city:this.queryObj ? this.queryObj.city : '',
+					district:this.queryObj ? this.queryObj.district : '',
+					province:this.queryObj ? this.queryObj.province : '',
 					paperTitle:'',//试卷id
 					testThemeId:'',
 					testcaseId:this.id,
@@ -118,6 +121,16 @@
 					xcxCustomerId:userId,
 				};
 				requestConfig('submitAnswer', params,true);
+				let param = {
+					type: 'CLK', //埋点类型
+					clkId: 'clk_2cmina_24022002', //点击ID
+					clkName: 'option_clk', //点击前往的页面名称
+					clkParams: {
+						locusValue: this.tabData[tabIndex].options[optionIndex].content,
+						locusName: "选项选择",
+					}
+				};
+				util.trackRequest(param);
 			},
 			changeHouse(item,index){
 				this.curHouseObj = item;
@@ -133,6 +146,7 @@
 						note: item.note,
 						area: item.houseArea,
 						id: item.id,
+						locusValue: item.houseType,
 						locusName: "空间选择",
 					}
 				};
@@ -156,7 +170,7 @@
 			async findHouseTypeSpaceList() {
 				// const { houseId, brandId } = getApp().globalData;
 				var parmas = {
-					brandId: 94,
+					brandId: $config.brandId,
 					houseId: this.houseId,
 					pageNo: 1,
 					pageSize: 2000,

+ 20 - 9
src/pages/webgl_rxdz_role/webgl_rxdz_role.vue

@@ -194,6 +194,16 @@
 					xcxCustomerId:userId,
 				};
 				requestConfig('submitAnswer', params,true);
+				let param = {
+					type: 'CLK', //埋点类型
+					clkId: 'clk_2cmina_24022001', //点击ID
+					clkName: 'option_clk', //点击前往的页面名称
+					clkParams: {
+						locusValue: this.options[this.optionIndex].content,
+						locusName: "选项选择",
+					}
+				};
+				util.trackRequest(param);
 			},
 			catchTouchMove: function() {
 				return false;
@@ -206,6 +216,15 @@
 					});
 					return false;
 				}
+				let param = {
+					type: 'CLK', //埋点类型
+					clkId: 'clk_2cmina_24012303', //点击ID
+					clkName: 'confirm_clk', //点击前往的页面名称
+					clkParams: {
+						locusName: "确定个人偏好",
+					}
+				};
+				util.trackRequest(param);
 				let data = [];
 				this.tabData.forEach(tab=>{
 					let _dt = {
@@ -233,15 +252,7 @@
 				// 	name: "webgl_rxdz_look",
 				// 	query:data
 				// });
-				let param = {
-					type: 'CLK', //埋点类型
-					clkId: 'clk_2cmina_24012303', //点击ID
-					clkName: 'confirm_clk', //点击前往的页面名称
-					clkParams: {
-						locusName: "确定个人偏好",
-					}
-				};
-				util.trackRequest(param);
+				
 			},
 		}
 

+ 1 - 1
src/pages/webgl_rxdz_test/webgl_rxdz_test.vue

@@ -181,7 +181,7 @@
 			console.warn("***beforeDestroy-webgl_rxdz***");
 		},
         mounted() {
-			console.log("***onLoad-webgl_rxdz_test***", this.$route.query);
+			console.log("***onLoad-webgl_rxdz_test***", this.$route.query,this.$store.state.houseId);
 			let isIOS = !!navigator.userAgent.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/);
 			this.isIOS = isIOS;
 			var that = this;

+ 12 - 3
src/pages/webgl_rxdz_text_customize/webgl_rxdz_text_customize.vue

@@ -90,7 +90,9 @@ export default {
 			return false;
 		}else{
 			this.getIdData();
-			this.likeOrView()
+			setTimeout(()=>{
+				this.likeOrView()
+			},500)
 		}
     },
 	computed: {
@@ -254,6 +256,7 @@ export default {
 		//去往首页
 		toIndex(){
 			if(window.__wxjs_environment === 'miniprogram'){
+				this.pvCloseHandle();//小程序跳转会主动杀死关闭当前页面-不经过页面框架跳转关闭逻辑-所以需要主动触发关闭埋点
 				wx.miniProgram.redirectTo({url: '/pages/index/index?houseId='+this.houseId})
 			}else{
 				let url = $config.min_uri + "pages/index/index?houseId=" + this.houseId
@@ -264,6 +267,7 @@ export default {
 		//联系我们
         conectUS(){
 			if(window.__wxjs_environment === 'miniprogram'){
+				this.pvCloseHandle();//小程序跳转会主动杀死关闭当前页面-不经过vue跳转关闭逻辑-所以需要主动触发关闭埋点
 				wx.miniProgram.navigateTo({url: '/pages/transfer/transfer?event=openCustomerServiceChat&houseId='+this.houseId})
 			}else{
 				// this.$message.warning("敬请期待");
@@ -280,8 +284,13 @@ export default {
 			}else{
 				// window.location.href = shottingImg;
 				let ind =  window.location.href.indexOf('?');
-				let webUrl = window.location.href.substr(0,ind) + "?houseId=" + this.houseId +"&id=" + this.id + "&typeStatus=1";
-				let url = $config.min_uri + "pages/webView/webView?view=" + encodeURIComponent(webUrl) + "&title=梦想设计";
+				let webUrl = window.location.href.substr(0,ind) + "?houseId=" + this.houseId +"&id=" + this.id + "&typeStatus=1"+ "&brandId=" + $config.brandId;
+				let url = '';
+				if (window.self !== window.top) {
+					url = $config.min_uri + "pages/webView/webView?view=" + encodeURIComponent(webUrl) + "&title=梦想设计";
+				} else {
+					url = webUrl;
+				}
 				var textArea = document.createElement("textarea");
 				console.warn("***复制***",url)
 				textArea.value = url;

+ 1 - 0
src/services/requestConfig.js

@@ -55,6 +55,7 @@ const endpoints = {
 	generateShareSign: 'elab-marketing-user/brand/shareSign/generateShareSign',//用户信息加密 获取 秘钥
 	submitAnswer: 'elab-marketing-content/question/submitAnswer',//答题
 	leavephone: 'elab-marketing-user/brandXcx/leavePhone',//web留电
+	webXcxLogin: 'elab-marketing-user/htmlLogin/login', //H5平台登录
 	// predictions: "https://api.replicate.com/v1/deployments/feathers-wing/spacely-realistic-style-softedge-a100/predictions", // 分享查看
 };
 /**

+ 72 - 30
src/utils/util.js

@@ -91,10 +91,24 @@ function websocketclose(e) {
 }
 
 function websocketsend(Data) {
-    console.log('ws状态', wsConfig.ws.readyState)
-	if(wsConfig.ws.readyState==1){
+    console.log('ws状态', wsConfig.ws)
+	if(wsConfig.ws && wsConfig.ws.readyState==1){
+		let param = [
+			"SEND" +
+			"\nproject:" +
+			"elab-marketing-system" +
+			"\nmethod:" +
+			"POST" +
+			"\npath:" +
+			"/behavior/brandMiniWeb/upload" +
+			"\ndestination:" +
+			"/ws/remote/invoke" +
+			"\n\n" +
+			JSON.stringify(Data) +
+			"\u0000",
+		];
 		//数据发送
-		wsConfig.ws.send(Data);
+		wsConfig.ws.send(JSON.stringify(param));
 	}else{
 		// 如果还没有创建好socket链接或者链接还没打开,则放到待发送列表中
 		if(Data){
@@ -126,15 +140,17 @@ function getQueryString(name) {
  * 初始进入页面参数
  */
 function initPage(){
+	let userInfo = getStorage('userInfo') ? JSON.parse(getStorage('userInfo')) : null;
 	let queryObj = getStorage('queryObj') ? JSON.parse(getStorage('queryObj')) : null;
 	let urlObj = queryObj || util.getUrlParams(location.href) || {};
-	let brandId = urlObj.special_ID || $config.brandId || ''
+	let brandId = urlObj.brandId || urlObj.special_ID || $config.brandId || '';
+	let userId = urlObj.leavePhoneCustomerId ? urlObj.leavePhoneCustomerId : (userInfo?userInfo.userId:'');
     return {
         session: urlObj.session || '',
         // 项目id,默认仙女山项目
         houseId: urlObj.xcxHouseId || '',
-        userId: urlObj.leavePhoneCustomerId || '',
-        openId: urlObj.openid || '',
+        userId: userId || '',
+        openId: urlObj.openid || (userInfo ? userInfo.openId : ''),
         brandId: brandId || '',
         product: urlObj.xcxHouseId || '',
         fromPlatform: urlObj.fromProduce || '',
@@ -165,9 +181,31 @@ function connectSend(openid, userid, houseId) {
 	if (socketTaskList && socketTaskList.length > 0) {
 		for (var i = 0; i < socketTaskList.length; i++) {
 			if(socketTaskList[i]){
-				console.log("***ws-socketTaskList列表***", i)
+				// wsConfig.ws.send(socketTaskList[i]);
+				if(!socketTaskList[i].userId){
+					socketTaskList[i].userId = userid;
+					socketTaskList[i].brandUserId = userid;
+				}
+				if(!socketTaskList[i].openId){
+					socketTaskList[i].openId = openid;
+				}
+				// console.log("***ws-socketTaskList列表***", socketTaskList[i])
+				let param = [
+					"SEND" +
+					"\nproject:" +
+					"elab-marketing-system" +
+					"\nmethod:" +
+					"POST" +
+					"\npath:" +
+					"/behavior/brandMiniWeb/upload" +
+					"\ndestination:" +
+					"/ws/remote/invoke" +
+					"\n\n" +
+					JSON.stringify(socketTaskList[i]) +
+					"\u0000",
+				];
 				// 发送堆积的待发送消息
-				wsConfig.ws.send(socketTaskList[i]);
+				wsConfig.ws.send(JSON.stringify(param));
 				socketTaskList[i] = null;
 			}
 		}
@@ -202,7 +240,7 @@ function reconnect() {
  *  重置ws连接
  */
 function reset() {
-    console.log('重置ws', wsConfig)
+    console.log('重启心跳')
     //重置心跳
     clearTimeout(wsConfig.timeoutObj);
     //清除时间
@@ -217,14 +255,14 @@ function reset() {
 function start() {
     let ws = wsConfig.ws;
     //开启心跳
-    console.log("开启心跳", wsConfig);
+    console.log("开启心跳", wsConfig,ws.readyState);
     wsConfig.timeoutObj && clearTimeout(wsConfig.timeoutObj);
     wsConfig.serverTimeoutObj && clearTimeout(wsConfig.serverTimeoutObj);
     wsConfig.timeoutObj = setTimeout(function() {
         //这里发送一个心跳,后端收到后,返回一个心跳消息,
         if (ws.readyState == 1) {
             //如果连接正常
-            // websock.send("heartCheck"); //这里可以自己跟后端约定
+            ws.send("heartCheck"); //这里可以自己跟后端约定
         } else {
             //否则重连
             reconnect();
@@ -390,6 +428,8 @@ var util = {
 			}
 			let queryObj = getStorage('queryObj') ? JSON.parse(getStorage('queryObj')) : null;
 			let urlObj = queryObj || util.getUrlParams(location.href) || {};
+			let userInfo = getStorage('userInfo') ? JSON.parse(getStorage('userInfo')) : null;
+			let userId = urlObj.leavePhoneCustomerId ? urlObj.leavePhoneCustomerId : (userInfo?userInfo.userId:'');
 			let brandId = urlObj.special_ID || $config.brandId || ''
 			//在页面参数里面手动添加path参数
 			pvCurPageParams.brandId = brandId;
@@ -405,9 +445,9 @@ var util = {
 				fromPlatform: urlObj.fromPlatform || urlObj.fromProduce || 'h5',
 				ip: window.ip || '',
 				cookieId: from_cookie || getStorage("cookie_id") || '',
-				openId: urlObj.openid || '',
-				userId: urlObj.leavePhoneCustomerId || '',
-				brandUserId: urlObj.leavePhoneCustomerId || '',
+				openId: urlObj.openid || (userInfo ? userInfo.openId : ''),
+				userId: userId,
+				brandUserId: userId,
 				createTime: this.formatTime(new Date()),
 				uploadTime: this.formatTime(new Date()),
 				product: 'h5', //iframeUrl代表是顾问分享的外链
@@ -428,6 +468,7 @@ var util = {
 				pvLastPageParams: para.pvLastPageParams || '', //上一页页面参数
 				pvPageLoadTime: para.pvPageLoadTime || '', //加载时间
 				type: para.type || '', //埋点类型
+				reserve1: urlObj.channel || '', //来源平台,抖音百度微信
 			}
 			let timeNow = new Date().getTime();
 			let session = getStorage('sessionNumber') ? Number(getStorage('sessionNumber')) : timeNow;
@@ -452,22 +493,23 @@ var util = {
 			// ];
 			// app.wsSendOrder(param,data);//socket 消息发送
 			console.warn("***mook***", (data.pvId || data.clkId || data.eventId), data)
-			let param = [
-			    "SEND" +
-			    "\nproject:" +
-			    "elab-marketing-system" +
-			    "\nmethod:" +
-			    "POST" +
-			    "\npath:" +
-			    "/behavior/brandMiniWeb/upload" +
-			    "\ndestination:" +
-			    "/ws/remote/invoke" +
-			    "\n\n" +
-			    JSON.stringify(data) +
-			    "\u0000",
-			];
-			console.log("上报埋点数据", param);
-			websocketsend(JSON.stringify(param));
+			// let param = [
+			//     "SEND" +
+			//     "\nproject:" +
+			//     "elab-marketing-system" +
+			//     "\nmethod:" +
+			//     "POST" +
+			//     "\npath:" +
+			//     "/behavior/brandMiniWeb/upload" +
+			//     "\ndestination:" +
+			//     "/ws/remote/invoke" +
+			//     "\n\n" +
+			//     JSON.stringify(data) +
+			//     "\u0000",
+			// ];
+			// console.log("上报埋点数据", param);
+			// websocketsend(JSON.stringify(param));
+			websocketsend(data);
 		} catch (e) {
 			console.warn("***util.js-onError***", e);
 		}