﻿
var appShop=new Object();


appShop.getProductPrice=function(strPrice,strDiscount)
{
	if (!dcs.common.isNumber(strDiscount)) strDiscount=100;
	var re=strPrice*strDiscount/100;
	re=dcs.common.toPrice(re);
	return re;
}

appShop.getProductDiscount=function(strDiscount)
{
	if (!dcs.common.isNumber(strDiscount)) strDiscount=100;
	strDiscount=strDiscount/10;
	var re="";
	if (strDiscount<10) re=strDiscount+"折";
	else re="不打折";
	return re;
}

appShop.getProductAmount=function(strAmount,strUnit)
{
	if (!dcs.common.isNumber(strAmount)) strAmount=0;
	var re="";
	if (strAmount<1) re="缺货";
	else if (strAmount==999999999) re="不限";
	else re=strAmount+strUnit;
	return re;
}

appShop.doCartCheck=function(strfrm)
{
	var err=new libError();
	if (strfrm.o_realname.value.length==0)
	{
		err.addItem("请输入收货人姓名！");
		strfrm.o_realname.focus();
	}
	if (strfrm.o_address.value.length==0)
	{
		err.addItem("请输入收货人具体地址！");
		strfrm.o_address.focus();
	}
	if (strfrm.o_postcode.value.length==0)
	{
		err.addItem("请输入邮政编码！");
		strfrm.o_postcode.focus();
	}
	if (strfrm.o_phone.value.length==0)
	{
		err.addItem("请输入联系电话！");
		strfrm.o_phone.focus();
	}
	if (strfrm.o_email.value.length==0)
	{
		err.addItem("请输入电子邮件！");
		strfrm.o_email.focus();
	}
	err.doPop();
	var re=err.isCheck();
	if (re)
	{
		re=window.confirm("您确定填写的收货信息准确无误吗？\n\n提交生成订单后将不可更改！");
	}
	return re;
}

appShop.toCartStatus=function(strNum)
{
	var re='';
	if (strNum>0) re='<font class=\"gray\">您已订购 <font class=\"total\">'+strNum+'</font> 件商品</font>';
	else re='<font class=\"gray\">您还没有订购商品</font>';
	return re;
}

appShop.getOrderPayable=function(strOrdernum,strPayable)
{
	re='';
	if (strPayable==1)
	{
		tmpURL=dcs.config.getURL("common")+"payment.asp?channel=shop&ordernum="+strOrdernum;
		re=' <a href="'+tmpURL+'" title="点击重新在线支付订单 '+strOrdernum+'">支付</a>';
	}
	return re;
}
