⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tpl_common.js

📁 产品简介: JEECSM是JavaEE版网站管理系统(Java Enterprise Edition Content Manage System)的简称。 ·基于java技术开发
💻 JS
字号:
Pn.ns('Pn.Cms', 'Pn.Cms.Shop');
/* 显示flash */
Pn.Cms.showFlash = function(str, wid, hei) {
	var fs = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0' width='"
			+ wid + "' height='" + hei + "'>";
	fs += "<param name='movie' value='" + str + "'>";
	fs += "<param name='wmode' value='transparent'>";
	fs += "<embed src='" + str;
	fs += "' quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"
			+ wid + "' height='" + hei + "'></embed></object>";
	document.write(fs);
}
/* 提交留言 */
Pn.Cms.saveMsg = function(base, callback) {
	base = base || '';
	$.postJson(base + '/msg/ajax/msgSave.do', {
		'ctg.id' : $('#msg_ctg_id').val(),
		'title' : $('#msg_title').val(),
		'content' : $('#msg_content').val(),
		'checkCode' : $('#msg_checkCode').val()
	}, function(data) {
		if (callback) {
			callback.apply(document, [data]);
		} else {
			alert(data.msg);
		}
		if (data.success) {
			location.reload();
		} else {
			$('#msg_checkCode_img').attr('src',
					base + '/check_code?d=' + new Date().getTime());
		}
	});
}
/* 检查用户是否被注册 */
Pn.Cms.checkRegister = function(base, callback) {
	if (!Pn.checkText('username', 4)) {
		alert('请输入用户名,且长度大于4!');
		return false;
	}
	base = base || '';
	$.postJson(base + '/jeecms/sys/ajax/checkUserName.do', {
		'username' : $('#username').val()
	}, function(data) {
		if (callback) {
			callback.apply(document, [data]);
		} else {
			if (data.success) {
				alert('该用户没有被注册,可以使用。');
			} else {
				alert('该用户名已经被使用,不能注册。');
			}
		}
	});
}
/* 找回密码 */
Pn.Cms.Shop.findPwd = function(base, callback) {
	if (!Pn.checkText('username', 4)) {
		alert('请输入用户名,且长度大于4!');
		return false;
	}
	base = base || '';
	$.postJson(base + '/login/ajax/FindPwd.do', {
		'loginName' : $('#username').val()
	}, function(data) {
		if (callback) {
			callback.apply(document, [data]);
		} else {
			alert(data.msg);
		}
	});
}
/* 商城AJAX登录 */
Pn.Cms.Shop.loginSubmit = function(base, callback) {
	base = base || '';
	$.postJson(base + '/jeeshop/ajax/LoginSubmit.do', {
		'username' : $('#username').val(),
		'password' : $('#password').val(),
		'checkCode' : $('#checkCode').val()
	}, function(data) {
		if (callback) {
			callback.apply(document, [data]);
		} else {
			if (!data.success) {
				alert(data.msg);
			}
		}
		if (data.success) {
			location.reload();
		} else {
			$('#msg_checkCode_img').attr('src',
					base + '/check_code?d=' + new Date().getTime());
		}
	});
}
/* 购物车 增加或减少商品 */
Pn.Cms.Shop.shoppingCart = function(base, productId, count, color) {
	count = count || $('#productCount').val();
	count = count || 1;
	if (color == null) {
		if ($('#scolor').val() == '') {
			alert('请选择颜色!');
			return;
		}
	}
	color = color || $('#scolor').val();
	color = color || '';
	var url = base + '/guest/shop/ShoppingCart.do?d=' + new Date().getTime();
	if (productId != null && productId > 0) {
		$.postJson(base + '/jeeshop/ajax/ShoppingCart.do', {
			'productId' : productId,
			'count' : count,
			'color' : color
		}, function(data) {
			var popup = window.open(url, "_jeeshop_shoppingCart");
		});
	}
	var popup = window.open(url, "_jeeshop_shoppingCart");
	popup.focus();
}
/* 购物车 删除项 */
Pn.Cms.Shop.removeItems = function(base, itemIdArr) {
	var itemIds;
	if (itemIdArr == null) {
		itemIds = new Array();
		$('input[@name=itemIds][@checked]').each(function(i) {
			itemIds[i] = $(this).val();
		});
	} else {
		itemIds = itemIdArr;
	}
	if (itemIds != null && itemIds.length > 0) {
		$.postJson(base + '/jeeshop/ajax/RemoveItems.do', {
			'itemIds' : itemIds
		}, function(data) {
			var url = base + '/guest/shop/ShoppingCart.do?d='
					+ new Date().getTime();
			var popup = window.open(url, "_jeecsm_shoppingCart");
		});
	} else {
		alert("请选择要删除的商品!");
	}
}
/* 购物车 */
Pn.Cms.Shop.shopping = function(base) {
	base = base || '';
	var color = $('#productColor').val();
	var size = $('#productSize').val();
	var count = $('#productCount').val();
	// 有颜色但未选择
	if (color != undefined && color == '') {
		alert("请选择颜色!");
		return;
	}
	// 有尺寸但未选择
	if (size != undefined && size == '') {
		alert("请选择尺寸!");
		return;
	}
	if (color == undefined && size == undefined) {
		Pn.Cms.Shop.shoppingCart(base, pid, count);
		return;
	} else if (color != undefined && size == undefined) {
		for (var i = 0;i < productList.length; i++) {
			if (color == productList[i].pcolor) {
				Pn.Cms.Shop.shoppingCart(base, productList[i].pid, count);
				return;
			}
		}
	} else if (color == undefined && size != undefined) {
		for (var i = 0;i < productList.length; i++) {
			if (size == productList[i].psize) {
				Pn.Cms.Shop.shoppingCart(base, productList[i].pid, count);
				return;
			}
		}
	} else if (color != undefined && size != undefined) {
		for (var i = 0;i < productList.length; i++) {
			if (size == productList[i].psize && color == productList[i].pcolor) {
				Pn.Cms.Shop.shoppingCart(base, productList[i].pid, count);
				return;
			}
		}
	} else {
		// never
	}
}
/**
 * 加入收藏夹
 */
