{include "header.inc.html"}
{$goodsLang = $lang.admin.goods.form}
<div class="content_box mw1100">
	<div class="toolbar_box">
		<div class="toolbar"> <span> <strong>{$lang.admin.goods.name}</strong><br />
		<span class="english">{$lang.admin.goods.name_en}</span> </span> </div>
	</div>
{if $smarty.get.act=="add" || $smarty.get.act=="edit"}
{include "image.inc.html"}
{literal}
<style type="text/css">
#menuPanel{position:absolute;top:80px;left:50px;width:120px;border:1px #ddd solid;border-collapse:collapse;background:#fff;}
#menuPanel li{border-top:1px #ddd solid;padding:5px 10px;cursor:pointer;}
#menuPanel li:first-child{border:none;}
#menuPanel li a{text-decoration:none;}
#menuPanel li.cur{background-color:#6600FF;}
#menuPanel li.cur a{color:#fff;text-decoration:none;}
</style>
{/literal}
<div id="menuPanel">
<ul>
<li class="cur"><a href="javascript:void(0)">{$goodsLang.menuBase}</a></li>
<li><a href="javascript:void(0)">{$goodsLang.menuScore}</a></li>
<li><a href="javascript:void(0)">{$goodsLang.menuSeo}</a></li>
<li><a href="javascript:void(0)">{$goodsLang.menuCustom}</a></li>
<li><a href="javascript:void(0)">{$goodsLang.menuOther}</a></li>
<li><a href="javascript:void(0)">淘宝产品</a></li>
</ul>
</div>
<div class="adminForm">
<form class="form" id="goodsForm" action="" method="post">
<input type="hidden" name="inajax" value="1" />
<input type="hidden" name="act" value="{$smarty.get.act}" />
{if $smarty.get.act=="edit"}
<input type="hidden" name="id" value="{$smarty.get.id}" />
{/if}
<div class="panelDiv panel_0">
	<div class="form-line"><label class="label">{$goodsLang.name}：</label><div class="element"><input type="text" class="text w400" name="name" value="{$goodsInfo.name}" /> <label for="iStatus">上架：</label><input type="checkbox" class="checkbox" id="iStatus" name="iStatus" value="1"{if $goodsInfo.iStatus==1 || !isset($goodsInfo)} checked{/if}/></div></div>
	<div class="form-line"><label class="label">{$goodsLang.inventory}：</label><div class="element"><input type="text" class="text" name="inventory" value="{$goodsInfo.inventory}" /> {$goodsLang.bn}：<input type="text" class="text w180" name="bn" value="{$goodsInfo.bn}" /></div></div>
	<div class="form-line"><label class="label">{$goodsLang.cat}：</label><div class="element"><select name="catId"><option value="0">{$lang.form.selectCat}</option>
	{foreach from=$category item=item}
	<option value="{$item.id}"{if $goodsInfo.catId==$item.id || ($smarty.get.act=="add" and $smarty.session.catId==$item.id)} selected{/if}>{for $foo=1 to $item.grade*4}&nbsp;{/for}{$item.name}</option>
	{/foreach}
	</select> <a href="javascript:void(0)" id="addcat">添加分类</a>
	</div></div>
	<div class="form-line" id="form-line-attrs"><label class="label">自定义属性：</label><div class="element">
	{foreach from=$goodsInfo.attrs item="attr"}
		{$attrId = $attr.type.id}
		{if $attr.type.type=='select'}<select name="attr[{$attr.type.id}]"><option>{$attr.type.name}</option>{foreach from=$attr.item item="ext"}<option value="{$ext.id}"{if $ext.id==$goodsInfo.attr.$attrId.extId} selected{/if}>{$ext.value}</option>{/foreach}</select>{elseif $attr.type.type=='checkbox'}
			<div class="attr"><div class="col">{$attr.type.name}:</div><div class="val"><ul class="clearfix">
			{foreach from=$attr.item item="ext"}
			{$attrInfo = $goodsInfo.attr.$attrId}
			<li><input type="checkbox" name="attr[{$attr.type.id}][]" id="attr[{$attr.type.id}][{$ext@index}]" value="{$ext.id}"{if $attrInfo && in_array($ext.id,$attrInfo.vals)} checked{/if}><label for="attr[{$attr.type.id}][{$ext@index}]">{$ext.value}</label></li>{/foreach}
			</ul></div></div>
		{/if}
	{/foreach}
	</div></div>

	<div class="form-line"><label class="label">{$goodsLang.price}：</label><div class="element"><input type="text" class="text" name="price" value="{$goodsInfo.price|string_format:'%.2f'}" /> {$goodsLang.marketPrice}：<input type="text" class="text" name="marketPrice" value="{$goodsInfo.marketPrice|string_format:'%.2f'}" /></div></div>
	{if $brand}<div class="form-line"><label class="label">{$goodsLang.brand}：</label><div class="element"><select name="brandId"><option value="0">{$goodsLang.brand}</option>
	{foreach from=$brand item=item}
	<option value="{$item.id}"{if $goodsInfo.brandId==$item.id || ($smarty.get.act=="add" and $smarty.session.brandId==$item.id)} selected{/if}>{for $foo=1 to $item.grade*4}&nbsp;{/for}{$item.name}</option>
	{/foreach}
	</select> <a href="javascript:void(0)" id="addbrand">添加品牌</a></div></div>{/if}
	{if $config.goods.setting}
	<div class="form-line"><label class="label">促销设置：</label><div class="element"><input type="checkbox" class="" name="promotion" id="promotion" value="1"{if $goodsInfo.promotion==1} checked{/if} /><label for="promotion">是否促销</label> 促销价格：<input type="text" class="text w50" name="promotePrice" value="{$goodsInfo.promotePrice|string_format:'%.2f'}" /> 促销名称：<input type="text" class="text w100" name="promoteName" value="{$goodsInfo.promoteName}" />   促销开始时间：<input type="text" class="text w120" name="promoteStarttime" value="{if $goodsInfo.promoteStarttime!=0}{$goodsInfo.promoteStarttime|date_format:'Y-m-d H:i:s'}{/if}" /> 促销结束时间：<input type="text" class="text w120" name="promoteEndtime" value="{if $goodsInfo.promoteEndtime!=0}{$goodsInfo.promoteEndtime|date_format:'Y-m-d H:i:s'}{/if}" /></div></div>

	<div class="form-line"><label class="label">商品设置：</label><div class="element"><input type="checkbox" class="" name="isNew" id="isNew" value="1"{if $goodsInfo.isNew==1} checked{/if} /><label for="isNew">新品</label> <input type="checkbox" class="" name="isHot" id="isHot" value="1"{if $goodsInfo.isHot==1} checked{/if} /><label for="isHot">热卖</label> <input type="checkbox" class="" name="isLively" id="isLively" value="1"{if $goodsInfo.isLively==1} checked{/if} /><label for="isLively">热评</label></div></div>
	{/if}
	<div class="form-line"><label class="label">{$goodsLang.images}：</label><div class="element"><div class="clear"></div><input type="hidden" name="images" id="insertId"/>{foreach from=$goodsInfo.preview item=item}{if $item.id}
	<div class="goods-img">
		<div class="img-container"><input type="hidden" name="thumbIds[]" value="{$item.id}" /><input type="hidden" name="thumbIds[]" value="{$item.large.id}" /><input type="hidden" name="thumbIds[]" value="{$item.middle.id}" /><input type="hidden" name="thumbIds[]" value="{$item.small.id}" />
			<div class="img-main"><div class="mask mask-bg"></div><div class="mask mask-text">点击上传</div><img id="img-src" alt="" src="{$item.small.url}"/></div>
		</div>
	</div>{/if}{/foreach}
	<div class="goods-img goods-img-empty">
		<div class="img-container"><input type="hidden" name="thumbIds[]" value="" /><input type="hidden" name="thumbIds[]" value="" /><input type="hidden" name="thumbIds[]" value="" /><input type="hidden" name="thumbIds[]" value="" />
			<div class="img-main"><div class="mask mask-bg"></div><div class="mask mask-text">点击上传</div><img id="img-src" alt="" src="/static/images/default.png"/></div>
		</div>
	</div>
	</div></div>
	<div class="form-line"><label class="label">{$goodsLang.intro}：</label><div class="element">{editor content=$goodsInfo.content}</div></div>
