01 / SEIRBHÍS MONARAITHE
Iomaíocht bithbhreacsa
Gearr, foirm, ceangail agus cuma cuidí le meitil ó do tharraingt.
Braibseáil Monaraithe Leathair Meitile →\n\n
,需要通过父级DOM结构来判断
*/
var trackActionPhone = function (node) {
var nodeInnerText = node.innerText || '';
if (!limitRegLength(nodeInnerText)) return;
var nodeText = trimText(nodeInnerText);
if (nodeText.length < 5 || nodeText.length > 20) return false;
var type =
arguments.length > 1 && arguments[1] !== undefined
? arguments[1]
: 'click';
var str = trimText(node.href || nodeText || '');
if (phoneReg.test(str) && numUseReg.test(str)) {
window.postMessage({
type: 'SHOPS_CONTACT_TRACK',
data: {
phone: nodeText,
},
}, '*');
_paq.push(['trackEvent', type, 'phone', nodeText]);
return true;
}
/** 排查父级嵌套非标签场景,并且对dom的正则校验做一个性能兜底,通过控制innerText的长度,来确保正则的性能 */
var fatherText = trimText(node.parentNode.innerText || '');
if (fatherText.length < 5 || fatherText.length > 20) return false;
if (phoneReg.test(fatherText) && numUseReg.test(fatherText)) {
window.postMessage({
type: 'SHOPS_CONTACT_TRACK',
data: {
phone: nodeText,
},
}, '*');
_paq.push(['trackEvent', type, 'phone', nodeText]);
return true;
}
return false;
};
window.addEventListener('click', function (e) {
var node = e.target;
/** 社媒点击 */
var appName = '';
var getAppAriaLabel =
node.ariaLabel || node.parentNode.ariaLabel || '';
if (mediaList.includes(getAppAriaLabel.toLowerCase())) {
appName = getAppAriaLabel;
}
if (
!appName &&
node.nodeName &&
node.nodeName.toLowerCase() === 'a'
) {
appName = getMediaName(node.href) || getMediaName(node.alt);
}
if (
!appName &&
node.nodeName &&
node.nodeName.toLowerCase() === 'img'
) {
appName = getMediaName(node.alt) || getMediaName(node.src);
}
if (
!appName &&
node.nodeName &&
node.nodeName.toLowerCase() === 'i'
) {
appName = getMediaName(node.className);
}
if (appName) {
_paq.push(['trackEvent', 'click', 'contactApp', appName]);
return;
}
/** 联系方式点击 */
if (trackActionPhone(node, 'click')) return;
if (node.nodeName && node.nodeName.toLowerCase() === 'a') {
var val = node.href;
if (!limitRegLength(val)) return;
if (emailReg.test(val)) {
window.postMessage({
type: 'SHOPS_CONTACT_TRACK',
data: {
email: val,
},
}, '*');
_paq.push(['trackEvent', 'click', 'email', val]);
return;
}
}
if (node.nodeName && node.nodeName.toLowerCase() === 'i') {
var val = node.className;
var content = node.parentNode.href || '';
if (val.includes('email')) {
window.postMessage({
type: 'SHOPS_CONTACT_TRACK',
data: {
email: content,
},
}, '*');
_paq.push(['trackEvent', 'click', 'email', content]);
return;
}
}
var nodeChildList = node.childNodes;
for (var i = 0; i < nodeChildList.length; i++) {
if (nodeChildList[i].nodeType !== 3) continue;
var val = nodeChildList[i].textContent.replace(/\s?:?/g, '');
if (!limitRegLength(val)) continue;
if (emailReg.test(val)) {
window.postMessage({
type: 'SHOPS_CONTACT_TRACK',
data: {
email: val,
},
}, '*');
_paq.push(['trackEvent', 'click', 'email', val]);
return;
}
}
trackNumberData(node);
});
window.addEventListener('copy', function (e) {
if (trackActionPhone(e.target, 'copy')) return;
var text = e.target.textContent;
if (!text) return;
var val = text.replace(/\s:?/g, '');
if (!limitRegLength(val)) return;
if (emailReg.test(val)) {
window.postMessage({
type: 'SHOPS_CONTACT_TRACK',
data: {
email: val,
},
}, '*');
_paq.push(['trackEvent', 'copy', 'email', val]);
return;
}
trackNumberData(e.target);
});
}
trackContactInit();
/**
* 基于custom_inquiry_form.js 以及 form.js 对于询盘表单提交的实现,来反推询盘表单的input标签触发,用来收集意向客户
* 1. 缓存的KEY:TRACK_INPUT_ID_MTM_00;
* 2. 缓存策略 - lockTrackInput:单个页面内,10分钟内,不重复上报
*/
function trackActionInput() {
const CACHE_KEY = 'TRACK_INPUT_ID_MTM_00';
const pathName = window.location.hostname + window.location.pathname;
var lockTrackInput = function () {
try {
const lastCacheData = localStorage.getItem(CACHE_KEY);
if (!lastCacheData) return false;
const cacheData = JSON.parse(lastCacheData);
const cacheTime = cacheData[pathName];
if (!cacheTime) return false;
return Date.now() - cacheTime < 1000 * 60 * 10; // 10分钟内,不重复上报
} catch (error) {
console.error('lockTrackInput Error', error);
return false;
}
};
var setInputTrackId = function () {
try {
const curCacheData = localStorage.getItem(CACHE_KEY);
if (curCacheData) {
const cacheData = JSON.parse(curCacheData);
cacheData[pathName] = Date.now();
localStorage.setItem(CACHE_KEY, JSON.stringify(cacheData));
return;
}
const cacheData = {
[pathName]: Date.now(),
};
localStorage.setItem(CACHE_KEY, JSON.stringify(cacheData));
} catch (error) {
console.error('setInputTrackId Error', error);
}
};
var getInputDom = function (initDom) {
var ele = initDom;
while (ele) {
/**
* isWebSiteForm 是站点的表单
* isChatWindowForm 是聊天窗口的表单
*/
/** 旧模板表单 */
var isWebSiteForm = !!(
/crm-form/i.test(ele.className) && ele.querySelector('form')
);
/** 1:新模板自定义表单、2:Get a Quote 弹框表单 */
var isWebSiteFormNew = !!(
/inquiry/i.test(ele.className) && ele.querySelector('form')
);
if (isWebSiteForm || isWebSiteFormNew) {
_paq.push(['trackEvent', 'formInquiry', 'formInput', 'page']);
setInputTrackId();
return;
}
/** Mkt会话触达-聊天弹框的表单输入: MKT由于是iframe嵌入,所以MKT的上报,会单独写到MKT-form代码上 */
var isInquiryChatForm = !!(
/comp-form/i.test(ele.className) && ele.querySelector('form')
);
if (isInquiryChatForm) {
_paq.push(['trackEvent', 'formInquiry', 'formInput', 'chat']);
setInputTrackId();
return;
}
/** 向上查找父节点 */
ele = ele.parentNode;
}
};
function initInputListener() {
var inputUseDebounce = function (fn, delay) {
var timer = null;
var that = this;
return function () {
var args = Array.prototype.slice.call(arguments);
if (timer) clearTimeout(timer);
timer = setTimeout(function () {
fn.apply(that, args);
}, delay);
};
};
var optimizeGetInputDom = inputUseDebounce(getInputDom, 300);
window.addEventListener('input', function (e) {
/** 如果已经上报过,则不再上报 */
if (lockTrackInput()) return;
optimizeGetInputDom(e.target);
});
}
try {
initInputListener();
} catch (error) {
console.log('initInputListener Error', error);
}
}
trackActionInput();
}
/** 第三方消息上报:目前主要是针对全点托管会话;在msgCollect/index.js中调试,访问test.html */
function thirdMsgCollect() {
/** 先检测是否是stayReal托管:如果stayReal脚本都没有,那么说明当前站点未开启stayReal会话托管 */
const scriptList = Array.prototype.slice.call(
document.querySelectorAll('script'),
);
const checkStayReal = () =>
!!scriptList.find((s) => s.src.includes('stayreal.xiaoman.cn'));
if (!checkStayReal()) return;
/** 缓存当前消息队列的最后一条消息id */
const CACHE_KEY = 'CACHE_KEY_MONITOR';
const setCache = (msgIndex) => {
/** 对缓存KEY进行base64转码处理 */
const cacheMsgIndex = btoa(msgIndex);
localStorage.setItem(CACHE_KEY, cacheMsgIndex);
};
const getCache = () => {
const cacheMsgIndex = localStorage.getItem(CACHE_KEY);
if (cacheMsgIndex) return Number(atob(cacheMsgIndex));
return -1;
};
/** 拉取最新msg列表 */
const pullMsgList = () => {
const msgEleList = Array.prototype.slice.call(
document.querySelectorAll('#chat-list li'),
);
const msgIds = [];
const msgMap = msgEleList.reduce((acc, item) => {
const sendTime = item
.querySelector('.message-data-time')
.textContent.trim();
const sendContent = item.querySelector('.message').textContent.trim();
/** msg带有class:other-message的是访客消息,my-message的是客服消息 */
const isOtherMessage = item
.querySelector('.message')
.classList.contains('other-message');
const msgId = item.querySelector('.message').getAttribute('id');
const msgItemData = {
msgId,
user: isOtherMessage ? 'visitor' : 'official',
time: sendTime,
content: sendContent,
};
msgIds.push(msgId);
acc[msgId] = msgItemData;
return acc;
}, {});
return {
ids: msgIds,
dataMap: msgMap,
};
};
/** 加密并上传消息数据 */
let ENCRYPT_KEY = 'de29f1aab63ab033';
let ENCRYPT_IV = 'b8d2badf875e76ac';
const baseUrl = 'https://cms.xiaoman.cn';
// var getEncryptConfig = function () {
// const url = baseUrl + '/shop-api/innerApi/getKeyIv'
// $.get(
// url,
// function (result) {
// console.log('result', result)
// if (Number(result.code) === 0 && result.data.key && result.data.iv) {
// ENCRYPT_KEY = result.data.key
// ENCRYPT_IV = result.data.iv
// uploadMsgData()
// } else {
// /** 如果获取失败,则重试 */
// setTimeout(() => {
// getEncryptConfig()
// }, 1000)
// }
// },
// 'json'
// )
// }
// getEncryptConfig()
const encryptMsg = function (msgData) {
const enc = new TextEncoder();
// 转字节
const keyBytes = enc.encode(ENCRYPT_KEY);
const ivBytes = enc.encode(ENCRYPT_IV);
const plainBytes = enc.encode(msgData);
// 导入密钥并加密
return crypto.subtle
.importKey('raw', keyBytes, { name: 'AES-CBC' }, false, ['encrypt'])
.then(function (cryptoKey) {
return crypto.subtle.encrypt(
{ name: 'AES-CBC', iv: ivBytes },
cryptoKey,
plainBytes,
);
})
.then(function (encryptedBuffer) {
// 转 base64 返回
return btoa(
String.fromCharCode(...new Uint8Array(encryptedBuffer)),
);
})
.catch((err) => {
return Promise.reject(err);
});
};
let uploadFlag = false;
const uploadMsgData = function () {
if (uploadFlag) return;
uploadFlag = true;
const { ids, dataMap } = pullMsgList();
let cacheMsgIndex = getCache();
const msgLen = ids.length;
if (!msgLen) {
// 消息DOM未挂载 || 消息DOM已挂载,但是消息列表为空
uploadFlag = false;
return;
}
if (msgLen - 1 < cacheMsgIndex) {
/** 针对站点挂后台一段时间,消息列表会自动塞入重复消息,导致消息有重复,刷新后又重置回正常消息列表,所以这里需要更新锚点下标 */
cacheMsgIndex = msgLen - 1;
setCache(cacheMsgIndex);
uploadFlag = false;
return;
}
if (msgLen - 1 === cacheMsgIndex) {
// 缓存的最后一次发送的消息ID是最后一条(说明当前消息均已经上报),则不跳过本地上报
uploadFlag = false;
return;
}
const currentMsgIds = ids.slice(cacheMsgIndex + 1, msgLen);
const currentMsgData = currentMsgIds.map((id) => dataMap[id]);
const mtmId = window.matomo_site_id_cookie_key || ''; // 获取mtm会话id
const msgBody = {
mtmId,
curl: window.location.href,
msgList: currentMsgData,
};
const msgBodyStr = JSON.stringify(msgBody);
encryptMsg(msgBodyStr)
.then(function (encryptedMsg) {
console.log('encryptedMsg:', encryptedMsg, msgBodyStr);
const url = baseUrl + '/shop-api/External/ListenSiteActiveStatus';
$.ajax({
type: 'POST',
url,
data: JSON.stringify({ d_v: encryptedMsg }),
contentType: 'application/json',
success: function (result) {
if (Number(result.code) === 0) {
// 更新消息队列
setCache(msgLen - 1);
}
uploadFlag = false;
},
error: function (err) {
console.error(err, '请求异常');
uploadFlag = false;
},
});
})
.catch((err) => {
console.error(err, '数据加密失败');
uploadFlag = false;
});
};
/** 监控chat-list的DOM变更 */
const initChatListObserver = () => {
// 需要监听的 DOM 节点
const target = document.getElementById('chat-list');
if (!target) return;
// 回调函数
const callback = function (mutationsList, observer) {
for (const mutation of mutationsList) {
console.log('mutation', mutation);
if (mutation.type === 'childList') {
uploadMsgData();
}
}
};
// 配置
const config = {
childList: true, // 监听子节点的增删
subtree: true, // 是否也监听后代节点
};
// 创建 observer
const observer = new MutationObserver(callback);
// 开始监听
observer.observe(target, config);
};
let testCount = 30;
let itv = null;
const checkChatDom = () => !!document.querySelector('#vc-model');
const initTalkCheck = () => {
itv = setTimeout(() => {
console.log('checkChatDom', checkChatDom(), testCount);
if (!checkChatDom() && testCount > 0) {
testCount--;
initTalkCheck();
return;
}
clearTimeout(itv);
uploadMsgData();
initChatListObserver();
}, 1500);
};
initTalkCheck();
}
try {
gtmTrack();
thirdMsgCollect();
console.log('inserted gtm code');
} catch (error) {
console.error('gtmTrack Error', error);
}
});
})();
Roghnaigh ó 12 seirbhís nó seol do tharraingt chun a mheas ar son tionscnamh áirithe. D’fhéadfadh tarraingiú a bheith ag teastáil níos mó ná aon phróiseas. Úsáid na pointí tosaichte thíos chun athbhreithniú a struchtúrú, ná mar ionad do mheas inžinéiríochta. 01 Deimhnigh an leathbhreithniú, an táirge, na líon, na gnéithe criticiúla agus na critéir glacta. 02 Roghnaigh an t-ord na hoibríochtaí gearrtha, cruthaithe, ceangailte, meaisínithe agus críochnaithe. 03 Seiceáil na tomhais agus an t-áis a d’fhógair an tionscadal i gcomparáid le riachtanais an tionscadail a bheith dearbhaithe. 04 Dearbhaigh an pacáil, an lipéadú agus treoracha an ionspairt roimh an seoladh. Seol do thionchar athbhreithnithe, an gradam ábhair, an tiús nó an trastomhas, na méid, na tolairtí criticiúla agus an críochnú aghaidhe. Cuir leis na riachtanais inspéicte, na doiciméid agus na riachtanais pacála má tá sé oiriúnach. An bhfuil samplaí de dhíth ort sula dtosóidh tú ag plé ar an mbealach? Brabhsáil samplaí tionscadal monaraithe → Athbhreithniú ar chruth, ar an uimhir agus ar an mbaol athbhreithnithe i gcomhbhrí. Úsáideann gearradh le lasair próifílí clártha gan bhacán tionscnaimh; d’fhéadfadh stampáil a bheith oiriúnach nuair a bhíonn iarratas atá ina dhiaidh sin ann agus nuair a mhíníonn an bealach uirlisí é. Is féidir le tionscadal roinnt próiseas a chur le chéile – gearradh, corrú, ceangal, maisiú agus comhlámh. Ba cheart an t-ord a athbhreithniú timpeall ar na hiontrálacha criticiúla, ar na tolarainseanna agus ar an nplán inspéicte. Aithnigh an ranga ábhair, an tiús nó an trastomhas, an timpeallacht oibriúcháin agus an críochnú. Tagann an oiriúnacht i dtreo cruth an pháirte agus an phróiseas roghnaithe; dearbhaigh an ranga le linn athbhreithnithe na ndearbhchárta. Tá protatíopa tapa agus tionscnaimh i mbroinn mór mar sheirbhísí scartha. Cabhraíonn fás an dhearbhchárta, an mbaol athbhreithnithe agus an iarratas atá ag súil leis le cinneadh a dhéanamh ar an mbealach oiriúnach. Cuir isteach an leagan reatha den tionscadal, an t-ábhar, an uimhir, na tolaráinsí criticiúla, an críochnú agus na riachtanais um sholáthar. Aithnigh freisin na taifid a éilítear maidir le scrúdú, an phacáil nó láimhseáil speisialta. Tagann an praghas agus an tréimhse roimh ré i gceist leis an tionscadal, an t-ábhar, an uimhir, an bealach próiseála, an críochnú, an scrúdú agus raon an phacáil. Dearbhaítear iad seo don tionscadal sonrach seachas iad a ghealltaint roimh ré. Roinn an tionscadal, an t-ábhar agus na huimhreacha. Tosaigh le athbhreithniú ar tháirgeadh sula dtugtar aon ghealltanas ar bhealach próiseála.
Seirbhísí Feabhsuithe
Cuidí le meitil. An próiseas ceart.
Aimsigh Do Sheirbhís Monaraithe
Roghnaigh an próiseas monaraithe ceart
Teastas an pháirt nó an tionscnamh
Bóithre le hathbhreithniú
Ionchuir tábhachtacha don ghníomh a dhéanamh
Proifílí cothrom, pláinéid agus comhlaí cruthaithe
Gearrthar le lasair, baineadh, fabhráil meirge le haghaidh cláir
Tineas an ábhair, geoiméadracht an bhainthe, críochnú
Páirteanna cruthaithe atá arís nó cuainn tarraingte
Staimpáil, tarraingt domhain
Uirlisí, líon, geoméatriú, riosc leathbhreithniú
Boráin, snáitheanna, páicéid nó gnéithe rothartha
Macháil CNC, milliú, timpeallú
Córas dátam, toléráinsí, rochtain ar uirlisí
Frámaí agus cruinniúcháin iolachád
Imbógáil, cruinniú agus próisis tacaíochta
Comhthéacsanna, easpa fhoirme, sraith inspéicte
Ó Leathbhreithniú na n-earraí go dtí na príomhpháirteanna a sholáthar
Leathbhreithniú an t-oileáin
Pleanáil an bealach
Seiceáil na codanna
Ullmhaigh an t-ionspairt
Tabhair do RFQ pointe tosaithe soiléir
Ceisteanna Coitianta
Conas a roghnú idir gearradh le lasair agus stampáil?
An féidir le tionscadal amháin roinnt próiseas a chur le chéile?
Cén ábhar a chórasfaidh mé?
An dtacaíonn sibh le protatíopa agus le tionscnaimh atá ina dhiaidh sin?
Céard a chórasfaidh mé i mo iarratas ar fhaighte?
Conas a bhfuil an prís agus an tréimhse roimh ré dearbhaithe?
Nach bhfuil tú cinnte cén tseirbhís a bheidh oiriúnach do do chuid páirteanna?