Pn.Cms.Shop.addFavorites = function(base, productIdArr) {
	base = base || '';
	if (productIdArr == null) {
		productIdArr = new Array();
		$('input[@name=productIds][@checked]').each(function(i) {
			productIdArr[i] = $(this).val();
		});
	}
	if (productIdArr.length <= 0) {
		alert("请选择要加入收藏夹的商品!");
		return;
	}
	$.postJson(base + '/jeeshop/ajax/AddFavorites.do', {
		'ids' : productIdArr
	}, function(data) {
		if (data.success) {
			alert(data.msg);
		} else {
			alert(data.msg);
		}
	});
}
/**
 * 从收藏夹删除
 */
Pn.Cms.Shop.rmFavorites = function(base, productIdArr) {
	base = base || '';
	if (productIdArr == null) {
		productIdArr = new Array();
		$('input[@name=productIds][@checked]').each(function(i) {
			productIdArr[i] = $(this).val();
		});
	}
	if (productIdArr.length <= 0) {
		alert("请选择要加入收藏夹的商品!");
		return;
	}
	$.postJson(base + '/jeeshop/ajax/RmFavorites.do', {
		'ids' : productIdArr
	}, function(data) {
		if (data.success) {
			alert(data.msg);
			location.reload();
		} else {
			alert(data.msg);
		}
	});
}
/**
 * 商品比较
 */
Pn.Cms.Shop.compare = function(base, productIdArr) {
	base = base || '';
	if (productIdArr == null) {
		productIdArr = new Array();
		$('input[@name=productIds][@checked]').each(function(i) {
			productIdArr[i] = $(this).val();
		});
	}
	if (productIdArr.length <= 0) {
		alert("请选择要比较的商品!");
		return;
	}
	var url = base + "/jeeshop/Compare.do?";
	for (var i = 0;i < productIdArr.length; i++) {
		url += "ids=" + productIdArr[i] + "&";
	}
	url = url.substring(0, url.length - 1);
	window.open(url, "_jeeshop_compare");
}
/**
 * 删除汇退款记录
 */