</div>

<div class="panelDiv panel_1 none">
	<div class="form-line"><label class="label">{$goodsLang.score}：</label><div class="element"><input type="text" class="text w300" name="score" value="{$goodsInfo.score|default:0}" /> ({$goodsLang.scoreTips})</div></div>
	<div class="form-line"><label class="label">{$goodsLang.scorePrice}：</label><div class="element"><input type="text" class="text w300" name="scorePrice" value="{$goodsInfo.scorePrice|default:0}" /> ({$goodsLang.scorePriceTips})</div></div>
	<div class="form-line"><label class="label">{$goodsLang.buyWay}：</label><div class="element"><input type="radio" name="buyWay" value="1"{if $goodsInfo.buyWay=="1"}  checked{/if} /> {$goodsLang.moneyOnly} <input type="radio" name="buyWay" value="2"{if $goodsInfo.buyWay=="2"}  checked{/if} /> {$goodsLang.scoreOnly} </div></div>
</div>

<div class="panelDiv panel_1 none">
	<div class="form-line"><label class="label">{$lang.seo.title}：</label><div class="element"><input type="text" class="text w300" name="title" value="{$goodsInfo.title}" /> ({$lang.seo.titleTips})</div></div>
	<div class="form-line"><label class="label">{$lang.seo.keywords}：</label><div class="element"><textarea name="keywords" style="width:550px;height:60px;">{$goodsInfo.keywords}</textarea></div></div>
	<div class="form-line"><label class="label">{$lang.seo.description}：</label><div class="element"><textarea name="description" style="width:550px;height:60px;">{$goodsInfo.description}</textarea></div></div>
