用vuejs实现浙里办埋点注意事项及全部代码案例

762 ℃

用vuejs实现浙里办埋点注意事项及全部代码案例,注意所有埋点都要写到index.html中,写到其它的vuejs中无效。

//获取链接参数
function getQueryString(name) {
	var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
	var r = window.location.search.substr(1).match(reg);
	if (r != null) return decodeURI(r[2]);
	return null;
}
//判断是否有票据ticket
const _t = getQueryString("ticket");
if (!localStorage.getItem("ZLB_TICKET")) {
	if (!_t) {
		localStorage.setItem("INIT_LINK", window.location.href);
		window.location.href =
			"https://puser.zjzwfw.gov.cn/sso/mobile.do?action=oauth&scope=1&servicecode=业务代码&goto=https://mapi.zjzwfw.gov.cn/web/mgop/gov-open/zj/2001832594/1.3.7/index&debug=true";
	} else {
		localStorage.setItem("ZLB_TICKET", _t);
	}
}
//原生js-ajax方法
function ajax() {  
	var ajaxData = {    
		type: arguments[0].type || "GET",
		    url: arguments[0].url || "",
		    async: arguments[0].async || "true",
		    data: arguments[0].data || null,
		    dataType: arguments[0].dataType || "text",
		    contentType: arguments[0].contentType || "application/x-www-form-urlencoded",
		    beforeSend: arguments[0].beforeSend || function() {},
		    success: arguments[0].success || function() {},
		    error: arguments[0].error || function() {}  
	}  
	ajaxData.beforeSend()
	var xhr = createxmlHttpRequest();   
	xhr.responseType = ajaxData.dataType;  
	xhr.open(ajaxData.type, ajaxData.url, ajaxData.async);   
	xhr.setRequestHeader("Content-Type", ajaxData.contentType);
	xhr.setRequestHeader("ticket", localStorage.getItem("ZLB_TICKET")); 
	xhr.send(convertData(ajaxData.data));   
	xhr.onreadystatechange = function() {     
		if (xhr.readyState == 4) {       
			if (xhr.status == 200) {        
				ajaxData.success(xhr.response)      
			} else {        
				ajaxData.error()      
			}     
		}  
	} 
}  
function createxmlHttpRequest() {   
	if (window.ActiveXObject) {     
		return new ActiveXObject("Microsoft.XMLHTTP");   
	} else if (window.XMLHttpRequest) {     
		return new XMLHttpRequest();   
	} 
}  
function convertData(data) {
	if (typeof data === 'object') {    
		var convertResult = "";     
		for (var c in data) {       
			convertResult += c + "=" + data[c] + "&";     
		}     
		convertResult = convertResult.substring(0, convertResult.length - 1)
		return convertResult;  
	} else {    
		return data;  
	}
}
//获取token接口
function getTokenByToken() {
	ajax({
		type: "get",
		url: "接口链接",
		dataType: "json",
		data: {

		},
		beforeSend: function() {

		},
		success: function(res) {
			console.log('res', res)
			if (res && res.code == 10000) {
				localStorage.setItem("ZLB_TOKEN", res.content.token);
				// 埋点
				(function(w, d, s, q, i) {
					w[q] = w[q] || [];
					var f = d.getElementsByTagName(s)[0];
					var j = d.createElement(s);
					j.async = true;
					j.id = "beacon-aplus";
					j.src = "https://d.alicdn.com/alilog/mlog/aplus.js?id=202951085";
					f.parentNode.insertBefore(j, f);
				})(window, document, "script", "aplus_queue");
				aplus_queue.push({
					action: "aplus.setMetaInfo",
					arguments: ["aplus-rhost-v", "alog.zjzwfw.gov.cn"]
				});
				aplus_queue.push({
					action: "aplus.setMetaInfo",
					arguments: ["aplus-rhost-g", "alog.zjzwfw.gov.cn"]
				});
				aplus_queue.push({
					action: "aplus.setMetaInfo",
					arguments: ["appId", "60506758"]
				});
				aplus_queue.push({
					action: "aplus.setMetaInfo",
					arguments: ["_user_id", res.content.userId]
				});
				aplus_queue.push({
					action: "aplus.setMetaInfo",
					arguments: ["_user_nick", res.content.userName]
				});
			} else if (res && res.code == 403) {
				// Message.warning({ message: response.data.message });
				window.location.replace(localStorage.getItem("INIT_LINK"));
			} else {
				console.log(res.message)
			}
		},
		error: function() {
			console.log("error")
		}
	})
}

浙里办小程序window.open失效解决方法(ios系统)

浙里办获取PV日志参数埋点

浙里办调用ZWJSBridge方法须知

浙里办二次回退已解决,兼容支付宝小程序和浙里办app

浙里办项目中如何获取经纬度、城市区域、当前地址等相关信息

标签: 埋点, 浙里办

上面是“用vuejs实现浙里办埋点注意事项及全部代码案例”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。

当前网址:https://m.ipkd.cn/webs_1429.html

声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

织梦DEDE会员空间文章列表无法分页的问题的解决
html5中video视频只有声音没有图像怎么解决
JS和JQuery获取当前屏幕宽度和高度的代码(新手小
wordpress如何在文章阅读量上新增一个基数?
网站排名好都具备哪些特点