function Com() { this.hostnames = { 'nj.shangceng.com.cn': '/weboms/Template/pc_web/statics/images/nj_wx_code.jpeg', } this.kf_hosts = { 'nj.shangceng.com.cn': { kf_url: 'https://tb.53kf.com/code/code/10145594/1', }, 'tj.shangceng.com.cn': { kf_url: 'https://tb.53kf.com/code/code/10120480/1', }, } this.hide_footer_hosts = 'nj.shangceng.com.cn,ns.shangceng.com.cn,bj.shangceng.com.cn' } Com.prototype.getspreadID = function (spreadID) { var spreadway = '' var filter = { code: spreadID, } $.ajaxSettings.async = false $.get('/api?url=' + encodeURIComponent('mk/anon/getSpreadCode') + '&data=' + encodeURIComponent(JSON.stringify(filter)), function (result) { if (result.res.status === 'success') { spreadway = result.res.resSpread[0].way || '' } }) return spreadway } Com.prototype.GetRequest = function (url) { var theRequest = new Object() if (url.indexOf('?') != -1) { var str = url.substr(1) strs = str.split('&') if (strs.length > 0) { for (var i = 0; i < strs.length; i++) { if (strs[i].split('=')[0]) { theRequest[strs[i].split('=')[0]] = unescape(strs[i].split('=')[1]) } } } } return theRequest } Com.prototype.search = function (site, page_name, title) { var path_url = window.location.href if (title === '') { if (path_url.indexOf('shangceng.com.cn') > -1 && path_url.indexOf('test.shangceng') == -1) { window.location.href = '/' + page_name + '/' + title } else { window.location.href = '/' + site + '/' + page_name + '/' + title } } else { if (path_url.indexOf('shangceng.com.cn') > -1 && path_url.indexOf('test.shangceng') == -1) { window.location.href = '/' + page_name + '/' + title } else { window.location.href = '/' + site + '/' + page_name + '/' + title + '/' } } } Com.prototype.addCookie = function (name, value, expiresHours, domainMain) { var cookieString = name + '=' + escape(value) //判断是否设置过期时间 if (expiresHours > 0) { var date = new Date() date.setTime(date.getTime + expiresHours * 3600 * 1000) if (domainMain.indexOf('shangceng.com.cn') > -1) { cookieString = cookieString + ';expires=' + date.toGMTString() + ';Path=/' + ';domain=.' + domainMain } else { cookieString = cookieString + ';expires=' + date.toGMTString() } } document.cookie = cookieString } Com.prototype.getCookie = function (name) { var strCookie = document.cookie var arrCookie = strCookie.split('; ') for (var i = 0; i < arrCookie.length; i++) { var arr = arrCookie[i].split('=') if (arr[0] == name) return arr[1] } return '' } Com.prototype.throttle = function (method, delay, duration) { var timer = null, begin = new Date() return function () { var context = this, args = arguments, current = new Date() clearTimeout(timer) if (current - begin >= duration) { method.apply(context, args) begin = current } else { timer = setTimeout(function () { method.apply(context, args) }, delay) } } } Com.prototype.runDom = function () { $(window).scroll(function () { var scrollTop = $(this).scrollTop() var offset_top = $('.process_box').offset().top var windowHeight = $(this).height() if (scrollTop + windowHeight > offset_top) { } }) } Com.prototype.set_wx_code = function () { var host_name = window.location.hostname host_name = host_name if (this.hostnames.hasOwnProperty(host_name)) { $('.bottom_price_center_modal').attr('src', this.hostnames[host_name]) $('.wx_qcode img').attr('src', this.hostnames[host_name]).width(101) $('.f_info_rt div').eq(0).find('img').attr('src', this.hostnames[host_name]).width(74) $('.f_info_rt div').eq(1).find('img').attr('src', this.hostnames[host_name]).width(74) } } Com.prototype.qiyuObj = function () { return { 'bj.shangceng.com.cn': { staffid: '3869565', groupid: '10309143', templateId: '10309143', }, 'ns.shangceng.com.cn': { staffid: '3868657', groupid: '397755629', templateId: '10301197', }, 'nj.shangceng.com.cn': { staffid: '3880639', groupid: '397753635', templateId: '10306188', }, } } Com.prototype.setSpaceTagUrl = function (arg, i) { let kj_cnum if (i) { kj_cnum = 'kj' + i.cnum.substring(2) + i.space_cnum.substring(1) } function remove(arrArg, value) { var newArr = [] for (var i of arrArg) { if (!(i.indexOf('kj') > -1)) { newArr.push(i) } } newArr.push(kj_cnum) return newArr } var args = (arg || '').split('_'), space_tag_url = '', space_tags = [] if (args[0]) { args.map((a, i) => { space_tag_url = remove(args, a).join('_') }) } if (!arg) { space_tag_url = kj_cnum } return (space_tag_url || '').replace(/\"/g, '') } Com.prototype.setUrl = function (site, search_value) { var host_url = window.location.hostname var url = '' if (host_url.indexOf('localhost') > -1) { url = 'http://localhost:3000/' + site + search_value } else if (host_url.indexOf('test') > -1) { url = 'http://test.shangceng.com.cn:8052/' + site + search_value } else { url = search_value } return url } Com.prototype.serializeJson = function () { $.fn.serializeJson = function () { var serializeObj = {} var array = this.serializeArray() var str = this.serialize() $(array).each(function () { if (serializeObj[this.name]) { if ($.isArray(serializeObj[this.name])) { serializeObj[this.name].push(this.value) } else { serializeObj[this.name] = [serializeObj[this.name], this.value] } } else { serializeObj[this.name] = this.value } }) return serializeObj } } Com.prototype.defaultPlaceholder = function () { $("input[name='name']").attr('placeholder', '请输入您的姓名') $("input[name='reservation_phone']").attr('placeholder', '输入手机号,稍后会有客服人员和您详细沟通') $("input[name='phone']").attr('placeholder', '请输入您的手机号') $("input[name='from']").attr('placeholder', '请输入您的楼盘名称') $("input[name='area']").attr('placeholder', '请输入您的房屋面积') } Com.prototype.clearFooter = function () { var host_name = window.location.hostname if (this.hide_footer_hosts.indexOf(host_name) > -1) { $('.introduction_box').hide() $('.footer_box').hide() } } //设置旧网站客服功能 Com.prototype.setCustomerServer = function () { var host_name = window.location.hostname if (this.kf_hosts.hasOwnProperty(host_name)) { $('#div_company_mini').addClass('hide') $('.customer_service_box').addClass('old_customer_server') $('.old_customer_server').removeClass('customer_service_box') var _53code = document.createElement('script') _53code.src = this.kf_hosts[host_name].kf_url var s = document.getElementsByTagName('script')[0] s.parentNode.insertBefore(_53code, s) function oldCustomerServer() { var api = $53.createApi() $('.old_customer_server') .unbind('click') .on('click', function () { $('#div_company_mini').removeClass('hide') api.push('cmd', 'kfclient') api.push('type', 'popup') api.query() }) } setTimeout(oldCustomerServer, 2000) } } function chkForm2() { var obj = document.getElementById('frm2') if (!/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test($('#shouji2').val())) { alert('请输入正确的手机号码') return false } subForm2() } function subForm2() { $.ajax({ type: 'POST', url: $('#frm2').attr('action'), data: $('#frm2').serialize(), success: function (msg) { msg = eval('(' + msg + ')') if (msg.status == 1) { alert('感谢您的留言,我们会尽快联系您!') window.location.reload() } else { alert(msg.txt) } }, }) } // (function(doc, win) { // // var docEl = doc.documentElement, // var docEl =doc.documentElement, // docElCur = document.getElementsByClassName('pop-ups'), // resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize', // recalc = function() { // var clientWidth = docEl.clientWidth; // if (!clientWidth) return; // if (clientWidth >= 2560) { // docElCur[0].style.fontSize = '200px'; // } else if (clientWidth <= 640) { // docElCur[0].style.fontSize = '32px'; // } else { // console.log('*****'); // docElCur[0].style.fontSize = 100 * (clientWidth / 1920) + 'px'; // 1rem = 100px // } // }; // if (!doc.addEventListener) return; // win.addEventListener(resizeEvt, recalc, false); // doc.addEventListener('DOMContentLoaded', recalc, false); // })(document, window);