lp.js 2.1 KB
$(function(){
	
	changeBannerInit();

	function changeBannerInit(){

		var changeBannerFn = function(){
			var Config = {
		    }
		    var FunInit = function(){
		    	var now = new Date().getTime(),
		    		timeStart = Date.parse(Config.timeStart),
		    		timeEnd = Date.parse(Config.timeEnd),
		    		data = Config.data;

				if (now >= timeStart && now < timeEnd) {

					$('[data-changeimg]').each(function(i,e){
						$(this).attr('src',data[$(this).data('changeimg')]);
						$(this).bind('click',function(event){
                        	window.open('https://www.acadsoc.com.cn/lps/act2018/nov3.htm');
						})
					})

					$('[data-changebg]').each(function(i,e){
						$(this).css({
							'background-image':'url('+data[$(this).data('changebg')]+')',
							'height':500
						});
						$(this).bind('click',function(event){
                        	window.open('https://www.acadsoc.com.cn/lps/act2018/nov3.htm');
						});
					})

					$('[data-change=hide]').hide();
					$('[data-change=visiblehide]').css('visibility','hidden');

				}
		    }
		    return {
		    	init: function(option){
		            Config = $.extend(true, Config, option);
		            FunInit();
		    	}
		    }
		}();

		var changeData = {
			'banner':'https://img.acadsoc.com.cn/web/lps/activity/img/banners/DoubleEleven2018.jpg',
			'banner-logo':'https://img.acadsoc.com.cn/web/lps/activity/img/banners/DoubleEleven2018-logo.jpg',
			'banner-reg':'https://img.acadsoc.com.cn/web/lps/activity/img/banners/DoubleEleven2018-reg.jpg',
			'banner-reg-logo':'https://img.acadsoc.com.cn/web/lps/activity/img/banners/DoubleEleven2018-reg-logo.jpg',
			'banner-m':'https://img.acadsoc.com.cn/web/lps/activity/img/banners/DoubleEleven2018-m.jpg',
			'banner-m-logo':'https://img.acadsoc.com.cn/web/lps/activity/img/banners/DoubleEleven2018-m-logo.jpg',
			'banner-m-zh1':'https://img.acadsoc.com.cn/web/lps/activity/img/banners/DoubleEleven2018-m-zh1.png',
			'banner-m-hl':'https://img.acadsoc.com.cn/web/lps/activity/img/banners/DoubleEleven2018-m-hl.png'
		}

		changeBannerFn.init({
			timeStart: 'November 9, 2018 11:00:00',
			timeEnd: 'November 12, 2018 00:00:00',
			data: changeData
		})

	}

})