Pn.Cms.Shop.rmShopFund = function(base, id) {
	if (id == null) {
		alert('ID不能为空');
	}
	$.postJson(base + '/jeeshop/ajax/RmShopFund.do', {
		'id' : id
	}, function(data) {
		if (data.success) {
			alert(data.msg);
			location.reload();
		} else {
			alert(data.msg);
		}
	});
}
/**
 * 发表商品评论
 */
Pn.Cms.Shop.comment = function(base) {
	base = base || '';
	var commentTitle = $('#commentTitle').val();
	var commentContent = $('#commentContent').val();
	var checkCode = $('#checkCodeComment').val();
	var productId = $('#productId').val();
	if (checkCode.length < 1) {
		alert('请填写验证码!');
		$('#checkCodeComment').focus();
		return false;
	}
	if (commentTitle.length < 5) {
		alert('标题内容不得少于5个字符!');
		return false;
	}
	$.postJson(base + '/jeeshop/ajax/ShopComment.do', {
		'commentTitle' : commentTitle,
		'commentContent' : commentContent,
		'checkCode' : checkCode,
		'productId' : productId
	}, function(data) {
		if (data.success) {
			alert(data.msg);
			location.reload();
		} else {
			alert(data.msg);
			$('#checkCodeImgComment')[0].src = base + '/check_code?d='
					+ new Date().getTime();
		}
	});
}
/**
 * 向上滚动js类
 */
Pn.Cms.UpRoller = function(rid, speed, isSleep, sleepTime, rollCount, rollSpan,
		unitHight) {
	this.speed = speed;
	this.rid = rid;
	this.isSleep = isSleep;
	this.sleepTime = sleepTime;
	this.rollCount = rollCount;
	this.rollSpan = rollSpan;
	this.unitHight = unitHight;
	this.proll = $('#p-roll-' + rid);
	this.prollOrig = $('#p-roll-orig-' + rid);
	this.prollCopy = $('#p-roll-copy-' + rid);
	// this.prollLine = $('#p-roll-line-'+rid);
	this.sleepCount = 0;
	this.prollCopy[0].innerHTML = this.prollOrig[0].innerHTML;
	var o = this;
	this.pevent = setInterval(function() {
		o.roll.call(o)
	}, this.speed);
}
Pn.Cms.UpRoller.prototype.roll = function() {
	if (this.proll[0].scrollTop > this.prollCopy[0].offsetHeight) {
		this.proll[0].scrollTop = this.rollSpan + 1;
	} else {
		if (this.proll[0].scrollTop % (this.unitHight * this.rollCount) == 0
				&& this.sleepCount <= this.sleepTime && this.isSleep) {
			this.sleepCount++;
			if (this.sleepCount >= this.sleepTime) {
				this.sleepCount = 0;
				this.proll[0].scrollTop += this.rollSpan;
			}
		} else {
			var modCount = (this.proll[0].scrollTop + this.rollSpan)
					% (this.unitHight * this.rollCount);
			if (modCount < this.rollSpan) {
				this.proll[0].scrollTop += this.rollSpan - modCount;
			} else {
				this.proll[0].scrollTop += this.rollSpan;
			}
		}
	}
}
Pn.Cms.LeftRoller = function(rid, speed, rollSpan) {
	this.rid = rid;
	this.speed = speed;
	this.rollSpan = rollSpan;
	this.proll = $('#p-roll-' + rid);
	this.prollOrig = $('#p-roll-orig-' + rid);
	this.prollCopy = $('#p-roll-copy-' + rid);
	this.prollCopy[0].innerHTML = this.prollOrig[0].innerHTML;
	var o = this;
	this.pevent = setInterval(function() {
		o.roll.call(o)
	}, this.speed);
}
Pn.Cms.LeftRoller.prototype.roll = function() {
	if (this.proll[0].scrollLeft > this.prollCopy[0].offsetWidth) {
		this.proll[0].scrollLeft = this.rollSpan + 1;
	} else {
		this.proll[0].scrollLeft += this.rollSpan;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -