{include file="public/seller_top" /} 
<div class="seller_main w1200">
    {include file="public/seller_left" /}
    <div class="seller_right">
        


        
        
        
<style type="text/css">
#fixedNavBar { filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',startColorstr='#CCFFFFFF', endColorstr='#CCFFFFFF');background:rgba(255,255,255,0.8); width: 90px; margin-left: 510px; border-radius: 4px; position: fixed; z-index: 999; top: 172px; left: 50%;}
#fixedNavBar h3 { font-size: 12px; line-height: 24px; text-align: center; margin-top: 4px;}
#fixedNavBar ul { width: 80px; margin: 0 auto 5px auto;}
#fixedNavBar li { margin-top: 5px;}
#fixedNavBar li a { font-family: Arial, Helvetica, sans-serif; font-size: 12px; line-height: 20px; background-color: #F5F5F5; color: #999; text-align: center; display: block;  height: 20px; border-radius: 10px;}
#fixedNavBar li a:hover { color: #FFF; text-decoration: none; background-color: #27a9e3;}
</style>

<div id="fixedNavBar">
<h3>页面导航</h3>
  <ul>
    <li><a id="demo1Btn" href="#demo1" class="demoBtn">基本信息</a></li>
    <li><a id="demo2Btn" href="#demo2" class="demoBtn">详情描述</a></li>
    <li><a id="demo3Btn" href="#demo3" class="demoBtn">特殊商品</a></li>
    <li><a id="demo4Btn" href="#demo4" class="demoBtn">物流运费</a></li>
    <li><a id="demo5Btn" href="#demo5" class="demoBtn">发票信息</a></li>
    <li><a id="demo6Btn" href="#demo6" class="demoBtn">其他信息</a></li>
  </ul>
</div>
<?php if (isset($edit_goods_sign)) {?>
        <div class="seller_items">
            {include file="public/seller_items" /}
        </div>
<?php } else {?>
<ul class="add-goods-step">
  <li><i class="icon icon-list-alt"></i>
    <h6>STEP.1</h6>
    <h2>选择商品分类</h2>
    <i class="arrow icon-angle-right"></i> </li>
  <li class="current"><i class="icon icon-edit"></i>
    <h6>STEP.2</h6>
    <h2>填写商品详情</h2>
    <i class="arrow icon-angle-right"></i> </li>
  <li><i class="icon icon-camera-retro "></i>
    <h6>STEP.3</h6>
    <h2>上传商品图片</h2>
    <i class="arrow icon-angle-right"></i> </li>
  <li><i class="icon icon-ok-circle"></i>
    <h6>STEP.4</h6>
    <h2>商品发布成功</h2>
  </li>
</ul>
<?php }?>
<div class="item-publish">
  <form method="post" id="goods_form" action="<?php if (isset($edit_goods_sign)) { echo url('Home/Sellergoodsonline/edit_save_goods');} else { echo url('Home/Sellergoodsadd/save_goods');}?>">
    <input type="hidden" name="form_submit" value="ok" />
    <input type="hidden" name="commonid" value="{$goods.goods_commonid|default=''}" />
    <input type="hidden" name="type_id" value="{$goods_class.type_id|default=''}" />
    <div class="dssc-form-goods">
      <h3 id="demo1">{$Think.lang.store_goods_index_goods_base_info}</h3>
      <dl>
        <dt>{$Think.lang.store_goods_index_goods_class}{$Think.lang.ds_colon}</dt>
        <dd id="gcategory"> {$goods_class.gc_tag_name|default=''}
            <a class="dssc-btn" href="<?php if (isset($edit_goods_sign)) { echo url('/Home/Sellergoodsonline/edit_class/',['commonid'=>$goods['goods_commonid']]); } else { echo url('/Home/Sellergoodsadd/add_step_one/'); }?>">{$Think.lang.ds_edit}</a>
          <input type="hidden" id="cate_id" name="cate_id" value="{$goods_class.gc_id|default=''}" class="text" />
          <input type="hidden" name="cate_name" value="{$goods_class.gc_tag_name|default=''}" class="text"/>
        </dd>
      </dl>
      <dl>
        <dt><i class="required">*</i>{$Think.lang.store_goods_index_goods_name}{$Think.lang.ds_colon}</dt>
        <dd>
          <input name="g_name" type="text" class="text w400" value="{$goods.goods_name|default=''}" />
          <span></span>
          <p class="hint">{$Think.lang.store_goods_index_goods_name_help}</p>
        </dd>
      </dl>
      <dl>
        <dt>商品卖点{$Think.lang.ds_colon}</dt>
        <dd>
          <textarea name="g_jingle" class="textarea h60 w400">{$goods.goods_jingle|default=''}</textarea>
          <span></span>
          <p class="hint">商品卖点最长不能超过140个汉字</p>
        </dd>
      </dl>
      <dl>
        <dt nc_type="no_spec"><i class="required">*</i>{$Think.lang.store_goods_index_store_price}{$Think.lang.ds_colon}</dt>
        <dd nc_type="no_spec">
          <input name="g_price" value="{$goods.goods_price|default=''}" type="text"  class="text w60" /><em class="add-on"><i class="icon-renminbi"></i></em> <span></span>
          <p class="hint">{$Think.lang.store_goods_index_store_price_help}，且不能高于市场价。<br>
            此价格为商品实际销售价格，如果商品存在规格，该价格显示最低价格。</p>
        </dd>
      </dl>
      <dl>
        <dt><i class="required">*</i>市场价{$Think.lang.ds_colon}</dt>
        <dd>
          <input name="g_marketprice" value="{$goods.goods_marketprice|default=''}" type="text" class="text w60" /><em class="add-on"><i class="icon-renminbi"></i></em> <span></span>
          <p class="hint">{$Think.lang.store_goods_index_store_price_help}，此价格仅为市场参考售价，请根据该实际情况认真填写。</p>
        </dd>
      </dl>
      <dl>
        <dt>成本价{$Think.lang.ds_colon}</dt>
        <dd>
          <input name="g_costprice" value="{$goods.goods_costprice|default=''}" type="text" class="text w60" /><em class="add-on"><i class="icon-renminbi"></i></em> <span></span>
          <p class="hint">价格必须是0.00~9999999之间的数字，此价格为商户对所销售的商品实际成本价格进行备注记录，非必填选项，不会在前台销售页面中显示。</p>
        </dd>
      </dl>
      <dl>
        <dt>折扣{$Think.lang.ds_colon}</dt>
        <dd>
          <input name="g_discount" value="{$goods.goods_discount|default=''}" type="text" class="text w60" readonly="readonly" style="background:#E7E7E7 none;" /><em class="add-on">%</em>
          <p class="hint">根据销售价与市场价比例自动生成，不需要编辑。</p>
        </dd>
      </dl>
      <?php if(is_array($spec_list) && !empty($spec_list)){?>
      <?php $i = '0';?>
      <?php foreach ($spec_list as $k=>$val){?>
      <dl nc_type="spec_group_dl_<?php echo $i;?>" nctype="spec_group_dl" class="spec-bg" <?php if($k == '1'){?>spec_img="t"<?php }?>>
        <dt>
          <input name="sp_name[<?php echo $k;?>]" type="text" class="text w60 tip2 tr" title="自定义规格类型名称，规格值名称最多不超过4个字" value="<?php if (isset($goods['spec_name'][$k])) { echo $goods['spec_name'][$k];} else {echo $val['sp_name'];}?>" maxlength="4" nctype="spec_name" data-param="{id:<?php echo $k;?>,name:'<?php echo $val['sp_name'];?>'}"/>
          {$Think.lang.ds_colon}
          </dt>
        <dd <?php if($k == '1'){?>nctype="sp_group_val"<?php }?>>
          <ul class="spec">
            <?php if(is_array($val['value'])){?>
            <?php foreach ($val['value'] as $v) {?>
            <li><span nctype="input_checkbox">
              <input type="checkbox" value="<?php echo $v['sp_value_name'];?>" nc_type="<?php echo $v['sp_value_id'];?>" <?php if($k == '1'){?>class="sp_val"<?php }?> name="sp_val[<?php echo $k;?>][<?php echo $v['sp_value_id']?>]">
              </span><span nctype="pv_name"><?php echo $v['sp_value_name'];?></span>
            </li>
            <?php }?>
            <?php }?>
            <li data-param="{gc_id:<?php echo $goods_class['gc_id'];?>,sp_id:<?php echo $k;?>,url:'{:url('/Home/Sellergoodsadd/ajax_add_spec')}'}">
              <div nctype="specAdd1"><a href="javascript:void(0);" class="dssc-btn" nctype="specAdd"><i class="icon-plus"></i>添加规格值</a></div>
              <div nctype="specAdd2" style="display:none;">
                <input class="text w60" type="text" placeholder="规格值名称" maxlength="20">
                <a href="javascript:void(0);" nctype="specAddSubmit" class="dssc-btn dssc-btn-acidblue ml5 mr5">确认</a><a href="javascript:void(0);" nctype="specAddCancel" class="dssc-btn dssc-btn-orange">取消</a></div>
            </li>
          </ul>
          <?php if(isset($edit_goods_sign) && $k == '1'){?>
          <p class="hint">添加或取消颜色规格时，提交后请编辑图片以确保商品图片能够准确显示。</p>
          <?php }?>
        </dd>
      </dl>
      <?php $i++;?>
      <?php }?>
      <?php }?>
      <dl nc_type="spec_dl" class="spec-bg" style="display:none; overflow: visible;">
        <dt>{$Think.lang.srore_goods_index_goods_stock_set}{$Think.lang.ds_colon}</dt>
        <dd class="spec-dd">
          <table border="0" cellpadding="0" cellspacing="0" class="spec_table">
            <thead>
              <?php if(is_array($spec_list) && !empty($spec_list)){?>
              <?php foreach ($spec_list as $k=>$val){?>
            <th nctype="spec_name_<?php echo $k;?>"><?php if (isset($goods['spec_name'][$k])) { echo $goods['spec_name'][$k];} else {echo $val['sp_name'];}?></th>
              <?php }?>
              <?php }?>
              <th class="w90"><span class="red">*</span>市场价
                <div class="batch"><i class="icon-edit" title="批量操作"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>批量设置价格：</h6>
                    <a href="javascript:void(0)" class="close">X</a>
                    <input name="" type="text" class="text price" />
                    <a href="javascript:void(0)" class="dssc-btn-mini" data-type="marketprice">设置</a><span class="arrow"></span></div>
                </div></th>
              <th class="w90"><span class="red">*</span>{$Think.lang.store_goods_index_price}
                <div class="batch"><i class="icon-edit" title="批量操作"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>批量设置价格：</h6>
                    <a href="javascript:void(0)" class="close">X</a>
                    <input name="" type="text" class="text price" />
                    <a href="javascript:void(0)" class="dssc-btn-mini" data-type="price">设置</a><span class="arrow"></span></div>
                </div></th>
              <th class="w60"><span class="red">*</span>{$Think.lang.store_goods_index_stock}
                <div class="batch"><i class="icon-edit" title="批量操作"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>批量设置库存：</h6>
                    <a href="javascript:void(0)" class="close">X</a>
                    <input name="" type="text" class="text stock" />
                    <a href="javascript:void(0)" class="dssc-btn-mini" data-type="stock">设置</a><span class="arrow"></span></div>
                </div></th>
              <th class="w70">预警值
                <div class="batch"><i class="icon-edit" title="批量操作"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>批量设置预警值：</h6>
                    <a href="javascript:void(0)" class="close">X</a>
                    <input name="" type="text" class="text stock" />
                    <a href="javascript:void(0)" class="dssc-btn-mini" data-type="alarm">设置</a><span class="arrow"></span></div>
                </div></th>
              <th class="w100">{$Think.lang.store_goods_index_goods_no}</th>
                </thead>
            <tbody nc_type="spec_table">
            </tbody>
          </table>
          <p class="hint">点击<i class="icon-edit"></i>可批量修改所在列的值。</p>
        </dd>
      </dl>
      <dl>
        <dt nc_type="no_spec"><i class="required">*</i>{$Think.lang.store_goods_index_goods_stock}{$Think.lang.ds_colon}</dt>
        <dd nc_type="no_spec">
          <input name="g_storage" value="{$goods.g_storage|default=''}" type="text" class="text w60" />
          <span></span>
          <p class="hint">{$Think.lang.store_goods_index_goods_stock_help}</p>
        </dd>
      </dl>
      <dl>
        <dt>库存预警值{$Think.lang.ds_colon}</dt>
        <dd>
          <input name="g_alarm" value="{$goods.goods_storage_alarm|default=''}" type="text" class="text w60" />
          <span></span>
          <p class="hint">设置最低库存预警值。当库存低于预警值时商家中心商品列表页库存列红字提醒。<br>
            请填写0~255的数字，0为不预警。</p>
        </dd>
      </dl>
      <dl>
        <dt nc_type="no_spec">{$Think.lang.store_goods_index_goods_no}{$Think.lang.ds_colon}</dt>
        <dd nc_type="no_spec">
          <p>
            <input name="g_serial" value="{$goods.goods_serial|default=''}" type="text"  class="text"  />
          </p>
          <p class="hint">{$Think.lang.store_goods_index_goods_no_help}</p>
        </dd>
      </dl>
      <dl>
        <dt><i class="required">*</i>{$Think.lang.store_goods_album_goods_pic}{$Think.lang.ds_colon}</dt>
        <dd>
          <div class="dssc-goods-default-pic">
            <div class="goodspic-uplaod">
              <div class="upload-thumb"> <img nctype="goods_image" src="<?php if(isset($goods)){echo thumb($goods, 240);}?>"/> </div>
              <input type="hidden" name="image_path" id="image_path" nctype="goods_image" value="{$goods.goods_image|default=''}" />
              <span></span>
              <p class="hint">{$Think.lang.store_goods_step2_description_one}<?php printf(lang('store_goods_step2_description_two'),intval(config('image_max_filesize'))/1024);?></p>
              <div class="handle">
                <div class="dssc-upload-btn"> <a href="javascript:void(0);"><span>
                  <input type="file" hidefocus="true" size="1" class="input-file" name="goods_image" id="goods_image">
                  </span>
                  <p><i class="icon-upload-alt"></i>图片上传</p>
                  </a> </div>
                <a class="dssc-btn mt5" nctype="show_image" href="{:url('/Home/Selleralbum/pic_list',['item'=>'goods'])}"><i class="icon-picture"></i>从图片空间选择</a> <a href="javascript:void(0);" nctype="del_goods_demo" class="dssc-btn mt5" style="display: none;"><i class="icon-circle-arrow-up"></i>关闭相册</a></div>
            </div>
          </div>
          <div id="demo"></div>
        </dd>
      </dl>
      <h3 id="demo2">{$Think.lang.store_goods_index_goods_detail_info}</h3>
      <dl style="overflow: visible;">
        <dt>{$Think.lang.store_goods_index_goods_brand}{$Think.lang.ds_colon}</dt>
        <dd>
          <div class="dssc-brand-select">
            <div class="selection">
              <input name="b_name" id="b_name" value="{$goods.brand_name|default=''}" type="text" class="text w180" readonly="readonly" />
              <input type="hidden" name="b_id" id="b_id" value="{$goods.brand_id|default=''}" />
              <em class="add-on" nctype="add-on"><i class="icon-collapse"></i></em></div>
            <div class="dssc-brand-select-container">
              <div class="brand-index" data-tid="<?php echo $goods_class['type_id'];?>" data-url="{:url('/Home/Sellergoodsadd/ajax_get_brand')}">
                <div class="letter" nctype="letter">
                  <ul>
                    <li><a href="javascript:void(0);" data-letter="all">全部</a></li>
                    <li><a href="javascript:void(0);" data-letter="A">A</a></li>
                    <li><a href="javascript:void(0);" data-letter="B">B</a></li>
                    <li><a href="javascript:void(0);" data-letter="C">C</a></li>
                    <li><a href="javascript:void(0);" data-letter="D">D</a></li>
                    <li><a href="javascript:void(0);" data-letter="E">E</a></li>
                    <li><a href="javascript:void(0);" data-letter="F">F</a></li>
                    <li><a href="javascript:void(0);" data-letter="G">G</a></li>
                    <li><a href="javascript:void(0);" data-letter="H">H</a></li>
                    <li><a href="javascript:void(0);" data-letter="I">I</a></li>
                    <li><a href="javascript:void(0);" data-letter="J">J</a></li>
                    <li><a href="javascript:void(0);" data-letter="K">K</a></li>
                    <li><a href="javascript:void(0);" data-letter="L">L</a></li>
                    <li><a href="javascript:void(0);" data-letter="M">M</a></li>
                    <li><a href="javascript:void(0);" data-letter="N">N</a></li>
                    <li><a href="javascript:void(0);" data-letter="O">O</a></li>
                    <li><a href="javascript:void(0);" data-letter="P">P</a></li>
                    <li><a href="javascript:void(0);" data-letter="Q">Q</a></li>
                    <li><a href="javascript:void(0);" data-letter="R">R</a></li>
                    <li><a href="javascript:void(0);" data-letter="S">S</a></li>
                    <li><a href="javascript:void(0);" data-letter="T">T</a></li>
                    <li><a href="javascript:void(0);" data-letter="U">U</a></li>
                    <li><a href="javascript:void(0);" data-letter="V">V</a></li>
                    <li><a href="javascript:void(0);" data-letter="W">W</a></li>
                    <li><a href="javascript:void(0);" data-letter="X">X</a></li>
                    <li><a href="javascript:void(0);" data-letter="Y">Y</a></li>
                    <li><a href="javascript:void(0);" data-letter="Z">Z</a></li>
                    <li><a href="javascript:void(0);" data-letter="0-9">其他</a></li>
                    <li><a href="javascript:void(0);" data-empty="0">清空</a></li>
                  </ul>
                </div>
                <div class="search" nctype="search">
                  <input name="search_brand_keyword" id="search_brand_keyword" type="text" class="text" placeholder="品牌名称关键字查找"/><a href="javascript:void(0);" class="dssc-btn-mini" style="vertical-align: top;">Go</a></div>
              </div>
              <div class="brand-list" nctype="brandList">
                <ul nctype="brand_list">
                  <?php if(is_array($brand_list) && !empty($brand_list)){?>
                  <?php foreach($brand_list as $val) { ?>
                  <li data-id='<?php echo $val['brand_id'];?>'data-name='<?php echo $val['brand_name'];?>'><em><?php echo $val['brand_initial'];?></em><?php echo $val['brand_name'];?></li>
                  <?php } ?>
                  <?php }?>
                </ul>
              </div>
              <div class="no-result" nctype="noBrandList" style="display: none;">没有符合"<strong>搜索关键字</strong>"条件的品牌</div>
            </div>
          </div>
        </dd>
      </dl>
      <?php if(is_array($attr_list) && !empty($attr_list)){?>
      <dl>
        <dt>{$Think.lang.store_goods_index_goods_attr}{$Think.lang.ds_colon}</dt>
        <dd>
          <?php foreach ($attr_list as $k=>$val){?>
          <span class="mr30">
          <label class="mr5"><?php echo $val['attr_name']?></label>
          <input type="hidden" name="attr[<?php echo $k;?>][name]" value="<?php echo $val['attr_name']?>" />
          <?php if(is_array($val) && !empty($val)){?>
          <select name="" attr="attr[<?php echo $k;?>][__NC__]" nc_type="attr_select">
            <option value='不限' nc_type='0'>不限</option>
            <?php foreach ($val['value'] as $v){?>
            <option value="<?php echo $v['attr_value_name']?>" <?php if(isset($attr_checked) && in_array($v['attr_value_id'], $attr_checked)){?>selected="selected"<?php }?> nc_type="<?php echo $v['attr_value_id'];?>"><?php echo $v['attr_value_name'];?></option>
            <?php }?>
          </select>
          <?php }?>
          </span>
          <?php }?>
        </dd>
      </dl>
      <?php }?>
      <dl>
        <dt>{$Think.lang.store_goods_index_goods_desc}{$Think.lang.ds_colon}</dt>
        <dd id="ncProductDetails">
          <div class="tabs">
            <ul class="ui-tabs-nav">
              <li class="ui-tabs-selected"><a href="#panel-1"><i class="icon-desktop"></i> 电脑端</a></li>
              <li class="selected"><a href="#panel-2"><i class="icon-mobile-phone"></i>手机端</a></li>
            </ul>
            <div id="panel-1" class="ui-tabs-panel">
                {:buildEditor(['name'=>'g_body','content'=>$goods.goods_body])}
                <textarea name="g_body" id="g_body"></textarea>
              <div class="hr8">
                <div class="dssc-upload-btn"> <a href="javascript:void(0);"><span>
                  <input type="file" hidefocus="true" size="1" class="input-file" name="add_album" id="add_album" multiple="multiple">
                  </span>
                  <p><i class="icon-upload-alt" data_type="0" nctype="add_album_i"></i>图片上传</p>
                  </a>
                </div>
                <a class="dssc-btn mt5" nctype="show_desc" href="{:url('/Home/Selleralbum/pic_list',['item'=>'des'])}"><i class="icon-picture"></i>{$Think.lang.store_goods_album_insert_users_photo}</a> <a href="javascript:void(0);" nctype="del_desc" class="dssc-btn mt5" style="display: none;"><i class=" icon-circle-arrow-up"></i>关闭相册</a>
              </div>
              <p id="des_demo"></p>
            </div>
            <div id="panel-2" class="ui-tabs-panel ui-tabs-hide">
              <div class="dssc-mobile-editor">
                <div class="pannel">
                  <div class="size-tip"><span nctype="img_count_tip">图片总数得超过<em>20</em>张</span><i>|</i><span nctype="txt_count_tip">文字不得超过<em>5000</em>字</span></div>
                  <div class="control-panel" nctype="mobile_pannel">
                    <?php if (!empty($goods['mb_body'])) {?>
                    <?php foreach ($goods['mb_body'] as $val) {?>
                    <?php if ($val['type'] == 'text') {?>
                    <div class="module m-text">
                      <div class="tools"><a nctype="mp_up" href="javascript:void(0);">上移</a><a nctype="mp_down" href="javascript:void(0);">下移</a><a nctype="mp_edit" href="javascript:void(0);">编辑</a><a nctype="mp_del" href="javascript:void(0);">删除</a></div>
                      <div class="content">
                        <div class="text-div"><?php echo $val['value'];?></div>
                      </div>
                      <div class="cover"></div>
                    </div>
                    <?php }?>
                    <?php if ($val['type'] == 'image') {?>
                    <div class="module m-image">
                      <div class="tools"><a nctype="mp_up" href="javascript:void(0);">上移</a><a nctype="mp_down" href="javascript:void(0);">下移</a><a nctype="mp_rpl" href="javascript:void(0);">替换</a><a nctype="mp_del" href="javascript:void(0);">删除</a></div>
                      <div class="content">
                        <div class="image-div"><img src="<?php echo $val['value'];?>"></div>
                      </div>
                      <div class="cover"></div>
                    </div>
                    <?php }?>
                    <?php }?>
                    <?php }?>
                  </div>
                  <div class="add-btn">
                    <ul class="btn-wrap">
                      <li><a href="javascript:void(0);" nctype="mb_add_img"><i class="icon-picture"></i>
                        <p>图片</p>
                        </a></li>
                      <li><a href="javascript:void(0);" nctype="mb_add_txt"><i class="icon-font"></i>
                        <p>文字</p>
                        </a></li>
                    </ul>
                  </div>
                </div>
                <div class="explain">
                  <dl>
                    <dt>1、基本要求：</dt>
                    <dd>（1）手机详情总体大小：图片+文字，图片不超过20张，文字不超过5000字；</dd>
                    <dd>建议：所有图片都是本宝贝相关的图片。</dd>
                  </dl><dl>
                    <dt>2、图片大小要求：</dt>
                    <dd>（1）建议使用宽度480 ~ 620像素、高度小于等于960像素的图片；</dd>
                    <dd>（2）格式为：JPG\JEPG\GIF\PNG；</dd>
                    <dd>举例：可以上传一张宽度为480，高度为960像素，格式为JPG的图片。</dd>
                  </dl><dl>
                    <dt>3、文字要求：</dt>
                    <dd>（1）每次插入文字不能超过500个字，标点、特殊字符按照一个字计算；</dd>
                    <dd>（2）请手动输入文字，不要复制粘贴网页上的文字，防止出现乱码；</dd>
                    <dd>（3）以下特殊字符“<”、“>”、“"”、“'”、“\”会被替换为空。</dd>
                    <dd>建议：不要添加太多的文字，这样看起来更清晰。</dd>
                  </dl>
                </div>
              </div>
              <div class="dssc-mobile-edit-area" nctype="mobile_editor_area">
                <div nctype="mea_img" class="dssc-mea-img" style="display: none;"></div>
                <div class="dssc-mea-text" nctype="mea_txt" style="display: none;">
                  <p id="meat_content_count" class="text-tip"></p>
                  <textarea class="textarea valid" nctype="meat_content"></textarea>
                  <div class="button"><a class="dssc-btn dssc-btn-blue" nctype="meat_submit" href="javascript:void(0);">确认</a><a class="dssc-btn ml10" nctype="meat_cancel" href="javascript:void(0);">取消</a></div>
                  <a class="text-close" nctype="meat_cancel" href="javascript:void(0);">X</a>
                </div>
              </div>
              <input name="m_body" autocomplete="off" type="hidden" value="{$goods.mobile_body|default=''}">
            </div>
          </div>
        </dd>
      </dl>
      <dl>
        <dt>关联版式：</dt>
        <dd> <span class="mr50">
          <label>顶部版式</label>
          <select name="plate_top">
            <option>请选择</option>
            <?php if (!empty($plate_list[1])) {?>
            <?php foreach ($plate_list[1] as $val) {?>
            <option value="<?php echo $val['plate_id']?>" <?php if ($goods['plateid_top'] == $val['plate_id']) {?>selected="selected"<?php }?>><?php echo $val['plate_name'];?></option>
            <?php }?>
            <?php }?>
          </select>
          </span> <span class="mr50">
          <label>底部版式</label>
          <select name="plate_bottom">
            <option>请选择</option>
            <?php if (!empty($plate_list[0])) {?>
            <?php foreach ($plate_list[0] as $val) {?>
            <option value="<?php echo $val['plate_id']?>" <?php if ($goods['plateid_bottom'] == $val['plate_id']) {?>selected="selected"<?php }?>><?php echo $val['plate_name'];?></option>
            <?php }?>
            <?php }?>
          </select>
          </span> </dd>
      </dl>
      <h3 id="demo3">特殊商品</h3>
      <!-- 只有可发布虚拟商品才会显示 S -->
      <?php if ($goods_class['gc_virtual'] == 1) {?>
      <dl class="special-01">
        <dt>虚拟商品{$Think.lang.ds_colon}</dt>
        <dd>
          <ul class="dssc-form-radio-list">
            <li>
              <input type="radio" name="is_gv" value="1" id="is_gv_1" <?php if (isset($goods['is_virtual']) && $goods['is_virtual'] == 1) {?>checked<?php }?>>
              <label for="is_gv_1">是</label>
            </li>
            <li>
              <input type="radio" name="is_gv" value="0" id="is_gv_0" <?php if ($goods['is_virtual'] == 0) {?>checked<?php }?>>
              <label for="is_gv_0">否</label>
            </li>
          </ul>
          <p class="hint vital">*虚拟商品不能参加限时折扣和组合销售两种促销活动。也不能赠送赠品和推荐搭配。</p>
        </dd>
      </dl>
      <dl class="special-01" nctype="virtual_valid" <?php if ($goods['is_virtual'] == 0) {?>style="display:none;"<?php }?>>
        <dt><i class="required">*</i>虚拟商品有效期至{$Think.lang.ds_colon}</dt>
        <dd>
          <input type="text" name="g_vindate" id="g_vindate" class="w80 text" value="<?php if($goods['is_virtual'] == 1 && !empty($goods['virtual_indate'])) { echo date('Y-m-d', $goods['virtual_indate']);}?>"><em class="add-on"><i class="icon-calendar"></i></em>
          <span></span>
          <p class="hint">虚拟商品可兑换的有效期，过期后商品不能购买，电子兑换码不能使用。</p>
        </dd>
      </dl>
      <dl class="special-01" nctype="virtual_valid" <?php if ($goods['is_virtual'] == 0) {?>style="display:none;"<?php }?>>
        <dt><i class="required">*</i>虚拟商品购买上限{$Think.lang.ds_colon}</dt>
        <dd>
          <input type="text" name="g_vlimit" id="g_vlimit" class="w80 text" value="<?php if ($goods['is_virtual'] == 1) {echo $goods['virtual_limit'];}?>">
          <span></span>
          <p class="hint">请填写1~10之间的数字，虚拟商品最高购买数量不能超过10个。</p>
        </dd>
      </dl>
      <dl class="special-01" nctype="virtual_valid" <?php if ($goods['is_virtual'] == 0) {?>style="display:none;"<?php }?>>
        <dt>支持过期退款{$Think.lang.ds_colon}</dt>
        <dd>
          <ul class="dssc-form-radio-list">
            <li>
              <input type="radio" name="g_vinvalidrefund" id="g_vinvalidrefund_1" value="1" <?php if ($goods['virtual_invalid_refund'] ==1) {?>checked<?php }?>>
              <label for="g_vinvalidrefund_1">是</label>
            </li>
            <li>
              <input type="radio" name="g_vinvalidrefund" id="g_vinvalidrefund_0" value="0" <?php if ($goods['virtual_invalid_refund'] == 0) {?>checked<?php }?>>
              <label for="g_vinvalidrefund_0">否</label>
            </li>
          </ul>
          <p class="hint">兑换码过期后是否可以申请退款。</p>
        </dd>
      </dl>
      <?php }?>
      <!-- 只有可发布虚拟商品才会显示 E --> 
      <!-- F码商品专有项 S -->
      <dl class="special-02" nctype="virtual_null" <?php if (isset($goods['is_virtual']) && $goods['is_virtual'] == 1) {?>style="display:none;"<?php }?>>
        <dt>F码商品{$Think.lang.ds_colon}</dt>
        <dd>
          <ul class="dssc-form-radio-list">
            <li>
              <input type="radio" name="is_fc" id="is_fc_1" value="1" <?php if (isset($goods['is_fcode']) && $goods['is_fcode'] == 1) {?>checked<?php }?>>
              <label for="is_fc_1">是</label>
            </li>
            <li>
              <input type="radio" name="is_fc" id="is_fc_0" value="0" <?php if (isset($goods['is_fcode']) && $goods['is_fcode'] == 0) {?>checked<?php }?>>
              <label for="is_fc_0">否</label>
            </li>
          </ul>
          <p class="hint vital">*F码商品不能参加抢购、限时折扣和组合销售三种促销活动。也不能预售和推荐搭配。</p>
        </dd>
      </dl>
      <dl class="special-02" nctype="fcode_valid" <?php if (isset($goods['is_fcode']) && $goods['is_fcode'] == 0) {?>style="display:none;"<?php }?>>
        <dt>
          <?php if (!isset($edit_goods_sign)) {?>
          <i class="required">*</i>
          <?php }?>
          生成F码数量{$Think.lang.ds_colon}</dt>
        <dd>
          <input type="text" name="g_fccount" id="g_fccount" class="w80 text" value="">
          <span></span>
          <p class="hint">请填写100以内的数字。编辑商品时添加F码会不计算原有F码数量继续生成相应数量。</p>
        </dd>
      </dl>
      <dl class="special-02" nctype="fcode_valid" <?php if (isset($goods['is_fcode']) && $goods['is_fcode'] == 0) {?>style="display:none;"<?php }?>>
        <dt>
          <?php if (!isset($edit_goods_sign)) {?>
          <i class="required">*</i>
          <?php }?>
          F码前缀{$Think.lang.ds_colon}</dt>
        <dd>
          <input type="text" name="g_fcprefix" id="g_fcprefix" class="w80 text" value="">
          <span></span>
          <p class="hint">请填写3~5位的英文字母。建议每次生成的F码使用不同的前缀。</p>
        </dd>
      </dl>
      <?php if (isset($goods['is_fcode']) && $goods['is_fcode'] == 1) {?>
      <dl class="special-02" nctype="fcode_valid">
        <dt>
            <a class="dssc-btn-mini dssc-btn-red" href="<?php echo url('sellergoodsonline/download_f_code_excel', array('commonid' => $goods['goods_commonid']));?>">下载F码</a>&nbsp;&nbsp;F码{$Think.lang.ds_colon}</dt>
        <dd>
          <ul class="dssc-form-radio-list">
            <?php if (!empty($fcode_array)) {?>
            <?php foreach ($fcode_array as $val) {?>
            <li><?php echo $val['fc_code']?>(
              <?php if ($val['fc_state'] == 1) {?>
              使用
              <?php } else {?>
              未用
              <?php }?>
              )</li>
            <?php }?>
            <?php }?>
          </ul>
        </dd>
      </dl>
      <?php }?>
      <!-- F码商品专有项 E --> 
      <!-- 预售商品 S -->
      <dl class="special-03" nctype="virtual_null" <?php if (isset($goods['is_virtual']) && $goods['is_virtual'] == 1) {?>style="display:none;"<?php }?>>
        <dt>预售{$Think.lang.ds_colon}</dt>
        <dd>
          <ul class="dssc-form-radio-list">
            <li>
              <input type="radio" name="is_presell" id="is_presell_1" value="1" <?php if(isset($goods['is_presell']) && $goods['is_presell'] == 1) {?>checked<?php }?>>
              <label for="is_presell_1">是</label>
            </li>
            <li>
              <input type="radio" name="is_presell" id="is_presell_0" value="0" <?php if(isset($goods['is_presell']) && $goods['is_presell'] == 0) {?>checked<?php }?>>
              <label for="is_presell_0">否</label>
            </li>
          </ul>
          <p class="hint vital">*预售商品不能参加抢购、限时折扣和组合销售三种促销活动。也不能推荐搭配。</p>
        </dd>
      </dl>
      <dl class="special-03" nctype="is_presell" <?php if (isset($goods['is_presell']) && $goods['is_presell'] == 0) {?>style="display:none;"<?php }?>>
        <dt><i class="required">*</i>发货日期{$Think.lang.ds_colon}</dt>
        <dd>
          <input type="text" name="g_deliverdate" id="g_deliverdate" class="w80 text" value="<?php if (isset($goods['presell_deliverdate']) && $goods['presell_deliverdate'] > 0) {echo date('Y-m-d', $goods['presell_deliverdate']);}?>"><em class="add-on"><i class="icon-calendar"></i></em>
          <span></span>
          <p class="hint">商家发货时间。</p>
        </dd>
      </dl>
      <!-- 预售商品 E --> 
      <!-- 商品物流信息 S -->
      <h3 id="demo4">{$Think.lang.store_goods_index_goods_transport}</h3>
      <dl>
        <dt>{$Think.lang.store_goods_index_goods_szd}{$Think.lang.ds_colon}</dt>
        <dd>
           <input type="hidden" value="<?php echo $goods['areaid_2'] ? $goods['areaid_2'] : $goods['areaid_1'];?>" name="region" id="region">
           <input type="hidden" value="{$goods.areaid_1|default=''}" name="province_id" id="_area_1">
           <input type="hidden" value="{$goods.areaid_2|default=''}" name="city_id" id="_area_2">
          </p>
        </dd>
      </dl>
      <dl nctype="virtual_null" <?php if ($goods['is_virtual'] == 1) {?>style="display:none;"<?php }?>>
        <dt>{$Think.lang.store_goods_index_goods_transfee_charge}{$Think.lang.ds_colon}</dt>
        <dd>
          <ul class="dssc-form-radio-list">
            <li>
              <input id="freight_0" nctype="freight" name="freight" class="radio" type="radio" <?php if (intval($goods['transport_id']) == 0) {?>checked="checked"<?php }?> value="0">
              <label for="freight_0">固定运费</label>
              <div nctype="div_freight" <?php if (intval($goods['transport_id']) != 0) {?>style="display: none;"<?php }?>>
                <input id="g_freight" class="w50 text" nc_type='transport' type="text" value="<?php printf('%.2f', floatval($goods['goods_freight']));?>" name="g_freight"><em class="add-on"><i class="icon-renminbi"></i></em> </div>
            </li>
            <li>
              <input id="freight_1" nctype="freight" name="freight" class="radio" type="radio" <?php if (intval($goods['transport_id']) != 0) {?>checked="checked"<?php }?> value="1">
              <label for="freight_1">{$Think.lang.store_goods_index_use_tpl}</label>
              <div nctype="div_freight" <?php if (intval($goods['transport_id']) == 0) {?>style="display: none;"<?php }?>>
                <input id="transport_id" type="hidden" value="<?php echo $goods['transport_id'];?>" name="transport_id">
                <input id="transport_title" type="hidden" value="<?php echo $goods['transport_title'];?>" name="transport_title">
                <span id="postageName" class="transport-name" <?php if ($goods['transport_title'] != '' && intval($goods['transport_id'])) {?>style="display: inline-block;"<?php }?>><?php echo $goods['transport_title'];?></span>
                <a href="JavaScript:void(0);" onclick="window.open('{:url('/Home/Sellertransport/index',['type'=>'select'])}')" class="ncbtn" id="postageButton"><i class="icon-truck"></i>{$Think.lang.store_goods_index_select_tpl}</a> 
              </div>
            </li>
          </ul>
          <p class="hint">运费设置为 0 元，前台商品将显示为免运费。</p>
        </dd>
      </dl>
      <!-- 商品物流信息 E -->
      <h3 id="demo5" nctype="virtual_null" <?php if ($goods['is_virtual'] == 1) {?>style="display:none;"<?php }?>>发票信息</h3>
      <dl nctype="virtual_null" <?php if ($goods['is_virtual'] == 1) {?>style="display:none;"<?php }?>>
        <dt>是否开增值税发票：</dt>
        <dd>
          <ul class="dssc-form-radio-list">
            <li>
              <label>
                <input name="g_vat" value="1" <?php if (!empty($goods) && $goods['goods_vat'] == 1) { ?>checked="checked" <?php } ?> type="radio" />
                {$Think.lang.ds_yes}</label>
            </li>
            <li>
              <label>
                <input name="g_vat" value="0" <?php if (empty($goods) || $goods['goods_vat'] == 0) { ?>checked="checked" <?php } ?> type="radio"/>
                {$Think.lang.ds_no}</label>
            </li>
          </ul>
          <p class="hint"></p>
        </dd>
      </dl>
      <h3 id="demo6">{$Think.lang.store_goods_index_goods_other_info}</h3>
      <dl>
        <dt>{$Think.lang.store_goods_index_store_goods_class}{$Think.lang.ds_colon}</dt>
        <dd><span class="new_add"><a href="javascript:void(0)" id="add_sgcategory" class="dssc-btn">{$Think.lang.store_goods_index_new_class}</a> </span>
          <?php if (!empty($store_class_goods)) { ?>
          <?php foreach ($store_class_goods as $v) { ?>
          <select name="sgcate_id[]" class="sgcategory">
            <option value="0">{$Think.lang.ds_please_choose}</option>
            <?php foreach ($store_goods_class as $val) { ?>
            <option value="<?php echo $val['stc_id']; ?>" <?php if ($v==$val['stc_id']) { ?>selected="selected"<?php } ?>><?php echo $val['stc_name']; ?></option>
            <?php if (isset($val['child']) && count($val['child'])>0){?>
            <?php foreach ($val['child'] as $child_val){?>
            <option value="<?php echo $child_val['stc_id']; ?>" <?php if ($v==$child_val['stc_id']) { ?>selected="selected"<?php } ?>>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $child_val['stc_name']; ?></option>
            <?php }?>
            <?php }?>
            <?php } ?>
          </select>
          <?php } ?>
          <?php } else { ?>
          <select name="sgcate_id[]" class="sgcategory">
            <option value="0">{$Think.lang.ds_please_choose}</option>
            <?php if (!empty($store_goods_class)){?>
            <?php foreach ($store_goods_class as $val) { ?>
            <option value="<?php echo $val['stc_id']; ?>"><?php echo $val['stc_name']; ?></option>
            <?php if (isset($val['child']) && count($val['child'])>0){?>
            <?php foreach ($val['child'] as $child_val){?>
            <option value="<?php echo $child_val['stc_id']; ?>">&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $child_val['stc_name']; ?></option>
            <?php }?>
            <?php }?>
            <?php } ?>
            <?php } ?>
          </select>
          <?php } ?>
          <p class="hint">{$Think.lang.store_goods_index_belong_multiple_store_class}</p>
        </dd>
      </dl>
      <dl>
        <dt>{$Think.lang.store_goods_index_goods_show}{$Think.lang.ds_colon}</dt>
        <dd>
          <ul class="dssc-form-radio-list">
            <li>
              <label>
                <input name="g_state" value="1" type="radio" <?php if (empty($goods) || $goods['goods_state'] == 1 || $goods['goods_state'] == 10) {?>checked="checked"<?php }?> />
                 {$Think.lang.store_goods_index_immediately_sales}</label>
            </li>
            <li>
              <label>
                <input name="g_state" value="0" type="radio" nctype="auto" />
                 {$Think.lang.store_goods_step2_start_time}</label>
              <input type="text" class="w80 text" name="starttime" disabled="disabled" style="background:#E7E7E7 none;" id="starttime" value="<?php echo date('Y-m-d');?>" />
              <select disabled="disabled" style="background:#E7E7E7 none;" name="starttime_H" id="starttime_H">
                <?php foreach ($hour_array as $val){?>
                <option value="<?php echo $val;?>" <?php $sign_h = 0;if($val>=date('h') && $sign_h != 1){?>selected="selected"<?php $sign_H = 1;}?>><?php echo $val;?></option>
                <?php }?>
              </select>
              {$Think.lang.store_goods_step2_hour}
              <select disabled="disabled" style="background:#E7E7E7 none;" name="starttime_i" id="starttime_i">
                <?php foreach ($minute_array as $val){?>
                <option value="<?php echo $val;?>" <?php $sign_mi = 0;if($val>=date('i') && $sign_mi != 1){?>selected="selected"<?php $sign_mi = 1;}?>><?php echo $val;?></option>
                <?php }?>
              </select>
               {$Think.lang.store_goods_step2_minute}</li>
            <li>
              <label>
                <input name="g_state" value="0" type="radio" <?php if (!empty($goods) && $goods['goods_state'] == 0) {?>checked="checked"<?php }?> />
                {$Think.lang.store_goods_index_in_warehouse} </label>
            </li>
          </ul>
        </dd>
      </dl>
      <dl>
        <dt>预约{$Think.lang.ds_colon}</dt>
        <dd>
          <ul class="dssc-form-radio-list">
            <li>
              <input type="radio" name="is_appoint" id="is_appoint_1" value="1"  <?php if($goods['is_appoint'] == 1) {?>checked<?php }?>>
              <label for="is_appoint_1">是</label>
            </li>
            <li>
              <input type="radio" name="is_appoint" id="is_appoint_0" value="0"  <?php if($goods['is_appoint'] == 0) {?>checked<?php }?>>
              <label for="is_appoint_0">否</label>
            </li>
          </ul>
          <p class="hint">只有库存为零的商品才可以设为预约商品。商家补货后，平台自动发布消息通知已经预约的会员。</p>
        </dd>
      </dl>
      <dl nctype="is_appoint"  <?php if ($goods['is_appoint'] == 0) {?>style="display:none;"<?php }?>>
        <dt><i class="required">*</i>发售日期{$Think.lang.ds_colon}</dt>
        <dd>
          <input type="text" name="g_saledate" id="g_saledate" class="w80 text" value="<?php if ($goods['appoint_satedate'] > 0) {echo date('Y-m-d', $goods['appoint_satedate']);}?>">
          <span></span>
          <p class="hint">预约商品的发售日期。</p>
        </dd>
      </dl>
      <dl>
        <dt>{$Think.lang.store_goods_index_goods_recommend}{$Think.lang.ds_colon}</dt>
        <dd>
          <ul class="dssc-form-radio-list">
            <li>
              <label>
                <input name="g_commend" value="1" <?php if (empty($goods) || $goods['goods_commend'] == 1) { ?>checked="checked" <?php } ?> type="radio" />
                {$Think.lang.ds_yes}</label>
            </li>
            <li>
              <label>
                <input name="g_commend" value="0" <?php if (!empty($goods) && $goods['goods_commend'] == 0) { ?>checked="checked" <?php } ?> type="radio"/>
                {$Think.lang.ds_no}</label>
            </li>
          </ul>
          <p class="hint">{$Think.lang.store_goods_index_recommend_tip}</p>
        </dd>
      </dl>
    </div>
    <div class="bottom tc hr32">
      <label class="submit-border">
        <input type="submit" class="submit" value="<?php if (isset($edit_goods_sign)) {echo '提交';} else {?>{$Think.lang.store_goods_add_next}，上传商品图片<?php }?>" />
      </label>
    </div>
  </form>
</div>


<script src="{$Think.config.url_domain_root}static/plugins/jquery.ajaxContent.pack.js"></script>
<script src="{$Think.config.url_domain_root}static/home/js/mlselection.js"></script>
<script type="text/javascript" src="{$Think.config.url_domain_root}static/plugins/js/fileupload/jquery.iframe-transport.js" charset="utf-8"></script>
<script type="text/javascript" src="{$Think.config.url_domain_root}static/plugins/js/fileupload/jquery.ui.widget.js" charset="utf-8"></script>
<script type="text/javascript" src="{$Think.config.url_domain_root}static/plugins/js/fileupload/jquery.fileupload.js" charset="utf-8"></script>

<script src="{$Think.config.url_domain_root}static/plugins/jquery.poshytip.min.js"></script>
<script src="{$Think.config.url_domain_root}static/plugins/jquery.mousewheel.js"></script>
<script type="text/javascript" src="{$Think.config.url_domain_root}static/plugins/jquery.charCount.js"></script>


<!--[if lt IE 8]>
  <script src="{$Think.config.url_domain_root}js/json2.js"></script>
<![endif]-->
<script src="{$Think.config.url_domain_root}static/home/js/common.js"></script>
<script src="{$Think.config.url_domain_root}static/home/js/sellergoods_add_step2.js"></script>


<script type="text/javascript">
var SITEURL = "";
var DEFAULT_GOODS_IMAGE = "<?php echo thumb(array(), 60);?>";
var SHOP_RESOURCE_SITE_URL = "";

$(function(){
    $("#region").nc_region({show_deep:2,tip_type:1});
	//电脑端手机端tab切换
	$(".tabs").tabs();
    $.validator.addMethod('checkPrice', function(value,element){
    	_g_price = parseFloat($('input[name="g_price"]').val());
        _g_marketprice = parseFloat($('input[name="g_marketprice"]').val());
        if (_g_price > _g_marketprice) {
            return false;
        }else {
            return true;
        }
    }, '<i class="icon-exclamation-sign"></i>商品价格不能高于市场价格');
	jQuery.validator.addMethod("checkFCodePrefix", function(value, element) {       
		return this.optional(element) || /^[a-zA-Z]+$/.test(value);       
	},'<i class="icon-exclamation-sign"></i>请填写不多于5位的英文字母');  
    $('#goods_form').validate({
        errorPlacement: function(error, element){
            $(element).nextAll('span').append(error);
        },
        //方便测试一下可进行删除
        <?php if (isset($edit_goods_sign)) {?>
        submitHandler:function(form){
            ajaxpost('goods_form', '', '', 'onerror');
        },
        <?php }?>
        rules : {
            g_name : {
                required    : true,
                minlength   : 3,
                maxlength   : 50
            },
            g_jingle : {
                maxlength   : 140
            },
            g_price : {
                required    : true,
                number      : true,
                min         : 0.01,
                max         : 9999999,
                checkPrice  : true
            },
            g_marketprice : {
                required    : true,
                number      : true,
                min         : 0.01,
                max         : 9999999
            },
            g_costprice : {
                number      : true,
                min         : 0.00,
                max         : 9999999
            },
            g_storage  : {
                required    : true,
                digits      : true,
                min         : 0,
                max         : 999999999
            },
            image_path : {
                required    : true
            },
            g_vindate : {
                required    : function() {if ($("#is_gv_1").prop("checked")) {return true;} else {return false;}}
            },
			g_vlimit : {
				required	: function() {if ($("#is_gv_1").prop("checked")) {return true;} else {return false;}},
				range		: [1,10]
			},
			g_fccount : {
				<?php if (!isset($edit_goods_sign)) {?>required	: function() {if ($("#is_fc_1").prop("checked")) {return true;} else {return false;}},<?php }?>
				range		: [1,100]
			},
			g_fcprefix : {
				<?php if (!isset($edit_goods_sign)) {?>required	: function() {if ($("#is_fc_1").prop("checked")) {return true;} else {return false;}},<?php }?>
				checkFCodePrefix : true,
				rangelength	: [3,5]
			},
			g_saledate : {
				required	: function () {if ($('#is_appoint_1').prop("checked")) {return true;} else {return false;}}
			},
			g_deliverdate : {
				required	: function () {if ($('#is_presell_1').prop("checked")) {return true;} else {return false;}}
			}
        },
        messages : {
            g_name  : {
                required    : '<i class="icon-exclamation-sign"></i>{$Think.lang.store_goods_index_goods_name_null}',
                minlength   : '<i class="icon-exclamation-sign"></i>{$Think.lang.store_goods_index_goods_name_help}',
                maxlength   : '<i class="icon-exclamation-sign"></i>{$Think.lang.store_goods_index_goods_name_help}'
            },
            g_jingle : {
                maxlength   : '<i class="icon-exclamation-sign"></i>商品卖点不能超过140个字符'
            },
            g_price : {
                required    : '<i class="icon-exclamation-sign"></i>{$Think.lang.store_goods_index_store_price_null}',
                number      : '<i class="icon-exclamation-sign"></i>{$Think.lang.store_goods_index_store_price_error}',
                min         : '<i class="icon-exclamation-sign"></i>{$Think.lang.store_goods_index_store_price_interval}',
                max         : '<i class="icon-exclamation-sign"></i>{$Think.lang.store_goods_index_store_price_interval}'
            },
            g_marketprice : {
                required    : '<i class="icon-exclamation-sign"></i>请填写市场价',
                number      : '<i class="icon-exclamation-sign"></i>请填写正确的价格',
                min         : '<i class="icon-exclamation-sign"></i>请填写0.01~9999999之间的数字',
                max         : '<i class="icon-exclamation-sign"></i>请填写0.01~9999999之间的数字'
            },
            g_costprice : {
                number      : '<i class="icon-exclamation-sign"></i>请填写正确的价格',
                min         : '<i class="icon-exclamation-sign"></i>请填写0.00~9999999之间的数字',
                max         : '<i class="icon-exclamation-sign"></i>请填写0.00~9999999之间的数字'
            },
            g_storage : {
                required    : '<i class="icon-exclamation-sign"></i>{$Think.lang.store_goods_index_goods_stock_null}',
                digits      : '<i class="icon-exclamation-sign"></i>{$Think.lang.store_goods_index_goods_stock_error}',
                min         : '<i class="icon-exclamation-sign"></i>{$Think.lang.store_goods_index_goods_stock_checking}',
                max         : '<i class="icon-exclamation-sign"></i>{$Think.lang.store_goods_index_goods_stock_checking}'
            },
            image_path : {
                required    : '<i class="icon-exclamation-sign"></i>请设置商品主图'
            },
            g_vindate : {
                required    : '<i class="icon-exclamation-sign"></i>请选择有效期'
            },
			g_vlimit : {
				required	: '<i class="icon-exclamation-sign"></i>请填写1~10之间的数字',
				range		: '<i class="icon-exclamation-sign"></i>请填写1~10之间的数字'
			},
			g_fccount : {
				required	: '<i class="icon-exclamation-sign"></i>请填写1~100之间的数字',
				range		: '<i class="icon-exclamation-sign"></i>请填写1~100之间的数字'
			},
			g_fcprefix : {
				required	: '<i class="icon-exclamation-sign"></i>请填写3~5位的英文字母',
				rangelength	: '<i class="icon-exclamation-sign"></i>请填写3~5位的英文字母'
			},
			g_saledate : {
				required	: '<i class="icon-exclamation-sign"></i>请选择有效期'
			},
			g_deliverdate : {
				required	: '<i class="icon-exclamation-sign"></i>请选择有效期'
			}
        }
    });
    <?php if (isset($goods)) {?>
	setTimeout("setArea(<?php echo $goods['areaid_1'];?>, <?php echo $goods['areaid_2'];?>)", 1000);
	<?php }?>
});
// 按规格存储规格值数据
var spec_group_checked = [<?php for ($i=0; $i<$sign_i; $i++){if($i+1 == $sign_i){echo "''";}else{echo "'',";}}?>];
var str = '';
var V = new Array();

