!(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) { PROFILE_NAME = 'sit'; BASE_URL = 'https://kwesit.huawei.com'; } else if (window.location.href.indexOf('uat') > -1) { PROFILE_NAME = 'uat'; BASE_URL = 'https://kweuat.huawei.com'; } else if (window.location.href.indexOf('icsl') > -1) { PROFILE_NAME = 'icsl'; BASE_URL = 'https://icsl-epartner.his-beta.huawei.com'; } else { PROFILE_NAME = 'production'; BASE_URL = 'https://partner.huawei.com'; } } 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('icsl') > -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 { LOGIN_PATH = 'https://uniportal.huawei.com/uniportal1/login-pc.html'; } } let IS_DEVELOPMENT = $('#wcm_resource_load') ? $('#wcm_resource_load').val() : ''; if (!IS_DEVELOPMENT || IS_DEVELOPMENT.indexOf('wcm_resource_load') > -1) { IS_DEVELOPMENT = true; } else { IS_DEVELOPMENT = false; } function getS3BaseUrl() { let S3_BASE_PATH = $('#wcm_s3_base_url') ? $('#wcm_s3_base_url').val() : ''; if (!S3_BASE_PATH || S3_BASE_PATH.indexOf('wcm_s3_base_url') > -1) { if (window.location.href.indexOf('sit') > -1 || window.location.href.indexOf('b1') > -1 || window.location.href.indexOf('localhost.huawei.com') > -1) { S3_BASE_PATH = 'https://kwesit.huawei.com/partnercloud/epartner/assets'; } else if (window.location.href.indexOf('icsl') > -1) { S3_BASE_PATH = 'https://kwesit.huawei.com/partnercloud/epartner/assets'; } else if (window.location.href.indexOf('uat') > -1) { S3_BASE_PATH = 'https://kweuat.huawei.com/partnercloud/epartner/assets'; } else { S3_BASE_PATH = 'https://partner.huawei.com/partnercloud/epartner/assets'; } } return S3_BASE_PATH; } 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://kwesit.huawei.com/eplusmeta'; } else if (window.location.href.indexOf('uat') > -1) { HOME_BASE_URL = 'https://kweuat.huawei.com/eplusmeta'; } else if (window.location.href.indexOf('icsl') > -1) { HOME_BASE_URL = 'https://icsl-epartner.his-beta.huawei.com/eplusmeta'; } else { HOME_BASE_URL = 'https://partner.huawei.com/eplusmeta'; } } 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', HTTPS_STATUS: { SUCCESS: 200, }, FOOTER_CONFIG_MAP: { ZH_CN: 'footer-cn-meta', EN_US: 'footer-en-meta', JA_JP: 'footer-jp-meta', RU_RU: 'footer-ru-meta', ES_MX: 'footer-es-meta', PT_BR: 'footer-pt-meta', }, uipmIcslOrigin: 'icsl-uipm.his-beta.huawei.com', }; function interceptAjax() { $.ajaxSetup({ beforeSend: function (xhr, httpConfig) { if (httpConfig.url.indexOf(constants.APP_ID) === -1) { return; } const csrfToken = localStorage.getItem('x-csrf-token'); if (csrfToken) { xhr.setRequestHeader('x-csrf-token', csrfToken); } if (!httpConfig.headers) { httpConfig.headers = {}; } if (!httpConfig.headers['x-app-id']) { xhr.setRequestHeader('x-app-id', constants.APP_ID); } if (!httpConfig.headers['x-sub-app-id']) { xhr.setRequestHeader('x-sub-app-id', constants.SUB_APP_ID); } }, complete: function (xhr) { const token = xhr.getResponseHeader('x-csrf-token'); if (token) { localStorage.setItem('x-csrf-token', token); } if (xhr.status === 403) { goUniPortalLogin(); } }, }); } function initAjaxSet() { $.ajaxSetup({ xhrFields: { withCredentials: true, }, contentType: 'application/json', crossDomain: true, }); } function getCurrentUserInfo() { return sessionStorage.getItem('current-user-info') && JSON.parse(sessionStorage.getItem('current-user-info')); } function isChina() { return sessionStorage.getItem('epartner-current-language') && sessionStorage.getItem('epartner-current-language').toString() === constants.LANGUAGE.ZH_CN; } function getCurrentLanguage() { return sessionStorage.getItem('epartner-current-language'); } function isAssociatedCompany() { return sessionStorage.getItem('epartner-is-associated') && sessionStorage.getItem('epartner-is-associated').toString() === 'true'; } function isLogin() { return sessionStorage.getItem('epartner-is-login') && sessionStorage.getItem('epartner-is-login').toString() === 'true'; } function isHW() { return getCurrentUserInfo().userType !== 'E_PT'; } function getLogoOutUrl() { return sessionStorage.getItem('epartner-logout-url'); } 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); } localStorage.removeItem('x-csrf-token'); window.location.href = DOMPurify.sanitize(`${LOGIN_PATH.replace('com', com)}?redirect=${url || window.location.href}`); } function getHomeUrl() { return sessionStorage.getItem('epartner-home-url'); } function isProduction() { return PROFILE_NAME === 'production'; } function getProfileName() { return PROFILE_NAME; } function getUrlValue(value) { let hash = top.window.location.hash.split('?'); if (value != '' && hash != undefined) { let arr = hash[hash.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 replaceOrigin(str, oldV) { let origin = BASE_URL, newOrigin = ''; if (origin.indexOf('huawei.com') == -1) { newOrigin = `.huawei.${origin.substring(origin.lastIndexOf('.') + 1, origin.length)}`; } if (newOrigin != '') { let reg = new RegExp(`\\${oldV}`, 'gi'); return str.replace(reg, newOrigin); } return str; } function dialogDragging({ $dialog, $header, closeDialog }) { let baseLeft = 0; let baseTop = 0; return e => { const offsetX = e.clientX - $dialog.offsetLeft; const offsetY = e.clientY - $dialog.offsetTop; const width = $($dialog).width(); const height = $($dialog).height(); const isOutLeft = offsetX < -width / 2; const isOutRight = offsetX > width / 2; const isOuterTop = offsetY < -height / 2; const isOuterBottom = offsetY > height / 2; if (isOutLeft || isOutRight || isOuterTop || isOuterBottom) { closeDialog(); return; } const isOutHeader = offsetY > -height / 2 + $($header).outerHeight(); if (isOutHeader) { return; } if (baseLeft === 0) { baseLeft = $dialog.offsetLeft; baseTop = $dialog.offsetTop; } function dragDialog(ev) { let dragLeft = ev.clientX - offsetX; let dragTop = ev.clientY - offsetY; if (dragLeft < width / 2) { dragLeft = width / 2; } else if (dragLeft >= Math.floor(baseLeft * 2 - width / 2 - 1)) { dragLeft = Math.floor(baseLeft * 2 - width / 2 - 1); } if (dragTop < height / 2) { dragTop = height / 2; } else if (dragTop >= Math.floor(baseTop * 2 - height / 2 - 1)) { dragTop = Math.floor(baseTop * 2 - height / 2 - 1); } $dialog.style.left = dragLeft + 'px'; $dialog.style.top = dragTop + 'px'; } function stopDragging() { document.removeEventListener('mousemove', dragDialog); document.removeEventListener('mouseup', stopDragging); } document.addEventListener('mousemove', dragDialog); document.addEventListener('mouseup', stopDragging); }; } async function getMenusPrivilege() { return await new Promise(resolve => { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/control/getMenusPrivilege`, error: function (err) { resolve(err); }, success: function (res) { resolve(res); }, }); }); } function isIcsl() { return PROFILE_NAME === 'icsl'; } function cnPartnerI18n() { this.i18nConfig = { zh_CN: { pageTitle: '华为政企合作伙伴门户', }, en_US: { pageTitle: 'Huawei Partner for Global Enterprise Business', }, }; } cnPartnerI18n.prototype.init = function (key) { window.$t = key => { const lang = getCurrentLanguage(); const currentI18n = this.i18nConfig[lang]; if (!key) { return ''; } i18nKeyArray = key.toString().split('.'); let result = ''; let temp = JSON.parse(JSON.stringify(currentI18n)); i18nKeyArray.some(item => { if (temp[item]) { temp = temp[item]; } }); if (typeof temp === 'string') { return temp; } return key; }; }; function getLangFromPageUrl() { const url = window.location.href; let lang = ''; 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 = 'zh_CN'; } return lang; } function checkLanguage(isLoginType, isAssociatedType, countryName) { let url = window.location.href; let lang; let domainType = false; let hrefList = [ 'https://kwesit.huawei.com/eplusmeta/', 'https://kwesit.huawei.com/eplusmeta', 'https://kweuat.huawei.com/eplusmeta/', 'https://kweuat.huawei.com/eplusmeta', 'http://localhost.huawei.com:9051/', 'http://localhost.huawei.com:9051', 'https://partner.huawei.com/', 'https://partner.huawei.com', 'http://partner.huawei.com/', 'http://partner.huawei.com', ]; domainType = hrefList.includes(url); if (domainType) { lang = domainLanguageFn(isLoginType, isAssociatedType, countryName); } else { lang = getLangFromPageUrl(); } return lang; } function domainLanguageFn(isLoginType, isAssociatedType, countryName) { let curLang; if (isLoginType && isAssociatedType) { switch (countryName) { case 'China': curLang = 'zh_CN'; break; case 'Russia': curLang = 'ru_RU'; break; case 'Japan': curLang = 'ja_JP'; break; default: curLang = 'en_US'; break; } } else if (!isLoginType || (isLoginType && !isAssociatedType)) { let navLang = navigator.language || navigator.userLanguage; navLang = navLang.substr(0, 2); if (navLang === 'ru') { curLang = 'ru_RU'; } else if (navLang === 'ja') { curLang = 'ja_JP'; } else if (navLang === 'es') { curLang = 'es_MX'; } else if (navLang === 'pt') { curLang = 'pt_BR'; } else { curLang = navLang === 'zh' ? 'zh_CN' : 'en_US'; } } return curLang; } let env = 'beta'; if (isProduction()) { env = 'pro'; } const hwaAppConfig = { ABVersion: 'A', env, platform: 'web', appKeys: { beta: '2806bc73dadccef524ed5f58ff569881', pro: '07b478fa338f66d7fc00f4e86dfb41fb', }, }; (function (hw, wc, f, t) { const myDomain = window.location.origin.indexOf('huawei.cn') > -1 ? 'huawei.cn' : 'huawei.com'; try { if (!hw[t]) { hw.GlobalHwaNamespace = hw.GlobalHwaNamespace || []; hw.GlobalHwaNamespace.push(t); hw[t] = function () { (hw[t].q = hw[t].q || []).push(arguments); }; hw.trackerload = function () { (hw[t].q = hw[t].q && hw[t].q.length ? hw[t].q : []).unshift(arguments); }; hw[t].q = hw[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`; hw.hwahost = welinkHost; host = `${host}/fg/ProxyForDownLoad/hwa_f`; } hw.aids = f; hw.space = t; let ts = String(String(new Date().getFullYear()) + new Date().getMonth()) + new Date().getDate(); let script = wc.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 = wc.getElementsByTagName('head')[0].firstChild || wc.getElementsByTagName('head')[0].lastChild || wc.getElementsByTagName('script')[0]; if (where) { where.parentNode.insertBefore(script, where); } else { wc.getElementsByTagName('head')[0].appendChild(script); } } catch (e) { if (!hw[t]) { hw[t] = function () {}; } } })(window, document, hwaAppConfig, 'hwa'); 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 (err) { resolve(err); }, }); }); } function checkAssociated(userAccount) { const params = { userId: userAccount, }; return new Promise(resolve => { queryAssociatedStatus(params) .then(response => { let isAssociated = false; if (typeof response === 'string' && response !== '') { response = JSON.parse(response); } if (response.status === true) { isAssociated = true; } else { isAssociated = false; } resolve(isAssociated); }) .catch(() => { resolve(false); }); }); } 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(); window.hwa && window.hwa('trackPageView', 'P988021629E26D0', { sub_page: '首页-已登录' }); } else { await getUnLoginUserInfo(); window.hwa && window.hwa('trackPageView', 'P988021629E26D0', { sub_page: '首页-未登录' }); } new cnPartnerI18n().init(); document.title = $t('pageTitle'); new epartnerPageTopNav({ loginFlag: isLogin() }).init(); new epartnerPageMenuHorizontal({ loginFlag: isLogin() }).init(); showLoginInfo(); initLang(); new rightTools().initTools(); $('.header-lang-current .header-lang-label').html(constants.LANGUAGE_NAME[getCurrentLanguage()]); 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 menuHead({ loginFlag: isLogin(), isAssociatedType: isAssociatedCompany(), isHW: isHW() }).init(); new downloadCnEApp().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 protocolWebsite().init(); new autoRenewal({ loginFlag: isLogin() }).init(); new renewalNotice({ userInfo: userInfo }).init(); new infoSigned({ userInfo: userInfo }).init(); new uncertified({ isHW: isHW() }).init(); const isAssociatedType = (await checkAssociated(userInfo.userAccount)) || false; sessionStorage.setItem('epartner-is-associated', isAssociatedType); const accountInfo = (await findAccountRoleFn(userInfo.userAccount)) || ''; const currentLang = checkLanguage(true, isAssociatedType, accountInfo.countryName); sessionStorage.setItem('epartner-current-language', currentLang); if (isAssociatedType) { $('.header-lang').remove(); } $('.login-user-info .item-container').css('borderLeft', 'none'); initLogout(); initMyTodo(); const workspaceFlagRes = await queryWorkspaceFlag(); if (workspaceFlagRes.value !== '1') { $('.header-user-list #myHuawei').remove(); $('.header-user-list #workspace').remove(); $('.header-user-list #logout').css('border', 'none'); $('.header-user-list #logout').css('paddingTop', '0'); } else if (!isAssociatedType) { $('.header-user-list #myHuawei').remove(); } if (workspaceFlagRes.value === '1' && isAssociatedType) { createGoMyWorkspaceElement(); } } } function logOut() { const curOrigin = BASE_URL.split('://')[1]; const logoutOrigin = isIcsl() ? constants.uipmIcslOrigin : curOrigin; const delCookieUrl = `https://${logoutOrigin}/uipmgateway/app_000000035487:uipmfront/uipm/servlet/logout?redirect=https://${curOrigin}/eplusmeta/cn/china`; const logoutCookieIframe = ``; $('.epartner-tenant-header-topnav').append(logoutCookieIframe); setTimeout(() => { localStorage.removeItem('x-csrf-token'); const logoutUrl = replaceOrigin(getLogoOutUrl(), '.huawei.com'); window.location.href = logoutUrl; }); } function initLogout() { $('#epartnerPageMenu').on('click', '#workspace', function () { gotoWorkSpace(); }); $('#epartnerPageMenu').on('click', '.log-out', function () { logOut(); }); $('#epartnerPageMenu').on('click', '#myHuawei', function () { gotoMyHuawei(); }); } async function gotoMyHuawei() { let isNewStyle = sessionStorage.getItem('ePartnerCnNewStyle'); if (isNewStyle === null || isNewStyle === undefined) { const newMenu = await getMenusPrivilege(); isNewStyle = newMenu.newStyle; sessionStorage.setItem('ePartnerCnNewStyle', isNewStyle); } const newMenu = await getMenusPrivilege(); if (isNewStyle) { window.open(`${BASE_URL}/eplus/#/cn/group/my-permission-new`); } else { window.open(`${BASE_URL}/eplus/#/cn/group/my-huawei-cn`); } } async function gotoWorkSpace() { let hrefLink = `${BASE_URL}/eplus/#/cn/group/login-page`; let isNewStyle = sessionStorage.getItem('ePartnerCnNewStyle'); if (isNewStyle === null || isNewStyle === undefined) { const newMenu = await getMenusPrivilege(); isNewStyle = newMenu.newStyle; sessionStorage.setItem('ePartnerCnNewStyle', isNewStyle); } const newMenu = await getMenusPrivilege(); if (!newMenu.newStyle && newMenu.switchFlag) { hrefLink = `${hrefLink}?isToggleChange=true`; } window.open(hrefLink); } function initLang() { $('.header-lang').on('click', '.lang-select-item', function (e) { const currentLang = e.currentTarget.dataset.lang; $('.header-lang-list').css('display', 'none'); if (currentLang === getCurrentLanguage()) { return; } sessionStorage.setItem('epartner-current-language', currentLang); $('.header-lang-list .lang-select-item').removeClass('active'); $(e.currentTarget).addClass('active'); $('.header-lang-current .header-lang-label').html(constants.LANGUAGE_NAME[currentLang]); const link = isHomeLink(currentLang); 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 myTodoCount = 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 () { window.hwa && window.hwa('trackPageView', 'P106112FFAA5B58D'); 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(myTodoCount); if (myTodoCount > 0) { $('.my-todo-name').attr('title', '您有新的待办任务,请及时查看处理'); } } } function isHomeLink(lang) { const linkType = 'web'; const href = location.href; if ((href.indexOf('/cn/') > -1 && !lang) || lang === constants.LANGUAGE.ZH_CN) { return `${HOME_BASE_URL}/cn/web/china.html`; } if ((href.indexOf('/en/') > -1 && !lang) || lang === constants.LANGUAGE.EN_US) { return `${HOME_BASE_URL}/en/web/worldwide.html`; } return isOtherHomeLink(lang, href, linkType); } function isOtherHomeLink(lang, href, linkType) { if ((href.indexOf('/ru/') > -1 && !lang) || lang === constants.LANGUAGE.RU_RU) { return `${BASE_URL + constants.CONTEXT_ROOT}/#/ru/${linkType}/worldwide`; } if ((href.indexOf('/pt/') > -1 && !lang) || lang === constants.LANGUAGE.PT_BR) { return `${BASE_URL + constants.CONTEXT_ROOT}/#/pt/${linkType}/worldwide`; } if ((href.indexOf('/es/') > -1 && !lang) || lang === constants.LANGUAGE.EN_US) { return `${BASE_URL + constants.CONTEXT_ROOT}/#/es/${linkType}/worldwide`; } else { return `${BASE_URL + constants.CONTEXT_ROOT}/#/jp/${linkType}/worldwide`; } } function getUserInfo() { return new Promise((resolve, reject) => { $.ajax({ dataType: 'json', type: 'GET', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/jalor/web/support/workspace/current?_t=${new Date().getTime()}`, error: function (e) { resolve(e); }, success: function (res) { resolve(res); }, }); }); } async function getToDoNum() { const currentLang = getCurrentLanguage(); const lang = [constants.LANGUAGE.ZH_CN, constants.LANGUAGE.RU_RU, constants.LANGUAGE.JA_JP].includes(currentLang) ? currentLang : constants.LANGUAGE.EN_US; let params = { todoUser: getCurrentUserInfo().userAccount, language: lang, status: 1, }; return new Promise(resolve => { $.ajax({ type: 'GET', dataType: 'json', success: function (res) { if (res && res.result) { resolve(res.result); } else { resolve(0); } }, url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/todoList/queryTodoRecords?todoUser=${params.todoUser}&language=${params.language}&status=${params.status}`, 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}`, error: function (err) { resolve(err.responseJSON); }, success: function (res) { resolve(res); }, }); }); } function handlerHwAccount(userAccount) { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/public/purl/handlerHwAccount/${userAccount}`, }); } function showLoginInfo() { const userContainerDom = $('.login-status-container'); 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); $('.item-current-user .login-user-info .user-prefix').html(userInfo.userAccount && userInfo.userAccount.split('')[0]); } else { loginDom.css('display', 'none'); userContainerDom.removeClass('already-login'); unLoginDom.css('display', 'flex'); } } 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`, error: function (err) { resolve(err.responseJSON); }, success: function (res) { resolve(res); }, }); }); } function createGoMyWorkspaceElement() { const btnDev = document.createElement('div'); btnDev.title = '跳转到我的工作台'; btnDev.className = 'workspace'; const icon = document.createElement('div'); icon.className = 'icon'; btnDev.append(icon); btnDev.addEventListener('click', async function () { let herfLink = `${BASE_URL}/eplus/#/cn/group/login-page`; const newMenu = await getMenusPrivilege(); if (!newMenu.newStyle && newMenu.switchFlag) { herfLink = `${herfLink}?isToggleChange=true`; } window.open(herfLink); }); $('#epartnerPageMenu .epartner-home-menu-row-size').append(btnDev); } function loginView(url, flag) { const origin = window.location.origin; const newOriginPrefix = origin.substring(origin.lastIndexOf('.') + 1, origin.length); if (flag) { return url.replace(/{origin}/gi, newOriginPrefix); } const loginPath = '{wcm_login_url}'; return `${loginPath.replace(/com/gi, newOriginPrefix)}?redirect=${url}`; } function skipToRegisterPage() { const lang = getCurrentLanguage() || 'en_US'; let url = ''; if (window.location.origin.indexOf('localhost.huawei.com') > -1 || window.location.origin.indexOf('//partner.huawei') == -1) { url = `https://uniportal-beta.huawei.com/accounts1/register-pc.html?redirect=${window.location.origin}#/cn/group/login-page&msg=1&v=V0.1&lang=`; } else { url = `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(`${url}${lang}`, true); } function initHeaderRightUserClickEvent() { const userContainerDom = $('.item-current-user'); userContainerDom.on('click', '.unLogin-user-info', function () { goUniPortalLogin(getHomeUrl()); }); } function initRegisterClickEvent() { $('.login-status-container').on('click', '.register', function () { skipToRegisterPage(); }); } function rightTools() { this.toolsBarObject = { flags: false, position: { x: 0, y: 0 }, dx: '', dy: '', nx: '', ny: '', isShowList: 0, isFaq: false, searchData: {}, allSidebarList: [], judgeDragOffset: 2, businessList: [], xPum: '', yPum: '', isIHepShunt: false, sidebarList: [], sidebarSubList: [], isAssociated: false, }; } rightTools.prototype.toolsBarMouseDown = function (event) { const targetDom = $('.partner-drag-drop-tools'); if (!targetDom) { return; } this.setOffsetLocal(); $('.floatBar-bottom-demo').css('display', 'none'); const targetWindow = window.getComputedStyle(targetDom[0], null); const prefixX = event.clientX - parseFloat(targetWindow.left); const prefixY = event.clientY - parseFloat(targetWindow.top); let clientWidth = 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 > clientWidth) { return false; } $('.floatBar-bottom-demo').css('display', 'block'); const curLeft = moveEvent.clientX - prefixX; const curTop = moveEvent.clientY - prefixY; targetDom[0].style.left = `${curLeft}px`; targetDom[0].style.top = `${curTop}px`; targetDom[0].style.right = 'unset'; }; }; rightTools.prototype.toolsBarMouseUp = function () { document.onmousemove = null; }; rightTools.prototype.toolsBarTouchStart = function (event) { const targetDom = $('.partner-drag-drop-tools'); if (!targetDom) { return; } document.body.onselectstart = () => { return false; }; document.body.onselect = () => { return false; }; this.toolsBarObject.flags = false; let touch; if (event.touches) { touch = event.touches[0]; } else { touch = (event.originalEvent && event.originalEvent.touches[0]) || event; } this.toolsBarObject.position.x = touch.clientX; this.toolsBarObject.position.y = touch.clientY; this.toolsBarObject.dx = targetDom[0].offsetLeft; this.toolsBarObject.dy = targetDom[0].offsetTop; }; rightTools.prototype.toolsBarTouchMove = function (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; } this.toolsBarObject.flags = true; this.toolsBarObject.nx = touch.clientX - this.toolsBarObject.position.x; this.toolsBarObject.ny = touch.clientY - this.toolsBarObject.position.y; this.toolsBarObject.xPum = this.toolsBarObject.dx + this.toolsBarObject.nx; this.toolsBarObject.yPum = this.toolsBarObject.dy + this.toolsBarObject.ny; let width = window.innerWidth - target[0].offsetWidth; let height = window.innerHeight - target[0].offsetHeight; this.toolsBarObject.xPum < 0 && (this.toolsBarObject.xPum = 0); this.toolsBarObject.yPum < 0 && (this.toolsBarObject.yPum = 0); this.toolsBarObject.xPum > width && (this.toolsBarObject.xPum = width); this.toolsBarObject.yPum > height && (this.toolsBarObject.yPum = height); target[0].style.left = `${this.toolsBarObject.xPum}px`; target[0].style.top = `${this.toolsBarObject.yPum}px`; target[0].style.right = 'unset'; }; rightTools.prototype.toolsBarTouchEnd = function (event) { this.toolsBarObject.flags = false; $('.floatBar-bottom-demo').css('display', 'none'); }; rightTools.prototype.showHelp = function () { this.turnPageLookUp(this.toolsBarObject.sidebarList[0].linkUrl); }; rightTools.prototype.openBusiness = function () { this.toolsBarObject.isShowList = 2; this.showBusinessList(); this.toolsBarObject.showBusiness = true; $('#business-list-help-container').addClass('more-width'); $('.i-help-shunt').css('display', 'none'); }; rightTools.prototype.closeBusiness = function () { $('#business-list-help-container').removeClass('more-width'); $('#business-list-help-container').css('display', 'none'); }; rightTools.prototype.initToolsEvent = function () { $(document).on('touchstart', '.partner-drag-drop-tools', e => { this.toolsBarTouchStart(e); }); $(document).on('touchmove', '.partner-drag-drop-tools', e => { this.toolsBarTouchMove(e); }); $(document).on('touchend', '.partner-drag-drop-tools', e => { this.toolsBarTouchEnd(e); }); $(document).on('mousedown', '.partner-drag-drop-tools', e => { this.toolsBarMouseDown(e); }); $(document).on('mouseup', '.partner-drag-drop-tools', e => { this.toolsBarMouseUp(e); }); $('.partner-drag-drop-tools').on('click', '.partner-it-help-icon', e => { this.showHelp(e); }); $('.partner-drag-drop-tools').on('click', '.cn-business-entry', e => { this.openBusiness(e); }); $('.partner-drag-drop-tools #business-list-help-container').on('click', '.common-close', e => { this.closeBusiness(e); }); $('.partner-drag-drop-tools #business-list-help-container').on('click', '.get-email-btn', e => { this.getAccountEmailApi(e.target.dataset.id); }); document.addEventListener('mouseup', e => { const itBusinessContainer = document.getElementById('it-business-help-container'); if (itBusinessContainer) { if (!itBusinessContainer.contains(e.target)) { this.toolsBarObject.isFaq = false; this.toolsBarObject.isShowList = 0; itBusinessContainer.style.display = 'none'; } } let list = document.getElementById('business-list-help-container'); if (list) { if (!list.contains(e.target)) { this.toolsBarObject.isFaq = false; this.toolsBarObject.isShowList = 0; list.style.display = 'none'; } } }); }; rightTools.prototype.setOffsetLocal = function () { const toolsDom = document.getElementById('partner-drag-drop-tools'); sessionStorage['ePartnerToolsPosition'] = JSON.stringify({ curTop: toolsDom.offsetTop, curLeft: toolsDom.offsetLeft }); }; rightTools.prototype.isToolsDrag = function (curTop, curLeft) { const container = document.getElementById('partner-drag-drop-tools'); return ( curTop !== undefined && !( Math.abs(curLeft - container.offsetLeft) < this.toolsBarObject.judgeDragOffset && Math.abs(curTop - container.offsetTop) < this.toolsBarObject.judgeDragOffset ) ); }; rightTools.prototype.isHomeOrWorkView = function () { const href = window.location.href; const viewsCn = ['/cn-cp', '/china', '/cn-csp', '/saleswork', '/salespartnerworkspace', '/solutionpartnerworkspace']; viewsCn.forEach(item => { if (href.indexOf(item) > -1 && href.indexOf('/cn/') > -1) { this.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) { this.toolsBarObject.isIHepShunt = true; } }); return this.toolsBarObject.isIHepShunt; }; rightTools.prototype.getOnlineSupportTree = function (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 (err) { resolve(err); }, }); }); }; rightTools.prototype.getOnLineList = async function () { let res = await this.getOnlineSupportTree(1); if (!res) { return; } let onlineHtml = ''; res.children.forEach(item => { onlineHtml += `
${item.name} `; onlineHtml += '
'; onlineHtml += '
'; }); onlineHtml += ``; $('#online-support-tree').html(onlineHtml); }; rightTools.prototype.initTools = function () { this.initToolsEvent(); this.findHelpSidebarList(); if (isLogin()) { this.getOnLineList(); } else { $('.partner-drag-drop-tools').addClass('partner-mobile-tools'); } }; rightTools.prototype.getFAQAndInstructionInfo = function (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 (err) { resolve(err); }, }); }); }; rightTools.prototype.findBusinessContactList = function () { return new Promise(resolve => { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/contact/findBusinessContactList`, success: function (res) { resolve(res); }, error: function (err) { resolve(err); }, }); }); }; rightTools.prototype.getAccountEmailApi = function (rowId) { if (!rowId) { return; } return new Promise((resolve, reject) => { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/contact/getAccountEmail/${rowId}`, success: function (res) { if (res && res.content) { $(`.email-${rowId}`).html(`${res.content}`); } }, }); }); }; rightTools.prototype.initHelp = function () { return new Promise(resolve => { $.ajax({ type: 'get', dataType: 'json', url: `${BASE_URL}${constants.COMMON_SERVICE}/jalor/lookup/item/list/iHelp_config/page/new/100/1`, success: function (res) { resolve(res); }, error: function (err) { resolve(err); }, }); }); }; rightTools.prototype.turnPageByLookUp = function (url) { const myUrl = url.split('?')[0]; let myAppId = ''; this.initHelp().then(data => { myAppId = this.getAppId(data); setTimeout(() => { if (myAppId != '') { window.open(`${myUrl}?appId=${myAppId}&page_category=`); } else { window.open(url); } }, 300); }); }; rightTools.prototype.getAppId = function (res) { let myAppId = ''; if (!res || !res.result || res.result.length <= 1) { return myAppId; } res.result.forEach(v => { if (window.location.href.indexOf(v.itemName) > -1) { myAppId = v.itemAttr1; } }); return myAppId; }; rightTools.prototype.openHelpByCondition = function (url) { if (url.indexOf('index.do?appId') > 1) { this.turnPageLookUp(url); } else { window.open(url); } }; rightTools.prototype.showBusinessList = function () { $('#business-list-help-container').css('display', 'inline-block'); let businessHtml = `业务接口人清单
`; businessHtml += ''; businessHtml += ''; businessHtml += ''; this.toolsBarObject.businessList.forEach(item => { businessHtml += ''; businessHtml += `${this.enCodeHtml(item.moduleName)} | `; businessHtml += `${this.enCodeHtml(item.contact)} | `; businessHtml += ` | `; businessHtml += '
'; }); businessHtml += ''; businessHtml += '
'; $('#business-list-help-container').html(businessHtml); }; rightTools.prototype.enCodeHtml = function (htmlString) { return htmlString.replace(/[&<>"']/g, match => { const escapeMap = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }; return escapeMap[match]; }); }; rightTools.prototype.getAssociatedDoc = function () { this.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 req1 = this.getFAQAndInstructionInfo(params); const req2 = this.findBusinessContactList(); let httpArr = [req1, req2]; if (getCurrentLanguage() != constants.LANGUAGE.ZH_CN) { httpArr = [p1]; } Promise.all(httpArr) .then(res => { this.parseAssociatedDoc(res); }) .catch(() => { this.turnPageByLookUp(this.toolsBarObject.sidebarList[0].linkUrl); }); }; rightTools.prototype.parseAssociatedDoc = function (res) { if (getCurrentLanguage() === constants.LANGUAGE.ZH_CN) { if (res[1] && res[1].length) { res[1].forEach((item, index) => { item.email = ''; item.emailName = '点击获取邮箱'; item.itemIndex = index; }); this.toolsBarObject.businessList = res[1]; } } if (!res[0]) { this.turnPageByLookUp(this.toolsBarObject.sidebarList[0].linkUrl); return; } if (res[0].faqList.length == 0 && res[0].instructionInfoList.length == 0) { this.toolsBarObject.isFaq = true; if (this.isHomeOrWorkView()) { this.toolsBarObject.isShowList = 0; $('.i-help-shunt').css('display', 'block'); $('.i-help-shunt').on('click', '.common-close', function (e) { $('.i-help-shunt').css('display', 'none'); }); return; } if (!isChina()) { this.turnPageByLookUp(this.toolsBarObject.sidebarList[0].linkUrl); return; } this.toolsBarObject.isShowList = 1; $('#it-business-help-container').addClass('help_container_list'); $('#it-business-help-container').html('IT在线帮助
业务接口人
'); return; } this.toolsBarObject.isFaq = true; this.toolsBarObject.isShowList = 2; this.showBusinessList(); this.toolsBarObject.showBusiness = false; $('#business-list-help-container').removeClass('more-width'); this.toolsBarObject.searchData = res[0].data; }; rightTools.prototype.iHelpClick = function (e) { window.hwa && window.hwa('trackPageView', 'P988021629E26D0', { sub_page: '模板-侧边栏' }); let { curTop, curLeft } = sessionStorage['ePartnerToolsPosition'] ? JSON.parse(sessionStorage['ePartnerToolsPosition']) : {}; if (this.isToolsDrag(curTop, curLeft)) { return; } const index = e.currentTarget.dataset?.index; const obj = this.toolsBarObject.sidebarList[index]; if (!obj) { return; } if (index.toString() === '0' && isLogin() && (isAssociatedCompany() || isHW())) { this.getAssociatedDoc(); return; } if (obj.uemPageCode) { window.hwa && window.hwa('trackPageView', obj.uemPageCode); } if (obj.linkUrl) { if (obj.linkUrl) if (obj.linkUrl.indexOf('pvmvc#/create-task') > -1) { window.location.href = obj.linkUrl; } else { window.open(obj.linkUrl); } } else { this.toolsBarObject.sidebarList.map((item, i) => { if (i === index) { obj.flag = true; } else { obj.flag = false; } return item; }); this.initIHelpHtml(); } }; rightTools.prototype.changeStyle = function (e) { const index = e.currentTarget.dataset?.index; const obj = this.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('.bar-item-container img').prop('src', obj.hoverImagePath); } } else { $(e.currentTarget).removeClass('float-bar__list__li_color'); $(e.currentTarget).find('.bar-item-container img').prop('src', obj.defaultImagePath); } this.toolsBarObject.sidebarList[index].flag = !this.toolsBarObject.sidebarList[index].flag; }; rightTools.prototype.initIHelpHtml = function () { let html = ''; this.toolsBarObject.sidebarList.forEach((item, index) => { html += ``; html += ''; html += `

`; html += `
${item.buttonName}
`; html += '
'; if (item.qrCodeImage) { html += `'; } html += ''; }); $('.partner-drag-drop-tools .ihelp-list').html(html); }; rightTools.prototype.setHelpData = function (response) { const maxShowSize = 5; const defaultShowSize = 3; if (!response.length && isLogin()) { $('.float-bar__list').remove(); } if (!isAssociatedCompany() && !isHW() && isLogin()) { const notAssociateList = response.filter(item => { return item.buttonName === 'Guide' || item.buttonName === '帮助'; }); this.toolsBarObject.sidebarSubList = notAssociateList; $('.exp').css('display', 'none'); } else if (response.length > maxShowSize) { $('.exp').css('display', 'block'); this.toolsBarObject.sidebarSubList = response.slice(0, defaultShowSize); $('.exp').off('click'); $('.partner-drag-drop-tools .ihelp-list').removeClass('no-last-border'); $('.exp').on('click', () => { if ($('.float-bar__list').hasClass('float-bar__list-show')) { $('.float-bar').removeClass('float-bar_all'); $('.float-bar__list').removeClass('float-bar__list-show'); this.toolsBarObject.sidebarList = this.toolsBarObject.sidebarSubList; $('.exp').removeClass('translate'); } else { this.toolsBarObject.sidebarList = this.toolsBarObject.allSidebarList; $('.float-bar').addClass('float-bar_all'); $('.float-bar__list').addClass('float-bar__list-show'); $('.exp').addClass('translate'); } this.initIHelpHtml(); }); } else { this.toolsBarObject.sidebarSubList = response; $('.partner-drag-drop-tools .ihelp-list').addClass('no-last-border'); $('.exp').css('display', 'none'); } this.toolsBarObject.sidebarList = this.toolsBarObject.sidebarSubList; this.toolsBarObject.allSidebarList = response; this.initIHelpHtml(); $('.partner-drag-drop-tools .ihelp-list').on('click', '.float-bar__list__li', e => { this.iHelpClick(e); }); $('.partner-drag-drop-tools .ihelp-list').on('mouseover', '.float-bar__list__li', e => { this.changeStyle(e); }); $('.partner-drag-drop-tools .ihelp-list').on('mouseout', '.float-bar__list__li', e => { this.changeStyle(e); }); }; rightTools.prototype.getHelp = function (website) { const origin = window.location.origin; const com = origin.substring(origin.lastIndexOf('.') + 1, origin.length); const data = { buttonName: '支持', defaultImagePath: IS_DEVELOPMENT ? 'https://kwesit.huawei.com/partnercloud/epartner/assets/image/support.png' : `${getS3BaseUrl()}/image/support.png`, hoverImagePath: IS_DEVELOPMENT ? 'https://kwesit.huawei.com/partnercloud/epartner/assets/image/support.png' : `${getS3BaseUrl()}/image/support.png`, linkUrl: `https://app.huawei.${com}/ihelp/icsclientC60/index.do?appId=M000735&page_category=`, }; return data; }; rightTools.prototype.findHelpSidebarList = function () { const website = 1; $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/pub/public/findHelpSidebarList?website=${website}&sidebarVersion=V2`, success: res => { const dataList = res || []; if (isLogin()) { dataList.unshift(this.getHelp(website)); } if (dataList.length == 0) { $('.partner-drag-drop-tools').css('display', 'none'); } else { $('.partner-drag-drop-tools').css('display', 'block'); } this.setHelpData(dataList); }, error: () => { this.setHelpData([this.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: '企业业务网站', 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; const newMenuBtnMap = { 产品与解决方案: [ { label: '查看全部产品和解决方案', url: 'https://e.huawei.com/cn/products-and-solutions', icon: '#iconDown svg', iconClass: 'rotate--90 icon-red' }, { label: '资料中心', url: 'https://e.huawei.com/cn/resource/material-center', icon: '#iconForwarding svg', iconClass: 'scale-80' }, ], 学习与技术支持: [ { label: '技术支持首页', url: 'https://support.huawei.com/enterprise/zh/index.html', icon: '#iconForwarding svg', iconClass: 'scale-80' }, { label: '互动社区', url: 'https://forum.huawei.com/enterprise/cn/zh/index.html', icon: '#iconForwarding svg', iconClass: 'scale-80' }, ], 合作伙伴: [{ label: '合作伙伴首页', url: 'https://partner.huawei.com/eplusweb/#/cn/web/china', icon: '#iconForwarding svg', iconClass: 'scale-80' }], }; 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).parent().append(''); 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.zh_CN, target: '_blank', class: 'menu-title', }); $linkHead.innerHTML = `${item.text.zh_CN}`; $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.zh_CN, target: '_blank', class: 'menu-comment', }); $linkContent.innerText = item.subText.zh_CN; $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'); $('.partner-top-cookie-close-btn').on('click', function () { let date = new Date(); date.setTime(date.getTime() + 30 * 24 * 60 * 60 * 1000); document.cookie = `read_policy_noru=1;path=/;expires=${date.toGMTString()}`; $('.partner-top-cookie').fadeOut(); }); $('.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}`); $('#epartnerMobileQuickMenuTitle').on('click', () => { $('#epartnerMobileQuickMenuTitle').toggleClass('active'); $('#epartnerMobileQuickMenu').toggle(); $('#epartnerMobileLangMenuTitle').removeClass('active'); $('#epartnerMobileLangMenu').hide(); if ($('#epartnerMobileQuickMenuTitle').hasClass('active') || $('#epartnerMobileLangMenuTitle').hasClass('active')) { $('.epartner-m-menu-header').addClass('border-none'); } else { $('.epartner-m-menu-header').removeClass('border-none'); } }); 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.zh_CN, target: '_blank', class: 'menu-title', }); const $menuHead = document.createElement('div'); $menuHead.className = 'menu-header'; $menuHead.innerHTML = `${item.text.zh_CN}`; $item.append($menuHead); const $menuContent = document.createElement('div'); $menuContent.className = 'menu-row'; $menuContent.innerText = item.subText.zh_CN; $item.append($menuContent); $quickMenu.append($item); } const $ul = document.createElement('ul'); const langList = this.data.topnav.language; const $checkedLi = document.createElement('li'); $checkedLi.className = 'checked-li'; for (let i = 0; i < langList.length; i++) { const $li = document.createElement('li'); const langItem = langList[i]; $($li).attr({ 'data-lang': langItem.language, }); $li.innerText = langItem.text; if (langItem.language === getCurrentLanguage()) { $checkedLi.innerHTML = `🌐︎${langItem.text}`; } $ul.append($li); $ul.prepend($checkedLi); } $langMenu.append($ul); $('.company-close').on('click', () => { $('#epartnerMobileQuickMenuTitle').toggleClass('active'); $('#epartnerMobileQuickMenu').toggle(); $('#epartnerMobileLangMenu').hide(); $('#epartnerMobileLangMenuTitle').removeClass('active'); if ($('#epartnerMobileQuickMenuTitle').hasClass('active') || $('#epartnerMobileLangMenuTitle').hasClass('active')) { $('.epartner-m-menu-header').addClass('border-none'); } else { $('.epartner-m-menu-header').removeClass('border-none'); } }); $('.lang-close').on('click', () => { this.menuSwitch(); }); $('#epartnerMobileLangMenuTitle').on('click', () => { this.menuSwitch(); }); $('#epartnerMobileLangMenu').on('click', 'li', e => { const currentLang = $(e.target).closest('li').data('lang'); 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) { if (isAssociated) { privilegeRes = await getMenusPrivilege(); if (privilegeRes.newStyle) { this.newStyle = true; sessionStorage.setItem('ePartnerCnNewStyle', true); res = await this.findOfficialWebsiteList(); } else { res = await this.getMenuListByAuth(); } } else { res = await this.getCMSPublicMenu(); } } else if (isChina()) { this.newStyle = true; res = await this.findOfficialWebsiteList(); } else { res = await this.getCMSPublicMenu(); } if (this.newStyle) { this.loadNewMenu(res); } else { this.getResData(res); this.loadMenu(res); } }; epartnerPageMenuHorizontal.prototype.loadMenu = function (res) { const $quickMenu = $('#epartnerMobileQuickMenu'); const $quickMenuSadow = document.createElement('div'); $quickMenuSadow.className = 'quickMenu-sadow'; $('#epartnerMobileQuickMenu > .epartner-m-menu-header:first-child').after($quickMenuSadow); $('#epartnerMobileLangMenu').addClass('lang-background'); this.data = res.menuData; new epartnerPageMenuVertical({ loginFlag: this.loginFlag, data: this.data, 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.loadNewMenu = function (res) { this.data = res.menuDataList; new epartnerPageMenuVertical({ loginFlag: this.loginFlag, data: res.menuDataList, newStyle: this.newStyle, }).init(); this.createLevel1NewMenu(); this.createMobileNewMenu({ children: this.data }); this.createNewMobileEvents(); this.replaceHowToBuyIcon(); res.luBanlogoOutURL && sessionStorage.setItem('epartner-logout-url', res.luBanlogoOutURL); res.luBanHomeURL && sessionStorage.setItem('epartner-home-url', res.luBanHomeURL); this.createEvents(); }; epartnerPageMenuHorizontal.prototype.replaceHowToBuyIcon = function (res) { const $wrapper = $('.icon-wrapper'); const $iconRight = this.cloneNodeByTemplate('#iconDown svg'); $wrapper.append($iconRight); const $wrapperRed = $('.icon-wrapper-red'); const $iconRightRed = this.cloneNodeByTemplate('#iconDown svg', 'icon-red rotate-270'); $wrapperRed.append($iconRightRed); const $shoppingWrapper = $('.LiveChat'); const $iconShopping = this.cloneNodeByTemplate('#iconShoppingCart svg'); $shoppingWrapper.append($iconShopping); }; epartnerPageMenuHorizontal.prototype.createNewMobileEvents = function (res) { $('#epartnerHomeNewMenuHowBuy .four a').on('click', event => { buriedCode(); }); const $content = $('#epartnerMobileMenuContent'); this.$container.on('click', '.epartner-home-menu-mobile', () => { $('#epartnerMobileMenu').show(); $('.icon-yewu').on('click', () => { $('#epartnerMobileQuickMenuTitle').toggleClass('active'); $('#epartnerMobileQuickMenu').toggle(); $('#epartnerMobileLangMenu').hide(); $('#epartnerMobileLangMenuTitle').removeClass('active'); if ($('#epartnerMobileQuickMenuTitle').hasClass('active') || $('#epartnerMobileLangMenuTitle').hasClass('active')) { $('.epartner-m-menu-header').addClass('border-none'); } else { $('.epartner-m-menu-header').removeClass('border-none'); } }); $('.icon-diqiu2').on('click', () => { $('#epartnerMobileLangMenuTitle').toggleClass('active'); $('#epartnerMobileLangMenu').toggle(); $('#epartnerMobileQuickMenuTitle').removeClass('active'); $('#epartnerMobileQuickMenu').hide(); if ($('#epartnerMobileQuickMenuTitle').hasClass('active') || $('#epartnerMobileLangMenuTitle').hasClass('active')) { $('.epartner-m-menu-header').addClass('border-none'); } else { $('.epartner-m-menu-header').removeClass('border-none'); } }); $('.person-logIn').on('click', () => { goUniPortalLogin(getHomeUrl()); }); $('.person-logOut').on('click', () => { logOut(); }); $('.epartner-m-new-menu-level2-page a').on('click', () => { buriedCode(); }); }); }; epartnerPageMenuHorizontal.prototype.getMenusPrivilege = async function () { const res = await 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); }, }); }); if (res.newStyle) { this.newStyle = true; return await this.findOfficialWebsiteList(); } else { return await this.getMenuListByAuth(); } }; 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.findOfficialWebsiteList = function () { return new Promise(resolve => { $.get( `${BASE_URL}${constants.E_PARTNER_SERVICE}/public/official/findOfficialWebsiteList?languageId=${this.language}&description=${ LANG_DESC[this.language] }`, {}, res => { menuDataReplaceUrl(res); resolve(res); } ); }); }; epartnerPageMenuHorizontal.prototype.parseV2MenuList = function (res) { if (res.horizontalMenuList && res.horizontalMenuList.length > 0) { res.menuData = res.horizontalMenuList; res.menuData.forEach(item1 => { item1.levelOne = true; item1.children = item1.items; setMenuData(item1); }); } if (res.verticalMenuList && res.verticalMenuList.length > 0) { res.verticalMenuList.forEach(item1 => { item1.levelOne = true; item1.children = item1.items; setMenuData(item1); }); } if (res.menuDataList && res.menuDataList.length > 0) { res.menuData = res.menuDataList; res.menuData.forEach(item1 => { item1.levelOne = true; item1.items = item1.children; 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]; 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; level1Data.items && level1Data.items.length && 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); } $level3.onclick = () => openMenuPage(item, this.loginFlag, this.newStyle); level3List.push($level3); } return level3List; }; epartnerPageMenuHorizontal.prototype.newMenuIsPanelStyle = function (level1Data) { return level1Data?.children?.some(v => v.children?.length); }; epartnerPageMenuHorizontal.prototype.newMenuMoreBtn = function (name) { const btns = newMenuBtnMap[name]; if (!btns) return null; const $btnWrapper = document.createElement('div'); $btnWrapper.className = 'epartner-home-new-menu-more-btn-wrapper'; for (let i = 0; i < btns.length; i++) { const item = btns[i]; const $btn = document.createElement('div'); $btn.className = 'btn'; const $link = document.createElement('a'); $link.setAttribute('href', item.url); $link.setAttribute('target', '_blank'); const $text = document.createElement('span'); $text.innerText = item.label; const $icon = this.cloneNodeByTemplate(item.icon, `${item.iconClass} icon-red`); $link.append($text); $link.append($icon); $btn.append($link); $btnWrapper.append($btn); } return $btnWrapper; }; epartnerPageMenuHorizontal.prototype.createLevel1NewMenu = function () { $('.e-cistern-buy .level-one-li').on('click', e => { $(e.currentTarget).find('svg').toggleClass('rotate-180'); $(e.currentTarget).siblings().find('.wap-item-list2').removeClass('showDom'); $(e.currentTarget).find('.wap-item-list2').toggleClass('showDom'); }); $('.e-cistern-buy .e-link-box').on('click', e => { e.stopPropagation(); }); const $level1List = document.createElement('div'); $level1List.className = 'epartner-home-new-menu flex-x-center'; const $level2Wrapper = document.createElement('div'); $level2Wrapper.className = 'epartner-home-new-menu-level1-wrapper'; for (let i = 0; i < this.data.length; i++) { const item = this.data[i]; const $level1 = document.createElement('div'); $level1.className = `epartner-home-new-menu-level1 hand-cursor`; const $a = document.createElement('a'); $a.className = 'epartner-home-new-menu-level1-link'; $a.innerText = item.title; if (item.link) { $($a).attr({ href: item.link, target: item.targetBlank ? '_blank' : '_self', }); } if (item.name === '如何购买') { $level1.append($a); const $howBuy = document.getElementById('epartnerHomeNewMenuHowBuy'); $level1List.append($level1); $level2Wrapper.append($howBuy); continue; } $level1.append($a); $level2Wrapper.append(this.createNewLevel2Menu(item)); $level1List.append($level1); } const $level2Mask = document.createElement('div'); $level2Mask.className = 'epartner-home-new-menu-level1-mask'; $('#epartnerPageMenuNav').append($level2Wrapper); $('#epartnerPageMenuNav').append($level2Mask); $('#epartnerPageMenuNav').append($level1List); }; epartnerPageMenuHorizontal.prototype.createNewLevel2Menu = function (level1Data) { const $level2Content = document.createElement('div'); $level2Content.className = 'epartner-home-new-menu-level1-content'; $level2List = document.createElement('div'); $level2List.className = 'epartner-home-new-menu-level1-list'; for (let i = 0; level1Data.children && level1Data.children.length && i < level1Data.children.length; i++) { const item = level1Data.children[i]; const $level2 = document.createElement('div'); const isPanelStyle = this.newMenuIsPanelStyle(item); const extraClass = isPanelStyle ? 'panel-bg' : 'common-bg'; $level2.className = `epartner-home-new-menu-level2 ${extraClass}`; const $title = this.createNewMenuTitle(item); $level2.append($title); let $level3 = isPanelStyle ? this.createNewPanelLevel3Menu(item) : this.createNewCommonLevel3Menu(item); $level2.append($level3); $level2List.append($level2); } $level2Content.append($level2List); const $btns = this.newMenuMoreBtn(level1Data.name); $btns && $level2Content.append($btns); return $level2Content; }; epartnerPageMenuHorizontal.prototype.createNewMenuTitle = function (item) { const $title = document.createElement('h3'); $title.className = 'epartner-header-new-menu-subtile'; if (item.url) { const $link = document.createElement('a'); $link.className = 'flex-v-center'; $link.setAttribute('href', item.url); const $icon = this.cloneNodeByTemplate('#iconDown svg', 'icon-red rotate--90'); $link.append(item.name); $link.append($icon); $title.append($link); } else { $title.innerHTML = item.name; } return $title; }; epartnerPageMenuHorizontal.prototype.createNewPanelLevel3Menu = function (level2Data) { const $level3List = document.createElement('ul'); $level3List.className = 'epartner-home-new-panel-menu-level3-list'; for (let i = 0; level2Data.children && level2Data.children.length && i < level2Data.children.length; i++) { const item = level2Data.children[i]; const $level3 = document.createElement('li'); $level3.className = 'epartner-home-new-panel-menu-level3-item'; if (i === 0) { $level3.className = `${$level3.className} active`; } const $content = document.createElement('p'); $content.innerText = item.name; $level3.append($content); $level3.append(this.createNewPanelLevel4Menu(i, item)); $level3List.append($level3); } return $level3List; }; epartnerPageMenuHorizontal.prototype.createNewPanelLevel4Menu = function (index, level2Data) { const $content = document.createElement('div'); $content.className = 'epartner-home-new-panel-menu-level4-wrapper'; $content.className = index === 0 ? `${$content.className} flex` : $content.className; const $level4List = document.createElement('ul'); $level4List.className = 'epartner-home-new-panel-menu-level4-list'; for (let i = 0; level2Data.children && level2Data.children.length && i < level2Data.children.length; i++) { const item = level2Data.children[i]; const $level4 = document.createElement('li'); $level4.className = 'epartner-home-new-panel-menu-level4-item'; const $content = document.createElement('a'); $content.setAttribute('href', item.url); $content.innerText = item.name; $level4.append($content); $level4List.append($level4); } $content.append($level4List); if (level2Data.url) { const $link = document.createElement('a'); $link.innerText = `${level2Data.name}首页`; $link.setAttribute('href', level2Data.url); $link.setAttribute('target', '_blank'); $link.className = 'forwarding-home'; const $icon = this.cloneNodeByTemplate('#iconDown svg', 'rotate--90 icon-red'); $link.append($icon); $content.append($link); } return $content; }; epartnerPageMenuHorizontal.prototype.createNewCommonLevel3Menu = function (level2Data) { const $level3List = document.createElement('ul'); const extraClass = level2Data?.children?.length > 9 ? 'flex-row flex-wrap' : 'flex-column'; $level3List.className = `epartner-home-new-common-menu-level3-list ${extraClass}`; for (let i = 0; level2Data.children && level2Data.children.length && i < level2Data.children.length; i++) { const item = level2Data.children[i]; const $level3 = document.createElement('li'); $level3.className = 'epartner-home-new-common-menu-level3-item'; if (i === 0) { $level3.className = `${$level3.className} active`; } const $content = document.createElement('a'); $content.setAttribute('href', item.url); $content.innerHTML = `${item.name}`; $level3.append($content); $level3List.append($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')); }); $('.epartner-home-new-menu-level1').on('mouseover', function (event) { $('.epartner-home-new-menu-level1-mask').show(); const index = $(this).index(); $('.epartner-home-new-menu-level1-content').eq(index).show().siblings().hide(); $('.epartner-home-new-menu-level1-wrapper').slideDown(); const $activePanel4 = $('.epartner-home-new-menu-level1-content').eq(index).find('.epartner-home-new-panel-menu-level3-item.active'); const $panel = $('.epartner-home-new-menu-level1-content').eq(index).find('.epartner-home-new-panel-menu-level3-item'); if ($panel?.length && !$activePanel4?.length) { $('.epartner-home-new-menu-level1-content') .eq(index) .find('.epartner-home-new-menu-level2.panel-bg .epartner-home-new-panel-menu-level3-item:first-child') .trigger('click'); } }); $('.epartner-home-new-menu-level1-content').on('mouseover', function () { const index = $(this).index(); $('.epartner-home-new-menu-level1-link').removeClass('active'); $('.epartner-home-new-menu-level1-link').eq(index).addClass('active'); }); $('.epartner-home-new-menu-level1-content').on('mouseleave', function () { $('.epartner-home-new-menu-level1-link').removeClass('active'); }); $('#epartnerPageMenuNav').on('mouseleave', function () { $('.epartner-home-new-menu-level1-wrapper').slideUp(); $('.epartner-home-new-menu-level1-mask').fadeOut(); }); $('.epartner-home-new-menu-level1-mask').on('mouseover', function (event) { $('.epartner-home-new-menu-level1-wrapper').slideUp(); $('.epartner-home-new-menu-level1-mask').fadeOut(); }); $('.epartner-home-new-panel-menu-level3-item').on('click', function (event) { $('.epartner-home-new-panel-menu-level3-item').removeClass('active'); $(event.currentTarget).addClass('active'); $('.epartner-home-new-panel-menu-level4-wrapper').removeClass('flex'); $(event.currentTarget).find('.epartner-home-new-panel-menu-level4-wrapper').toggleClass('flex'); }); $('.epartner-home-new-menu-level2 a, .epartner-m-new-menu-level2-page a').on('click', () => { buriedCode(); }); }; epartnerPageMenuHorizontal.prototype.createMobileContent = function () { const $content = $('#epartnerMobileMenuContent'); let menuList = []; const _loginFlag = this.loginFlag; const createLevel = function (_data, deepLevel, parentIndex) { let $levelPage; if (menuList.length > deepLevel) { $levelPage = menuList[deepLevel]; } else { $levelPage = document.createElement('div'); $levelPage.className = `epartner-m-menu-level-page`; $($levelPage).attr({ 'data-deep': deepLevel, }); menuList.push($levelPage); $content.append($levelPage); } const $levelList = document.createElement('ul'); $levelList.className = `epartner-m-menu-level small-scrollbar ${deepLevel === 0 ? '' : 'list-hide'}`; $($levelList).attr('data-parent-index', parentIndex); for (let index = 0; index < _data.length; index++) { const levelData = _data[index]; if (deepLevel === 0 && !showLevel1MenuFlag(levelData)) { continue; } if (deepLevel === 1 && !showLevel2MenuFlag(levelData)) { continue; } if (deepLevel === 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, deepLevel + 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 = '退出'; $logOut.append($logOutBtn); $content.append($logOut); } }; epartnerPageMenuHorizontal.prototype.createMobileEvents = function () { $('#epartnerMobileMenu').on('click', '.page-close', () => { $('#epartnerMobileMenu').hide(); while (this.mobileMenuPath.length > 0) { backMenu(); } $('#epartnerMobileLangMenuTitle').removeClass('active'); $('#epartnerMobileLangMenu').hide(); $('#epartnerMobileQuickMenuTitle').removeClass('active'); $('#epartnerMobileQuickMenu').hide(); }); const $content = $('#epartnerMobileMenuContent'); const $menuHeader = $('#epartnerMobileMenu .child-menu-header'); const $backDom = $('#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) { $backDom.hide(); $logo.show(); $menuHeader.text(''); } else { $menuHeader.text(this.mobileMenuPath[this.mobileMenuPath.length - 1].currentTitle); } } }; $('#epartnerMobileMenu').on('click', '.m-menu-back', backMenu); this.$container.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}]`); $backDom.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); } }); }; epartnerPageTopNav.prototype.menuSwitch = function () { $('#epartnerMobileLangMenuTitle').toggleClass('active'); $('#epartnerMobileLangMenu').toggle(); $('#epartnerMobileQuickMenuTitle').removeClass('active'); $('#epartnerMobileQuickMenu').hide(); if ($('#epartnerMobileQuickMenuTitle').hasClass('active') || $('#epartnerMobileLangMenuTitle').hasClass('active')) { $('.epartner-m-menu-header').addClass('border-none'); } else { $('.epartner-m-menu-header').removeClass('border-none'); } }; epartnerPageMenuHorizontal.prototype.menuSwitch = epartnerPageTopNav.prototype.menuSwitch; epartnerPageMenuHorizontal.prototype.createNewMobileEvents = function (res) { $('#epartnerHomeNewMenuHowBuy .four a').on('click', event => { buriedCode(); }); const $blankBox = document.createElement('div'); $blankBox.className = 'blank-box'; $('#epartnerMobileMenu').append($blankBox); $('#epartnerMobileMenu').on('click', '.page-close', () => { $('#epartnerMobileMenu').hide(); $('.epartner-m-new-menu-level2-page').hide(); $('.epartner-m-new-menu-page').show(); while (this.mobileMenuPath.length > 0) { backMenu(); } $('#epartnerMobileLangMenuTitle').removeClass('active'); $('#epartnerMobileLangMenu').hide(); $('#epartnerMobileQuickMenuTitle').removeClass('active'); $('#epartnerMobileQuickMenu').hide(); }); $('#epartnerMobileMenuContent .four a').on('click', event => { buriedCode(); }); this.$container.on('click', '.epartner-home-menu-mobile', () => { $('#epartnerMobileMenu').show(); $('.icon-yewu').off('click'); $('.icon-diqiu2').off('click'); $('.person-logIn').off('click'); $('.person-logOut').off('click'); $('.icon-yewu').on('click', () => { $('#epartnerMobileLangMenuTitle').removeClass('active'); $('#epartnerMobileLangMenu').hide(); $('#epartnerMobileQuickMenuTitle').toggleClass('active'); $('#epartnerMobileQuickMenu').toggle(); if ($('#epartnerMobileQuickMenuTitle').hasClass('active') || $('#epartnerMobileLangMenuTitle').hasClass('active')) { $('.epartner-m-menu-header').addClass('border-none'); } else { $('.epartner-m-menu-header').removeClass('border-none'); } }); $('.icon-diqiu2').on('click', () => { this.menuSwitch(); }); $('.person-logIn').on('click', () => { goUniPortalLogin(getHomeUrl()); }); $('.person-logOut').on('click', () => { logOut(); }); }); }; epartnerPageMenuHorizontal.prototype.createMobileNewMenuFooterLogin = function () { const $heaMobBtns = document.createElement('div'); $heaMobBtns.className = 'hea-mob-btns'; const $wapFirst = document.createElement('div'); $wapFirst.className = 'wap-first'; const $eCisternl = document.createElement('div'); $eCisternl.className = 'e-cistern-l'; for (let i = 0; i < 3; i++) { const $heaBtn = document.createElement('div'); $heaBtn.className = 'hea-btn'; const $iconYewu = document.createElement('span'); $iconYewu.className = 'iconfont icon-yewu'; const $pDom = document.createElement('p'); if (i === 0) { $pDom.innerText = '企业业务网站'; $iconYewu.className = 'iconfont icon-yewu'; } else if (i === 1) { $pDom.innerText = '选择区域/语言'; $iconYewu.className = 'iconfont icon-diqiu2'; } else if (i === 2) { $pDom.innerText = this.loginFlag ? '登出' : '登录'; $iconYewu.className = this.loginFlag ? 'iconfont person-logOut icon-denglu' : 'iconfont person-logIn icon-denglu'; } $heaBtn.append($iconYewu); $heaBtn.append($pDom); $heaMobBtns.append($heaBtn); } $eCisternl.append($heaMobBtns); return $eCisternl; }; epartnerPageMenuHorizontal.prototype.createMobileNewMenu = function (level1Data) { const $content = $('#epartnerMobileMenuContent'); const $level1Wrapper = document.createElement('div'); $level1Wrapper.className = 'epartner-m-new-menu-page'; const $list = this.createNewMenuList(level1Data, { ul: 'epartner-m-new-menu-level1 small-scrollbar', li: 'epartner-m-new-menu-level1-item', }); $level1Wrapper.append($list); const $loginWrapper = this.createMobileNewMenuFooterLogin(); $level1Wrapper.append($loginWrapper); $content.append($level1Wrapper); $('.epartner-m-new-menu-level1-item').on('click', event => { const currentTargetId = event.currentTarget?.id; let level2Page = document.querySelector(`.epartner-m-new-menu-level2-page[data-parent='${currentTargetId}']`); if (!level2Page) { const data = this.data.find(v => String(v.id) === String(currentTargetId)); this.createMobileNewMenuLevel2(data); } $('.epartner-m-new-menu-level2-page,.epartner-m-new-menu-page').hide(); $(`.epartner-m-new-menu-level2-page[data-parent='${currentTargetId}']`).show(); }); $('#epartnerMobileMenuContent').on('click', '.epartner-m-new-menu-level2-item', event => { $(event.currentTarget).siblings().find('.epartner-m-new-menu-level-item-wrapper svg').removeClass('rotate-180'); $(event.currentTarget).siblings().find('.epartner-m-new-menu-level3-list').removeClass('flex'); $(event.currentTarget).find('.epartner-m-new-menu-level3-list').toggleClass('flex'); $(event.currentTarget).find('>.epartner-m-new-menu-level-item-wrapper svg').toggleClass('rotate-180'); $('.epartner-m-new-menu-level4-wrapper').removeClass('flex'); }); $('#epartnerMobileMenuContent').on('click', '.epartner-m-new-menu-level3-item', event => { event.stopPropagation(); $(event.currentTarget).siblings().find('.epartner-m-new-menu-level-item-wrapper svg').removeClass('rotate-180'); $(event.currentTarget).siblings().find('.epartner-m-new-menu-level4-wrapper').removeClass('flex'); $(event.currentTarget).find('.epartner-m-new-menu-level4-wrapper').toggleClass('flex'); $(event.currentTarget).find('>.epartner-m-new-menu-level-item-wrapper svg').toggleClass('rotate-180'); }); $('#epartnerMobileMenuContent').on('click', '.epartner-m-new-menu-level2-page .back', () => { $('.epartner-m-new-menu-level2-page').hide(); $('.epartner-m-new-menu-page').show(); }); $('#epartnerMobileMenuContent').on('click', '.epartner-m-new-menu-level4-item', event => { event.stopPropagation(); }); $('.epartner-m-menu-header .m-menu-back').on('click', () => { $('#epartnerMobileMenu').hide(); }); $('#epartnerMobileMenuContent').on('click', '.epartner-m-new-menu-level2-page a', event => { buriedCode(); }); return $content; }; epartnerPageMenuHorizontal.prototype.createMobileNewMenuLevel2Header = function (level1Item) { const $header = document.createElement('header'); $header.className = 'header back'; const $icon = this.cloneNodeByTemplate('#iconDown svg', 'rotate-90'); const $title = document.createElement('h3'); $title.innerText = '返回主菜单'; $header.append($icon); $header.append($title); return $header; }; epartnerPageMenuHorizontal.prototype.cloneNodeByTemplate = function (selector, className) { const $template = document.querySelector(selector); const $dom = $template.cloneNode(true); if (className) { $dom.setAttribute('class', className); } return $dom; }; epartnerPageMenuHorizontal.prototype.createMenuItem = function ($wrapper, item) { const setText = text => { const $text = document.createElement('span'); $text.innerText = text; $wrapper.append($text); }; if ((item.children && item.children.length) || item.name === '如何购买') { setText(item.name); const $icon = this.cloneNodeByTemplate('#iconDown svg'); $wrapper.append($icon); } else if (item.url) { const $link = document.createElement('a'); $link.setAttribute('href', item.url); $link.innerText = item.name; $wrapper.append($link); } else { setText(item.name); } return $wrapper; }; epartnerPageMenuHorizontal.prototype.createNewMenuList = function (data, classMap, generateChildrenMethod, childrenClassMap) { const list = data.children || []; const $list = document.createElement('ul'); $list.className = classMap['ul']; for (let i = 0; i < list.length; i++) { const item = list[i]; const $level = document.createElement('li'); $level.className = classMap['li']; if (item.id) { $level.setAttribute('id', item.id); } const $wrapper = document.createElement('div'); $wrapper.className = 'epartner-m-new-menu-level-item-wrapper'; this.createMenuItem($wrapper, item); $level.append($wrapper); if (item.children && item.children.length && generateChildrenMethod) { const $children = generateChildrenMethod.call(this, item, childrenClassMap, this.createMobileNewMenuLevel4); $level.append($children); } $list.append($level); } return $list; }; epartnerPageMenuHorizontal.prototype.createMobileNewMenuHowToBuy = function (level1Item) {}; epartnerPageMenuHorizontal.prototype.createMobileNewMenuLevel2 = function (level1Item) { const $content = $('#epartnerMobileMenuContent'); const $level2Page = document.createElement('div'); $level2Page.className = 'epartner-m-new-menu-level2-page small-scrollbar'; if (level1Item.id) { $level2Page.setAttribute('data-parent', level1Item.id); } if (level1Item.name === '如何购买') { const $howBuy = document.getElementById('epartnerHomeMobileNewMenuHowBuy'); $($howBuy).removeClass('hidden'); $level2Page.append($howBuy); $content.append($level2Page); return $content; } const $header = this.createMobileNewMenuLevel2Header(level1Item); const $level2Content = document.createElement('div'); $level2Content.className = 'epartner-m-new-menu-level2-content'; const $level2MenuWrapper = document.createElement('div'); $level2Title = document.createElement('h3'); $level2Title.className = 'title'; $level2Title.innerText = level1Item.name; const $level2List = this.createNewMenuList( level1Item, { ul: 'epartner-m-new-menu-level2-list', li: 'epartner-m-new-menu-level2-item', parentId: level1Item.id, }, this.createNewMenuList, { ul: 'epartner-m-new-menu-level3-list', li: 'epartner-m-new-menu-level3-item', } ); $level2MenuWrapper.append($level2Title); $level2MenuWrapper.append($level2List); $level2Content.append($level2MenuWrapper); const $btnWrapper = this.createMobileNewMenuMoreBtn(level1Item.name); if ($btnWrapper) { $level2Content.append($btnWrapper); } $level2Page.append($header); $level2Page.append($level2Content); $content.append($level2Page); }; epartnerPageMenuHorizontal.prototype.createMobileNewMenuLevel4 = function (data) { const list = data.children || []; const $content = document.createElement('div'); $content.className = 'epartner-m-new-menu-level4-wrapper'; const $levelList = document.createElement('ul'); $levelList.className = 'epartner-m-new-menu-level4-list small-scrollbar'; for (let i = 0; i < list.length; i++) { const item = list[i]; const $level4 = document.createElement('li'); $level4.className = 'epartner-m-new-menu-level4-item'; const $p = document.createElement('p'); const $link = document.createElement('a'); $link.setAttribute('href', item.url); $link.innerText = item.name; $p.append($link); $level4.append($p); $levelList.append($level4); } $content.append($levelList); if (data.url) { const $link = document.createElement('a'); $link.innerText = `${data.name}首页`; $link.setAttribute('href', data.url); $link.className = 'forwarding-home'; const $icon = this.cloneNodeByTemplate('#iconDown svg', 'rotate--90 icon-red'); $link.append($icon); $content.append($link); } return $content; }; epartnerPageMenuHorizontal.prototype.createMobileNewMenuMoreBtn = function (name) { const btns = newMenuBtnMap[name]; if (!btns) return; const $btnWrapper = document.createElement('div'); $btnWrapper.className = 'epartner-m-new-menu-level2-more-btn'; for (let i = 0; i < btns.length; i++) { const item = btns[i]; const $btn = document.createElement('button'); const $link = document.createElement('a'); $link.setAttribute('target', '_blank'); $link.setAttribute('href', item.url); $link.innerText = item.label; const $icon = this.cloneNodeByTemplate(item.icon, `${item.iconClass} icon-gray`); $link.append($icon); $btn.append($link); $btnWrapper.append($btn); } return $btnWrapper; }; 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(); if (!this.loginFlag || (this.loginFlag && this.newStyle)) { $('#epartnerPageMenuNav').css('display', 'flex'); $('#epartnerPageMenuNav').css('justify-content', 'center'); } else { $('.epartner-home-menu-level0').css('display', 'flex'); } $('.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]; const $level1 = document.createElement('div'); $level1.className = 'epartner-home-menu-v-level1'; $level1.innerHTML = ``; $($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 $icon = document.createElement('img'); $icon.className = 'epartner-home-menu-v-level1-title-icon'; for (let k = 0; level1Data.items && level1Data.items.length && k < level1Data.items.length; k++) { const item = level1Data.items[k]; 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 k = 0; k < level2Data.items.length; k++) { const item = level2Data.items[k]; 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 = '您当前没有该功能权限,点击立即申请 获取使用权限。'; $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 buriedCode() { window.hwa && window.hwa('trackPageView', 'P988021629E26D0', { sub_page: '模板-菜单头' }); } function openMenuPage(item, loginFlag, newStyle) { const isAssociated = sessionStorage.getItem('epartner-is-associated') === 'true'; buriedCode(); 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 partnerFooter() {} partnerFooter.prototype.init = function () { this.queryRichText(); }; partnerFooter.prototype.queryRichText = function () { const lang = getCurrentLanguage(); const footerLang = constants.FOOTER_CONFIG_MAP[lang] || 'footer-cn-meta'; $.ajax({ type: 'get', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/pub/public/getHtmlAreaInfo/MessageTemplateEN/${footerLang}`, success: function (res) { if (!res.content) { return; } const str = replaceOrigin(res.content, '.huawei.com'); $('#partner-footer').html(str); }, }); }; function partnerHeader() {} partnerHeader.prototype.init = function () { this.initCookie(); }; partnerHeader.prototype.initCookie = function () { if (document.cookie.indexOf('read_policy_noru') < 0) { $('.partner-top-cookie').show(); } }; function search() { this.hotWordsData = []; } search.prototype.init = function () { let _this = this; let handlerSearch = function (event) { if ($(event.target).closest('#epartnerHomeHeaderSearch').length === 0) { $('#epartnerHomeHeaderSearch .search-con-box').removeClass('showSearch'); $('#epartnerHomeHeaderSearch .search-con-box .searching-tip').hide(); $(document).off('click', handlerSearch); $('#epartnerHomeHeaderSearch').hide(); $('#epartnerPageMenu .epartner-home-menu-pc').removeClass('hidden'); $('#epartnerPageMenu #epartnerPageMenuNav').removeClass('hidden'); } }; $('#epartnerPageMenu .search-btn').on('click', function () { $('#epartnerHomeHeaderSearch').show(); setTimeout(() => { $('#epartnerHomeHeaderSearch .search-con-box').addClass('showSearch'); $(document).on('click', handlerSearch); }, 10); setTimeout(() => { $('#epartnerHomeHeaderSearch .search-con-box .searching-tip').show(); }, 200); if ($(window).width() > 1024) { let searchOffSetLeft = $('#epartnerPageMenu .search-btn .menu-sou').offset().left; let searchWidth = $('#epartnerPageMenu .search-btn .menu-sou').width(); const $epartnerMenu = $('#epartnerPageMenuNav').children().children().last(); let menuOffSetLeft = $epartnerMenu.offset().left; let menuWidth = $epartnerMenu.width(); let distanceLeft = searchOffSetLeft + searchWidth - menuOffSetLeft - menuWidth - 656; if (distanceLeft < 0) { $('#epartnerPageMenu .epartner-home-menu-pc').addClass('hidden'); $('#epartnerPageMenu #epartnerPageMenuNav').addClass('hidden'); } } }); $('#epartnerHomeHeaderSearch .close-search').on('click', function (event) { event.stopPropagation(); $('#epartnerHomeHeaderSearch .search-con-box').removeClass('showSearch'); $('#epartnerHomeHeaderSearch .search-con-box .searching-tip').hide(); $(document).off('click', handlerSearch); $('#epartnerHomeHeaderSearch').hide(); $('#epartnerPageMenu .epartner-home-menu-pc').removeClass('hidden'); $('#epartnerPageMenu #epartnerPageMenuNav').removeClass('hidden'); }); $('#epartnerHomeHeaderSearch #delHistory').on('click', function () { let kwv = JSON.stringify({}); Cookies.set('search_history_kw', kwv, { raw: false, expires: Infinity, path: '/', secure: false }); _this.showOrHiddenTip('search-history', 'hide'); }); let timeout = null; $('#epartnerHomeHeaderSearch #txtSearch_Navigation').on('input', function () { let searchVal = $(this).val(); if (searchVal) { clearTimeout(timeout); timeout = setTimeout(() => { _this.searchValueFunction(searchVal); _this.searchValueFunction2(searchVal); $('#epartnerHomeHeaderSearch .clear-search').show(); _this.showOrHiddenTip('search-history', 'hide'); _this.showOrHiddenTip('search-hot', 'hide'); }, 600); } else { clearTimeout(timeout); _this.initSearchTip(); } }); $('#epartnerHomeHeaderSearch #txtSearch_Navigation').on('focus', function () { $('#epartnerHomeHeaderSearch .searching-tip').show(); }); $('#epartnerHomeHeaderSearch #txtSearch_Navigation').on('keydown', function (event) { if (event.keyCode + '' === '13') { _this.searchClick(); } }); $('#epartnerHomeHeaderSearch .clear-search').on('click', function () { $('#epartnerHomeHeaderSearch #txtSearch_Navigation').val(''); _this.initSearchTip(); }); $('#epartnerHomeHeaderSearch #searchBtn').on('click', function () { _this.searchClick(); }); this.setHistoryElement(); this.getHotWords(); }; search.prototype.setHistoryElement = function () { let _this = this; let historyData = this.getHistory(); 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 () { _this.searchJumping(key); }); $('#epartnerHomeHeaderSearch .search-history').append($a); }); } else { _this.showOrHiddenTip('search-history', 'hide'); } }; search.prototype.getHistory = function () { let history = Cookies.get('search_history_kw'); if (history) { try { history = JSON.parse(history); } catch { history = {}; } } else { history = {}; } return history; }; search.prototype.setHistory = function (word) { if (!word) { return; } const old = this.getHistory(); const now = Number(new Date()); old[word] = now; const curt = this.comListHis(old); const newValue = {}; curt.forEach(item => { newValue[item.name] = item.t; }); const cookieValue = JSON.stringify(newValue); Cookies.set('search_history_kw', cookieValue, { raw: false, expires: Infinity, path: '/', secure: false, }); }; search.prototype.delHistory = function () { const kwv = JSON.stringify({}); this.historyData = {}; Cookies.set('search_history_kw', kwv, { raw: false, expires: Infinity, path: '/', secure: false }); }; 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, 10); 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 _this = this; let param = { customParams: [ { customParamName: 'language', customParamValue: 'zh' }, { customParamName: 'site', customParamValue: 'cn' }, ], }; $.ajax({ type: 'POST', dataType: 'json', data: JSON.stringify(param), url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/pub/public/getHotWord`, success: function (res) { if (!res.body || !res.body.data || !res.body.data.data) { return; } _this.hotWordsData = res.body.data.data || []; _this.setHotWords(); }, }); }; search.prototype.setHotWords = function () { let _this = this; if (this.hotWordsData && this.hotWordsData.length > 0) { this.hotWordsData.forEach(item => { const $a = document.createElement('a'); $a.innerText = item.searchTxt; $a.title = item.searchTxt; $a.addEventListener('click', function () { _this.searchJumping(item.searchTxt); }); $('#epartnerHomeHeaderSearch .search-hot').append($a); }); } else { this.showOrHiddenTip('search-hot', 'hide'); } }; search.prototype.searchValueFunction = function (value) { let that = this; let params = { customParams: [ { customParamName: 'language', customParamValue: 'zh' }, { customParamName: 'site', customParamValue: 'cn' }, ], queryText: value, }; $.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) { that.setSearchValueFunction(res.body.data); } else { that.showOrHiddenTip('search-direct', 'hide'); } }, }); }; search.prototype.setSearchValueFunction = function (data) { this.showOrHiddenTip('search-direct', 'show'); let arr = []; data.forEach(e => { arr = [...arr, ...e.data]; }); let searchDirectlyData = arr.slice(0, 5); if (searchDirectlyData.length > 0) { 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 { this.showOrHiddenTip('search-direct', 'hide'); } }; search.prototype.searchValueFunction2 = function (value) { let that = this; let param = { customParams: [ { customParamName: 'language', customParamValue: 'zh' }, { customParamName: 'site', customParamValue: 'cn' }, ], queryText: value, }; $.ajax({ type: 'POST', dataType: 'json', data: JSON.stringify(param), 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) { that.showOrHiddenTip('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/#/cn/web/marketingsearch?from=partner&keyword=${val}&lang=zh&site=cn&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.searchJumping(searchValue); } }; search.prototype.initSearchTip = function () { $('#epartnerHomeHeaderSearch .clear-search').hide(); const historyData = this.getHistory(); if (Object.keys(historyData).length > 0) { this.showOrHiddenTip('search-history', 'show'); } else { this.showOrHiddenTip('search-history', 'hide'); } if (this.hotWordsData.length > 0) { this.showOrHiddenTip('search-hot', 'show'); } else { this.showOrHiddenTip('search-hot', 'hide'); } this.showOrHiddenTip('search-direct', 'hide'); this.showOrHiddenTip('search-suggest', 'hide'); }; search.prototype.showOrHiddenTip = function (rowName, type) { if (type === 'show') { $(`#epartnerHomeHeaderSearch .${rowName}-wap`).show(); } else if (type === 'hide') { $(`#epartnerHomeHeaderSearch .${rowName}-wap`).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; this.findCompanyInfo(); $('#menuHead #showPartnerType').on('click', function () { $('html, body').animate({ scrollTop: $('#pcPagePartner').offset().top - 64 }, { duration: 500, easing: 'swing' }); }); $('#menuHead #checkPrivacyStatement').on('click', function () { that.isCertify(); return; }); $('#menuHead .head-tips-close').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/#/cn/web/associate-company-cn`); that.dialogShowAndHide('hide'); }); $('#menuHead .menu-head-button.noBtn').on('click', function () { that.dialogShowAndHide('hide'); }); } else { $('#menuHead').remove(); } }; menuHead.prototype.isCertify = function (type) { $.ajax({ type: 'POST', dataType: 'json', data: JSON.stringify({}), url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/control/isRealNameAuthenticationEnabled`, success: function (res) { let isRealName = res.body || ''; if (isRealName === 'Y') { $('.epartner-dialog.uncertified-dialog').removeClass('close'); $('.epartner-dialog.uncertified-dialog').attr('frome-data', 'beforeApplication'); $('.epartner-dialog.uncertified-dialog')[0].showModal(); } else { window.location.href = `${BASE_URL}/eplus/#/cn/web/associate-company-cn`; } }, }); }; menuHead.prototype.findCompanyInfo = function () { const that = this; $.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 (Number(res.content.valid) === -1) { that.dialogShowAndHide('show'); } }, }); }; menuHead.prototype.dialogShowAndHide = function (type) { let $modal = $('#menuHead #menuHeadModal'); let $dialog = $('#menuHead #menuHeadDialog'); if (type === 'show') { $dialog.removeClass('hidden'); $modal.removeClass('hidden'); } else { $dialog.addClass('hidden'); $modal.addClass('hidden'); } }; function autoRenewal({ loginFlag }) { this.loginFlag = loginFlag; } autoRenewal.prototype.init = function () { if (!this.loginFlag) { return; } $.ajax({ type: 'GET', headers: { 'x-app-id': 'com.huawei.channelsales.echannel.echannel2.0', 'x-sub-app-id': 'ePartner_service', }, dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/partner/autoRenewalPop`, success: response => { if (response && response.data && response.data instanceof Array && response.data.length > 0) { response.data.forEach(item => { this.createDialog(item); }); } }, }); }; autoRenewal.prototype.createDialog = function ({ content, title, scena }) { const $dialog = document.createElement('dialog'); $dialog.className = 'epartner-dialog p-dialog'; document.body.append($dialog); const $header = document.createElement('div'); $header.className = 'epartner-dialog-header p-dialog__header p-dialog__title'; $header.innerText = title; $dialog.append($header); const $closeIcon = document.createElement('div'); $closeIcon.className = 'p-dialog__close_btn hand-cursor'; $closeIcon.innerHTML = ``; $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 p-button-group'; $dialog.append($optRow); const $closeBtn = document.createElement('button'); $closeBtn.className = 'p-button p-button--default'; $closeBtn.innerText = '关闭'; $optRow.append($closeBtn); const $okBtn = document.createElement('button'); $okBtn.className = 'p-button p-button--primary is-plain'; $okBtn.innerText = '已知晓'; $optRow.append($okBtn); const $tipsRow = document.createElement('div'); $tipsRow.className = 'epartner-dialog-footer-tips'; $tipsRow.innerHTML = '!温馨提示:如果您选择“已知晓”,后续30天将不再弹窗提醒您。'; $dialog.append($tipsRow); this.createEvents({ cookieKey: `read_Renew_Agreement_${scena}`, $okBtn, $closeBtn, $closeIcon, dialog: $dialog, $header, $content }); }; autoRenewal.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 p-dialog close'; setTimeout(() => { dialog.close(); dialog.removeEventListener('mousedown', startDragging); }, 300); }; const startDragging = dialogDragging({ $dialog: 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(); }); $($closeBtn).on('click', () => { closeDialog(); }); $($closeIcon).on('click', () => { closeDialog(); }); }; function renewalNotice({ userInfo }) { this.userInfo = userInfo; } renewalNotice.prototype.init = function () { $.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/getCheckIsSignAgreement?w3account=${this.userInfo.userAccount}`, success: res => { if (typeof res.body === 'string' && res.body !== '') { res = JSON.parse(res.body); } if (res.result && res.result.isSignDeclaration === 'Y') { this.getRoleName(); } }, }); }; renewalNotice.prototype.getRoleName = function () { let adminRoleArr = []; let validRoles = this.userInfo.validRoles; let validRolesNameArr = validRoles.map(item => item.roleName); $.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.COMMON_SERVICE}/common/v1/public/queryLookupList?classifyCode=INITROLE_ADMIN&language=zh`, success: res => { if (res && res.length > 0) { for (let i = 0; i < res.length; i++) { adminRoleArr.push(res[i].itemName); } let isAdmin = validRolesNameArr.some(item => { return adminRoleArr.includes(item); }); this.createDialog(isAdmin); } }, }); }; renewalNotice.prototype.createDialog = function (isAdmin) { const dialog = document.createElement('dialog'); dialog.className = 'epartner-dialog p-dialog reminder-dialog'; document.body.append(dialog); const header = document.createElement('div'); header.className = 'epartner-dialog-header p-dialog__header p-dialog__title'; const headerTitle = document.createElement('div'); const icon = document.createElement('span'); icon.className = 'icon-warn'; icon.innerHTML = '!'; headerTitle.append(icon); headerTitle.append('华为与伙伴《华为一站式平台使用与伙伴通用合作协议》续签通知'); header.append(headerTitle); dialog.append(header); const body = document.createElement('div'); body.className = 'epartner-dialog-content p-dialog__body small-scrollbar popup-content'; body.innerHTML = ` 贵公司与华为此前签署《华为一站式平台使用与伙伴通用合作协议》(以下简称:“《伙伴注册协议》”)和《销售伙伴认证协议》(如涉及)已期限届满终止。贵公司在华为系统中的合作状态已调整为“终止”,同时所有相关交易已被限制,请您知悉。
与现行协议相比,新的《伙伴注册协议》和《销售伙伴认证协议》部分条款有变更,如贵公司今年希望与华为在政企业务上继续合作,我们期待您与华为签署新的《伙伴注册协议》。如贵公司希望进一步获取或维持销售伙伴认证身份,您还需要签署《销售伙伴认证协议》
提醒:合作协议只能用贵公司管理员账号登录才能签署,请知会。
`; 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 = '关闭'; optRow.append(closeBtn); const signBtn = document.createElement('button'); signBtn.className = 'p-button p-button--primary is-plain'; signBtn.innerHTML = '签署协议'; if (isAdmin) { optRow.append(signBtn); } this.createEvents({ closeBtn, signBtn, dialog, header, body }); }; renewalNotice.prototype.createEvents = function ({ closeBtn, signBtn, dialog, header, body }) { dialog.showModal(); $(body).scrollTop(0); const closeDialog = () => { dialog.className = 'epartner-dialog p-dialog reminder-dialog close'; setTimeout(() => { dialog.close(); dialog.removeEventListener('mousedown', startDrag); }, 300); }; const startDrag = dialogDragging({ $dialog: dialog, $header: header, closeDialog }); dialog.addEventListener('mousedown', startDrag); $(closeBtn).off('click'); $(closeBtn).on('click', () => { closeDialog(); }); $(signBtn).off('click'); $(signBtn).on('click', () => { window.location.href = DOMPurify.sanitize(`${BASE_URL}/eplus/#/cn/group/annualDeclaration`); }); }; function infoSigned({ userInfo }) { this.userInfo = userInfo; this.signCancelTimeKey = ''; this.signTypePhone = false; this.signTypeEmail = false; this.signTypeNo = false; } infoSigned.prototype.init = function () { $.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/account/findAccountRole?screenName=${this.userInfo.userAccount}`, success: res => { let resRole = res || {}; if (resRole.isAdmin === 'Y') { this.getResInfo(); } }, }); }; infoSigned.prototype.getResInfo = function () { $.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/privacyConfig/getInfo`, success: res => { const body = res.body || {}; const result = body.result || {}; if (result.isSigned === 'N' && !this.isCancel()) { this.createDialog(); } }, }); }; infoSigned.prototype.isCancel = function () { this.signCancelTimeKey = `${this.userInfo.userAccount}-signCancelTimeKey`; const signCancelTime = window.localStorage.getItem(this.signCancelTimeKey); const currentTime = new Date().getTime(); return currentTime - signCancelTime < 48 * 60 * 60 * 1000 && signCancelTime; }; infoSigned.prototype.createDialog = function () { const dialog = document.createElement('dialog'); dialog.className = 'epartner-dialog p-dialog info-signed__wrapper'; document.body.append(dialog); const header = document.createElement('div'); header.className = 'epartner-dialog-header p-dialog__header p-dialog__title'; header.append('关于员工关联公司申请的隐私告知'); dialog.append(header); const body = document.createElement('div'); body.className = 'epartner-dialog-content p-dialog__body small-scrollbar info-signed-content'; body.innerHTML = `尊敬的伙伴公司管理员:为了贵公司员工申请关联公司以获取相应权限时能够及时联系到您、批复相关申请, 我们将在员工申请绑定公司界面公开您的账号,您也可以选择展示您的电话、邮箱信息。您也可以在“新版工作台-个人信息-管理员账号信息公开”撤销或修改本次公开的信息。 `; dialog.append(body); const optRow = document.createElement('div'); optRow.className = 'epartner-dialog-opt-row p-dialog__footer p-button-group'; dialog.append(optRow); const cancelBtn = document.createElement('button'); cancelBtn.className = 'p-button p-button--default'; cancelBtn.innerText = '取消'; optRow.append(cancelBtn); const submitBtn = document.createElement('button'); submitBtn.className = 'p-button p-button--primary is-plain is-disabled submit'; submitBtn.innerHTML = '提交'; submitBtn.disabled = true; optRow.append(submitBtn); this.createEvents({ cancelBtn, submitBtn, dialog, header, body }); }; infoSigned.prototype.createEvents = function ({ cancelBtn, submitBtn, dialog, header, body }) { dialog.showModal(); $(body).scrollTop(0); const closeDialog = () => { dialog.className = 'epartner-dialog p-dialog info-signed__wrapper close'; setTimeout(() => { dialog.close(); dialog.removeEventListener('mousedown', startMoving); }, 300); }; const startMoving = dialogDragging({ $dialog: dialog, $header: header, closeDialog }); dialog.addEventListener('mousedown', startMoving); $(cancelBtn).off('click'); $(cancelBtn).on('click', () => { closeDialog(); const signCancelTime = new Date().getTime(); window.localStorage.setItem(this.signCancelTimeKey, signCancelTime); }); $(submitBtn).off('click'); $(submitBtn).on('click', () => { this.onSubmit(closeDialog()); }); $('.p-dialog.info-signed__wrapper').on('click', '.checkbox', e => { e.preventDefault(); const pCheckbox = $(e.currentTarget).find('.p-checkbox'); if (pCheckbox.hasClass('is-disabled')) { return; } const checkBoxType = pCheckbox.attr('data'); let isChecked = false; if (pCheckbox.hasClass('is-checked')) { pCheckbox.find('.p-checkbox__input').removeClass('is-checked'); pCheckbox.removeClass('is-checked'); isChecked = false; } else { pCheckbox.find('.p-checkbox__input').addClass('is-checked'); pCheckbox.addClass('is-checked'); isChecked = true; } this[checkBoxType] = isChecked; this.checkBoxEvents(checkBoxType, isChecked); }); }; infoSigned.prototype.checkBoxEvents = function (checkBoxType, isChecked) { const $checkBox = $('.info-signed__wrapper .check-box__wrapper .checkbox-group .checkbox'); if (checkBoxType === 'signTypeNo') { this.setCheckBoxStatus($checkBox, isChecked); } const submitBtn = $('.info-signed__wrapper .p-button-group .submit'); if (this.signTypePhone || this.signTypeEmail || this.signTypeNo) { submitBtn.removeClass('is-disabled'); submitBtn.attr('disabled', false); } else { submitBtn.addClass('is-disabled'); submitBtn.attr('disabled', true); } }; infoSigned.prototype.setCheckBoxStatus = function ($checkBox, isChecked) { $checkBox.each((i, child) => { const checkBoxName = $(child).find('.p-checkbox').attr('data'); if (checkBoxName !== 'signTypeNo') { if (isChecked) { $(child).find('.p-checkbox').addClass('is-disabled'); $(child).find('.p-checkbox').removeClass('is-checked'); $(child).find('.p-checkbox__input').removeClass('is-checked'); $(child).find('.p-checkbox__input').addClass('is-disabled'); this[checkBoxName] = false; } else { $(child).find('.p-checkbox').removeClass('is-disabled'); $(child).find('.p-checkbox__input').removeClass('is-disabled'); } } }); }; infoSigned.prototype.onSubmit = function (closeDialog) { const params = { isSigned: 'Y', isShowPhone: this.signTypePhone ? 'Y' : 'N', isShowEmail: this.signTypeEmail ? 'Y' : 'N', }; $.ajax({ type: 'POST', dataType: 'json', data: JSON.stringify(params), url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/privacyConfig/save`, success: function (res) { closeDialog; }, }); }; function uncertified({ isHW }) { this.isHW = isHW; this.isRealName = ''; } uncertified.prototype.init = function () { this.isRealNameAuthenticationEnabled(); }; uncertified.prototype.isRealNameAuthenticationEnabled = function () { let that = this; $.ajax({ type: 'POST', dataType: 'json', data: JSON.stringify({}), url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/control/isRealNameAuthenticationEnabled`, success: function (res) { that.isRealName = res.body || ''; that.isCertify(); }, }); }; uncertified.prototype.isCertify = function () { if (this.isRealName === 'Y' && !this.isHW) { this.createDialog(); } }; uncertified.prototype.createDialog = function () { const dialog = document.createElement('dialog'); dialog.className = 'epartner-dialog p-dialog uncertified-dialog'; dialog.setAttribute('frome-data', 'home'); document.body.append(dialog); const header = document.createElement('div'); header.className = 'epartner-dialog-header uipm-dialog__title'; const headerTitle = document.createElement('div'); const icon = document.createElement('span'); icon.className = 'uipm-dialog__title_icon icon-solid'; icon.innerHTML = 'i'; headerTitle.append(icon); headerTitle.append('账号认证'); header.append(headerTitle); const closeIcon = document.createElement('div'); closeIcon.className = 'uipm-icom-colse'; closeIcon.innerHTML = ``; header.append(closeIcon); dialog.append(header); const body = document.createElement('div'); body.className = 'epartner-dialog-content uipm-dialog__body popup-content'; body.innerHTML = ` 关联公司需要完成账号认证,您的账号还未完成账号认证,点击下一步开始认证。`; dialog.append(body); const optRow = document.createElement('div'); optRow.className = 'epartner-dialog-footer uipm-dialog__footer uipm-button-group'; dialog.append(optRow); const closeBtn = document.createElement('button'); closeBtn.className = 'uipm-button uipm-button--default'; closeBtn.innerText = '取消'; optRow.append(closeBtn); const signBtn = document.createElement('button'); signBtn.className = 'uipm-button uipm-button--primary'; signBtn.innerHTML = '下一步'; optRow.append(signBtn); this.createEvents({ closeBtn, signBtn, closeIcon, dialog, header, body }); this.dialog = dialog; }; uncertified.prototype.createEvents = function ({ closeBtn, signBtn, closeIcon, dialog, header, body }) { if (this.isTipsTimeout()) { dialog.showModal(); } $(body).scrollTop(0); const closeDialog = () => { dialog.className = 'epartner-dialog p-dialog uncertified-dialog close'; setTimeout(() => { dialog.close(); dialog.removeEventListener('mousedown', startMoving); }, 300); }; const startMoving = dialogDragging({ $dialog: dialog, $header: header, closeDialog }); dialog.addEventListener('mousedown', startMoving); $(closeBtn).off('click'); $(closeBtn).on('click', () => { closeDialog(); localStorage.setItem('isShowCertifiedTip', new Date().getTime()); }); $(signBtn).off('click'); $(signBtn).on('click', () => { let formPage = $('.epartner-dialog.uncertified-dialog').attr('frome-data'); sessionStorage.setItem('formLoadPersonalInfo', formPage); window.location.href = `${BASE_URL}/eplus/#/cn/group/personal-information-maintain-certified?menuLeftStyle=true`; }); $(closeIcon).off('click'); $(closeIcon).on('click', () => { closeDialog(); localStorage.setItem('isShowCertifiedTip', new Date().getTime()); }); }; uncertified.prototype.isTipsTimeout = function () { const tipsTime = localStorage.getItem('isShowCertifiedTip') || ''; if (tipsTime) { const currentDate = new Date(); const year = currentDate.getFullYear(); const month = currentDate.getMonth() + 1; const day = currentDate.getDate(); let startTime = new Date(`${year}-${month}-${day} 00:00:00`).getTime(); let timeDifference = Number(tipsTime) - startTime; return timeDifference < 0 || timeDifference >= 24 * 60 * 60 * 1000; } else { return true; } }; function downloadCnEApp() {} downloadCnEApp.prototype.init = function () { this.checkShow(); this.initEvent(); }; downloadCnEApp.prototype.checkShow = function () { const isWeLink = navigator.userAgent.includes('com.huawei.eplus') && navigator.userAgent.includes('HuaWei-AnyOffice'); const noAppDownload = getUrlValue('noAppDownload'); let isShowTip = false; if (isWeLink || noAppDownload === 'true') { isShowTip = false; } else { isShowTip = /Android|web0s|iPhone|iPad|iPod|BlackBerry|IEMobile|0pera Mini|Phone|Tablet/i.test(navigator.userAgent); } const downloadDom = $('.partner-tenant-meta-app-download'); if (isShowTip && downloadDom) { downloadDom.css('display', 'flex'); } }; downloadCnEApp.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'); 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.off('click'); closeDom.on('click', function () { downloadDom.css('display', 'none'); }); }; function cnBrowser() {} cnBrowser.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'); }); }; cnBrowser.prototype.checkBrowserVersion = function () { const system = {}; const userAgent = navigator.userAgent.toLowerCase(); const s = userAgent.match(/chrome\/([\d\.]+)/); system.chrome = s && s[1] ? s[1] : 0; if (system.chrome) { if (parseInt(s[1]) <= 70) { return true; } } else if (userAgent.indexOf('msie') > -1) { return true; } else { return false; } }; function protocolWebsite() { 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 = ''; } protocolWebsite.prototype.init = function () { this.getEsdDpPrivacyType(); }; protocolWebsite.prototype.getEsdDpPrivacyType = function () { const _this = 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) { _this.declarationNo = item.itemName; _this.querySignedPrivacyState(); } }); }, }); }; protocolWebsite.prototype.querySignedPrivacyState = function () { $.ajax({ type: 'GET', dataType: 'json', url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/privacy/signedPrivacyStatement?declarationNo=${this.declarationNo}`, success: resp => { if (resp && !resp.result) { this.openSignedPrivacyWebsiteDialog(); } }, }); }; protocolWebsite.prototype.openSignedPrivacyWebsiteDialog = function () { const content = ``; this.openDialog({ title: '关于华为e+Partner官网声明', content, cancelText: '不同意,退出', confirmText: '同意', type: 1, className: 'partner-official-website-dialog', }); }; protocolWebsite.prototype.openNoSignedNoticeDialog = function () { const content = ` 如您不同意《用户协议》,我们将无法为您提供本平台服务,若您需要继续使用该平台,请再次登录并选择同意。
`; this.openDialog({ title: '温馨提示', content, cancelText: '返回', confirmText: '确定', type: 0, className: 'partner-official-website-dialog' }); }; protocolWebsite.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 (minWidth) { dialog.style.minWidth = minWidth; } if (width) { dialog.style.width = width; } if (maxWidth) { dialog.style.maxWidth = maxWidth; } document.body.append(dialog); const headerDom = document.createElement('div'); headerDom.className = 'epartner-dialog-header p-dialog__header p-dialog__title'; const headerTitle = document.createElement('div'); if (type !== 1) { const icon = document.createElement('span'); icon.className = 'icon-warn'; icon.innerHTML = '!'; headerTitle.append(icon); } headerTitle.append(title); headerDom.append(headerTitle); dialog.append(headerDom); const body = document.createElement('div'); body.className = 'epartner-dialog-content p-dialog__body small-scrollbar'; body.innerHTML = content; dialog.append(body); const optionRow = document.createElement('div'); optionRow.className = 'epartner-dialog-opt-row p-dialog__footer p-button-group'; dialog.append(optionRow); const closeBtn = document.createElement('button'); closeBtn.className = 'p-button p-button--default'; closeBtn.innerText = cancelText; if (cancelText) { optionRow.append(closeBtn); } const confirmBtn = document.createElement('button'); confirmBtn.className = `p-button p-button--primary is-plain ${type === 1 && !this.acceptPersonalInfo ? 'is-disabled' : ''}`; confirmBtn.innerText = confirmText; optionRow.append(confirmBtn); this.createEvents({ confirmBtn, closeBtn, dialog, header: headerDom, body, types: type }); }; protocolWebsite.prototype.createEvents = function ({ confirmBtn, closeBtn, dialog, header, body, types }) { dialog.showModal(); $(body).scrollTop(0); const closeDialog = () => { dialog.className = `${this.dialogClassName} close`; setTimeout(() => { dialog.close(); dialog.removeEventListener('mousedown', startMove); }, 300); }; const startMove = dialogDragging({ $dialog: dialog, $header: header, closeDialog }); dialog.addEventListener('mousedown', startMove); $('.p-dialog').off('click'); $(confirmBtn).off('click'); $(confirmBtn).on('click', () => { if (types === 1) { if (this.acceptPersonalInfo) { closeDialog(); this.signedPrivacy(this.acceptMailInfo); } } else if (!types) { const logoutUrl = getLogoOutUrl(); window.location.href = logoutUrl; } else { closeDialog(); } }); $(closeBtn).off('click'); $(closeBtn).on('click', () => { closeDialog(); types ? this.openNoSignedNoticeDialog() : this.openSignedPrivacyWebsiteDialog(); }); $('.p-dialog').on('click', '.checkbox', e => { e.preventDefault(); const checkbox = $(e.currentTarget).find('.p-checkbox'); if (checkbox.hasClass('is-checked')) { checkbox.find('.p-checkbox__input').removeClass('is-checked'); checkbox.removeClass('is-checked'); this[checkbox.hasClass('mail-info') ? 'acceptMailInfo' : 'acceptPersonalInfo'] = false; } else { checkbox.find('.p-checkbox__input').addClass('is-checked'); checkbox.addClass('is-checked'); this[checkbox.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/#/cn/web/partner-privacy`); }); $('.p-dialog').on('click', '.user-agree', e => { window.open(`${BASE_URL}/eplus/#/cn/web/user-agree`); }); }; protocolWebsite.prototype.signedPrivacy = function (checkSubProtocol) { if (checkSubProtocol) { 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: resp => { if (resp && resp.result) { this.closeDialog(); } else { this.createWarnMessage(); } }, error: () => { this.createWarnMessage(); }, }); }; protocolWebsite.prototype.createOrCancelTemporarySigning = function () { const param = { isSigned: 'Y', }; $.ajax({ type: 'post', dataType: 'json', data: JSON.stringify(param), url: `${BASE_URL}${constants.E_PARTNER_SERVICE}/portal/v1/privacy/createOrCancelTemporarySigning`, }); }; protocolWebsite.prototype.createWarnMessage = function () { const content = ``; this.openDialog({ title: '提示', content, cancelText: '', confirmText: '确定', type: 3, width: '40%', minWidth: '150px', maxWidth: '400px' }); }; initAjaxSet(); initLogin(); initHeaderRightUserClickEvent(); initRegisterClickEvent(); new partnerHeader().init(); new partnerFooter().init(); new cnBrowser().init(); window.hwa && window.hwa('trackPageView', 'P988021629E26D0'); }); })(window, jQuery);