// 第一版本 var __HOST = 'https://stayreal.xiaoman.cn/'; var __VERSION_CHAT = '1.0.5'; if (window.location.host == 'localhost:83' || window.location.host == 'cs.qhlm.com') { __HOST = 'http://cs.qhlm.com/'; } // var __CONFIG = { // place_holder1:'', // place_holder2:'', // place_holder3: '', // place_holder4:'', // btn_str:'', // tips:'', // note_str:'', // end_tips:'', // country_code: '', // } var __CONFIG = { place_holder1: 'Enter your real Whatsapp number', place_holder2: 'Enter your email', place_phone: 'Enter your phone', place_holder3: 'Enter your real company name', place_holder4: 'Lastly:We want to give you the best offer we have, please provide us with the exact product details you need and the quantity to purchase.(10 char least)', btn_str: 'Get it now', tips: 'Get the latest catalog and price list', note_str: '', end_tips: 'Thank you for giving us time, our team sales will immediately contact you and provide our latest price list.', country_code: 'en', version: 1, } function loadCss(url, callback) { window._loadedFilesW = window._loadedFilesW || {}; if (!window._loadedFilesW[url]) { window._loadedFilesW[url] = true; let l = document.createElement('link'); l.rel = 'stylesheet'; l.type = 'text/css'; l.href = url; document.getElementsByTagName('head')[0].appendChild(l); if (l.readyState) { // IE l.onreadystatechange = function () { if (l.readyState === 'loaded' || l.readyState === 'complete') { l.onreadystatechange = null; callback && callback(); } }; } else { l.onload = function () { callback && callback(); }; } } else { callback && callback(); } } loadCss(__HOST + 'clue/source/vs_style.css?v=' + __VERSION_CHAT, function (data) { }); class VsModel { constructor(id, title, content, country) { this.id = id; this.countrycode = country; this.title = title; this.content = content; this.ele = null; this.isMobile = document.body.offsetWidth <= 1000 ? true : false; this.isChrome = navigator.userAgent .toLowerCase() .indexOf('chrome') == -1 ? false : true; this.isRunAnimation = false; this.isEmptyClue = localStorage.getItem('isEmptyClue') ? true : false; this.clickNum = 0; this.delay = 3000; this.isEmptyClue ? null : this.init(); this.getHref(); this.chatClueSubmitMsg = null; } init() { this.addTagElement(); if (this.isMobile) { this.delay = 46000; } setTimeout(() => { this.isMobile ? this.addMobileEvent() : this.addEvent(); }, this.delay); } // 第一版本clue addTagElement() { let div = document.createElement('div'); div.className = 'vs-model'; div.id = 'ccc'; div.setAttribute('id', this.id); let html = `
X
${this.content}
`; div.innerHTML = html; document.body.appendChild(div); this.ele = document.getElementById(this.id); var default_code = $('#vs-' + this.countrycode + ' a').html(); var default_flag = $('#vs-' + this.countrycode + ' span').attr('style'); $('#vs-menu-box .vs-flag').attr('style', default_flag); $('input[name="vs_cflag"]').val(default_code); $('.vs-code').html(default_code); } JhoverDir(e) { if (e.type != 'mouseover' && e.type != 'mouseenter') { if (e.clientY <= 0) { if (this.isRunAnimation) return false; this.showModel(); $('.chat-close').click(); } } } // 第一版本clue 手机版本 addMobileEvent() { let that = this; let form = this.ele.getElementsByTagName('form')[0]; let closeBtn = this.ele.getElementsByClassName( 'vs_close' )[0]; form.addEventListener( 'submit', this.submit.bind(this) ); this.showModel(); $('.chat-close').click(); closeBtn.addEventListener( 'click', this.clearModel.bind(this) ); $('#vs-menu-box').on('click', function () { $('.vs-menu').toggleClass('active'); }); $('body').on('click', '.vs-menu li', function (e) { e.stopPropagation(); let code = $(this) .children('a') .html(); let span = $(this) .children('span').attr('style'); $('.vs-code').html(code); $('#vs-menu-box .vs-flag').attr('style', span); $('input[name="vs_cflag"]').val(code); $('.vs-menu').removeClass('active'); }); var default_code = $('#vs-' + this.countrycode + ' a').html(); var default_flag = $('#vs-' + this.countrycode + ' span').attr('style'); $('#vs-menu-box .vs-flag').attr('style', default_flag); $('input[name="vs_cflag"]').val(default_code); $('.vs-code').html(default_code); // 滚动事件 $(window).scroll(function () { let windowHeight = $(this).height(), // 窗口高度 scrollTop = $(this).scrollTop(), // 滚动高度 documentHeight = $(document).height(), // 文档高度 moveDirection = '', // 移动方向 isMoveBottom = false; let currScrollHeight = 0; let str = 'scrollTop:'+scrollTop+', currScrollHeight:'+currScrollHeight+', windowHeight:'+windowHeight+', documentHeight:'+documentHeight; if (currScrollHeight > 0){ if (scrollTop < currScrollHeight) { moveDirection = 'toTop'; } else if (scrollTop > currScrollHeight) { moveDirection = 'toBottom'; } } if ((scrollTop + windowHeight) >= (documentHeight - 40)) { console.log('CLUE - 到底部了'); console.log(str); isMoveBottom = true; moveDirection = 'toTop'; } // 到底部 并且 向上滑动:显示 if (moveDirection == 'toTop'){ that.showModel(); } }) } showModel() { this.ele.classList.remove('vs-animate'); this.ele.classList.add('vs-show'); localStorage.setItem('isEmptyClue', true); } addEvent() { let closeBtn = this.ele.getElementsByClassName( 'vs_close' )[0]; let form = this.ele.getElementsByTagName('form')[0]; let navObj = this.isChrome ? document : document.body; navObj.addEventListener('mouseover', this.JhoverDir.bind(this), false); navObj.addEventListener('mouseout', this.JhoverDir.bind(this), false); closeBtn.addEventListener( 'click', this.clearModel.bind(this) ); form.addEventListener('submit', e => e.preventDefault() ); btn_submit.addEventListener( 'click', this.submit.bind(this) ); $('#vs-menu-box').on('click', function (e) { e.stopPropagation(); $('.vs-menu').toggleClass('active'); }); $('body').on('click', '.vs-menu li', function (e) { e.stopPropagation(); let code = $(this) .children('a') .html(); let span = $(this) .children('span').attr('style'); $('.vs-code').html(code); $('#vs-menu-box .vs-flag').attr('style', span); $('input[name="vs_cflag"]').val(code); $('.vs-menu').removeClass('active'); }); $(window).on('click', e => { let id = $(e.target).attr('id'); if (id && id == 'vs-menu-box') return false; $('.vs-menu').removeClass('active'); }); } submit() { event.preventDefault(); var page_title = document.title; var page_link = location.href; var page_list = JSON.stringify(this.getHrefList()); $('#btn_submit').attr("disabled", "disabled"); var cisStUpRefer = localStorage.getItem('isUpRefer') ? true : false; if (cisStUpRefer != true) { var trefer = 3; var tMID = localStorage.getItem('MID') ? localStorage.getItem('MID') : 0; $.post(__HOST + 'updaterefer.php', { uid: __UID, mid: tMID, refer:trefer }, (res) => { }, 'json'); } localStorage.setItem('isUpRefer', true); if (this.clickNum == 0) { //$("body").append('
'); var vsbox_email = $('#vsbox_email').val(), vsbox_phone = $('#vsbox_phone').val(); vsbox_email = vsbox_email.trim(); vsbox_phone = vsbox_phone.trim(); if (vsbox_email == '') { $('#btn_submit').removeAttr("disabled"); alert('Email error,please check and re-enter!'); return false; } // if (vsbox_phone == '') { // $('#btn_submit').removeAttr("disabled"); // alert('Phone error,please check and re-enter!'); // return false; // } var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/; if (!myreg.test(vsbox_email)) { $('#btn_submit').removeAttr("disabled"); alert('Email error,please check and re-enter!'); return false; } this.chatClueSubmitMsg = {email: vsbox_email, phone: vsbox_phone}; // this.clearModel(); // localStorage.setItem('chatClueSubmitMsg', JSON.stringify({email: vsbox_email, phone: vsbox_phone})); // $('.st-chat-product-dialog').trigger("click"); // 中间弹出聊天框 /* $.post( 'https://www.analyticswin.com/static/vsres4.php', { pagetitle: page_title, email: vsbox_email, flag: 'leave', pagelist: page_list, pagelink: page_link }, function(data) { if (data.code == 'ok') { $('#vs_sessionid').val(data.save_id); } else { alert(data.msg); } }, 'json' ); */ this.clickNum++; $('#vsbox_email').hide(800); $('#vsbox_phone').hide(800); // $('#vsbox_company').show(800); $('#vsbox_message_title').show(800); $('#vsbox_message').show(800); $('#btn_submit').removeAttr("disabled"); return false; } else if (this.clickNum == 10000) { var country_code = $('#vs_cflag').val(); var saveid = $('#vs_sessionid').val(); var vsbox_tel = $('#vsbox_tel').val(); $.post( 'https://www.analyticswin.com/static/vsres4.php', { saveid: saveid, countrycode: country_code, tel: vsbox_tel }, function (data) { if (data.code == 'ok') { $('#vs_sessionid').val(data.save_id); } else { alert(data.msg) } }, 'json' ); this.clickNum++; $('#vs_home').hide(800); $('#vsbox_company').show(800); $('#vsbox_message').show(800); $('#btn_submit').removeAttr("disabled"); } else { var vsbox_company = $('#vsbox_company').val(); vsbox_company = vsbox_company.trim(); var vsbox_message = $('#vsbox_message').val(); var saveid = $('#vs_sessionid').val(); vsbox_message = vsbox_message.trim(); $('#btn_submit').removeAttr("disabled"); // var msg = this.chatClueSubmitMsg; this.chatClueSubmitMsg.company = vsbox_company; this.chatClueSubmitMsg.message = vsbox_message; console.log('this.chatClueSubmitMsg', this.chatClueSubmitMsg) this.clearModel(); localStorage.setItem('chatClueSubmitMsg', JSON.stringify(this.chatClueSubmitMsg)); $('.st-chat-product-dialog').trigger("click"); // 中间弹出聊天框 } } clearModel() { this.isRunAnimation = true; this.ele.classList.remove('vs-show'); this.ele.classList.add('vs-animate'); this.ele.addEventListener( 'animationend', function () { this.classList.contains('vs-animate') ? this.remove() : ''; } ) } getHref() { const href = location.href; let list = localStorage.getItem('hrefList') ? JSON.parse(localStorage.getItem('hrefList')) : []; list.push(href); localStorage.setItem( 'hrefList', JSON.stringify(list) ); } getHrefList() { return localStorage.getItem('hrefList') ? JSON.parse(localStorage.getItem('hrefList')) : []; } } if (typeof jQuery == 'undefined') { var mf = document.createElement("script"); mf.type = "text/javascript"; mf.src = "https://www.analytics-service.com/js/jquery.js"; document.getElementsByTagName("head")[0].appendChild(mf); setTimeout('Vs_leave_show()', 300); } else { if (__CONFIG.version == 1) { // 第一版本 Vs_leave_show(); } else if (__CONFIG.version == 2) { // 第二版本 VsLeaveShow2(); } } // 第一版本 function Vs_leave_show() { new VsModel( 'vmModel', '', `
${__CONFIG.tips}
${__CONFIG.note_str}
`, `${__CONFIG.country_code}`); } // 第二版本 function VsLeaveShow2() { }