<?php for ($i=0; $i<$sign_i; $i++){?>
var spec_group_checked_<?php echo $i;?> = new Array();
<?php }?>

$(function(){
	$('dl[nctype="spec_group_dl"]').on('click', 'span[nctype="input_checkbox"] > input[type="checkbox"]',function(){
		into_array();
		goods_stock_set();
	});

	// 提交后不没有填写的价格或库存的库存配置设为默认价格和0
	// 库存配置隐藏式 里面的input加上disable属性
	$('input[type="submit"]').click(function(){
		$('input[data_type="price"]').each(function(){
			if($(this).val() == ''){
				$(this).val($('input[name="g_price"]').val());
			}
		});
		$('input[data_type="stock"]').each(function(){
			if($(this).val() == ''){
				$(this).val('0');
			}
		});
		$('input[data_type="alarm"]').each(function(){
			if($(this).val() == ''){
				$(this).val('0');
			}
		});
		if($('dl[nc_type="spec_dl"]').css('display') == 'none'){
			$('dl[nc_type="spec_dl"]').find('input').attr('disabled','disabled');
		}
	});
	
});

// 将选中的规格放入数组
function into_array(){
<?php for ($i=0; $i<$sign_i; $i++){?>
		
		spec_group_checked_<?php echo $i;?> = new Array();
		$('dl[nc_type="spec_group_dl_<?php echo $i;?>"]').find('input[type="checkbox"]:checked').each(function(){
			i = $(this).attr('nc_type');
			v = $(this).val();
			c = null;
			if ($(this).parents('dl:first').attr('spec_img') == 't') {
				c = 1;
			}
			spec_group_checked_<?php echo $i;?>[spec_group_checked_<?php echo $i;?>.length] = [v,i,c];
		});

		spec_group_checked[<?php echo $i;?>] = spec_group_checked_<?php echo $i;?>;

<?php }?>
}