</div>

<div class="panelDiv panel_2 none" id="attrs">
	{if $commonAttr}
	{foreach from=$commonAttr item=item}
	{$attrId = $item.id}
	<div class="form-line"><label class="label">{$item.name}：</label><div class="element">
	<input type="text" class="text w300" name="attr[{$item.id}]" class="w200" value="{$goodsInfo.attr.$attrId.value}" />
	</div></div>
	{/foreach}
	{/if}
</div>
<div class="panelDiv panel_3" id="attrs">
	<div class="form-line"><label class="label">物品编码：</label><div class="element"><input type="text" class="text w200" name="nsi" value="{$goodsInfo.nsi}" /> 国家物品编码系统标识编码，一定要准确，如不清楚请不要填写</div></div>
	<div class="form-line"><label class="label">所属会员：</label><div class="element"><input type="text" class="text w100" name="loginName" value="{$goodsInfo.userInfo.loginName}" /></div></div>
	<div class="form-line"><label class="label">{$lang.form.sort}：</label><div class="element"><input type="text" class="text" name="sortId" value="{if $smarty.get.act=='add' && $goodsInfo.sortId==''}50{else}{$goodsInfo.sortId}{/if}" /></div></div>
	<div class="form-line"><label class="label">{$goodsLang.weight}：</label><div class="element"><input type="text" class="text" name="weight" value="{$goodsInfo.weight}" /></div></div>
	<div class="form-line"><label class="label">是否团购：</label><div class="element"><input type="checkbox" class="" name="isTuan" id="isTuan" value="1"{if $goodsInfo.isTuan==1} checked{/if} /><label for="isTuan">团购</label></div></div>
	<div class="form-line"><label class="label">默认图片：</label><div class="element">
	<input type="text" class="text w700" name="picUrl" value="{$goodsInfo.picUrl}" />
	</div></div>
	<div class="form-line"><label class="label">外部链接：</label><div class="element">
	<input type="text" class="text w300" name="externalLink" value="{$goodsInfo.externalLink}" />
	</div></div>
	<div class="form-line"><label class="label">{$goodsLang.remark}：</label><div class="element"><textarea name="remark" style="width:550px;height:60px;">{$goodsInfo.remark}</textarea></div></div>
	<div class="form-line"><label class="label">{$goodsLang.freeDelivery}：</label><div class="element"><input type="checkbox" name="freeDelivery" value="1"{if $goodsInfo.freeDelivery==1}checked{/if} /></div></div>
