!(function (window, $) { $(document).ready(function () { let BASE_URL = $('#wcm-base-url') ? $('#wcm-base-url').val() : ''; let PROFILE_NAME = $('#wcm-profile-name') ? $('#wcm-profile-name').val() : ''; if (!BASE_URL || BASE_URL.indexOf('wcm_base_url') > -1) { if (window.location.href.indexOf('sit') > -1 || window.location.href.indexOf('b1') > -1 || window.location.href.indexOf('localhost.huawei.com') > -1) { BASE_URL = 'https://kwesit.huawei.com'; PROFILE_NAME = 'sit'; } else if (window.location.href.indexOf('uat') > -1) { BASE_URL = 'https://kweuat.huawei.com'; PROFILE_NAME = 'uat'; } else if (window.location.href.indexOf('icsl') > -1) { BASE_URL = 'https://icsl-eplus.his-beta.huawei.com'; PROFILE_NAME = 'icsl'; } else { BASE_URL = 'https://partner.huawei.com'; PROFILE_NAME = 'production'; } } let LOGIN_PATH = $('#wcm-login-url') ? $('#wcm-login-url').val() : ''; if (!LOGIN_PATH || LOGIN_PATH.indexOf('wcm_login_url') > -1) { if (window.location.href.indexOf('sit') > -1 || window.location.href.indexOf('b1') > -1 || window.location.href.indexOf('localhost.huawei.com') > -1) { LOGIN_PATH = 'https://uniportal-beta.huawei.com/uniportal1/login-pc.html'; } else if (window.location.href.indexOf('uat') > -1) { LOGIN_PATH = 'https://uniportal-beta.huawei.com/uniportal1/login-pc.html'; } else if (window.location.href.indexOf('icsl') > -1) { LOGIN_PATH = 'https://uniportal-beta.huawei.com/uniportal1/login-pc.html'; } else { LOGIN_PATH = 'https://uniportal.huawei.com/uniportal1/login-pc.html'; } } let HOME_BASE_URL = $('#wcm-worldwide-base-url') ? $('#wcm-worldwide-base-url').val() : ''; if (!HOME_BASE_URL || HOME_BASE_URL.indexOf('wcm-worldwide-base-url') > -1) { if (window.location.href.indexOf('sit') > -1 || window.location.href.indexOf('b1') > -1 || window.location.href.indexOf('localhost.huawei.com') > -1) { HOME_BASE_URL = 'https://std.metacrm-b1.beta.huawei.com/metacrm/pub/openapi/kwesit.huawei.com'; } else if (window.location.href.indexOf('uat') > -1) { HOME_BASE_URL = 'https://std.metacrm-b1.beta.huawei.com/metacrm/pub/openapi/kweuat.huawei.com'; } else if (window.location.href.indexOf('icsl') > -1) { HOME_BASE_URL = 'https://std.metacrm-b1.beta.huawei.com/metacrm/pub/openapi/kweicsl.huawei.com'; } else { HOME_BASE_URL = 'https://std.crm.saas.huawei.com/metacrm/pub/openapi/partner.huawei.com'; } } const constants = { LANGUAGE: { ZH_CN: 'zh_CN', EN_US: 'en_US', JA_JP: 'ja_JP', RU_RU: 'ru_RU', ES_MX: 'es_MX', PT_BR: 'pt_BR', }, LANGUAGE_NAME: { zh_CN: '简体中文', en_US: 'English', ja_JP: '日本語', ru_RU: 'Русский', pt_BR: 'Português', ES_MX: 'español', }, LANGUAGE_TYPE: { zh_CN: 'cn', en_US: 'en', ja_JP: 'jp', ru_RU: 'ru', pt_BR: 'pt', ES_MX: 'es', }, APP_ID: 'com.huawei.channelsales.echannel.echannel2.0', SUB_APP_ID: 'ePartner_service', MY_TODO_NAME_MAP: { zh_CN: '我的待办', en_US: 'My Todo', ru_RU: 'Мои задачи', }, CONTEXT_ROOT: '/eplusweb', COMMON_SERVICE: '/ePartner/apigateway/com.huawei.channelsales.echannel.echannel2.0:ePartner_comservice/ePartner/commonservice/services', E_PARTNER_SERVICE: '/ePartner/apigateway/com.huawei.channelsales.echannel.echannel2.0:ePartner_service/ePartner/service/services', }; function initAjaxSet() { $.ajaxSetup({ xhrFields: { withCredentials: true, }, contentType: 'application/json', crossDomain: true, }); } function interceptAjax() { $.ajaxSetup({ beforeSend: function (xhr, config) { if (config.url.indexOf(constants.APP_ID) === -1) { return; } const token = localStorage.getItem('x-csrf-token'); if (token) { xhr.setRequestHeader('x-csrf-token', token); } if (!config.headers) { config.headers = {}; } if (!config.headers['x-app-id']) { xhr.setRequestHeader('x-app-id', constants.APP_ID); } if (!config.headers['x-sub-app-id']) { xhr.setRequestHeader('x-sub-app-id', constants.SUB_APP_ID); } }, complete: function (xhr, config) { const token = xhr.getResponseHeader('x-csrf-token'); if (token) { localStorage.setItem('x-csrf-token', token); } if (xhr.status === 403) { goUniPortalLogin(); } }, }); } function getCurrentLanguage() { return sessionStorage.getItem('epartner-current-language'); } function getCurrentUserInfo() { return sessionStorage.getItem('current-user-info') && JSON.parse(sessionStorage.getItem('current-user-info')); } function isLogin() { return sessionStorage.getItem('epartner-is-login') && sessionStorage.getItem('epartner-is-login').toString() === 'true'; } function isChina() { return sessionStorage.getItem('epartner-current-language') && sessionStorage.getItem('epartner-current-language').toString() === constants.LANGUAGE.ZH_CN; } function isAssociatedCompany() { return sessionStorage.getItem('epartner-is-associated') && sessionStorage.getItem('epartner-is-associated').toString() === 'true'; } function isHW() { return getCurrentUserInfo().userType !== 'E_PT'; } function goUniPortalLogin(url) { let origin = window.location.origin; let com = origin.substring(origin.lastIndexOf('.') + 1, origin.length).split(':')[0]; if (url) { url = url.replace(/{origin}/gi, com); } window.location.href = DOMPurify.sanitize(`${LOGIN_PATH.replace('com', com)}?redirect=${url || window.location.href}`); } function getLogoOutUrl() { return sessionStorage.getItem('epartner-logout-url'); } function getHomeUrl() { return sessionStorage.getItem('epartner-home-url'); } function getProfileName() { return PROFILE_NAME; } function isProduction() { return PROFILE_NAME === 'production'; } function replaceOrigin(str, oldV) { let origin = BASE_URL, newV = ''; if (origin.indexOf('huawei.com') == -1) { newV = `.huawei.${origin.substring(origin.lastIndexOf('.') + 1, origin.length)}`; } if (newV != '') { let reg = new RegExp(`\\${oldV}`, 'gi'); return str.replace(reg, newV); } return str; } function getUrlValue(value) { let hashs = top.window.location.hash.split('?'); if (value != '' && hashs != undefined) { let arr = hashs[hashs.length - 1].split('&'); for (let i = 0; i < arr.length; i++) { if (arr[i].search(`${value}=`) != -1) { return arr[i].substring(arr[i].indexOf('=') + 1, arr[i].length); } } } return ''; } function dialogDragging({ $dialog, $header, closeDialog }) { let baseLeft = 0; let baseTop = 0; return e => { var offsetX = e.clientX - $dialog.offsetLeft; var offsetY = e.clientY - $dialog.offsetTop; const width = $($dialog).width(); const height = $($dialog).height(); const isOuterLeft = offsetX < -width / 2; const isOuterRight = offsetX > width / 2; const isOuterTop = offsetY < -height / 2; const isOuterBottom = offsetY > height / 2; if (isOuterLeft || isOuterRight || isOuterTop || isOuterBottom) { closeDialog(); return; } const isOuterHeader = offsetY > -height / 2 + $($header).outerHeight(); if (isOuterHeader) { return; } if (baseLeft === 0) { baseLeft = $dialog.offsetLeft; baseTop = $dialog.offsetTop; } function dragDialog(ev) { let left = ev.clientX - offsetX; let top = ev.clientY - offsetY; if (left < width / 2) { left = width / 2; } else if (left >= Math.floor(baseLeft * 2 - width / 2 - 1)) { left = Math.floor(baseLeft * 2 - width / 2 - 1); } if (top < height / 2) { top = height / 2; } else if (top >= Math.floor(baseTop * 2 - height / 2 - 1)) { top = Math.floor(baseTop * 2 - height / 2 - 1); } $dialog.style.left = left + 'px'; $dialog.style.top = top + 'px'; } function stopDragging() { document.removeEventListener('mousemove', dragDialog); document.removeEventListener('mouseup', stopDragging); } document.addEventListener('mousemove', dragDialog); document.addEventListener('mouseup', stopDragging); }; } function partnerI18n() { this.i18nConfig = { zh_CN: { pageTitle: '华为政企合作伙伴门户', }, en_US: { pageTitle: 'Huawei Partner for Global Enterprise Business', }, }; } partnerI18n.prototype.init = function (key) { window.$t = key => { const lang = getCurrentLanguage(); const currentI18n = this.i18nConfig[lang]; if (!key) { return ''; } i18nKeyArr = key.toString().split('.'); let result = ''; let temp = JSON.parse(JSON.stringify(currentI18n)); i18nKeyArr.some(item => { if (temp[item]) { temp = temp[item]; } }); if (typeof temp === 'string') { return temp; } return key; }; }; function checkLanguage(isLoginType, isAssociatedType, countryName) { let url = window.location.href; let lang; let domainType = false; let hrefList = [ 'http://localhost.huawei.com:8082/', 'http://localhost.huawei.com:8082', 'http://localhost.huawei.com:8082/#', 'http://localhost.huawei.com:8082/#/', 'https://kwesit.huawei.com/eplusweb/', 'https://kwesit.huawei.com/eplusweb', 'https://kwesit.huawei.com/eplusweb/#', 'https://kwesit.huawei.com/eplusweb/#/', 'https://kweuat.huawei.com/eplusweb/', 'https://kweuat.huawei.com/eplusweb', 'https://kweuat.huawei.com/eplusweb/#', 'https://kweuat.huawei.com/eplusweb/#/', 'https://partner.huawei.com/', 'https://partner.huawei.com', 'https://partner.huawei.com/#', 'https://partner.huawei.com/#/', 'http://partner.huawei.com/', 'http://partner.huawei.com', 'http://partner.huawei.com/#', 'http://partner.huawei.com/#/', ]; domainType = hrefList.includes(url); if (domainType) { lang = domainLanguageFn(isLoginType, isAssociatedType, countryName); } else { if (url.indexOf('/en/') > -1) { lang = 'en_US'; } else if (url.indexOf('/jp/') > -1) { lang = 'ja_JP'; } else if (url.indexOf('/ru/') > -1) { lang = 'ru_RU'; } else if (url.indexOf('/es/') > -1) { lang = 'es_MX'; } else if (url.indexOf('/pt/') > -1) { lang = 'pt_BR'; } else if (url.indexOf('/cn/') > -1) { lang = 'zh_CN'; } else { lang = 'en_US'; } } return lang; } function domainLanguageFn(isLoginType, isAssociatedType, countryName) { let lang; if (isLoginType && isAssociatedType) { switch (countryName) { case 'China': lang = 'zh_CN'; break; case 'Russia': lang = 'ru_RU'; break; case 'Japan': lang = 'ja_JP'; break; default: lang = 'en_US'; break; } } else if (!isLoginType || (isLoginType && !isAssociatedType)) { let navLang = navigator.language || navigator.userLanguage; navLang = navLang.substr(0, 2); if (navLang === 'ru') { lang = 'ru_RU'; } else if (navLang === 'ja') { lang = 'ja_JP'; } else if (navLang === 'es') { lang = 'es_MX'; } else if (navLang === 'pt') { lang = 'pt_BR'; } else { lang = navLang === 'zh' ? 'zh_CN' : 'en_US'; } } return lang; } function initLogin() { $.ajax({ type: 'GET', dataType: 'json', headers: { 'x-app-id': constants.APP_ID, 'x-sub-app-id': constants.SUB_APP_ID, }, url: `${BASE_URL}${constants.COMMON_SERVICE}/common/v1/public/queryLookupList?classifyCode=Link_Trustlist_vue&language=zh`, success: function (res) { checkLoginByInterface(); }, error: function () { checkLoginByInterface(); }, }); } async function checkLoginByInterface(obj) { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/docHand/loginForMarket`, success: function (res) { if ((res.status && res.status.toString() === '200') || (res.respCode && res.respCode.toString() === '200')) { sessionStorage.setItem('epartner-is-login', true); } else { sessionStorage.setItem('epartner-is-login', false); } checkLoginCallback(); }, error: function (e) { sessionStorage.setItem('epartner-is-login', false); checkLoginCallback(); }, }); } async function checkLoginCallback() { interceptAjax(); if (isLogin()) { await getLoginUserInfo(); } else { await getUnLoginUserInfo(); } new partnerI18n().init(); document.title = $t('pageTitle'); new epartnerPageTopNav({ loginFlag: isLogin() }).init(); new epartnerPageMenuHorizontal({ loginFlag: isLogin() }).init(); new expartnerDialog({ loginFlag: isLogin() }).init(); showLoginInfo(); $('.header-lang-current .header-lang-label').html(constants.LANGUAGE_NAME[getCurrentLanguage()]); initLang(); initTools(); if (isLogin()) { $('.pep-partner-login') && $('.pep-partner-login').css('display', 'none'); } else { $('.pep-partner-login') && $('.pep-partner-login').css('display', 'flex'); } new search().init(); new cookieStatement().init(); new downloadEApp().init(); new menuHead({ loginFlag: isLogin(), isAssociatedType: isAssociatedCompany(), isHW: isHW() }).init(); } function getUnLoginUserInfo() { return new Promise(resolve => { $('.register').css('display', 'flex'); sessionStorage.setItem('epartner-current-language', checkLanguage(false)); sessionStorage.setItem('current-user-info', JSON.stringify({ userAccount: '-Default-' })); resolve(true); }); } async function getLoginUserInfo(linkArr, linkDesc) { let res = await getUserInfo(); if (res.status === 403) { sessionStorage.setItem('epartner-is-login', false); goUniPortalLogin(); return; } if (res.user && res.user.userAccount) { handlerHwAccount(res.user.userAccount); sessionStorage.setItem('epartner-is-login', true); const userInfo = res.user; sessionStorage.setItem('current-user-info', JSON.stringify(userInfo)); $('.register').remove(); new protocolAndWebsite().init(); const isAssociatedType = (await checkAssociated(userInfo.userAccount)) || false; sessionStorage.setItem('epartner-is-associated', isAssociatedType); if (isAssociatedType || isHW()) { getMenuData(); } const accountInfo = (await findAccountRoleFn(userInfo.userAccount)) || ''; const lang = checkLanguage(true, isAssociatedType, accountInfo.countryName); sessionStorage.setItem('epartner-current-language', lang); if (isAssociatedType) { $('.header-lang').remove(); } $('.login-user-info .item-container').css('borderLeft', 'none'); initLogout(); initMyTodo(); const workspaceRes = await queryWorkspaceFlag(); if (workspaceRes.value !== '1') { $('.header-user-list #myHuawei').remove(); $('.header-user-list #workspace').remove(); } else if (!isAssociatedType) { $('.header-user-list #myHuawei').remove(); } if (workspaceRes.value === '1' && isAssociatedType) { createGoMyWorkspaceElement(); } } } function logOut() { const origin = BASE_URL.split('://')[1]; const deleteCookieUrl = `https://${origin}/uipmgateway/app_000000035487:uipmfront/uipm/servlet/logout?redirect=https://${origin}/eplus/`; const logoutCookieIframe = ``; $('.epartner-tenant-header-topnav').append(logoutCookieIframe); setTimeout(() => { const logoutUrl = replaceOrigin(getLogoOutUrl(), '.huawei.com'); if (isProduction()) { window.location.href = logoutUrl; } else { window.location.href = `https://${origin}${logoutUrl}`; } }); } function initLogout() { $('.epartner-tenant-topnav-menu-right').on('click', '.log-out', function () { logOut(); }); } function initLang() { $('.header-lang').on('click', '.lang-select-item', function (e) { const curLang = e.currentTarget.dataset.lang; $('.header-lang-list').css('display', 'none'); if (curLang === getCurrentLanguage()) { return; } sessionStorage.setItem('epartner-current-language', curLang); $('.header-lang-list .lang-select-item').removeClass('active'); $(e.currentTarget).addClass('active'); $('.header-lang-current .header-lang-label').html(constants.LANGUAGE_NAME[curLang]); if (curLang === constants.LANGUAGE.EN_US) { return; } const link = isHomeLink(curLang); window.location.href = link; }); $('.header-lang').on('mouseover', function () { $('.header-lang-list').css('display', 'flex'); }); $('.header-lang').on('mouseleave', function () { $('.header-lang-list').css('display', 'none'); }); $('.header-lang-list .lang-select-item').removeClass('active'); $(`#${getCurrentLanguage()}`).addClass('active'); $('.header-lang-current .header-lang-label').html(constants.LANGUAGE_NAME[getCurrentLanguage()]); } async function initMyTodo() { if (isAssociatedCompany() && !isHW()) { const myTodoNum = await getToDoNum(); const name = constants.MY_TODO_NAME_MAP[getCurrentLanguage()] || constants.MY_TODO_NAME_MAP[constants.LANGUAGE.EN_US]; $('.my-todo').css('display', 'flex'); $('.my-todo').off('click'); $('.my-todo').on('click', function () { const end = constants.LANGUAGE_TYPE[getCurrentLanguage()] == 'cn' ? 'cn' : 'en'; window.open(`${BASE_URL}/eplus/#/${constants.LANGUAGE_TYPE[getCurrentLanguage()]}/group/mytodolist-${end}`); }); $('.my-todo .name').html(name); $('.my-todo .value').html(myTodoNum); if (myTodoNum > 0) { $('.my-todo-name').attr('title', 'You have new to-do tasks. Please handle in time.'); } } } function isHomeLink(lang) { const link = 'web'; const href = location.href; if ((href.indexOf('/cn/') > -1 && !lang) || lang === constants.LANGUAGE.ZH_CN) { return `${BASE_URL + constants.CONTEXT_ROOT}/#/cn/${link}/china`; } if ((href.indexOf('/en/') > -1 && !lang) || lang === constants.LANGUAGE.EN_US) { return `${HOME_BASE_URL}/en/web/worldwide.html`; } return isOtherHomeLink(lang, href, link); } function isOtherHomeLink(lang, href, link) { if ((href.indexOf('/ru/') > -1 && !lang) || lang === constants.LANGUAGE.RU_RU) { return `${BASE_URL + constants.CONTEXT_ROOT}/#/ru/${link}/worldwide`; } if ((href.indexOf('/pt/') > -1 && !lang) || lang === constants.LANGUAGE.PT_BR) { return `${BASE_URL + constants.CONTEXT_ROOT}/#/pt/${link}/worldwide`; } if ((href.indexOf('/es/') > -1 && !lang) || lang === constants.LANGUAGE.EN_US) { return `${BASE_URL + constants.CONTEXT_ROOT}/#/es/${link}/worldwide`; } else { return `${BASE_URL + constants.CONTEXT_ROOT}/#/jp/${link}/worldwide`; } } function getUserInfo() { return new Promise((resolve, reject) => { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/jalor/web/support/workspace/current?_t=${new Date().getTime()}`, success: function (res) { resolve(res); }, error: function (e) { resolve(e); }, }); }); } async function getToDoNum() { const curLang = getCurrentLanguage(); const lang = [constants.LANGUAGE.ZH_CN, constants.LANGUAGE.RU_RU, constants.LANGUAGE.JA_JP].includes(curLang) ? curLang : constants.LANGUAGE.EN_US; let params = { todoUser: getCurrentUserInfo().userAccount, language: lang, status: 1, }; return new Promise(resolve => { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/todoList/queryTodoRecords?todoUser=${params.todoUser}&language=${params.language}&status=${params.status}`, success: function (res) { if (res && res.result) { resolve(res.result); } else { resolve(0); } }, error: function () { resolve(0); }, }); }); } function findAccountRoleFn(userAccount) { return new Promise((resolve, reject) => { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/account/findAccountRole?screenName=${userAccount}`, success: function (res) { resolve(res); }, error: function (e) { resolve(e.responseJSON); }, }); }); } function showLoginInfo() { const userContainerDom = $('.item-current-user'); const unLoginDom = $('.item-current-user .unLogin-user-info'); const loginDom = $('.item-current-user .login-user-info'); if (isLogin()) { loginDom.css('display', 'flex'); userContainerDom.addClass('already-login'); unLoginDom.css('display', 'none'); const userInfo = getCurrentUserInfo(); $('.item-current-user .login-user-info .header-topnav-right-text').html(userInfo.userAccount); } else { loginDom.css('display', 'none'); userContainerDom.removeClass('already-login'); unLoginDom.css('display', 'flex'); } } function handlerHwAccount(userAccount) { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/public/purl/handlerHwAccount/${userAccount}`, }); } function queryWorkspaceFlag(userAccount) { return new Promise((resolve, reject) => { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/findRegistByPath/App.worktableFlag/true`, success: function (res) { resolve(res); }, error: function (e) { resolve(e.responseJSON); }, }); }); } function createGoMyWorkspaceElement() { const btnDev = document.createElement('div'); btnDev.title = 'Go to Workspace'; btnDev.className = 'workspace'; const icon = document.createElement('div'); icon.className = 'icon'; btnDev.append(icon); btnDev.addEventListener('click', async function () { let herfLink = `${BASE_URL}/eplus/#/en/group/login-page`; let newMenu = await getMenusPrivilege(); if (!newMenu.newStyle && newMenu.switchFlag) { herfLink = `${herfLink}?isToggleChange=true`; } window.open(herfLink); }); $('#epartnerPageMenu').append(btnDev); } function initHeaderRightUserClickEvent() { const userContainerDom = $('.item-current-user'); userContainerDom.on('click', '.unLogin-user-info', function () { goUniPortalLogin(getHomeUrl()); }); } function loginView(url, flag) { let origin = window.location.origin; let com1 = origin.substring(origin.lastIndexOf('.') + 1, origin.length); if (flag) { return url.replace(/{origin}/gi, com1); } const loginPath = '{wcm_login_url}'; return `${loginPath.replace(/com/gi, com1)}?redirect=${url}`; } function skipToRegisterPage() { const lang = getCurrentLanguage() || 'en_US'; let hrefUrl = ''; if (window.location.origin.indexOf('localhost.huawei.com') > -1 || window.location.origin.indexOf('//partner.huawei') == -1) { hrefUrl = `https://uniportal-beta.huawei.com/accounts1/register-pc.html?redirect=${window.location.origin}#/cn/group/login-page&msg=1&v=V0.1&lang=`; } else { hrefUrl = `https://uniportal.huawei.com/accounts1/register-pc.html?redirect=${window.location.origin}#/cn/group/login-page&msg=1&v=V0.1&lang=`; } window.location.href = loginView(`${hrefUrl}${lang}`, true); } function initRegisterClickEvent() { $('.epartner-tenant-topnav-menu-right').on('click', '.register', function () { skipToRegisterPage(); }); } async function getMenuData() { const menusPrivilege = await getMenusPrivilege(); } function getMenusPrivilege() { return new Promise((resolve, reject) => { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/control/getMenusPrivilege`, success: function (res) { resolve(res); }, error: function (e) { resolve(e); }, }); }); } const toolsBarObject = { flags: false, position: { x: 0, y: 0 }, dx: '', dy: '', nx: '', ny: '', xPum: '', yPum: '', isIHepShunt: false, sidebarList: [], sidebarSubList: [], isAssociated: false, isShowList: 0, isFaq: false, searchData: {}, allSidebarList: [], }; function toolsBarMouseDown(event) { const target = $('.partner-drag-drop-tools'); if (!target) { return; } toolsBarObject.flags = false; $('.floatBar-bottom-demo').css('display', 'none'); const targetWindow = window.getComputedStyle(target[0], null); const prefixX = event.clientX - parseFloat(targetWindow.left); const prefixY = event.clientY - parseFloat(targetWindow.top); let ww = document.documentElement.clientWidth; let wh = window.innerHeight; if (event.preventDefault) { event.preventDefault(); } else { event.returnValue = false; } document.onmousemove = function (e) { const moveEvent = e || window.event; if (moveEvent.clientY < 0 || moveEvent.clientX < 0 || moveEvent.clientY > wh || moveEvent.clientX > ww) { return false; } toolsBarObject.flags = true; $('.floatBar-bottom-demo').css('display', 'block'); target[0].style.left = `${moveEvent.clientX - prefixX}px`; target[0].style.top = `${moveEvent.clientY - prefixY}px`; target[0].style.right = 'unset'; }; } function toolsBarMouseUp() { document.onmousemove = null; } function toolsBarTouchStart(event) { const target = $('.partner-drag-drop-tools'); if (!target) { return; } document.body.onselectstart = () => { return false; }; document.body.onselect = () => { return false; }; toolsBarObject.flags = false; let touch; if (event.touches) { touch = event.touches[0]; } else { touch = (event.originalEvent && event.originalEvent.touches[0]) || event; } toolsBarObject.position.x = touch.clientX; toolsBarObject.position.y = touch.clientY; toolsBarObject.dx = target[0].offsetLeft; toolsBarObject.dy = target[0].offsetTop; } function toolsBarTouchMove(event) { const target = $('.partner-drag-drop-tools'); if (!target) { return; } let touch; if (event.touches) { touch = event.touches[0]; } else { touch = (event.originalEvent && event.originalEvent.touches[0]) || event; } toolsBarObject.flags = true; toolsBarObject.nx = touch.clientX - toolsBarObject.position.x; toolsBarObject.ny = touch.clientY - toolsBarObject.position.y; toolsBarObject.xPum = toolsBarObject.dx + toolsBarObject.nx; toolsBarObject.yPum = toolsBarObject.dy + toolsBarObject.ny; let width = window.innerWidth - target[0].offsetWidth; let height = window.innerHeight - target[0].offsetHeight; toolsBarObject.xPum < 0 && (toolsBarObject.xPum = 0); toolsBarObject.yPum < 0 && (toolsBarObject.yPum = 0); toolsBarObject.xPum > width && (toolsBarObject.xPum = width); toolsBarObject.yPum > height && (toolsBarObject.yPum = height); target[0].style.left = `${toolsBarObject.xPum}px`; target[0].style.top = `${toolsBarObject.yPum}px`; target[0].style.right = 'unset'; } function toolsBarTouchEnd(event) { toolsBarObject.flags = false; $('.floatBar-bottom-demo').css('display', 'none'); } function showHelp() { turnPageLookUp(toolsBarObject.sidebarList[0].linkUrl); } function openBusiness() { toolsBarObject.isShowList = 2; showBusinessList(); toolsBarObject.showBusiness = true; $('#business-list-help-container').addClass('more-width'); $('.i-help-shunt').css('display', 'none'); } function queryAssociatedStatus(params) { return new Promise((resolve, reject) => { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/account/isAssociatedCompany?userId=${params.userId}`, success: function (res) { resolve(res); }, error: function (e) { resolve(e); }, }); }); } function initToolsEvent() { $(document).on('mousedown', '.partner-drag-drop-tools', function (e) { toolsBarMouseDown(e); }); $(document).on('mouseup', '.partner-drag-drop-tools', function (e) { toolsBarMouseUp(e); }); $(document).on('touchstart', '.partner-drag-drop-tools', function (e) { toolsBarTouchStart(e); }); $(document).on('touchmove', '.partner-drag-drop-tools', function (e) { toolsBarTouchMove(e); }); $(document).on('touchend', '.partner-drag-drop-tools', function (e) { toolsBarTouchEnd(e); }); $('.partner-drag-drop-tools').on('click', '.partner-it-help-icon', function (e) { showHelp(e); }); $('.partner-drag-drop-tools').on('click', '.partner-business-icon', function (e) { openBusiness(e); }); document.addEventListener('mouseup', e => { const itBusinessContainer = document.getElementById('it-business-help-container'); if (itBusinessContainer) { if (!itBusinessContainer.contains(e.target)) { toolsBarObject.isFaq = false; toolsBarObject.isShowList = 0; itBusinessContainer.style.display = 'none'; } } let list = document.getElementById('business-list-help-container'); if (list) { if (!list.contains(e.target)) { toolsBarObject.isFaq = false; toolsBarObject.isShowList = 0; list.style.display = 'none'; } } }); } function isHomeOrWorkView() { let href = window.location.href; let views = ['/cn-cp', '/china', '/cn-csp', '/saleswork', '/salespartnerworkspace', '/solutionpartnerworkspace']; views.forEach(item => { if (href.indexOf(item) > -1 && href.indexOf('/cn/') > -1) { toolsBarObject.isIHepShunt = true; } }); let viewsOverseas = ['/en/group/worldwide', '/en/web/worldwide', '/overseas-cp', '/overseas-csp', '/solutionpartnerworkspace-en']; viewsOverseas.forEach(item => { if ((href.indexOf(item) > -1 && href.indexOf('/en/') > -1) || true) { toolsBarObject.isIHepShunt = true; } }); return toolsBarObject.isIHepShunt; } function checkAssociated(userAccount) { const params = { userId: userAccount, }; return new Promise(resolve => { queryAssociatedStatus(params) .then(res => { let isAssociated = false; if (typeof res === 'string' && res !== '') { res = JSON.parse(res); } if (res.status === true) { isAssociated = true; } else { isAssociated = false; } resolve(isAssociated); }) .catch(() => { resolve(false); }); }); } function getOnlineSupportTree(website) { return new Promise((resolve, reject) => { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/online/getOnlineSupportTree?website=${website}`, success: function (res) { resolve(res); }, error: function (e) { resolve(e); }, }); }); } async function getOnLineList() { let website = ''; if (getCurrentLanguage() === constants.LANGUAGE.EN_US) { website = 2; } else { website = 1; } let res = await getOnlineSupportTree(website); if (!res) { return; } let html = ''; res.children.forEach(item => { html += `
${item.name}
`; html += '
'; item.children.forEach(cItem => { html += '

'; if (cItem.email) { html += ` ${cItem.url ? '' : ''} ${cItem.name} ${cItem.email} `; } else { html += `${cItem.name}`; } html += '

'; }); html += '
'; html += '
'; }); $('#online-support-tree').html(html); } function initTools() { initToolsEvent(); findHelpSidebarList(); if (isLogin()) { getOnLineList(); } else { $('.partner-drag-drop-tools').addClass('partner-mobile-tools'); } } function getIHelp(website) { let origin = window.location.origin; const com = origin.substring(origin.lastIndexOf('.') + 1, origin.length); const data = { buttonName: '在线支持', defaultImagePath: 'https://partner.huawei.com/epartner/file/resource/ba1_7f12b.gif', hoverImagePath: 'https://partner.huawei.com/epartner/file/resource/ba2_4afdf.gif', linkUrl: `https://app.huawei.${com}/ihelp/icsclientC60/index.do?appId=M000735&page_category=`, }; if (website == 2) { data.buttonName = 'Help'; } return data; } function getFAQAndInstructionInfo(params) { return new Promise((resolve, reject) => { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/file/ifaqmanageservice/getFAQAndInstructionInfo?searchUrl=${params.searchUrl}`, success: function (res) { resolve(res); }, error: function (e) { resolve(e); }, }); }); } function findBusinessContactList() { return new Promise((resolve, reject) => { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/contact/findBusinessContactList`, success: function (res) { resolve(res); }, error: function (e) { resolve(e); }, }); }); } function initHelp() { return new Promise((resolve, reject) => { $.ajax({ type: 'post', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/jalor/lookup/item/list/iHelp_config/page/new/100/1`, success: function (res) { resolve(res); }, error: function (e) { resolve(e); }, }); }); } function turnPageByLookUp(url) { const myUrl = url.split('?')[0]; initHelp().then(data => { setTimeout(() => { if (myAppId != '') { window.open(`${myUrl}?appId=${getAppId(data)}&page_category=`); } else { window.open(url); } }, 300); }); } function getAppId(res) { let myAppId = ''; if (!res || !res.data || !res.res.result || res.data.result.length <= 1) { return myAppId; } res.data.result.forEach(v => { if (window.location.href.indexOf(v.itemName) > -1) { myAppId = v.itemAttr1; } }); return myAppId; } function openHelpByCondition(url) { if (url.indexOf('index.do?appId') > 1) { turnPageLookUp(url); } else { window.open(url); } } function showBusinessList() { $('#business-list-help-container').css('display', 'inline-block'); } function getAssociatedDoc() { toolsBarObject.searchData = { faqList: [], instructionInfoList: [] }; const pathArr = window.location.href.split('eplusmeta'); const pathPrefix = pathArr.length > 1 ? pathArr[1].split('.')[0] : ''; if (!pathPrefix) { return; } let params = { searchUrl: encodeURIComponent(`/eplus/${pathPrefix}`), }; const p1 = getFAQAndInstructionInfo(params); const p2 = findBusinessContactList(); let httpArr = [p1, p2]; if (getCurrentLanguage() != constants.LANGUAGE.ZH_CN) { httpArr = [p1]; } Promise.all(httpArr) .then(res => { parseAssociatedDoc(res); }) .catch(() => { turnPageByLookUp(toolsBarObject.sidebarList[0].linkUrl); }); } function parseAssociatedDoc(res) { if (getCurrentLanguage() === constants.LANGUAGE.ZH_CN) { if (res[1].data && res[1].data.length) { res[1].data.forEach((item, index) => { item.email = '点击获取邮箱'; item.itemIndex = index; item.emailStyle = false; }); } } if (!res[0]) { turnPageByLookUp(toolsBarObject.sidebarList[0].linkUrl); return; } if (res[0].faqList.length == 0 && res[0].instructionInfoList.length == 0) { toolsBarObject.isFaq = true; if (isHomeOrWorkView()) { toolsBarObject.isShowList = 0; $('.i-help-shunt').css('display', 'block'); if (isChina()) { $('.i-help-shunt .cn-business-entery').css('display', 'flex'); } $('.i-help-shunt').on('click', '.icon-close', function (e) { $('.i-help-shunt').css('display', 'none'); }); return; } if (!isChina()) { turnPageByLookUp(toolsBarObject.sidebarList[0].linkUrl); return; } toolsBarObject.isShowList = 1; $('#help_container_list').addClass('help_container_list'); $('#help_container_list').html('
IT在线帮助
业务接口人
'); return; } toolsBarObject.isFaq = true; toolsBarObject.isShowList = 2; showBusinessList(); toolsBarObject.showBusiness = false; $('#business-list-help-container').removeClass('more-width'); toolsBarObject.dowloadNum = 0; toolsBarObject.searchData = res[0].data; } function iHelpClick(e) { if (toolsBarObject.flags) { toolsBarObject.flags = false; return; } const index = e.currentTarget.dataset?.index; const obj = toolsBarObject.sidebarList[index]; if (!obj) { return; } if (index.toString() === '0' && isLogin() && (isAssociatedCompany() || isHW())) { getAssociatedDoc(); return; } if (obj.linkUrl) { if (obj.linkUrl.indexOf('pvmvc#/create-task') > -1) { window.location.href = obj.linkUrl; } else { window.open(obj.linkUrl); } } else { toolsBarObject.sidebarList.map((item, i) => { if (i === index) { obj.flag = true; } else { obj.flag = false; } return item; }); initIHelpHtml(); } } function changeStyle(e) { const index = e.currentTarget.dataset?.index; const obj = toolsBarObject.sidebarList[index]; if (!obj) { return; } if (!obj.flag) { if (obj.defaultImagePath.indexOf('.gif') === -1) { $(e.currentTarget).addClass('float-bar__list__li_color'); $(e.currentTarget).find('img').prop('src', obj.hoverImagePath); } } else { $(e.currentTarget).removeClass('float-bar__list__li_color'); $(e.currentTarget).find('img').prop('src', obj.defaultImagePath); } toolsBarObject.sidebarList[index].flag = !toolsBarObject.sidebarList[index].flag; } function initIHelpHtml() { let html = ''; toolsBarObject.sidebarList.forEach((item, index) => { html += `
  • `; html += `Failed to load the image`; html += `

    ${item.buttonName}

    `; html += '
  • '; }); $('.partner-drag-drop-tools .ihelp-list').html(html); } function setHelpData(res) { if (!res.length && isLogin()) { $('.float-bar__list').remove(); } if (!isAssociatedCompany() && !isHW() && isLogin()) { const listNotAssociate = res.filter(item => { return item.buttonName === 'Guide' || item.buttonName === '帮助中心'; }); toolsBarObject.sidebarSubList = listNotAssociate; $('.exp').css('display', 'none'); } else if (res.length > 2) { $('.exp').css('display', 'block'); toolsBarObject.sidebarSubList = res.slice(0, 2); $('.exp').off('click'); $('.partner-drag-drop-tools .ihelp-list').removeClass('no-last-border'); $('.exp').on('click', function () { if ($('.float-bar__list').hasClass('float-bar__list-show')) { $('.float-bar').removeClass('float-bar_all'); $('.float-bar__list').removeClass('float-bar__list-show'); toolsBarObject.sidebarList = toolsBarObject.sidebarSubList; $('.exp').addClass('shrinking'); } else { toolsBarObject.sidebarList = toolsBarObject.allSidebarList; $('.float-bar').addClass('float-bar_all'); $('.float-bar__list').addClass('float-bar__list-show'); $('.exp').removeClass('shrinking'); } initIHelpHtml(); }); } else { toolsBarObject.sidebarSubList = res; $('.partner-drag-drop-tools .ihelp-list').addClass('no-last-border'); $('.exp').css('display', 'none'); } toolsBarObject.sidebarList = toolsBarObject.sidebarSubList; toolsBarObject.allSidebarList = res; initIHelpHtml(); $('.partner-drag-drop-tools .ihelp-list').on('click', '.float-bar__list__li', function (e) { iHelpClick(e); }); $('.partner-drag-drop-tools .ihelp-list').on('mouseover', '.float-bar__list__li', function (e) { changeStyle(e); }); $('.partner-drag-drop-tools .ihelp-list').on('mouseout', '.float-bar__list__li', function (e) { changeStyle(e); }); } function getHelp(website) { let origin = window.location.origin; let com = origin.substring(origin.lastIndexOf('.') + 1, origin.length); let data = { buttonName: '在线支持', defaultImagePath: 'https://partner.huawei.com/epartner/file/resource/ba1_7f12b.gif', hoverImagePath: 'https://partner.huawei.com/epartner/file/resource/ba2_4afdf.gif', linkUrl: `https://app.huawei.${com}/ihelp/icsclientC60/index.do?appId=M000735&page_category=`, }; if (website == 2) { data.buttonName = 'Help'; } return data; } function findHelpSidebarList() { const website = isChina() ? 1 : 2; $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/pub/public/findHelpSidebarList?website=${website}`, success: function (res) { const data = res || []; if (isLogin()) { data.unshift(getHelp(website)); } if (data.length == 0) { $('.partner-drag-drop-tools').css('display', 'none'); } else { $('.partner-drag-drop-tools').css('display', 'block'); } setHelpData(data); }, error: function () { setHelpData([getHelp(website)]); }, }); } const data = { topnav: { menuTextpc: '选择区域/语言', menuTextmb: '语言', language: [ { text: '简体中文', href: '', targetBlank: false, active: false, language: 'zh_CN', }, { text: 'English', href: '', targetBlank: false, active: true, language: 'en_US', }, { text: '日本語', href: '', targetBlank: false, active: false, language: 'ja_JP', }, { text: 'Русский', href: '', targetBlank: false, active: false, language: 'ru_RU', }, { text: 'Português', href: '', targetBlank: false, active: false, language: 'pt_BR', }, { text: 'español', href: '', targetBlank: false, active: false, language: 'es_MX', }, ], leftMenuTitle: 'Enterprise', contactList: [ { id: 1, text: { zh_CN: '企业业务网站', en_US: 'Enterprise', ja_JP: '法人向け製品', ru_RU: 'Для предприятий', es_MX: 'Negócios', pt_BR: 'Los negocios', }, subText: { zh_CN: '企业商用产品、解决方案和云服务', en_US: 'Enterprise products, solutions & services', ja_JP: '企業ユーザー向け製品、ソリューション、サービス', ru_RU: 'Продукты, решения и услуги для предприятий', es_MX: 'Produtos, soluções and serviços para negócios', pt_BR: 'Productos, soluciones and servicios para los negocios', }, href: { zh_CN: 'https://e.huawei.com/cn/', en_US: 'https://e.huawei.com/en/', ja_JP: 'https://e.huawei.com/jp/', ru_RU: 'https://e.huawei.com/kz/', es_MX: 'https://e.huawei.com/es/', pt_BR: 'https://e.huawei.com/br/', }, }, { id: 2, text: { zh_CN: '华为云网站', en_US: 'Huawei Cloud', ja_JP: 'コンシューマー向け製品', ru_RU: 'Интернет-магазин', es_MX: 'Huawei Cloud', pt_BR: 'Portadores', }, subText: { zh_CN: '华为云服务及解决方案', en_US: 'Cloud products, solutions & services', ja_JP: '携帯電話、PC、タブレット、ウェアラブルなどの個人用および家庭用製品', ru_RU: 'Смартфоны, ПК и планшеты, носимые устройства и многое другое', es_MX: 'Cloud products, solutions & services', pt_BR: 'Productos, soluciones and servicios para portadores', }, href: { zh_CN: 'https://www.huaweicloud.com/', en_US: 'https://www.huaweicloud.com/', ja_JP: 'https://consumer.huawei.com/jp/', ru_RU: 'https://consumer.huawei.com/ru/', es_MX: 'https://carrier.huawei.com/en', pt_BR: 'https://www.huaweicloud.com/intl/pt-br/', }, }, { id: 3, text: { zh_CN: '运营商网络业务网站', en_US: 'Carrier', ja_JP: 'コーポレート', ru_RU: 'Сайт Huawei Россия', es_MX: 'Transportadores', pt_BR: 'Personal', }, subText: { zh_CN: '运营商网络解决方案、产品及服务', en_US: 'Products, Solutions and Services for Carrier', ja_JP: '会社紹介、ニュース&展示会の活動など', ru_RU: 'О компании Huawei, пресса, события и многое другое', es_MX: 'Produtos, soluções and serviços paratransportadores', pt_BR: 'Teléfonos, PC y Tablets, Wearables y más', }, href: { zh_CN: 'https://carrier.huawei.com/cn/', en_US: 'https://carrier.huawei.com/en', ja_JP: 'https://www.huawei.com/jp', ru_RU: 'https://www.huawei.com/ru', es_MX: 'https://consumer.huawei.com/es/', pt_BR: 'https://carrier.huawei.com/en', }, }, { id: 4, text: { zh_CN: '消费者业务网站', en_US: 'Consumer', ja_JP: '通信事業者向け製品', ru_RU: 'Для операторов', es_MX: 'Pessoal', pt_BR: 'Corporativo', }, subText: { zh_CN: '手机,PC和平板等智慧生活产品', en_US: 'Phones, laptops, tablets, wearables & other devices', ja_JP: '通信機器、ソリューションおよびサービス', ru_RU: 'Продукты, решения и услуги для операторов', es_MX: 'Celulares, Computadores e Tablets, Utensílios e mais', pt_BR: 'Acerca de HUAWEI, Prensa & Eventos , y más', }, href: { zh_CN: 'https://consumer.huawei.com/cn/', en_US: 'https://consumer.huawei.com/en/', ja_JP: 'https://carrier.huawei.com/jp', ru_RU: 'https://carrier.huawei.com/en', es_MX: 'https://www.huawei.com/es', pt_BR: 'https://consumer.huawei.com/br/', }, }, { id: 5, text: { zh_CN: '集团网站', en_US: 'Corporate', ja_JP: '', ru_RU: '', es_MX: 'Corporativo', pt_BR: '', }, subText: { zh_CN: '公司介绍、新闻动态、展会活动等信息', en_US: 'About Huawei, Press & Events , and More', ja_JP: '', ru_RU: '', es_MX: 'Sobre a Huawei , Imprensa e Eventos , e mais', pt_BR: '', }, href: { zh_CN: 'https://www.huawei.com/cn', en_US: 'https://www.huawei.com/en', ja_JP: '', ru_RU: '/', es_MX: '/', pt_BR: 'https://www.huawei.com/en', }, }, ], }, logo: { href: 'https://std.crm.saas.huawei.com/pep/page/metacrm.huawei.com/index.html', targetBlank: true, }, menus: [], }; const DELAY_TIME = 300; function showLevel1MenuFlag(item) { return item.items && item.items.length > 0; } function showLevel2MenuFlag(item) { return item.hasPermission && item.items && item.items.length > 0; } function showLevel3MenuFlag(item) { return item.hasPermission || item.isLock !== null; } const LANG_DESC = { zh_CN: 'china', ja_JP: 'japan', ru_RU: 'russia', en_US: 'worldwide', es_MX: 'spanish', pt_BR: 'portuguesebr', }; const epartnerPageTopNav = function ({ loginFlag }) { this.$container = $('#epartnerPageTopNav'); this.loginFlag = loginFlag; this.data = data; }; epartnerPageTopNav.prototype.init = function () { this.$container.find('#navLeftMenuTitle').text(this.data.topnav.leftMenuTitle); this.createMenuList(); this.createMobile(); this.registerEvents(); }; epartnerPageTopNav.prototype.createMenuList = function () { const $ul = document.createElement('ul'); const contactList = this.data.topnav.contactList; for (let i = 0; i < contactList.length; i++) { const item = contactList[i]; const $li = document.createElement('li'); const $menuHead = document.createElement('div'); $menuHead.className = 'menu-row'; const $linkHead = document.createElement('a'); $($linkHead).attr({ href: item.href.en_US, target: '_blank', class: 'menu-title', }); $linkHead.innerHTML = `${item.text.en_US}`; $menuHead.append($linkHead); $li.append($menuHead); const $menuContent = document.createElement('div'); $menuContent.className = 'menu-row'; const $linkContent = document.createElement('a'); $($linkContent).attr({ href: item.href.en_US, target: '_blank', class: 'menu-comment', }); $linkContent.innerText = item.subText.en_US; $menuContent.append($linkContent); $li.append($menuContent); $ul.append($li); } this.$container.find('.epartner-home-topnav-menu').append($ul); }; epartnerPageTopNav.prototype.registerEvents = function () { const $icon = $('.epartner-home-topnav-left').find('.icon-right'); const $menu = $('.epartner-home-topnav-menu'); $('.epartner-home-topnav-left').on('click', function () { const openClassName = 'icon-right-to-up'; const closeClassName = 'icon-right-to-down'; const isExpand = $icon.hasClass(openClassName); if (isExpand) { $icon.removeClass(openClassName).addClass(closeClassName); $menu.slideUp(); } else { $icon.removeClass(closeClassName).addClass(openClassName); $menu.slideDown(); } }); $('.epartner-home-menu-right') .on('click', '.log-in', () => { goUniPortalLogin(getHomeUrl()); }) .on('click', '.log-out', () => { logOut(); }); $('#epartnerMobileMenuContent').on('click', 'button.m-menu-logout-btn', () => { logOut(); }); }; epartnerPageTopNav.prototype.createMobile = function () { const $footer = $('.epartner-m-menu-footer'); const $langMenu = $('#epartnerMobileLangMenu'); $('#epartnerMobileQuickMenuTitle').html(`${this.data.topnav.leftMenuTitle}`); $footer.on('click', '#epartnerMobileQuickMenuTitle', () => { $('#epartnerMobileQuickMenuTitle').toggleClass('active'); $('#epartnerMobileQuickMenu').toggle(); $('#epartnerMobileLangMenuTitle').removeClass('active'); $('#epartnerMobileLangMenu').hide(); }); if (this.loginFlag) { $('#epartnerPageMenu').find('.log-out').addClass('show'); } else { $('#epartnerPageMenu').find('.log-in').addClass('show'); } const $quickMenu = $('#epartnerMobileQuickMenu'); const contactList = this.data.topnav.contactList; for (let i = 0; i < contactList.length; i++) { const item = contactList[i]; const $item = document.createElement('a'); $($item).attr({ href: item.href.en_US, target: '_blank', class: 'menu-title' }); const $menuHead = document.createElement('div'); $menuHead.className = 'menu-header'; $menuHead.innerHTML = `${item.text.en_US}`; if (i > 0) { $menuHead.innerHTML += ''; } $item.append($menuHead); const $menuContent = document.createElement('div'); $menuContent.className = 'menu-row'; $menuContent.innerText = item.subText.en_US; $item.append($menuContent); $quickMenu.append($item); } const $ul = document.createElement('ul'); const langList = this.data.topnav.language; for (let i = 0; i < langList.length; i++) { const $li = document.createElement('li'); const langItem = langList[i]; $($li).attr({ 'data-lang': langItem.language }); if (langItem.language === getCurrentLanguage()) { $li.innerHTML = `${langItem.text}🗸`; } else { $li.innerText = langItem.text; } $ul.append($li); } $langMenu.append($ul); $('#epartnerMobileLangMenuTitle').on('click', () => { $('#epartnerMobileLangMenuTitle').toggleClass('active'); $('#epartnerMobileLangMenu').toggle(); $('#epartnerMobileQuickMenuTitle').removeClass('active'); $('#epartnerMobileQuickMenu').hide(); }); $('#epartnerMobileLangMenu').on('click', 'li', e => { const currentLang = $(e.target).closest('li').data('lang'); if (currentLang === getCurrentLanguage()) { return; } const link = isHomeLink(currentLang); window.location.href = link; }); }; function setMenuData(item1) { if (!item1.items || item1.items.length <= 0) { return; } item1.items.forEach(item2 => { let newArr = []; item2.children = []; item2.levelTwo = true; item2.items && item2.items.length && item2.items.forEach(item3 => { item3.levelThree = true; if (!item3.hasPermission && !item3.isLock) { newArr.push(item3); } }); if (item2.items && newArr.length === item2.items.length) { item2.hasPermission = false; } }); } function menuDataReplaceUrl(res) { if (window.location.hostname.indexOf('localhost.huawei.com') > -1) { this.menuData = res; } else { let dataStr = JSON.stringify(res); if (window.location.hostname.indexOf('kwesit') > -1) { this.menuData = JSON.parse(dataStr.replace(/kwesit.huawei.com/g, BASE_URL)); } else if (window.location.hostname.indexOf('kwuat') > -1) { this.menuData = JSON.parse(dataStr.replace(/kwuat.huawei.com/g, BASE_URL)); } else { this.menuData = JSON.parse(dataStr.replace(/partner.huawei.com/g, BASE_URL)); } } } const epartnerPageMenuHorizontal = function ({ loginFlag }) { this.$container = $('#epartnerPageMenu'); this.loginFlag = loginFlag; this.cssSuffix = loginFlag ? 'login' : 'unlogin'; this.data = []; this.mobileMenuPath = []; if (loginFlag) { this.userAccount = getCurrentUserInfo().userAccount; } this.language = getCurrentLanguage(); this.newStyle = false; }; epartnerPageMenuHorizontal.prototype.init = async function () { const isAssociated = sessionStorage.getItem('epartner-is-associated') === 'true' || isHW(); let res = {}; if (this.loginFlag && isAssociated) { res = await this.getMenuListByAuth(); } else { res = await this.getCMSPublicMenu(); } this.getResData(res); this.loadMenu(res); }; epartnerPageMenuHorizontal.prototype.loadMenu = function (res) { this.data = res.menuData; new epartnerPageMenuVertical({ loginFlag: this.loginFlag, data: res.menuData, newStyle: this.newStyle }).init(); this.createLevel1Menu(); this.createMobileContent(); this.createMobileEvents(); res.luBanlogoOutURL && sessionStorage.setItem('epartner-logout-url', res.luBanlogoOutURL); res.luBanHomeURL && sessionStorage.setItem('epartner-home-url', res.luBanHomeURL); this.createEvents(); }; epartnerPageMenuHorizontal.prototype.getV2MenuListByAuth = function () { let params = { w3Account: this.userAccount, languageId: this.language, description: LANG_DESC[this.language], }; return new Promise(resolve => { $.get(`${BASE_URL}${constants.COMMON_SERVICE}/common/v1/menu/getV2MenuListByAuth`, params, res => { this.parseV2MenuList(res); menuDataReplaceUrl(res); resolve(res); }); }); }; epartnerPageMenuHorizontal.prototype.parseV2MenuList = function (res) { if (res.horizontalMenuList.length > 0) { res.menuData = res.horizontalMenuList; res.menuData.forEach(item1 => { item1.levelOne = true; item1.children = item1.items; setMenuData(item1); }); } if (res.verticalMenuList.length > 0) { res.verticalMenuList.forEach(item1 => { item1.levelOne = true; item1.children = item1.items; setMenuData(item1); }); } }; epartnerPageMenuHorizontal.prototype.munuSwitchFlag = function () { const params = { classifyCode: 'home_page_switches', language: 'zh', }; return new Promise(resolve => { $.get(`${BASE_URL}${constants.COMMON_SERVICE}/common/v1/public/queryLookupList`, params, res => { this.parseMenuSwitchFlag(); resolve(); }); }); }; epartnerPageMenuHorizontal.prototype.parseMenuSwitchFlag = function (res) { if (!res || !res.data) { return; } res.data.forEach(ele => { if (ele.itemName == 'menuShow') { sessionStorage.setItem('munuSwitchFlag', ele.itemDesc); } }); }; epartnerPageMenuHorizontal.prototype.getMenuListByAuth = async function () { try { await this.munuSwitchFlag(); } finally { const url = JSON.parse(sessionStorage.getItem('munuSwitchFlag')) ? `${BASE_URL}${constants.E_PARTNER_SERVICE}/common/v1/menu/getMenuListByAuth` : `${BASE_URL}${constants.COMMON_SERVICE}/common/v1/menu/getMenuListByAuth`; return new Promise(resolve => { $.get( url, { w3Account: this.userAccount, languageId: this.language, description: LANG_DESC[this.language], }, res => { resolve(res); } ); }); } }; epartnerPageMenuHorizontal.prototype.getCMSPublicMenu = function () { return new Promise(resolve => { $.get( `${BASE_URL}${constants.COMMON_SERVICE}/common/v1/menu/getCMSPublicMenu`, { languageId: this.language, description: LANG_DESC[this.language], }, res => { resolve(res); } ); }); }; epartnerPageMenuHorizontal.prototype.getResData = function (res) { if (res.menuData.length > 0) { res.menuData.forEach(item => { item.levelOne = true; item.children = item.items; setMenuData(item); }); } menuDataReplaceUrl(res); }; epartnerPageMenuHorizontal.prototype.createLevel1Menu = function () { const $level1List = document.createElement('div'); $level1List.className = 'epartner-home-menu flex-v-center'; for (let i = 0; i < this.data.length; i++) { const item = this.data[i]; if (!showLevel1MenuFlag(item)) { continue; } const $level1 = document.createElement('div'); $level1.className = `epartner-home-menu-level1-${this.cssSuffix} hand-cursor`; if (!this.loginFlag) { $($level1).on('click', () => { $(`.epartner-home-menu-v-level1`).removeClass('active'); $(`.epartner-home-menu-v-level1:nth-child(${i + 1})`).addClass('active'); $('#epartnerPageMenuVertical').slideDown(); }); } const $a = document.createElement('a'); $a.innerText = item.title; if (item.link) { $($a).attr({ href: item.link, target: item.targetBlank ? '_blank' : '_self', }); } $level1.append($a); $level1.append(this.createLevel2Menu(item)); $level1List.append($level1); } $('#epartnerPageMenuNav').append($level1List); $('#epartnerPageMenuNav').on('mouseover', '.epartner-home-menu-level1-login', () => { $('#epartnerPageMenuVertical').hide(); }); }; epartnerPageMenuHorizontal.prototype.createLevel2Menu = function (level1Data) { const $level2List = document.createElement('div'); $level2List.className = 'epartner-home-menu-level1-content small-scrollbar'; for (let i = 0; i < level1Data.items.length; i++) { const item = level1Data.items[i]; if (!showLevel2MenuFlag(item)) { continue; } const $level2 = document.createElement('dl'); $level2.className = 'epartner-home-menu-level2'; const $title = document.createElement('dt'); $title.innerText = item.title; $level2.append($title); $level2.append(...this.createLevel3Menu(item)); $level2List.append($level2); } return $level2List; }; epartnerPageMenuHorizontal.prototype.createLevel3Menu = function (level2Data) { let level3List = []; for (let i = 0; i < level2Data.items.length; i++) { const item = level2Data.items[i]; if (!showLevel3MenuFlag(item)) { continue; } const $level3 = document.createElement('dd'); $level3.className = 'epartner-home-menu-level3-title hand-cursor flex-v-center'; const $level3Title = document.createElement('span'); $level3Title.innerText = item.title; $level3.append($level3Title); if (item.isLock === 'true') { const $lock = document.createElement('span'); $lock.className = 'menu-lock'; $lock.innerHTML = `🔒`; $level3.append($lock); const $lockTips = document.createElement('div'); $lockTips.className = 'menu-lock-tips'; $lockTips.innerHTML = 'No function right, Please click Apply to gain access.'; $lock.append($lockTips); } $level3.onclick = () => openMenuPage(item, this.loginFlag, this.newStyle); level3List.push($level3); } return level3List; }; epartnerPageMenuHorizontal.prototype.createEvents = function () { $('#epartnerPageMenu').on('click', '.epartner-home-menu-logo', () => { let link = isHomeLink(getCurrentLanguage()); if (link) { window.location.href = link; setTimeout(() => { window.location.reload(); }, DELAY_TIME); } }); $('#epartnerPageMenuVertical').on('click', '.epartner-home-menu-v-level1-bottom', () => { let that = window.location.href; let lang = 'en'; if (that.indexOf('/ru/') > -1) { lang = 'ru'; } else if (that.indexOf('/cn/') > -1) { lang = 'cn'; } else if (that.indexOf('/es/') > -1) { lang = 'es'; } else if (that.indexOf('/pt/') > -1) { lang = 'pt'; } else if (that.indexOf('/jp/') > -1) { lang = 'jp'; } window.open(DOMPurify.sanitize(BASE_URL + '/eplus/#/' + lang + '/group/login-page')); }); }; epartnerPageMenuHorizontal.prototype.createMobileContent = function () { const $content = $('#epartnerMobileMenuContent'); let menuList = []; const _loginFlag = this.loginFlag; const createLevel = function (_data, deep, parentIndex) { let $levelPage; if (menuList.length > deep) { $levelPage = menuList[deep]; } else { $levelPage = document.createElement('div'); $levelPage.className = `epartner-m-menu-level-page`; $($levelPage).attr({ 'data-deep': deep }); menuList.push($levelPage); $content.append($levelPage); } const $levelList = document.createElement('ul'); $levelList.className = `epartner-m-menu-level small-scrollbar ${deep === 0 ? '' : 'list-hide'}`; $($levelList).attr('data-parent-index', parentIndex); for (let index = 0; index < _data.length; index++) { const levelData = _data[index]; if (deep === 0 && !showLevel1MenuFlag(levelData)) { continue; } if (deep === 1 && !showLevel2MenuFlag(levelData)) { continue; } if (deep === 2 && !showLevel3MenuFlag(levelData)) { continue; } const $level = document.createElement('li'); $level.className = 'epartner-m-menu-row flex-v-center'; $($level).attr('data-index', index); const $link = document.createElement('a'); if (levelData.items && levelData.items.length > 0) { $link.innerHTML = `${levelData.title}`; createLevel(levelData.items, deep + 1, parentIndex + '-' + index); } else { $link.onclick = () => openMenuPage(levelData, _loginFlag, this.newStyle); $link.innerText = levelData.title; } $level.append($link); $levelList.append($level); } $levelPage.append($levelList); }; createLevel(this.data, 0, '0'); if (this.loginFlag) { const $logOut = document.createElement('div'); $logOut.className = 'm-menu-logout-row'; const $logOutBtn = document.createElement('button'); $logOutBtn.className = 'm-menu-logout-btn'; $logOutBtn.innerText = 'Log Out'; $logOut.append($logOutBtn); $content.append($logOut); } }; epartnerPageMenuHorizontal.prototype.createMobileEvents = function () { const $content = $('#epartnerMobileMenuContent'); const $menuHeader = $('#epartnerMobileMenu .child-menu-header'); const $back = $('#epartnerMobileMenu .m-menu-back'); const $logo = $('#epartnerMobileMenu .m-menu-logo'); this.$container.on('click', '.epartner-home-menu-mobile', () => { $('#epartnerMobileMenu').show(); }); const backMenu = () => { const lastClickItem = this.mobileMenuPath.pop(); if (lastClickItem) { const $nextLevelPage = $(`.epartner-m-menu-level-page[data-deep=${lastClickItem.deep + 1}]`); $nextLevelPage.find('ul').addClass('list-hide'); if (this.mobileMenuPath.length === 0) { $back.hide(); $logo.show(); $menuHeader.text(''); } else { $menuHeader.text(this.mobileMenuPath[this.mobileMenuPath.length - 1].currentTitle); } } }; $('#epartnerMobileMenu').on('click', '.m-menu-back', backMenu); $('#epartnerMobileMenu').on('click', '.m-menu-close', e => { $('#epartnerMobileMenu').hide(); while (this.mobileMenuPath.length > 0) { backMenu(); } $('#epartnerMobileLangMenuTitle').removeClass('active'); $('#epartnerMobileLangMenu').hide(); $('#epartnerMobileQuickMenuTitle').removeClass('active'); $('#epartnerMobileQuickMenu').hide(); }); $content.on('click', 'li', e => { const $li = $(e.target).closest('li'); const $ul = $li.closest('ul'); const $page = $li.closest('.epartner-m-menu-level-page'); const clickInfo = { parentPath: $ul.data('parent-index'), deep: Number($page.data('deep')), currentIndex: $li.data('index'), nextParentIndex: `${$ul.data('parent-index')}-${$li.data('index')}`, currentTitle: $li.text(), }; const $nextLevelPage = $(`.epartner-m-menu-level-page[data-deep=${clickInfo.deep + 1}]`); const $child = $nextLevelPage.find(`ul[data-parent-index=${clickInfo.nextParentIndex}]`); $back.show(); $logo.hide(); if ($child && $child.length) { this.mobileMenuPath.push(clickInfo); $menuHeader.text(clickInfo.currentTitle); $nextLevelPage.find('ul').addClass('list-hide'); $child.removeClass('list-hide'); $child.scrollTop(0); } }); }; const epartnerPageMenuVertical = function ({ loginFlag, data, newStyle }) { this.$container = $('#epartnerPageMenuVertical'); this.data = data; this.loginFlag = loginFlag; this.cssSuffix = loginFlag ? 'login' : 'unlogin'; this.newStyle = newStyle; }; epartnerPageMenuVertical.prototype.init = function () { this.createLevel1Menu(); $('.epartner-home-menu-level0').on('click', () => { $(`.epartner-home-menu-v-level1`).removeClass('active'); $('.epartner-home-menu-v-level1:first-child').addClass('active'); this.$container.slideDown(); }); this.$container.on('mouseleave', () => { this.$container.slideUp(); }); }; epartnerPageMenuVertical.prototype.createLevel1Menu = function () { const $level1List = this.$container.find('.menu-v-level1-list'); const $level2AllList = this.$container.find('.epartner-home-menu-v-content-list'); for (let i = 0; i < this.data.length; i++) { const item = this.data[i]; if (!showLevel1MenuFlag(item)) { continue; } const $level1 = document.createElement('div'); $level1.className = 'epartner-home-menu-v-level1'; $level1.innerHTML = `
    ${item.title}
    `; $($level1) .on('mouseover', () => { $($level1).addClass('active'); }) .on('mouseleave', () => { $($level1).removeClass('active'); }); $level1.append(this.createLevel2Menu(item)); $level1List.append($level1); } }; epartnerPageMenuVertical.prototype.createLevel2Menu = function (level1Data) { const $level2List = document.createElement('div'); $level2List.className = 'epartner-home-menu-v-level2-list small-scrollbar'; const $level1TitleRow = document.createElement('div'); $level1TitleRow.className = 'epartner-home-menu-v-level1-title-big flex-v-center'; const $level1Title = document.createElement('a'); $level1Title.innerText = level1Data.title + ' Home'; $level1Title.className = 'flex-v-center'; if (level1Data.link) { $($level1Title).attr({ href: level1Data.link, target: level1Data.targetBlank ? '_blank' : '_self', }); } const $icon = document.createElement('img'); $icon.className = 'epartner-home-menu-v-level1-title-icon'; $icon.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJcAAADlCAIAAADRF/LkAAAIsklEQVR4Ae3dv2tTXRgH8EuwQ+Nyh3SQkKW1s7i5+A+4OBRBlyKIU6tiRxcHQbyzS/8AB5E6WDpIHUVKf4CDWkGhiMWSRTQUWkzknpf73pDG9ObHvXnOOc95zjeDpGnu85zz/eRJ2iYmwR+c3E8gUDi5nwAU3TdUCopQlJCAhD1gFqEoIQEJe8AsQlFCAhL2gFmEooQEJOwBswhFCQlI2ANmEYoSEpCwB8wiFCUkIGEPmEUoSkhAwh4wi1CUkICEPWAWoSghAQl7wCxCUUICEvaAWYSihAQk7AGzCEUJCUjYA2YRihISkLAHzCIUJSQgYQ+YRShKSEDCHjCLUJSQgIQ9YBahKCEBCXvIN4txHP/48ePFixd37ty5evVqzerp/v37QwXiOI6iKBB9mp+fH1Xx+/fvS0tLYRjyCWR+fn6oolJKPORIip8+fbp06RIfvM5KRlQUDzlEsdFoLC4udlLjdmZ0RdmQgxS3trZmZma4yXWvJ5eiYMi+imtra+VyuTsyhufzKkqFzFCM4/j58+elUokhW8+SCiiKhMxQXFlZcYIwCIJiivIgexU3NzdZ/S7RM3w9XxZWFAb5j+Lv378vX77ckxTnL8dRlAR5ohjH8ePHjzmbnV7bmIpiIE8UP378WKlUTifF+ZLxFWVAthXjOF5YWOAMlrk2EkUBkG3Fvb29arWamRTnC6kUXYdsKz579oyzVr+1ESo6DZkotlqtubm5fklxvpxW0V3IRLFer09PT3PW6rc2ckVHIRPFnZ0d/n8yzYTUoegiZKK4urqamRH/CzUpOgeZKC4vL/MHy1yhPkW3IBPFJ0+eZGbE/0Ktig5BQnHIC3eceM0OFIcoOjGRUByuyB8SiiMpMoekVJycnHz9+vWBwdOvX79GRaC4HtvHSErFcrm8s7NDERffGjwhoZj7FsMQEoq5FRk+RkKxiCI3SCgWVFRKffnyhclzQVAsqPj169fZ2Vkmf6SEYhFFVoTpq6vJ/hruw28aSiluhFDMPYgMCaGYT5EnIRRzKLIlhOKoipwJoTiSInNCKA5X5E8IxSGKThBCcZCiK4RQ7KvoECEUsxXdIoRihqJzhFDsVdRHWKvVbty4oek5EDyncQKpj7BSqWxvb+t7qQcU24q6CdM2miChmMRrhlAfJBSNEmqC9F3R5BSmhDogvVa0RUgO6a+iXUJaSE8V9RGGYbi5udl95zn4PMlPrT4q8iGkmkjvFLkRkkD6pciTcHxIjxQ5E44J6Ysif8JxIL1QdIWwMKR8RbcIi0EKV3SRsACkZEWthO/evUvj1vfv6H8QEKvoOmGuiZSpKINwdEiBipIIR4SUpvjz58+LFy/qeJFSGIYGHgv7PcoOfoyUpqiU0vEhS3YJh06kQEWl1Pb2NuEnvHAgHAwpU5EQMgzDN2/e9LujM3955l2rWEUSSG6E/SZSsqJS6v3797VardgPOzwJMyGFKxaG5Ex4GlK+YgFI/oQ9kF4o5oJ0hbAb8ubNm76899Tu7u7QN99zi7AD+fnzZ18UlVKDIV0kTCGVUh4pDoAsl8tra2udUJw745di5v+Qcp3Qu1lMh6z7eQ8BhJ4qdiZSBqG/ikqp/f39jY0N5x4CMxfs3eNiZgquXwhF1wWT9UMRil3PF3jyvuE8zTGLPF3yrQqK+fKiuvbh4SHVx+MdHh5CkcolXx3Cj4NOSlGVw+NiLkaq2IPgf0GqclCEYq4EJFyZangwizZvDVC0mT5VbyhSJWmzDhRtpk/VG4pUSdqsA0Wb6VP1hiJVkjbrQNFm+lS9oUiVpM06ULSZPlVvKFIlabMOFG2mT9UbilRJ2qwDRZvpU/WGIlWSNutA0Wb6VL2hSJWkzTpQtJk+VW8oUiVpsw4UbaZP1RuKVEnarANFm+lT9YYiVZI260DRZvpUvaFIlaTNOlC0mT5VbyhSJWmzDhRtpk/VG4pUSdqsA0Wb6VP1hiJVkjbrQNFm+lS9oUiVpM06TBWDIJiamqrhNFoCZ8+e7XqzoLHOJjcIwhvFWGvBwUUTgGLR5DgdB0VOGkXXAsWiyXE6DoqcNIqu5eXLl8Hq6mrRw3EciwQSwbdv3545c4bFcrCI/Amkb/kV7O/vV6vV/IfjCBYJTE9P1+v14Pj4+MqVKyxWhEXkT2Bubq7VagVKqeSHHJzcTGB5eTl533Cl1IcPH8IwdHMXXq+6Wq3u7e21FVut1vXr173Ow83NLywsxHHcVlRKra+vl0olN/fi6aq735A2uUdVSjWbzWvXrnmah5vbvnfvXjqIJ7OYfvTSuXPn3NyRd6uenZ399u1b5wnS9iymX6+srOB+lf8tolQqvXr1qkP4zywqpeI4jqKI/zY8X2EURZ370tTyn1lMHyBv377teUyct//w4cNms9k9iL2zmH7v6Ojo1q1bnHfi7doyCbMV04l89OiRt2Ex3HipVHr69GnPHWlnInvvUTvfiON4fX29Uqkw3JJvS5qZmdna2urQnD7TVzG9aqPRWFxc9C01PvudmJiIoujo6Oi0XPclQxTTqx4cHCwtLU1OTvLZnviVTE1NRVHUaDS6tfqdH0kxPbjZbG5sbNy9e/f8+fP4tVLHzWhiYuLChQsPHjzY3d39+/dvP7PTl+dQ7Dn4+PiY6rPnUKder5/+/aEn8AFfFlccUBTfMpwAFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEargoFA0HrqUdFLXEarjof17KdqdQxZa+AAAAAElFTkSuQmCC'; $level1Title.append($icon); $level1TitleRow.append($level1Title); $level2List.append($level1TitleRow); for (let i = 0; i < level1Data.items.length; i++) { const item = level1Data.items[i]; if (!showLevel2MenuFlag(item)) { continue; } const $level2 = document.createElement('div'); $level2.className = `epartner-home-menu-v-level2-${this.cssSuffix} `; const $title = document.createElement('div'); $title.className = 'epartner-home-menu-v-level2-title '; $title.innerText = item.title; $level2.append($title); $level2.append(this.createLevel3Menu(item)); $level2List.append($level2); } return $level2List; }; epartnerPageMenuVertical.prototype.createLevel3Menu = function (level2Data) { const $level3List = document.createElement('div'); $level3List.className = `epartner-home-menu-v-level3-list-${this.cssSuffix}`; for (let i = 0; i < level2Data.items.length; i++) { const item = level2Data.items[i]; if (!showLevel3MenuFlag(item)) { continue; } const $level3 = document.createElement('div'); $level3.className = 'epartner-home-menu-v-level3-title hand-cursor'; const $level3Title = document.createElement('span'); $level3Title.innerText = item.title; $level3.append($level3Title); if (item.isLock === 'true') { const $lock = document.createElement('span'); $lock.className = 'menu-lock'; $lock.innerHTML = `🔒`; $level3.append($lock); const $lockTips = document.createElement('div'); $lockTips.className = 'menu-lock-tips'; $lockTips.innerHTML = 'No function right, Please click Apply to gain access.'; $lock.append($lockTips); } $level3.onclick = () => openMenuPage(item, this.loginFlag, this.newStyle); $level3List.append($level3); } return $level3List; }; function openWindow(item, url) { if (item.target === '_blank') { window.open(url); } else { window.location.href = url; setTimeout(() => { window.location.reload(); }, DELAY_TIME); } } function openMenuPage(item, loginFlag, newStyle) { const isAssociated = sessionStorage.getItem('epartner-is-associated') === 'true'; if (item.buriedCode && window.hwa) { window.hwa('trackPageView', item.buriedCode); } let url = DOMPurify.sanitize(item.link); if (item.title === 'Permission Management') { url = `${BASE_URL}${url.split('layout=')[1]}`; } if (!loginFlag || url.indexOf('/web/') > -1) { openWindow(item, url); if (url.indexOf('/group/') > -1) { setTimeout(() => { window.location.reload(); }, DELAY_TIME); } return; } else if (loginFlag && !isAssociated) { openWindow(item, url); return; } let lang = url.indexOf('/en/') > -1 ? 'en_US' : 'zh_CN'; const menuName = item.title; let params = `menuName=${menuName}&w3Account=${getCurrentUserInfo().userAccount}&language=${lang}`; let requestUrl = ''; if (newStyle) { requestUrl = `${BASE_URL}${constants.E_PARTNER_SERVICE}/pub/error/v2NoPermission?${params}`; } else { requestUrl = `${BASE_URL}${constants.E_PARTNER_SERVICE}/pub/error/noPermission?${params}`; } $.post(requestUrl, res => { if (res.code === '0' || res.code === '-1') { openWindow(item, url); } else { if (window.location.href.indexOf('/cn/') > -1) { window.location.href = DOMPurify.sanitize(BASE_URL + '/eplus/#/cn/group/err-403?menuName=' + menuName); } else { window.location.href = DOMPurify.sanitize(BASE_URL + '/eplus/#/en/group/err-403-en?menuName=' + menuName); } setTimeout(() => { window.location.reload(); }, DELAY_TIME); } }); } function expartnerDialog({ loginFlag }) { this.loginFlag = loginFlag; } expartnerDialog.prototype.init = function () { if (!this.loginFlag) { return; } $.ajax({ type: 'GET', dataType: 'json', headers: { 'x-app-id': 'com.huawei.channelsales.echannel.echannel2.0', 'x-sub-app-id': 'ePartner_service', }, url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/partner/autoRenewalPop`, success: res => { if (res && res.data && res.data instanceof Array && res.data.length > 0) { res.data.forEach(item => { this.createDialog(item); }); } }, }); }; expartnerDialog.prototype.createDialog = function ({ content, title, scena }) { const $dialog = document.createElement('dialog'); $dialog.className = 'epartner-dialog'; document.body.append($dialog); const $header = document.createElement('div'); $header.className = 'epartner-dialog-header'; $header.innerText = title; $dialog.append($header); const $closeIcon = document.createElement('div'); $closeIcon.className = 'hand-cursor iconfont icon-close'; $header.append($closeIcon); const $content = document.createElement('div'); $content.className = 'epartner-dialog-content small-scrollbar'; $content.innerHTML = content; $dialog.append($content); const $optRow = document.createElement('div'); $optRow.className = 'epartner-dialog-opt-row'; $dialog.append($optRow); const $okBtn = document.createElement('button'); $okBtn.innerText = 'Has been known'; $optRow.append($okBtn); const $closeBtn = document.createElement('button'); $closeBtn.innerText = 'Close'; $optRow.append($closeBtn); const $tipsRow = document.createElement('div'); $tipsRow.className = 'epartner-dialog-footer-tips'; $tipsRow.innerHTML = '!Reminder: If you select “Has been known”, no dialog box will be displayed for you in the next 30 days. '; $dialog.append($tipsRow); this.createEvents({ cookieKey: `read_Renew_Agreement_${scena}`, $okBtn, $closeBtn, $closeIcon, $dialog, $header, $content }); }; expartnerDialog.prototype.createEvents = function ({ cookieKey, $okBtn, $closeBtn, $closeIcon, $dialog, $header, $content }) { if (document.cookie.indexOf(cookieKey) > 0) { return; } $dialog.showModal(); $($content).scrollTop(0); const closeDialog = () => { $dialog.className = 'epartner-dialog close'; setTimeout(() => { $dialog.close(); $dialog.removeEventListener('mousedown', startDragging); }, 300); }; const startDragging = dialogDragging({ $dialog, $header, closeDialog }); $dialog.addEventListener('mousedown', startDragging); $($okBtn).on('click', () => { let date = new Date(); date.setTime(date.getTime() + 30 * 24 * 60 * 60 * 1000); document.cookie = cookieKey + '=1' + ';path=/;expires=' + date.toGMTString(); closeDialog(); }); $($closeIcon).on('click', () => { console.info('closeIcon'); closeDialog(); }); $($closeBtn).on('click', () => { console.info('close'); closeDialog(); }); }; function partnerFooter() {} partnerFooter.prototype.init = function () { this.queryRichText(); }; partnerFooter.prototype.queryRichText = function () { const href = window.location.href; let footerLang = 'footer-en-meta'; if (href.indexOf('/cn/') > -1) { footerLang = 'footer-cn-meta'; } else if (href.indexOf('/ru/') > -1) { footerLang = 'footer-ru-meta'; } else if (href.indexOf('/jp/') > -1) { footerLang = 'footer-jp-meta'; } else if (href.indexOf('/pt/') > -1) { footerLang = 'footer-pt-meta'; } else if (href.indexOf('/es/') > -1) { footerLang = 'footer-es-meta'; } $.ajax({ type: 'get', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/pub/public/getHtmlAreaInfo/MessageTemplateEN/${footerLang}`, success: function (res) { if (res.content) { let str = replaceOrigin(res.content, '.huawei.com'); $('#partner-footer').html(str); } }, }); }; function cookieStatement() {} cookieStatement.prototype.init = async function () { let that = this; $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.COMMON_SERVICE}/common/v1/public/queryLookupList?classifyCode=ESDDP_PRIVACY_STATEMENT&language=zh`, success: function (res) { if (!res || !res.length) { return; } let showCookieProtocol = false; res.forEach(ele => { if (ele.itemCode === 'PrivacyCookieDeclaration') { showCookieProtocol = ele.itemDesc === 'Y' ? true : false; } }); if (showCookieProtocol && document.cookie.indexOf('read_EnPolicy_noru') < 0) { $('#cookiePoster').removeAttr('style'); that.initEvent(); } else { that.removeCookiePoster(); } }, }); }; cookieStatement.prototype.removeCookiePoster = function () { $('#cookiePoster').remove(); }; let isFirstLoad = true; cookieStatement.prototype.initEvent = function () { let that = this; $('#cookiePoster .accept-cookies').on('click', function () { let date = new Date(); date.setTime(date.getTime() + 6 * 30 * 24 * 60 * 60 * 1000); document.cookie = `read_EnPolicy_noru=1;path=/;expires=${date.toGMTString()}`; that.removeCookiePoster(); }); $('#cookiePoster .reject-cookies').on('click', function () { that.removeCookiePoster(); }); $('#cookiePoster .consent_link').on('click', function () { if (isFirstLoad) { that.loadCookieDialog(); } else { that.cookieDialogShowAndHide('show'); } }); }; cookieStatement.prototype.loadCookieDialog = function () { isFirstLoad = false; let that = this; this.getTipFun('Your-Privacy', '.Your-Privacy'); this.getTipFun('Essential-Cookies', '.Essential-Cookies'); this.getTipFun('Analytics-Cookies', '.Analytics-Cookies'); this.getTipFun('Your-Privacy-Move', '.Your-Privacy-Move'); this.getTipFun('Essential-Cookies-Move', '.Essential-Cookies-Move'); this.getTipFun('Analytics-Cookies-Move', '.Analytics-Cookies-Move'); $('#cookieDialog .partner-dialog-box__header .partner-dialog-box__headerbtn').on('click', function () { that.cookieDialogShowAndHide('hidden'); }); $('#cookieDialog .pc_ul_box .ul_title_box li').on('click', function (event) { let currentTarget = $(event.currentTarget); currentTarget.addClass('active').siblings().removeClass('active'); $(`#cookieDialog .pc_ul_box .ul_content_box .${currentTarget.attr('data-name')}`) .removeAttr('style') .siblings() .attr('style', 'display:none;'); }); $('#cookieDialog .mb_ul_box .ul_title_box li .li_p_title').on('click', function (event) { let currentTarget = $(event.currentTarget); currentTarget.next().removeAttr('style').parent().siblings().children('.li_box').attr('style', 'display:none;'); }); this.resetSure(); let $partnerSwitch = $('#cookieDialog .partner-switch'); $partnerSwitch.on('click', function () { if ($partnerSwitch.hasClass('partner-switch-checked')) { $partnerSwitch.removeClass('partner-switch-checked'); $('#cookieDialog .analytics-span').html('Inactive'); } else { $partnerSwitch.addClass('partner-switch-checked'); $('#cookieDialog .analytics-span').html('Active'); } }); $('#cookieDialog .partner-meta-cookie-dialog .partner-dialog-box__footer .resetBtn').on('click', function () { that.resetSure(); }); $('#cookieDialog .partner-meta-cookie-dialog .partner-dialog-box__footer .closeBtn').on('click', function () { that.setCookie(); that.cookieDialogShowAndHide('hidden'); }); }; cookieStatement.prototype.getTipFun = function (param, className) { let that = this; $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/pub/public/getHtmlAreaInfo/MessageTemplateEN/${param}`, success: function (res) { if (res && res.content) { if (param === 'Your-Privacy' || param === 'Your-Privacy-Move') { res.content = res.content.replace('/eplus/#', `${BASE_URL}/eplus/#`); } $(className).html(res.content); if (param === 'Your-Privacy') { that.cookieDialogShowAndHide('show'); } } }, }); }; cookieStatement.prototype.resetSure = function () { let $partnerSwitch = $('#cookieDialog .partner-switch'); let analyticsValue = this.getCookie(); if (analyticsValue === 'Active') { $partnerSwitch.addClass('partner-switch-checked'); } else { $partnerSwitch.removeClass('partner-switch-checked'); } $('#cookieDialog .analytics-span').html(analyticsValue); }; cookieStatement.prototype.cookieDialogShowAndHide = function (type) { let $modal = $('#cookiePoster #cookieModal'); let $cookieDialog = $('#cookiePoster #cookieDialog'); if (type === 'show') { $modal.removeClass('hidden'); $cookieDialog.removeClass('hidden'); } else { $modal.addClass('hidden'); $cookieDialog.addClass('hidden'); } }; cookieStatement.prototype.setCookie = function () { let analyticsValue = $('#cookieDialog .analytics-span').html(); Cookies.set('search_history_kw_switch', analyticsValue); }; cookieStatement.prototype.getCookie = function () { let his = Cookies.get('search_history_kw_switch'); if (!his) { his = 'Inactive'; } return his; }; function search() {} search.prototype.init = function () { let that = this; $('#epartnerPageMenu .search-btn').on('click', function () { $('#epartnerHomeHeaderSearch').show(); $('#epartnerHomeHeaderSearch .searching-tip').show(); document.body.style.overflow = 'hidden'; let scrollTop = $(window).scrollTop(); if (scrollTop > 0 && scrollTop < 42) { $('#epartnerHomeHeaderSearch').attr('style', `top: -${scrollTop}px;`); } else if (scrollTop >= 42) { $('#epartnerHomeHeaderSearch').attr('style', `top: -42px;`); } else if (scrollTop === 0) { $('#epartnerHomeHeaderSearch').attr('style', `top: 0;`); } }); $('#epartnerHomeHeaderSearch .close-search').on('click', function () { $('#epartnerHomeHeaderSearch').hide(); document.body.style.overflow = 'auto'; }); $('#epartnerHomeHeaderSearch .search-con-box.searching').on('click.self', function () { $('#epartnerHomeHeaderSearch').hide(); document.body.style.overflow = 'auto'; }); $('#epartnerHomeHeaderSearch #delHistory').on('click', function () { let kwv = JSON.stringify({}); Cookies.set('search_history_kw', kwv, { raw: false, expires: Infinity, path: '/', secure: false }); that.showOrHiddenTip('search-history', 'hide'); }); $('#epartnerHomeHeaderSearch .searching-cistern-l').on('click.self', function (event) { event.stopPropagation(); $('#epartnerHomeHeaderSearch .searching-tip').hide(); }); $('#epartnerHomeHeaderSearch .nav-searchbit-box').on('click', function (event) { event.stopPropagation(); }); let timeout = null; $('#epartnerHomeHeaderSearch #txtSearch_Navigation').on('input', function () { let searchValue = $(this).val(); if (searchValue) { clearTimeout(timeout); timeout = setTimeout(() => { that.searchValueFunction(searchValue); that.searchValueFunction2(searchValue); $('#epartnerHomeHeaderSearch .clear-search').show(); that.showOrHiddenTip('search-history', 'hide'); that.showOrHiddenTip('search-hot', 'hide'); }, 600); } else { clearTimeout(timeout); that.initSearchTip(); } }); $('#epartnerHomeHeaderSearch #txtSearch_Navigation').on('focus', function () { $('#epartnerHomeHeaderSearch .searching-tip').show(); }); $('#epartnerHomeHeaderSearch #txtSearch_Navigation').on('keydown', function (event) { if (event.keyCode + '' === '13') { that.searchClick(); } }); $('#epartnerHomeHeaderSearch .clear-search').on('click', function () { $('#epartnerHomeHeaderSearch #txtSearch_Navigation').val(''); that.initSearchTip(); }); $('#epartnerHomeHeaderSearch #searchBtn').on('click', function () { that.searchClick(); }); this.setHistoryElement(); this.getHotWords(); }; search.prototype.setHistoryElement = function () { let historyData = this.getHistory(); let that = this; if (Object.keys(historyData).length > 0) { Object.keys(historyData).forEach(key => { const $a = document.createElement('a'); $a.innerText = key; $a.title = key; $a.addEventListener('click', function () { that.searchJumping(key); }); $('#epartnerHomeHeaderSearch .search-history').append($a); }); } else { that.showOrHiddenTip('search-history', 'hide'); } }; search.prototype.getHistory = function () { let his = Cookies.get('search_history_kw'); if (his) { try { his = JSON.parse(his); } catch { his = {}; } } else { his = {}; } return his; }; search.prototype.setHistory = function (word) { if (!word) { return; } let old = this.getHistory(); let now = Number(new Date()); old[word] = now; let curt = this.comListHis(old); let newValue = {}; curt.forEach(item => { newValue[item.name] = item.t; }); let cookieValue = JSON.stringify(newValue); Cookies.set('search_history_kw', cookieValue, { raw: false, expires: Infinity, path: '/', secure: false, }); }; search.prototype.delHistory = function () { let kwv = JSON.stringify({}); Cookies.set('search_history_kw', kwv, { raw: false, expires: Infinity, path: '/', secure: false }); this.historyData = this.getHistory(); }; search.prototype.comListHis = function (obj) { let his = obj || {}; let curt = []; Object.keys(his) .filter(item => !this.isGarbled(item)) .forEach(key => { curt.push({ name: key, t: his[key], }); }); let now = Number(new Date()) - 2592000000; curt = [...curt] .filter(item => item.t > now) .sort((a, b) => { return b.t - a.t; }); curt = curt.splice(0, 5); return curt; }; search.prototype.isGarbled = function (word) { let en = /\w/gi; let cn = /[\u4e00-\u9fa5]/g; let enSymbol = '~!@#$%^&*(){}|:"<>?/*-+.`[]\\;\',./='; let cnSymbol = '~!@#¥%……&*()——+{}|”:《》?/*-+.·【】、;’,。、='; let txt = String(word).replaceAll(' ', ''); let flag = String(txt) .split('') .filter(t => Boolean(t)) .filter(li => { let curt = !String(li).match(cn) && !String(li).match(en) && enSymbol.indexOf(String(li)) < 0 && cnSymbol.indexOf(String(li)) < 0; return curt === true; }); return Boolean(flag.length); }; search.prototype.getHotWords = function () { let that = this; let params = { customParams: [ { customParamName: 'language', customParamValue: 'en' }, { customParamName: 'site', customParamValue: 'en' }, ], }; $.ajax({ type: 'POST', dataType: 'json', data: JSON.stringify(params), url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/pub/public/getHotWord`, success: function (res) { if (!res.body || !res.body.data || !res.body.data.data) { return; } let hotWordsData = res.body.data.data; hotWordsData.forEach(item => { const $a = document.createElement('a'); $a.innerText = item.searchTxt; $a.title = item.searchTxt; $a.addEventListener('click', function () { that.searchJumping(item.searchTxt); }); $('#epartnerHomeHeaderSearch .search-hot').append($a); }); }, }); }; search.prototype.searchValueFunction = function (value) { let that = this; let params = { queryText: value, customParams: [ { customParamName: 'language', customParamValue: 'en' }, { customParamName: 'site', customParamValue: 'en' }, ], }; $.ajax({ type: 'POST', dataType: 'json', data: JSON.stringify(params), url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/pub/public/searchDirectly`, success: function (res) { if (res.body && res.body.data) { $('#epartnerHomeHeaderSearch .search-direct-title').show(); $('#epartnerHomeHeaderSearch .search-direct').show(); let arr = []; res.body.data.forEach(e => { arr = [...arr, ...e.data]; }); let searchDirectlyData = arr.slice(0, 5); searchDirectlyData.forEach(item => { const $a = document.createElement('a'); $a.innerText = item.itemTitle; $a.title = item.itemTitle; $a.href = item.itemUrl; $('#epartnerHomeHeaderSearch .search-direct').append($a); }); } else { that.showOrHiddenTip('search-direct', 'hide'); } }, }); }; search.prototype.searchValueFunction2 = function (value) { let that = this; let params = { queryText: value, customParams: [ { customParamName: 'language', customParamValue: 'en' }, { customParamName: 'site', customParamValue: 'en' }, ], }; $.ajax({ type: 'POST', dataType: 'json', data: JSON.stringify(params), url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/pub/public/searchSuggestions`, success: function (res) { that.parseSearchSuggestions(res); }, }); }; search.prototype.parseSearchSuggestions = function (res) { const that = this; if (res.body && res.body.data) { $('#epartnerHomeHeaderSearch .search-suggest-title').show(); $('#epartnerHomeHeaderSearch .search-suggest').show(); const hotWordsData = res.body.data; hotWordsData.forEach(item => { const $a = document.createElement('a'); $a.innerText = item.suggestword; $a.title = item.suggestword; $a.addEventListener('click', function () { that.searchJumping(item.suggestword); }); $('#epartnerHomeHeaderSearch .search-suggest').append($a); }); } else { that.showOrHiddenTip('search-suggest', 'hide'); } }; search.prototype.searchJumping = function (val) { this.setHistory(val); let url = `${BASE_URL}/eplus/#/en/web/marketingsearch?from=partner&keyword=${val}&lang=en&site=en&filterType=partner`; window.location.href = DOMPurify.sanitize(url); setTimeout(() => { window.location.reload(); }, 500); }; search.prototype.searchClick = function () { let searchValue = $('#epartnerHomeHeaderSearch #txtSearch_Navigation').val(); if (searchValue !== '') { this.setHistory(searchValue); this.searchJumping(searchValue); } }; search.prototype.initSearchTip = function () { $('#epartnerHomeHeaderSearch .clear-search').hide(); let historyData = this.getHistory(); if (Object.keys(historyData).length > 0) { this.showOrHiddenTip('search-history', 'show'); } else { this.showOrHiddenTip('search-history', 'hide'); } this.showOrHiddenTip('search-hot', 'show'); this.showOrHiddenTip('search-direct', 'hide'); this.showOrHiddenTip('search-suggest', 'hide'); }; search.prototype.showOrHiddenTip = function (rowName, type) { if (type === 'show') { $(`#epartnerHomeHeaderSearch .${rowName}-title`).show(); $(`#epartnerHomeHeaderSearch .${rowName}`).show(); } else if (type === 'hide') { $(`#epartnerHomeHeaderSearch .${rowName}-title`).hide(); $(`#epartnerHomeHeaderSearch .${rowName}`).hide(); } }; function menuHead({ loginFlag, isAssociatedType, isHW }) { this.loginFlag = loginFlag; this.isAssociatedType = isAssociatedType; this.isHW = isHW; } menuHead.prototype.init = async function () { if (this.loginFlag && !this.isAssociatedType && !this.isHW) { $('#menuHead').show(); let that = this; $('#menuHead #checkPrivacyStatement').on('click', function () { window.location.href = `${BASE_URL}/eplus/#/en/web/associate-company-en`; }); $('#menuHead #showPartnerType').on('mouseenter', function () { $('#menuHead .head-tips-ul').show(); $('#menuHead .layer').show(); }); $('#menuHead .layer').on('click', function () { $('#menuHead .head-tips-ul').hide(); $('#menuHead .layer').hide(); }); $('#menuHead .icon-guanbianniu').on('click', function () { $('#menuHead').hide(); }); $('#menuHead .menu-head-dialog__close').on('click', function () { that.dialogShowAndHide('hide'); }); $('#menuHead .menu-head-button.yesBtn').on('click', function () { window.open(`${BASE_URL}/eplus/#/en/web/associate-progress-en`); that.dialogShowAndHide('hide'); }); $('#menuHead .menu-head-button.noBtn').on('click', function () { that.dialogShowAndHide('hide'); }); $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/account/findCompanyInfo?xhwId=com.huawei.ebg.epartner.uipm&env=${location.hostname}`, success: function (res) { if (res.content.valid == -1) { that.dialogShowAndHide('show'); } }, }); } else { $('#menuHead').remove(); } }; menuHead.prototype.dialogShowAndHide = function (type) { let $modal = $('#menuHead #menuHeadModal'); let $dialog = $('#menuHead #menuHeadDialog'); if (type === 'show') { $modal.removeClass('hidden'); $dialog.removeClass('hidden'); } else { $modal.addClass('hidden'); $dialog.addClass('hidden'); } }; function downloadEApp() {} downloadEApp.prototype.init = function () { this.checkShow(); this.initEvent(); }; downloadEApp.prototype.checkShow = function () { const isWeLink = navigator.userAgent.includes('com.huawei.eplus') && navigator.userAgent.includes('HuaWei-AnyOffice'); const noAppDownload = getUrlValue('noAppDownload'); let isShow = false; if (isWeLink || noAppDownload === 'true') { isShow = false; } else { isShow = /Android|web0s|iPhone|iPad|iPod|BlackBerry|IEMobile|0pera Mini|Phone|Tablet/i.test(navigator.userAgent); } const downloadDom = $('.partner-tenant-meta-app-download'); if (isShow && downloadDom) { downloadDom.css('display', 'flex'); } }; downloadEApp.prototype.initEvent = function () { const downloadDom = $('.partner-tenant-meta-app-download'); const openAppDom = $('.partner-tenant-meta-app-download .openApp'); const closeDom = $('.partner-tenant-meta-app-download .closeApp'); openAppDom.off('click'); closeDom.off('click'); openAppDom.on('click', function () { let weLinkUrl = `https://app.huawei.com/eplus/front/index.html#/findIndex`; let url = `https://app.huawei.com/eplus/front/download.html?welinkuri=${encodeURIComponent(weLinkUrl)}&welinkscheme=hwwelink://com.huawei.eplus/`; window.location.replace(url); }); closeDom.on('click', function () { downloadDom.css('display', 'none'); }); }; function browser() {} browser.prototype.init = function () { if (this.checkBrowserVersion()) { $('.partner-low-version-explore-tips').css('display', 'flex'); } $('.partner-low-version-explore-tips .icon-operationFailed').off('click'); $('.partner-low-version-explore-tips .icon-operationFailed').on('click', function () { $('.partner-low-version-explore-tips').css('display', 'none'); }); }; browser.prototype.checkBrowserVersion = function () { const sys = {}; const userAgent = navigator.userAgent.toLowerCase(); const s = userAgent.match(/chrome\/([\d\.]+)/); sys.chrome = s && s[1] ? s[1] : 0; if (sys.chrome) { if (parseInt(s[1]) <= 70) { return true; } } else if (userAgent.indexOf('msie') > -1) { return true; } else { return false; } }; function protocolAndWebsite() { this.declarationNo = 'PSTC'; this.privacyUrl = '/eplus/#/cn/web/partner-privacy'; this.userAgreeUrl = '/eplus/#/cn/web/user-agree'; this.acceptMailInfo = false; this.acceptPersonalInfo = false; this.dialogClassName = ''; } protocolAndWebsite.prototype.init = function () { this.getEsdDpPrivacyType(); }; protocolAndWebsite.prototype.getEsdDpPrivacyType = function () { const that = this; $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.COMMON_SERVICE}/common/v1/public/queryLookupList?classifyCode=ESDDP_PRIVACY_TYPE&language=zh`, success: function (res) { if (!res || !res.length) { return; } res.forEach(item => { if (getCurrentLanguage() == item.itemCode) { that.declarationNo = item.itemName; that.querySignedPrivacyState(); } }); }, }); }; protocolAndWebsite.prototype.querySignedPrivacyState = function () { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/privacy/signedPrivacyStatement?declarationNo=${this.declarationNo}`, success: res => { if (res && !res.result) { this.openSignedPrivacyWebsiteDialog(); } }, }); }; protocolAndWebsite.prototype.openSignedPrivacyWebsiteDialog = function () { const content = `

    We can provide information about the products, solutions, services, quotation and marketing activities to you by email notice. Please confirm whether you agree to receive the information and email above. You can cancel the subscription anytime as follow: My Huawei - Personal Profiles - Email Notification Settings - Cancel the subscription.

    Welcome to Huawei e+ Partner official website. According to the User Service Agreement, we will provide necessary service to you and enable your use of the platform. Based on that, we will need to obtain, process and protect your personal data pursuant to the Privacy Statement of Partner Platform. Please read Privacy Statement of Partner Platform carefully and click AGREE if you agree on the Privacy Statement of Partner Platform.

    `; this.openDialog({ title: 'Declaration of e+ Partners Official website', content, cancelText: 'Cancel', confirmText: 'Agreed', type: 1, className: 'partner-official-website-dialog', }); }; protocolAndWebsite.prototype.openNoSignedNoticeDialog = function () { const content = `

    Since you do not agree on the Privacy Statement of Partner Platform , we cannot provide the platform service to you. If you could like to use this platform, please login again and accept the Privacy Statement of Partner Platform

    `; this.openDialog({ title: 'Notice', content, cancelText: 'return', confirmText: 'Confirm', type: 0, className: 'partner-official-website-dialog' }); }; protocolAndWebsite.prototype.openDialog = function ({ title, content, cancelText, confirmText, type, width, minWidth, maxWidth, className }) { const dialog = document.createElement('dialog'); dialog.className = `epartner-dialog p-dialog ${className}`; this.dialogClassName = dialog.className; if (width) { dialog.style.width = width; } if (minWidth) { dialog.style.minWidth = minWidth; } if (maxWidth) { dialog.style.maxWidth = maxWidth; } document.body.append(dialog); const header = document.createElement('div'); header.className = 'epartner-dialog-header p-dialog__header p-dialog__title'; if (type !== 1) { const icon = document.createElement('span'); icon.className = 'icon-warn'; icon.innerHTML = '!'; header.append(icon); } header.append(title); dialog.append(header); const body = document.createElement('div'); body.className = 'epartner-dialog-content p-dialog__body small-scrollbar'; body.innerHTML = content; dialog.append(body); const optRow = document.createElement('div'); optRow.className = 'epartner-dialog-opt-row p-dialog__footer p-button-group'; dialog.append(optRow); const closeBtn = document.createElement('button'); closeBtn.className = 'p-button p-button--default'; closeBtn.innerText = cancelText; if (cancelText) { optRow.append(closeBtn); } const okBtn = document.createElement('button'); okBtn.className = `p-button p-button--primary is-plain ${type === 1 && !this.acceptPersonalInfo ? 'is-disabled' : ''}`; okBtn.innerText = confirmText; optRow.append(okBtn); this.createEvents({ okBtn, closeBtn, dialog, header, body, type }); }; protocolAndWebsite.prototype.createEvents = function ({ okBtn, closeBtn, dialog, header, body, type }) { dialog.showModal(); $(body).scrollTop(0); let baseLeft = 0; let baseTop = 0; const closeDialog = () => { dialog.className = `${this.dialogClassName} close`; setTimeout(() => { dialog.close(); dialog.removeEventListener('mousedown', startMoving); }, 300); }; const startMoving = dialogDragging({ $dialog: dialog, $header: header, closeDialog }); dialog.addEventListener('mousedown', startMoving); $('.p-dialog').off('click'); $(okBtn).off('click'); $(okBtn).on('click', () => { if (type === 1) { if (this.acceptPersonalInfo) { closeDialog(); this.signedPrivacy(this.acceptMailInfo); } } else if (!type) { const origin = BASE_URL.split('://')[1]; const logoutUrl = replaceOrigin(getLogoOutUrl(), '.huawei.com'); window.location.href = `https://${origin}${logoutUrl}`; } else { closeDialog(); } }); $(closeBtn).off('click'); $(closeBtn).on('click', () => { closeDialog(); type ? this.openNoSignedNoticeDialog() : this.openSignedPrivacyWebsiteDialog(); }); $('.p-dialog').on('click', '.checkbox', e => { e.preventDefault(); const pCheckbox = $(e.currentTarget).find('.p-checkbox'); if (pCheckbox.hasClass('is-checked')) { pCheckbox.find('.p-checkbox__input').removeClass('is-checked'); pCheckbox.removeClass('is-checked'); this[pCheckbox.hasClass('mail-info') ? 'acceptMailInfo' : 'acceptPersonalInfo'] = false; } else { pCheckbox.find('.p-checkbox__input').addClass('is-checked'); pCheckbox.addClass('is-checked'); this[pCheckbox.hasClass('mail-info') ? 'acceptMailInfo' : 'acceptPersonalInfo'] = true; } if (this.acceptPersonalInfo) { $('.p-button--primary.is-plain').removeClass('is-disabled'); } else { $('.p-button--primary.is-plain').addClass('is-disabled'); } }); $('.p-dialog').on('click', '.personal-privacy', e => { window.open(`${BASE_URL}/eplus/#/en/web/partner-privacy`); }); $('.p-dialog').on('click', '.platform-privacy', e => { window.open(`${BASE_URL}/eplus/#/en/web/partner-privacy`); }); }; protocolAndWebsite.prototype.signedPrivacy = function (checkSub) { debugger; if (checkSub) { this.createOrCancelTemporarySigning(); } const params = { declarationNo: this.declarationNo, }; $.ajax({ type: 'post', dataType: 'json', data: JSON.stringify(params), url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/privacy/signPrivacyStatement`, success: res => { if (res && res.result) { this.closeDialog(); } else { this.createWarnMessage(); } }, error: () => { this.createWarnMessage(); }, }); }; protocolAndWebsite.prototype.createOrCancelTemporarySigning = function () { const params = { isSigned: 'Y', }; $.ajax({ type: 'post', dataType: 'json', data: JSON.stringify(params), url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/privacy/createOrCancelTemporarySigning`, }); }; protocolAndWebsite.prototype.createWarnMessage = function () { const content = `

    Signing failed.

    `; this.openDialog({ title: 'Notice', content, cancelText: '', confirmText: 'Confirm', type: 3, width: '40%', minWidth: '150px', maxWidth: '400px' }); }; let env = 'beta'; if (isProduction()) { env = 'pro'; } let hwaAppKeys = { env: env, appKeys: { beta: '2806bc73dadccef524ed5f58ff569881', pro: '07b478fa338f66d7fc00f4e86dfb41fb', }, ABVersion: 'A', platform: 'web', }; (function (h, w, f, t) { const myDomain = window.location.origin.indexOf('huawei.cn') > -1 ? 'huawei.cn' : 'huawei.com'; try { if (!h[t]) { h.GlobalHwaNamespace = h.GlobalHwaNamespace || []; h.GlobalHwaNamespace.push(t); h[t] = function () { (h[t].q = h[t].q || []).push(arguments); }; h.trackerload = function () { (h[t].q = h[t].q && h[t].q.length ? h[t].q : []).unshift(arguments); }; h[t].q = h[t].q || []; } let host = f.env == 'pro' ? `hwa.his.${myDomain}` : f.env == 'beta' ? `hwa-beta.his.${myDomain}` : ''; let welinkHost = ''; if (f.platform == 'welink') { host = f.env == 'pro' ? `w3m.${myDomain}/mcloud/umag` : f.env == 'beta' ? `mcloud-uat.${myDomain}/mcloud/umag` : ''; welinkHost = `${host}/ProxyForText/hwa_trackload`; h.hwahost = welinkHost; host = `${host}/fg/ProxyForDownLoad/hwa_f`; } h.aids = f; h.space = t; let ts = String(String(new Date().getFullYear()) + new Date().getMonth()) + new Date().getDate(); let script = w.createElement('script'); script.id = 'uem_f'; script.src = `${(location.protocol == 'https:' ? 'https://' : 'http://') + host}/dist/uem_f.js?v=${ts}`; if (!(f.async == false)) { script.setAttribute('async', '1'); } script.setAttribute('style', 'display:none;'); let where = w.getElementsByTagName('head')[0].firstChild || w.getElementsByTagName('head')[0].lastChild || w.getElementsByTagName('script')[0]; if (where) { where.parentNode.insertBefore(script, where); } else { w.getElementsByTagName('head')[0].appendChild(script); } } catch (e) { if (!h[t]) { h[t] = function () {}; } } })(window, document, hwaAppKeys, 'hwa'); initAjaxSet(); initLogin(); initHeaderRightUserClickEvent(); initRegisterClickEvent(); new partnerFooter().init(); new browser().init(); window.hwa('trackPageView', 'PA60A67B3D600F8'); }); })(window, jQuery);