用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系统)
上面是“用vuejs实现浙里办埋点注意事项及全部代码案例”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_1429.html
workflows工作流
- 一个可爱的口袋妖怪ComfyUI工作流
- 一只可爱的毛茸茸的猫ComfyUI工作流
- 一只开屏的白色孔雀ComfyUI工作流
- 小孩手握锤子顽皮搞笑卡通3d形象
- 迷人的月光,发光的花朵
- Latent放大comfyui工作流
- 文生图工作流:树枝上站着一只鸟
- 一个女人站在海边的岩石上,飞来一只鸟
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!