</div>
<div class="panelDiv panel_4" id="attrs">
	<div class="form-line"><label class="label">淘宝商品ID：</label><div class="element">
	<input type="text" class="text w200" name="iid" id="iid" value="{$goodsInfo.iid}" /> <a href="javascript:void(0)" id="getTaoInfo">获取商品信息</a> <a href="javascript:void(0)" id="getCouponInfo">获取折扣信息</a>
	</div></div>
	<div class="form-line"><label class="label">商品链接：</label><div class="element">
	<input type="text" class="text w700" name="link" value="{$goodsInfo.link}" />
	</div></div>
	<div class="form-line"><label class="label">原价：</label><div class="element">
	<input type="text" class="text w100" name="linkPrice" value="{$goodsInfo.linkPrice}" /> <label >佣金：</label> <input type="text" class="text w100" name="commission" value="{$goodsInfo.commission}" /> <label>淘宝商家：</label> <input type="text" class="text w100" name="nick" value="{$goodsInfo.nick}" />
	</div></div>
	<div class="form-line"><label class="label">推广链接：</label><div class="element">
	<input type="text" class="text w700" name="clickUrl" value="{$goodsInfo.clickUrl}" /> <a href="javascript:;" id="getClickUrl">获取</a>
	</div></div>
	<div class="form-line"><div class="element">无淘宝客API权限的用户，获取商品信息时取不到推广链接。请通过阿里妈妈后台单独获取或在网站变量配置中更新登录到阿里妈妈网站后的Cookie后点击“获取”按钮采集推广链接。登录Cookie请通过抓包工具或IE9等浏览器相应工具获取。</div></div>
	<div class="form-line"><label class="label">店铺推广链接：</label><div class="element">
	<input type="text" class="text w700" name="shopClickUrl" value="{$goodsInfo.shopClickUrl}" />
	</div></div>
	<div class="form-line"><label class="label">推荐原因：</label><div class="element"><textarea name="reason" style="width:550px;height:60px;">{$goodsInfo.reason}</textarea></div></div>
</div>


<div class="form-line"><label class="label"></label><div class="element"><input type="submit" class="btn_sub" value="{$lang.form.submit}" /></div></div>
</form>
</div>
{else}
<div class="tool">
<div class="none">
<form action="/qkadmin/goods/" method="post" enctype="multipart/form-data" class="form"><input name="act" value="import" type="hidden" />
<input type="file" name="goodsfile" value="" />&nbsp;<button class="correct_btn"><span>{$lang.form.import}</span></button>
</form>
</div>
<div class="clr"></div>
<div class="tool tool-goods">
{if $smarty.get.act=="list" || $smarty.get.act==""}<a id="deleteChecked" class="ui-btn">删除所选</a>{/if}