// 生成库存配置
function goods_stock_set(){
    //  店铺价格 商品库存改为只读
    $('input[name="g_price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
    $('input[name="g_storage"]').attr('readonly','readonly').css('background','#E7E7E7 none');

    $('dl[nc_type="spec_dl"]').show();
    str = '<tr>';
    <?php recursionSpec(0,$sign_i);?>
    if(str == '<tr>'){
        //  店铺价格 商品库存取消只读
        $('input[name="g_price"]').removeAttr('readonly').css('background','');
        $('input[name="g_storage"]').removeAttr('readonly').css('background','');
        $('dl[nc_type="spec_dl"]').hide();
    }else{
        $('tbody[nc_type="spec_table"]').empty().html(str)
            .find('input[nc_type]').each(function(){
                s = $(this).attr('nc_type');
                try{$(this).val(V[s]);}catch(ex){$(this).val('');};
                if ($(this).attr('data_type') == 'marketprice' && $(this).val() == '') {
                    $(this).val($('input[name="g_marketprice"]').val());
                }
                if ($(this).attr('data_type') == 'price' && $(this).val() == ''){
                    $(this).val($('input[name="g_price"]').val());
                }
                if ($(this).attr('data_type') == 'stock' && $(this).val() == ''){
                    $(this).val('0');
                }
                if ($(this).attr('data_type') == 'alarm' && $(this).val() == ''){
                    $(this).val('0');
                }
            }).end()
            .find('input[data_type="stock"]').change(function(){
                computeStock();    // 库存计算
            }).end()
            .find('input[data_type="price"]').change(function(){
                computePrice();     // 价格计算
            }).end()
            .find('input[nc_type]').change(function(){
                s = $(this).attr('nc_type');
                V[s] = $(this).val();
            });
    }
}

<?php 
/**
 * 
 * 
 *  生成需要的js循环。递归调用	PHP
 * 
 *  形式参考 （ 2个规格）
 *  $('input[type="checkbox"]').click(function(){
 *      str = '';
 *      for (var i=0; i<spec_group_checked[0].length; i++ ){
 *      td_1 = spec_group_checked[0][i];
 *          for (var j=0; j<spec_group_checked[1].length; j++){
 *              td_2 = spec_group_checked[1][j];
 *              str += '<tr><td>'+td_1[0]+'</td><td>'+td_2[0]+'</td><td><input type="text" /></td><td><input type="text" /></td><td><input type="text" /></td>';
 *          }
 *      }
 *      $('table[class="spec_table"] > tbody').empty().html(str);
 *  });
 */
function recursionSpec($len,$sign) {
    if($len < $sign){
        echo "for (var i_".$len."=0; i_".$len."<spec_group_checked[".$len."].length; i_".$len."++){td_".(intval($len)+1)." = spec_group_checked[".$len."][i_".$len."];\n";
        $len++;
        recursionSpec($len,$sign);
    }else{
        echo "var tmp_spec_td = new Array();\n";
        for($i=0; $i< $len; $i++){
            echo "tmp_spec_td[".($i)."] = td_".($i+1)."[1];\n";
        }
        echo "tmp_spec_td.sort(function(a,b){return a-b});\n";
        echo "var spec_bunch = 'i_';\n";
        for($i=0; $i< $len; $i++){
            echo "spec_bunch += tmp_spec_td[".($i)."];\n";
        }
        echo "str += '<input type=\"hidden\" name=\"spec['+spec_bunch+'][goods_id]\" nc_type=\"'+spec_bunch+'|id\" value=\"\" />';";
        for($i=0; $i< $len; $i++){
            echo "if (td_".($i+1)."[2] != null) { str += '<input type=\"hidden\" name=\"spec['+spec_bunch+'][color]\" value=\"'+td_".($i+1)."[1]+'\" />';}";
            echo "str +='<td><input type=\"hidden\" name=\"spec['+spec_bunch+'][sp_value]['+td_".($i+1)."[1]+']\" value=\"'+td_".($i+1)."[0]+'\" />'+td_".($i+1)."[0]+'</td>';\n";
        }
        echo "str +='<td><input class=\"text price\" type=\"text\" name=\"spec['+spec_bunch+'][marketprice]\" data_type=\"marketprice\" nc_type=\"'+spec_bunch+'|marketprice\" value=\"\" /><em class=\"add-on\"><i class=\"icon-renminbi\"></i></em></td><td><input class=\"text price\" type=\"text\" name=\"spec['+spec_bunch+'][price]\" data_type=\"price\" nc_type=\"'+spec_bunch+'|price\" value=\"\" /><em class=\"add-on\"><i class=\"icon-renminbi\"></i></em></td><td><input class=\"text stock\" type=\"text\" name=\"spec['+spec_bunch+'][stock]\" data_type=\"stock\" nc_type=\"'+spec_bunch+'|stock\" value=\"\" /></td><td><input class=\"text stock\" type=\"text\" name=\"spec['+spec_bunch+'][alarm]\" data_type=\"alarm\" nc_type=\"'+spec_bunch+'|alarm\" value=\"\" /></td><td><input class=\"text sku\" type=\"text\" name=\"spec['+spec_bunch+'][sku]\" nc_type=\"'+spec_bunch+'|sku\" value=\"\" /></td></tr>';\n";
        for($i=0; $i< $len; $i++){
            echo "}\n";
        }
    }
}

?>


<?php if (!empty($goods) && !empty($sp_value) && !empty($spec_checked) && !empty($spec_list)){?>
    
//  编辑商品时处理JS
$(function(){
	var E_SP = new Array();
	var E_SPV = new Array();
	{php}
	$string = '';
	foreach ($spec_checked as $v) {
		$string .= "E_SP[".$v['id']."] = '".$v['name']."';";
	}
	echo $string;
	echo "\n";
	$string = '';
	foreach ($sp_value as $k=>$v) {
		$string .= "E_SPV['".$k."'] = '".$v."';";
	}
	echo $string;
	{/php}
	V = E_SPV;
	$('dl[nc_type="spec_dl"]').show();
	$('dl[nctype="spec_group_dl"]').find('input[type="checkbox"]').each(function(){
            
		//  店铺价格 商品库存改为只读
		$('input[name="g_price"]').attr('readonly','readonly').css('background','#E7E7E7 none');
		$('input[name="g_storage"]').attr('readonly','readonly').css('background','#E7E7E7 none');
		s = $(this).attr('nc_type');
		if (!(typeof(E_SP[s]) == 'undefined')){
			$(this).attr('checked',true);
			v = $(this).parents('li').find('span[nctype="pv_name"]');
			if(E_SP[s] != ''){
				$(this).val(E_SP[s]);
				v.html('<input type="text" maxlength="20" value="'+E_SP[s]+'" />');
			}else{
				v.html('<input type="text" maxlength="20" value="'+v.html()+'" />');
			}
			change_img_name($(this));			// 修改相关的颜色名称
		}
	});

    into_array();	// 将选中的规格放入数组
    str = '<tr>';
    <?php recursionSpec(0,$sign_i);?>
    if(str == '<tr>'){
        $('dl[nc_type="spec_dl"]').hide();
        $('input[name="g_price"]').removeAttr('readonly').css('background','');
        $('input[name="g_storage"]').removeAttr('readonly').css('background','');
    }else{
        $('tbody[nc_type="spec_table"]').empty().html(str)
            .find('input[nc_type]').each(function(){
                s = $(this).attr('nc_type');
                try{$(this).val(E_SPV[s]);}catch(ex){$(this).val('');};
            }).end()
            .find('input[data_type="stock"]').change(function(){
                computeStock();    // 库存计算
            }).end()
            .find('input[data_type="price"]').change(function(){
                computePrice();     // 价格计算
            }).end()
            .find('input[type="text"]').change(function(){
                s = $(this).attr('nc_type');
                V[s] = $(this).val();
            });
    }
});
<?php }?>
</script> 








    </div>
</div>
{include file="public/mall_footer" /}