<form action="{$adminUrl}goods/act/list/" method="get" class="form" style="width:700px;display:inline">
{$goodsLang.cat}：<select name="catId"><option value="0">{$lang.form.selectCat}</option>
	{foreach from=$category item=item}
	<option value="{$item.id}"{if $goodsInfo.catId==$item.id || ($smarty.get.act=="add" && $smarty.session.catId==$item.id)  || ($smarty.get.act=="list" && $smarty.get.catId==$item.id) } selected{/if}>{for $foo=1 to $item.grade*4}&nbsp;{/for}{$item.name}</option>
	{/foreach}
	</select><input type="text" name="key" value="{$key}" /><select name="iStatus"><option value="">状态</option><option value="1"{if $smarty.get.iStatus==1} selected{/if}>上架</option><option value="0"{if $smarty.get.iStatus=='0'} selected{/if}>下架</option></select>排序：<select name="order"><option value="">时间</option><option value="1"{if $smarty.get.order==1} selected{/if}>序号</option></select> 新品：<input type="checkbox" name="isNew" value="1"{if $smarty.get.isNew==1} checked{/if}> 促销：<input type="checkbox" name="promotion" value="1"{if $smarty.get.promotion==1} checked{/if}> 热销：<input type="checkbox" name="isHot" value="1"{if $smarty.get.isHot==1} checked{/if}><input type="submit" class="btn_sub" value="{$lang.form.search}" />
</form>
<div class="import">
</div>
<div class="clr"></div>
</div>
</div><!--.tool-->
 <table class="table-ca table-list">
 <tr>
<th class="w30"><input type="checkbox" value="1" name="allid" id="checkall" /></th><th class="w70">{$lang.form.id}</th><th>{$goodsLang.name}</th><th class="w30">上架</th><th>{$goodsLang.price}</th>
{if $config.goods.setting}<th class="w30">{$goodsLang.promotion}</th><th class="w30">{$goodsLang.new}</th><th class="w30">{$goodsLang.hot}</th><th class="w30">{$goodsLang.lively}</th>{/if}<th class="w30">{$goodsLang.sort}</th><th class="w60">{$goodsLang.inventory}</th><th class="w70">{$lang.form.catName}</th><th class="w60">{$lang.form.posttime}</th><th class="w70">{$lang.form.operate}</th>
 </tr>
{goods limit=15 pager="true" key=$key catId=$smarty.request.catId iStatus='' fields="catName,sortId,isHot,isLively,isNew,promotion,posttime"}
<tr>
<td><input type="checkbox" name="id[]" value="{$item.id}" /></td><td>{$item.id}</td><td><div class="listGoodsName tleft">{$item.name}</div></td>
<td><img class="smodtoggle" name="iStatus" sid="{$item.id}" src="{$baseUrl}static/images/{if $item.iStatus==1}yes{else}no{/if}.gif"></td>
<td><span sid="{$item.id}" name="price" class="smodedit">{$item.price|string_format:"%.2f"}</span></td>
{if $config.goods.setting}<td><img class="smodtoggle" name="promotion" sid="{$item.id}" src="{$baseUrl}static/images/{if $item.promotion==1}yes{else}no{/if}.gif"></td><td><img class="smodtoggle" name="isNew" sid="{$item.id}" src="{$baseUrl}static/images/{if $item.isNew==1}yes{else}no{/if}.gif"></td><td><img class="smodtoggle" name="isHot" sid="{$item.id}" src="{$baseUrl}static/images/{if $item.isHot==1}yes{else}no{/if}.gif"></td>
<td><img class="smodtoggle" name="isLively" sid="{$item.id}" src="{$baseUrl}static/images/{if $item.isLively==1}yes{else}no{/if}.gif"></td>{/if}
<td><span class="smodedit" width="30" name="sortId" sid="{$item.id}">{$item.sortId}</span></td>
<td><span width="50" class="smodedit" name="inventory" sid="{$item.id}">{$item.inventory}</span></td>
<td title="{$item.catName}"><div class="w60 nowrap">{$item.catName}</div></td>
<td title="{$item.posttime|date_format:'Y-m-d H:i:s'}">{$item.posttime|date_format:"m-d"}</td>
<td><a href="{$item.url}" target="_blank" class="viewBtn" title="{$lang.view}">{$lang.view}</a> <a href="{$adminUrl}goods/act/edit/id/{$item.id}" class="modBtn" title="{$lang.edit}">{$lang.edit}</a> <a href="javascript:void(0)" class="delBtn" title="{$lang.del}" sid="{$item.id}">{$lang.del}</a></td>
</tr>
{/goods}
</table>
<div class="page">
{$key=$key|escape:"url"}
{if $key}
{$key = "/key/$key"}
{/if}
	<div class="pagin fr">{if $cfg_lang=="zh-ch"}共 {$allCount} 条记录{else} {$allCount} 条记录{/if}&nbsp;&nbsp;&nbsp;&nbsp; {pager allCount=$allCount type="goods"  number="false" dispatcher='false' role='admin'}</div>
</div>
{/if}
<div class="image-upload-dialog" style="display:none">
	<div class="image-item" id="image-item-0"><input type="hidden" name="thumbIds[]" value="" />
		<div class="image-thumb"><img src="/static/images/default.png" width="100px" height="100px" /></div><div class="image-upload"><a class="image-upbtn" item="0">上&nbsp;&nbsp;传</a><div class="image-result">默认图片</div></div>
	</div>
	<div class="image-item" id="image-item-1"><input type="hidden" name="thumbIds[]" value="" />
		<div class="image-thumb"><img src="/static/images/default.png" width="100px" height="100px" /></div><div class="image-upload"><a class="image-upbtn" item="1">上&nbsp;&nbsp;传</a><div class="image-result">大图</div></div>
	</div>
	<div class="image-item" id="image-item-2"><input type="hidden" name="thumbIds[]" value="" />
		<div class="image-thumb image-thumb-middle"><img src="/static/images/default.png" width="80px" height="80px" /></div><div class="image-upload"><a class="image-upbtn" item="2">上&nbsp;&nbsp;传</a><div class="image-result">中图</div></div>
	</div>
	<div class="image-item"  id="image-item-3"><input type="hidden" name="thumbIds[]" value="" />
		<div class="image-thumb image-thumb-small"><img src="/static/images/default.png" width="60px" height="60px" /></div><div class="image-upload image-upload-small"><a class="image-upbtn" item="3">上&nbsp;&nbsp;传</a><div class="image-result">小图</div></div>
	</div>
</div><!---image-upload-dialog-->

<script type="text/javascript" src="{$basePath}admin/js/goods.js"></script>
{if $smarty.get.act=="edit" || $smarty.get.act=="add"}
<script type="text/javascript">
var goodsUpload = {};
    //上传图片后的处理
   function showImgResult( json ){
        var jsonImgNameStatus = 'pic_area_status';
        var img_name_value = UPLOAD_IMG_NAME_VALUE;
        var pic_path_value = json['url'];
		if(json['state'] == 'SUCCESS'){
					$("#"+img_name_value).find("input[name='thumbIds[]']").val(json['id']);
					$("#"+img_name_value).find(".image-thumb").find("img").attr('src',pic_path_value);
					$("#"+img_name_value).find(".image-upload").find(".image-result").html('<span class="msg-icon-success"></span>上传成功');
					if(img_name_value in GLOBALIMG){
                         GLOBALIMG[img_name_value] = true;
                     }
                    setTimeout(closePicArea, 30);
		}else{
		    GLOBALIMG[img_name_value] = false;
			//$("#"+img_name_value).find(".image-upload").find(".image-result").html('<font style="color:red">'+ json['state'] +'</font>');
			$("#pic_area_status").html('<font style="color:red">'+ json['state'] +'</font>');
		}
    }
$(function(){

$(".img-main").hover(function(){
	$(this).find(".mask").show();
},function(){
	$(this).find(".mask").hide();
});
$(".img-main").click(function(){
	var imgM=$(this);
	var imgC = $(this).parent(".img-container");
	imgC.find("input[name='thumbIds[]']").each(function(idx){
		var thumbId = $(this).val();
		if(thumbId){
				$("#image-item-"+idx).find("input[name='thumbIds[]']").val(thumbId);
				$.ajax({ url:'/upload/data',type:'POST',data:"inajax=1&id="+thumbId,dataType:'json',success:function(json){ $("#image-item-"+idx).find(".image-thumb").find("img").attr('src',json.data.url); }})
		}
	});
	$(".image-upload-dialog").find("img").attr('src','/static/images/default.png');
	var imageUploadDialog = $(".image-upload-dialog").dialog({ title:"上传图片",width:400,height:530,modal:true,closeOnEscape:false,dialogClass:'upload-dialog',buttons:{ "确定":function(){
			imgC.find("input[name='thumbIds[]']").remove();
			var hasImg=false;
			$(".image-upload-dialog").find("input[name='thumbIds[]']").each(function(){
				var thumbId=$(this).val();
				if(thumbId){
					hasImg=true;
					imgM.find("img").attr('src',$(this).next(".image-thumb").find("img").attr('src'));
				}
				imgM.before('<input type="hidden" name="thumbIds[]" value="'+thumbId+'" />');
				$(this).next(".image-thumb").find("img").attr('src','/static/images/default.png');
				$(this).val('');
				if(!hasImg){ imgM.find("img").attr('src','/static/images/default.png'); }
			});
			if(hasImg){ imgC.parent("goods-img").removeClass("goods-img-empty"); }
			if(hasImg && $(".goods-img-empty").length==0){
				$(".goods-img").last().after('<div class="goods-img goods-img-empty"><div class="img-container"><input type="hidden" name="thumbIds[]" value="" /><input type="hidden" name="thumbIds[]" value="" /><input type="hidden" name="thumbIds[]" value="" /><input type="hidden" name="thumbIds[]" value="" /><div class="img-main"><div class="mask mask-bg"></div><div class="mask mask-text">点击上传</div><img id="img-src" alt="" src="/static/images/default.png"/></div></div></div>');
			}
			imageUploadDialog.dialog("destroy");
	} } });
});

//$(".img-main").eq(0).trigger('click');
$(".image-upbtn").click(function(){
	var imgItem = $(this).parent(".img-main").parent(".img-container").parent(".goods-img");
	var type=$(this).attr("item")*1+1;var title='';switch(type){ case 1:title='默认图片';break;case 2:title='大图';break;case 3:title='中图';break;case 4:title='小图';break;}
	$("#upload_pic_form").attr("action","/upload?callback=parent.showImgResult&typeId="+type);
	showPicArea("image-item-"+$(this).attr("item"),title,'image');
});

{if $config.goods.preview.zoom}
	$("#newupload").css({ldelim}"cursor":"pointer"{rdelim}).click(function(){
		var p = $(this).parent().parent(".goods-img");
		var src = $("#img-src").attr("src");
		if(src=="/static/images/default.png"){
			return false;
		}else{
			var html = '<div class="goods-img"><div class="img-container"><div class="img-main"><img width="60" height="60" alt="" src="'+src+'"/></div></div></div>';
			p.before(html);
			$("#img-src").attr({ldelim}"src":"/static/images/default.png","width":60,"height":60{rdelim});
		}
	});
{/if}
{if $smarty.get.act=="add" || count($goodsInfo.attrs)===0}
$("select[name='catId']").trigger("change");
{/if}
});
</script>
{/if}
<script type="text/javascript">
$(function(){
	$("a#deleteChecked").button().click(function(){
		if(!confirm(lang[4])){ return false; }		
		var id = [];
		$("input[name='id[]']:checkbox:checked").each(function(index){
			id[index] = $(this).val();
			var sid = $(this).val();
			if(sid){
				var tr = $(this).parent("td").parent("tr"),sdata = "inajax=1&act=del&id="+sid;
				$.ajax({ type:"POST",url:"{$adminUrl}goods",data:sdata,dataType:"json",success:function(data){ if(data.success){ tr.fadeOut("slow").remove(); }else{ alert(data.message); } } });
			}
		});
	});
});
</script>
</div>
{include "footer.inc.html"}