{include file="public/header" /}

<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 class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>商品管理</h3>
                <h5></h5>
            </div>
            {if isset($edit_goods_sign)}
            {include file="public/admin_items" /}
            {else /}
            <ul class="add-goods-step">
                <li><i class="icon fa fa-list-alt"></i>
                    <h6>STEP.1</h6>
                    <h2>{$Think.lang.select_category}</h2>
                    <i class="arrow fa fa-angle-right"></i> </li>
                <li class="current"><i class="icon fa fa-pencil-square"></i>
                    <h6>STEP.2</h6>
                    <h2>{$Think.lang.fill_item_details}</h2>
                    <i class="arrow fa fa-angle-right"></i> </li>
                <li><i class="icon fa fa-camera-retro "></i>
                    <h6>STEP.3</h6>
                    <h2>{$Think.lang.goods_index_upload_goods_pic}</h2>
                    <i class="arrow fa fa-angle-right"></i> </li>
                <li><i class="icon fa fa-check-circle-o"></i>
                    <h6>STEP.4</h6>
                    <h2>{$Think.lang.goods_index_flow_chart_step3}</h2>
                </li>
            </ul>
            {/if}
        </div>
    </div>
  <div class="fixed-empty"></div>
  
  
  <div id="fixedNavBar">
<h3>{$Think.lang.page_navigation}</h3>
  <ul>
    <li><a id="demo1Btn" href="#demo1" class="demoBtn">{$Think.lang.basic_information}</a></li>
    <li><a id="demo2Btn" href="#demo2" class="demoBtn">{$Think.lang.detailed_description}</a></li>
    <li><a id="demo3Btn" href="#demo3" class="demoBtn">{$Think.lang.special_goods}</a></li>
    <li><a id="demo4Btn" href="#demo4" class="demoBtn">{$Think.lang.logistics_freight}</a></li>
    <li><a id="demo5Btn" href="#demo5" class="demoBtn">{$Think.lang.invoice_information}</a></li>
    <li><a id="demo6Btn" href="#demo6" class="demoBtn">{$Think.lang.goods_index_goods_other_info}</a></li>
  </ul>
</div>
  
  
  
  
  
  
  
  
  
  
  <div class="item-publish">
  <form method="post" id="goods_form" action="{if isset($edit_goods_sign)}{:url('Goods/edit_save_goods')}{else/}{:url('Goodsadd/save_goods')}{/if}">
    <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.goods_index_goods_base_info}</h3>
      <dl>
        <dt>{$Think.lang.goods_index_goods_class}{$Think.lang.ds_colon}</dt>
        <dd id="gcategory"> {$goods_class.gctag_name|default=''}
            <a class="dssc-btn" href="{if isset($edit_goods_sign)}{:url('Goods/edit_class',['commonid'=>$goods['goods_commonid']])}{else/}{:url('Goodsadd/add_step_one')}{/if}">{$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.gctag_name|default=''}" class="text"/>
        </dd>
      </dl>
      <dl>
        <dt><i class="required">*</i>{$Think.lang.ds_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.goods_index_goods_name_help}</p>
        </dd>
      </dl>
      <dl>
        <dt>{$Think.lang.selling_point_}{$Think.lang.ds_colon}</dt>
        <dd>
          <textarea name="g_jingle" class="textarea h60 w400">{$goods.goods_advword|default=''}</textarea>
          <span></span>
          <p class="hint">{$Think.lang.price_instructions1}</p>
        </dd>
      </dl>
      <dl>
        <dt ds_type="no_spec"><i class="required">*</i>{$Think.lang.goods_index_price}{$Think.lang.ds_colon}</dt>
        <dd ds_type="no_spec">
          <input name="g_price" value="{$goods.goods_price|default=''}" type="text"  class="text w60" /><em class="add-on"><i class="fa fa-cny"></i></em> <span></span>
          <p class="hint">{$Think.lang.goods_index_price_help}，{$Think.lang.price_instructions2}<br>
            {$Think.lang.price_instructions3}</p>
        </dd>
      </dl>
      <dl>
        <dt><i class="required">*</i>{$Think.lang.market_price}{$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="fa fa-cny"></i></em> <span></span>
          <p class="hint">{$Think.lang.goods_index_price_help}{$Think.lang.price_instructions4}</p>
        </dd>
      </dl>
      <dl>
        <dt>{$Think.lang.cost_price}{$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="fa fa-cny"></i></em> <span></span>
          <p class="hint">{$Think.lang.price_instructions5}</p>
        </dd>
      </dl>
      <dl>
        <dt>{$Think.lang.discount}{$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">{$Think.lang.specifications_instructions1}</p>
        </dd>
      </dl>
      <?php if(is_array($spec_list) && !empty($spec_list)){?>
      <?php $i = '0';?>
      <?php foreach ($spec_list as $k=>$val){?>
      <dl ds_type="spec_group_dl_{$i}" dstype="spec_group_dl" class="spec-bg" {if $k == '1'}spec_img="t"{/if}>
        <dt>
          <input name="sp_name[{$k}]" type="text" class="text w60 tip2 tr" title="{$Think.lang.specifications_instructions2}" value="<?php if (isset($goods['spec_name'][$k])) { echo $goods['spec_name'][$k];} else {echo $val['sp_name'];}?>" maxlength="4" dstype="spec_name" data-param="{id:<?php echo $k;?>,name:'<?php echo $val['sp_name'];?>'}"/>
          {$Think.lang.ds_colon}
          </dt>
        <dd {if $k == '1'}dstype="sp_group_val"{/if}>
          <ul class="spec">
            <?php if(is_array($val['value'])){?>
            {foreach name="$val.value" item="v" }
            <li><span dstype="input_checkbox">
              <input type="checkbox" value="{$v.spvalue_name}" ds_type="{$v.spvalue_id}" {if $k == '1'}class="sp_val"{/if} name="sp_val[{$k}][{$v.spvalue_id}]">
              </span><span dstype="pv_name">{$v.spvalue_name}</span>
            </li>
            {/foreach}
            <?php }?>
            <li data-param="{gc_id:{$goods_class.gc_id},sp_id:{$k},url:'{:url('Goodsadd/ajax_add_spec')}'}">
              <div dstype="specAdd1"><a href="javascript:void(0);" class="dssc-btn" dstype="specAdd"><i class="fa fa-plus"></i>{$Think.lang.add_specification_value}</a></div>
              <div dstype="specAdd2" style="display:none;">
                <input class="text w60" type="text" placeholder="{$Think.lang.specification_value_name}" maxlength="20">
                <a href="javascript:void(0);" dstype="specAddSubmit" class="dssc-btn dssc-btn-acidblue ml5 mr5">{$Think.lang.ds_ok}</a><a href="javascript:void(0);" dstype="specAddCancel" class="dssc-btn dssc-btn-orange">{$Think.lang.ds_cancel}</a></div>
            </li>
          </ul>
          <?php if(isset($edit_goods_sign) && $k == '1'){?>
          <p class="hint">{$Think.lang.specifications_instructions3}</p>
          <?php }?>
        </dd>
      </dl>
      <?php $i++;?>
      <?php }?>
      <?php }?>
      <dl ds_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>
              {notempty name="spec_list"}
			  <?php $spec_i=0; ?>
              {foreach name="spec_list" item="val" key="k" }
            <th dstype="spec_name_{$k}" data-type="spec_name_<?php echo $spec_i; ?>" style="display:none"><?php if (isset($goods['spec_name'][$k])) { echo $goods['spec_name'][$k];} else {echo $val['sp_name'];}?></th>
              <?php $spec_i++; ?>
			  {/foreach}
              {/notempty}
              <th class="w90"><span class="red">*</span>{$Think.lang.market_price}
                <div class="batch"><i class="fa fa-pencil-square" title="{$Think.lang.batch_operation}"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>{$Think.lang.batch_setting_price}：</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">{$Think.lang.ds_set}</a><span class="arrow"></span></div>
                </div></th>
              <th class="w90"><span class="red">*</span>{$Think.lang.goods_index_price}
                <div class="batch"><i class="fa fa-pencil-square" title="{$Think.lang.batch_operation}"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>{$Think.lang.batch_setting_price}：</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">{$Think.lang.ds_set}</a><span class="arrow"></span></div>
                </div></th>
              <th class="w60"><span class="red">*</span>{$Think.lang.goods_index_stock}
                <div class="batch"><i class="fa fa-pencil-square" title="{$Think.lang.batch_operation}"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>{$Think.lang.batch_setting_inventory}：</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">{$Think.lang.ds_set}</a><span class="arrow"></span></div>
                </div></th>
              <th class="w70">{$Think.lang.warning_value}
                <div class="batch"><i class="fa fa-pencil-square" title="{$Think.lang.batch_operation}"></i>
                  <div class="batch-input" style="display:none;">
                    <h6>{$Think.lang.set_warning_value_batches}：</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">{$Think.lang.ds_set}</a><span class="arrow"></span></div>
                </div></th>
              <th class="w100">{$Think.lang.goods_index_goods_no}</th>
                </thead>
            <tbody ds_type="spec_table">
            </tbody>
          </table>
          <p class="hint">{$Think.lang.click}<i class="fa fa-pencil-square"></i>{$Think.lang.modify_value_column_batches}。</p>
        </dd>
      </dl>
      <dl>
        <dt ds_type="no_spec"><i class="required">*</i>{$Think.lang.goods_index_goods_stock}{$Think.lang.ds_colon}</dt>
        <dd ds_type="no_spec">
          <input name="g_storage" value="{$goods.g_storage|default=''}" type="text" class="text w60" />
          <span></span>
          <p class="hint">{$Think.lang.goods_index_goods_stock_help}</p>
        </dd>
      </dl>
      <dl>
        <dt>{$Think.lang.stock_warning_value}{$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">{$Think.lang.minimum_stock_warning_value}<br>
           {$Think.lang.fill_warning_number_value}</p>
        </dd>
      </dl>
      <dl>
        <dt ds_type="no_spec">{$Think.lang.goods_index_goods_no}{$Think.lang.ds_colon}</dt>
        <dd ds_type="no_spec">
          <p>
            <input name="g_serial" value="{$goods.goods_serial|default=''}" type="text"  class="text"  />
          </p>
          <p class="hint">{$Think.lang.goods_index_goods_no_help}</p>
        </dd>
      </dl>
      <dl>
        <dt><i class="required">*</i>{$Think.lang.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 dstype="goods_image" src="{:goods_thumb($goods, 240)}"/> </div>
              <input type="hidden" name="image_path" id="image_path" dstype="goods_image" value="{$goods.goods_image|default=''}" />
              <span></span>
              <p class="hint">{$Think.lang.goods_step2_description_one}<?php printf(lang('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="fa fa-upload"></i>{$Think.lang.goods_img_upload}</p>
                  </a> </div>
                <a class="dssc-btn mt5" dstype="show_image" href="{:url('Goodsalbum/pic_list',['item'=>'goods'])}"><i class="fa fa-picture-o"></i>{$Think.lang.image_space_selection}</a> <a href="javascript:void(0);" dstype="del_goods_demo" class="dssc-btn mt5" style="display: none;"><i class="fa fa-arrow-circle-up"></i>{$Think.lang.close_album}</a></div>
            </div>
          </div>
          <div id="demo"></div>
        </dd>
      </dl>
      <h3 id="demo2">{$Think.lang.goods_index_goods_detail_info}</h3>
      <dl style="overflow: visible;">
        <dt>{$Think.lang.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" dstype="add-on"><i class="fa fa-toggle-down"></i></em></div>
            <div class="dssc-brand-select-container">
              <div class="brand-index" data-tid="{$goods_class.type_id}" data-url="{:url('Goodsadd/ajax_get_brand')}">
                <div class="letter" dstype="letter">
                  <ul>
                    <li><a href="javascript:void(0);" data-letter="all">{$Think.lang.ds_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">{$Think.lang.goodsadd_empty}</a></li>
                  </ul>
                </div>
                <div class="search" dstype="search">
                  <input name="search_brand_keyword" id="search_brand_keyword" type="text" class="text" placeholder="{$Think.lang.brand_name_keyword_search}"/><a href="javascript:void(0);" class="dssc-btn-mini" style="vertical-align: top;">Go</a></div>
              </div>
              <div class="brand-list" dstype="brandList">
                <ul dstype="brand_list">
                  {notempty name="brand_list"}
                  {foreach name="brand_list" item="val"}
                  <li data-id='{$val.brand_id}'data-name='{$val.brand_name}'><em>{$val.brand_initial}</em>{$val.brand_name}</li>
                  {/foreach}
                  {/notempty}
                </ul>
              </div>
              <div class="no-result" dstype="noBrandList" style="display: none;">{$Think.lang.does_not_match}"<strong>{$Think.lang.search_keywords}</strong>"{$Think.lang.conditional_brand}</div>
            </div>
          </div>
        </dd>
      </dl>
      {notempty name="attr_list"}
      <dl>
        <dt>{$Think.lang.goods_index_goods_attr}{$Think.lang.ds_colon}</dt>
        <dd>
          {foreach name="attr_list" item="val" key="k" }
          <span class="mr30">
          <label class="mr5">{$val.attr_name}</label>
          <input type="hidden" name="attr[{$k}][name]" value="{$val.attr_name}" />
          {notempty name="val"}
          <select name="" attr="attr[{$k}][__NC__]" ds_type="attr_select">
            <option value='{$Think.lang.goodsadd_unlimited}' ds_type='0'>{$Think.lang.goodsadd_unlimited}</option>
            {foreach name="$val.value" item="v"}
            <option value="{$v.attrvalue_name}" <?php if(isset($attr_checked) && in_array($v['attrvalue_id'], $attr_checked)){?>selected="selected"<?php }?> ds_type="{$v.attrvalue_id}">{$v.attrvalue_name}</option>
            {/foreach}
          </select>
          {/notempty}
          </span>
          {/foreach}
        </dd>
      </dl>
      {/notempty}
      <dl>
        <dt>{$Think.lang.goods_index_goods_desc}{$Think.lang.ds_colon}</dt>
        <dd id="dsProductDetails">
          <div class="tabs">
            <ul class="ui-tabs-nav">
              <li class="ui-tabs-selected"><a href="#panel-1"><i class="fa fa-desktop"></i> {$Think.lang.computer_side}</a></li>
              <li class="selected"><a href="#panel-2"><i class="fa fa-mobile-phone"></i>{$Think.lang.mobile_side}</a></li>
            </ul>
            <div id="panel-1" class="ui-tabs-panel">
                {:build_editor(['name'=>'goods_body','content'=>$goods.goods_body?htmlspecialchars_decode($goods.goods_body):''])}
                <textarea name="goods_body" id="goods_body"></textarea>
              <div class="hr8">
                
                <a class="dssc-btn mt5" dstype="show_desc" href="{:url('Goodsalbum/pic_list',['item'=>'des'])}"><i class="fa fa-picture-o"></i>{$Think.lang.goods_album_insert_users_photo}</a> <a href="javascript:void(0);" dstype="del_desc" class="dssc-btn mt5" style="display: none;"><i class=" fa fa-arrow-circle-up"></i>{$Think.lang.close_album}</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 dstype="img_count_tip">{$Think.lang.picture_number_than}<em>20</em>{$Think.lang.goodsadd_sheet}</span><i>|</i><span dstype="txt_count_tip">{$Think.lang.words_must_not_exceed}<em>5000</em>{$Think.lang.goodsadd_words}</span></div>
                  <div class="control-panel" dstype="mobile_pannel">
                    {notempty name="$goods.mb_body"}
                    {foreach name="$goods.mb_body" item="val" }
                    {if $val.type == 'text'}
                    <div class="module m-text">
                      <div class="tools"><a dstype="mp_up" href="javascript:void(0);">{$Think.lang.goodsadd_up}</a><a dstype="mp_down" href="javascript:void(0);">{$Think.lang.goodsadd_down}</a><a dstype="mp_edit" href="javascript:void(0);">{$Think.lang.ds_edit}</a><a dstype="mp_del" href="javascript:void(0);">{$Think.lang.ds_del}</a></div>
                      <div class="content">
                        <div class="text-div">{$val.value}</div>
                      </div>
                      <div class="cover"></div>
                    </div>
                    {/if}
                    {if $val.type == 'image'}
                    <div class="module m-image">
                      <div class="tools"><a dstype="mp_up" href="javascript:void(0);">{$Think.lang.goodsadd_up}</a><a dstype="mp_down" href="javascript:void(0);">{$Think.lang.goodsadd_down}</a><a dstype="mp_rpl" href="javascript:void(0);">{$Think.lang.goodsadd_replace}</a><a dstype="mp_del" href="javascript:void(0);">{$Think.lang.ds_del}</a></div>
                      <div class="content">
                        <div class="image-div"><img src="{$val.value}"></div>
                      </div>
                      <div class="cover"></div>
                    </div>
                    {/if}
                    {/foreach}
                    {/notempty}
                  </div>
                  <div class="add-btn">
                    <ul class="btn-wrap">
                      <li><a href="javascript:void(0);" dstype="mb_add_img"><i class="fa fa-picture-o"></i>
                        <p>{$Think.lang.goodsadd_picture}</p>
                        </a></li>
                      <li><a href="javascript:void(0);" dstype="mb_add_txt"><i class="fa fa-font"></i>
                        <p>{$Think.lang.goodsadd_text}</p>
                        </a></li>
                    </ul>
                  </div>
                </div>
                <div class="explain">
                  <dl>
                    <dt>{$Think.lang.request_information1}</dt>
                    <dd>{$Think.lang.request_information2}</dd>
                    <dd>{$Think.lang.request_information3}</dd>
                  </dl><dl>
                    <dt>{$Think.lang.request_information4}</dt>
                    <dd>{$Think.lang.request_information5}</dd>
                    <dd>{$Think.lang.request_information6}</dd>
                    <dd>{$Think.lang.request_information7}</dd>
                  </dl><dl>
                    <dt>{$Think.lang.request_information8}</dt>
                    <dd>{$Think.lang.request_information9}</dd>
                    <dd>{$Think.lang.request_information10}</dd>
                    <dd>{$Think.lang.request_information11}</dd>
                    <dd>{$Think.lang.request_information12}</dd>
                  </dl>
                </div>
              </div>
              <div class="dssc-mobile-edit-area" dstype="mobile_editor_area">
                <div dstype="mea_img" class="dssc-mea-img" style="display: none;"></div>
                <div class="dssc-mea-text" dstype="mea_txt" style="display: none;">
                  <p id="meat_content_count" class="text-tip"></p>
                  <textarea class="textarea valid" dstype="meat_content"></textarea>
                  <div class="button"><a class="dssc-btn dssc-btn-blue" dstype="meat_submit" href="javascript:void(0);">确认</a><a class="dssc-btn ml10" dstype="meat_cancel" href="javascript:void(0);">{$Think.lang.ds_cancel}</a></div>
                  <a class="text-close" dstype="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 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="fa fa-upload" data_type="0" dstype="add_album_i"></i>{$Think.lang.goods_img_upload}</p>
                  </a>
                </div>
          </div>
        </dd>
      </dl>
      <h3 id="demo3">{$Think.lang.special_goods}</h3>
      <!-- 只有可发布虚拟商品才会显示 S -->
      {if $goods_class.gc_virtual == 1}
      <dl class="special-01">
        <dt>{$Think.lang.virtual_goods}{$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">{$Think.lang.ds_yes}</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">{$Think.lang.ds_no}</label>
            </li>
          </ul>
          <p class="hint vital">{$Think.lang.virtual_goods_instructions1}</p>
        </dd>
      </dl>
      <dl class="special-01" dstype="virtual_valid" <?php if ($goods['is_virtual'] == 0) {?>style="display:none;"<?php }?>>
        <dt><i class="required">*</i>{$Think.lang.virtual_goods_instructions2}{$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="fa fa-calendar"></i></em>
          <span></span>
          <p class="hint">{$Think.lang.virtual_goods_instructions3}</p>
        </dd>
      </dl>
      <dl class="special-01" dstype="virtual_valid" <?php if ($goods['is_virtual'] == 0) {?>style="display:none;"<?php }?>>
        <dt><i class="required">*</i>{$Think.lang.virtual_goods_instructions4}{$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">{$Think.lang.virtual_goods_instructions5}</p>
        </dd>
      </dl>
      <dl class="special-01" dstype="virtual_valid" <?php if ($goods['is_virtual'] == 0) {?>style="display:none;"<?php }?>>
        <dt>{$Think.lang.virtual_goods_instructions6}{$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">{$Think.lang.ds_yes}</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">{$Think.lang.ds_no}</label>
            </li>
          </ul>
          <p class="hint">{$Think.lang.virtual_goods_instructions7}</p>
        </dd>
      </dl>
      {/if}
      <!-- 只有可发布虚拟商品才会显示 E --> 
      <!-- F码商品专有项 S -->
      <dl class="special-02" dstype="virtual_null" <?php if (isset($goods['is_virtual']) && $goods['is_virtual'] == 1) {?>style="display:none;"<?php }?>>
        <dt>{$Think.lang.f_code_goods}{$Think.lang.ds_colon}</dt>
        <dd>
          <ul class="dssc-form-radio-list">
            <li>
              <input type="radio" name="is_fc" id="is_goodsfcode_1" value="1" <?php if (isset($goods['is_goodsfcode']) && $goods['is_goodsfcode'] == 1) {?>checked<?php }?>>
              <label for="is_goodsfcode_1">{$Think.lang.ds_yes}</label>
            </li>
            <li>
              <input type="radio" name="is_fc" id="is_goodsfcode_0" value="0" <?php if (isset($goods['is_goodsfcode']) && $goods['is_goodsfcode'] == 0) {?>checked<?php }?>>
              <label for="is_goodsfcode_0">{$Think.lang.ds_no}</label>
            </li>
          </ul>
          <p class="hint vital">{$Think.lang.f_code_guidelines1}</p>
        </dd>
      </dl>
      <dl class="special-02" dstype="fcode_valid" <?php if (isset($goods['is_goodsfcode']) && $goods['is_goodsfcode'] == 0) {?>style="display:none;"<?php }?>>
        <dt>
          {if !isset($edit_goods_sign)}
          <i class="required">*</i>
          {/if}
          {$Think.lang.f_code_guidelines2}{$Think.lang.ds_colon}</dt>
        <dd>
          <input type="text" name="g_fccount" id="g_fccount" class="w80 text" value="">
          <span></span>
          <p class="hint">{$Think.lang.f_code_guidelines3}</p>
        </dd>
      </dl>
      <dl class="special-02" dstype="fcode_valid" <?php if (isset($goods['is_goodsfcode']) && $goods['is_goodsfcode'] == 0) {?>style="display:none;"<?php }?>>
        <dt>
          {if !isset($edit_goods_sign)}
          <i class="required">*</i>
          {/if}
          {$Think.lang.f_code_guidelines4}{$Think.lang.ds_colon}</dt>
        <dd>
          <input type="text" name="g_fcprefix" id="g_fcprefix" class="w80 text" value="">
          <span></span>
          <p class="hint">{$Think.lang.f_code_guidelines5}</p>
        </dd>
      </dl>
      <?php if (isset($goods['is_goodsfcode']) && $goods['is_goodsfcode'] == 1) {?>
      <dl class="special-02" dstype="fcode_valid">
        <dt>
        <a class="dssc-btn-mini dssc-btn-red" href="{:url('Goods/download_f_code_excel',['commonid'=>$goods.goods_commonid])}">{$Think.lang.download_code_f}</a>&nbsp;&nbsp;{$Think.lang.goodsadd_f_code}{$Think.lang.ds_colon}</dt>
        <dd>
          <ul class="dssc-form-radio-list">
            {notempty name="fcode_array"}
            {foreach name="fcode_array" item="val" }
            <li>
                {$val.goodsfcode_code}({if $val.goodsfcode_state == 1}{$Think.lang.goodsadd_employ}{else /}{$Think.lang.goodsadd_unused}{/if})
            </li>
            {/foreach}
            {/notempty}
          </ul>
        </dd>
      </dl>
      <?php }?>
      <!-- F码商品专有项 E --> 
      <!-- 预售商品 S -->
      <dl class="special-03" dstype="virtual_null" <?php if (isset($goods['is_virtual']) && $goods['is_virtual'] == 1) {?>style="display:none;"<?php }?>>
        <dt>{$Think.lang.goodsadd_presell}{$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">{$Think.lang.ds_yes}</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">{$Think.lang.ds_no}</label>
            </li>
          </ul>
          <p class="hint vital">{$Think.lang.booking_information}</p>
        </dd>
      </dl>
      <dl class="special-03" dstype="is_presell" <?php if (isset($goods['is_presell']) && $goods['is_presell'] == 0) {?>style="display:none;"<?php }?>>
        <dt><i class="required">*</i>{$Think.lang.delivery_date}{$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="fa fa-calendar"></i></em>
          <span></span>
          <p class="hint">{$Think.lang.ship_time}。</p>
        </dd>
      </dl>
      <!-- 预售商品 E --> 
      <!-- 商品物流信息 S -->
      <h3 id="demo4">{$Think.lang.goods_index_goods_transport}</h3>
      <dl>
        <dt>{$Think.lang.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 dstype="virtual_null" {if $goods.is_virtual == 1}style="display:none;"{/if}>
        <dt>{$Think.lang.order_total_transport}{$Think.lang.ds_colon}</dt>
        <dd>
          <ul class="dssc-form-radio-list">
            <li>
              <input id="freight_0" dstype="freight" name="freight" class="radio" type="radio" <?php if (intval($goods['transport_id']) == 0) {?>checked="checked"<?php }?> value="0">
              <label for="freight_0">{$Think.lang.fixed_freight}</label>
              <div dstype="div_freight" <?php if (intval($goods['transport_id']) != 0) {?>style="display: none;"<?php }?>>
                <input id="g_freight" class="w50 text" ds_type='transport' type="text" value="<?php printf('%.2f', floatval($goods['goods_freight']));?>" name="g_freight"><em class="add-on"><i class="fa fa-cny"></i></em> </div>
            </li>
            <li>
              <input id="freight_1" dstype="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.goods_index_use_tpl}</label>
              <div dstype="div_freight" <?php if (intval($goods['transport_id']) == 0) {?>style="display: none;"<?php }?>>
                <input id="transport_id" type="hidden" value="{$goods.transport_id}" name="transport_id">
                <input id="transport_title" type="hidden" value="{$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 }?>>{$goods.transport_title}</span>
                <a href="JavaScript:void(0);" onclick="window.open('{:url('Transport/index',['type'=>'select'])}')" class="dsbtn" id="postageButton"><i class="fa fa-truck"></i>{$Think.lang.goods_index_select_tpl}</a> 
              </div>
            </li>
          </ul>
          <p class="hint"> {$Think.lang.freight_set}</p>
        </dd>
      </dl>
      <!-- 商品物流信息 E -->
      <h3 id="demo5" dstype="virtual_null" <?php if ($goods['is_virtual'] == 1) {?>style="display:none;"<?php }?>>{$Think.lang.invoice_information}</h3>
      <dl dstype="virtual_null" <?php if ($goods['is_virtual'] == 1) {?>style="display:none;"<?php }?>>
        <dt>{$Think.lang.whether_add_tax_invoice}：</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>
      <dl>
        <dt>{$Think.lang.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.goods_index_immediately_sales}</label>
            </li>
            <li>
              <label>
                <input name="g_state" value="0" type="radio" dstype="auto" />
                 {$Think.lang.goods_step2_start_time}
              </label>
              <input type="text" class="w80 text" name="starttime" disabled="disabled" style="background:#E7E7E7 none;" id="starttime" value="{:date('Y-m-d')}" />
              <select disabled="disabled" style="background:#E7E7E7 none;" name="starttime_H" id="starttime_H">
                  {foreach name="hour_array" item="val" }
                  <option value="{$val}" <?php $sign_h = 0;if($val>=date('h') && $sign_h != 1){?>selected="selected"<?php $sign_H = 1;}?>>{$val}</option>
                  {/foreach}
              </select>
              {$Think.lang.goods_step2_hour}
              <select disabled="disabled" style="background:#E7E7E7 none;" name="starttime_i" id="starttime_i">
                {foreach name="minute_array" item="val"}
                <option value="{$val}" <?php $sign_mi = 0;if($val>=date('i') && $sign_mi != 1){?>selected="selected"<?php $sign_mi = 1;}?>>{$val}</option>
                {/foreach}
              </select>
               {$Think.lang.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.goods_index_in_warehouse} </label>
            </li>
          </ul>
        </dd>
      </dl>
      <dl>
        <dt>{$Think.lang.goodsadd_make}{$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">{$Think.lang.ds_yes}</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">{$Think.lang.ds_no}</label>
            </li>
          </ul>
          <p class="hint">{$Think.lang.booking_information}</p>
        </dd>
      </dl>
      <dl dstype="is_appoint"  <?php if ($goods['is_appoint'] == 0) {?>style="display:none;"<?php }?>>
        <dt><i class="required">*</i>{$Think.lang.release_date}{$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">{$Think.lang.booking_goods}</p>
        </dd>
      </dl>
      <dl>
        <dt>{$Think.lang.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.goods_index_recommend_tip}</p>
        </dd>
      </dl>
    </div>
    <div class="bottom tc hr32">
        <input type="submit" class="btn" value="<?php if (isset($edit_goods_sign)) {echo lang('ds_submit');} else {?>{$Think.lang.goods_add_next}，{$Think.lang.goods_index_upload_goods_pic}<?php }?>" />
    </div>
  </form>
</div>


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

<script src="{$Think.PLUGINS_SITE_ROOT}/jquery.mousewheel.js"></script>
<script type="text/javascript" src="{$Think.PLUGINS_SITE_ROOT}/jquery.charCount.js"></script>


<!--[if lt IE 8]>
  <script src="{$Think.BASE_SITE_ROOT}/js/json2.js"></script>
<![endif]-->
<script src="{$Think.ADMIN_SITE_ROOT}/js/goods_add_step2.js"></script>


<script type="text/javascript">
var DEFAULT_GOODS_IMAGE = "{:goods_thumb(array(), 60)}";

$(function(){
    $("#region").ds_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="fa fa-exclamation-circle"></i>{$Think.lang.not_higher_than}');
	jQuery.validator.addMethod("checkFCodePrefix", function(value, element) {       
		return this.optional(element) || /^[a-zA-Z]+$/.test(value);       
	},'<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information1}');  
    $('#goods_form').validate({
        errorPlacement: function(error, element){
            $(element).nextAll('span').append(error);
        },
        //方便测试一下可进行删除
        <?php if (isset($edit_goods_sign)) {?>
        submitHandler:function(form){
            ds_ajaxpost('goods_form', 'url', '{:url('goods/index')}');
        },
        <?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_goodsfcode_1").prop("checked")) {return true;} else {return false;}},<?php }?>
				range		: [1,100]
			},
			g_fcprefix : {
				<?php if (!isset($edit_goods_sign)) {?>required	: function() {if ($("#is_goodsfcode_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="fa fa-exclamation-circle"></i>{$Think.lang.goods_index_goods_name_null}',
                minlength   : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.goods_index_goods_name_help}',
                maxlength   : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.goods_index_goods_name_help}'
            },
            g_jingle : {
                maxlength   : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information2}'
            },
            g_price : {
                required    : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.goods_index_price_null}',
                number      : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.goods_index_price_error}',
                min         : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.goods_index_price_interval}',
                max         : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.goods_index_price_interval}'
            },
            g_marketprice : {
                required    : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information3}',
                number      : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information4}',
                min         : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information5}0.01~9999999{$Think.lang.prompt_information6}',
                max         : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information5}0.01~9999999{$Think.lang.prompt_information6}'
            },
            g_costprice : {
                number      : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information4}',
                min         : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information5}0.00~9999999{$Think.lang.prompt_information6}',
                max         : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information5}0.00~9999999{$Think.lang.prompt_information6}'
            },
            g_storage : {
                required    : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.goods_index_goods_stock_null}',
                digits      : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.goods_index_goods_stock_error}',
                min         : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.goods_index_goods_stock_checking}',
                max         : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.goods_index_goods_stock_checking}'
            },
            image_path : {
                required    : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information8}'
            },
            g_vindate : {
                required    : '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information9}'
            },
			g_vlimit : {
				required	: '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information5}1~10{$Think.lang.prompt_information6}',
				range		: '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information5}1~10{$Think.lang.prompt_information6}'
			},
			g_fccount : {
				required	: '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information5}1~100{$Think.lang.prompt_information6}',
				range		: '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information5}1~100{$Think.lang.prompt_information6}'
			},
			g_fcprefix : {
				required	: '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information5}3~5{$Think.lang.prompt_information7}',
				rangelength	: '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information5}3~5{$Think.lang.prompt_information7}'
			},
			g_saledate : {
				required	: '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information9}'
			},
			g_deliverdate : {
				required	: '<i class="fa fa-exclamation-circle"></i>{$Think.lang.prompt_information9}'
			}
        }
    });
    <?php if (isset($goods)) {?>
	setTimeout("setArea(<?php echo $goods['areaid_1'];?>, <?php echo $goods['areaid_2'];?>)", 1000);
	<?php }?>
});
// 按规格存储规格值数据
var spec_group_checked = new Array();
<?php for($i=0; $i<$sign_i; $i++){ ?>  
        spec_group_checked["<?php echo $i;?>"]='';
<?php } ?>
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[dstype="spec_group_dl"]').on('click', 'span[dstype="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[ds_type="spec_dl"]').css('display') == 'none'){
			$('dl[ds_type="spec_dl"]').find('input').prop('disabled','disabled');
		}
	});
	
});

// 将选中的规格放入数组
function into_array(){
<?php for ($i=0; $i<$sign_i; $i++){?>
		
		spec_group_checked_<?php echo $i;?> = new Array();
		$('dl[ds_type="spec_group_dl_<?php echo $i;?>"]').find('input[type="checkbox"]:checked').each(function(){
			i = $(this).attr('ds_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[ds_type="spec_dl"]').show();
    str = '<tr>';
    <?php recursionSpec(0,$sign_i);?>
    //生成字符串开始

var total_length=0;
for(var i in checked_group){
$('[data-type=spec_name_'+(i)+']').show();
if(total_length==0){
    total_length=1;
}
total_length=total_length*spec_group_checked[checked_group[i]].length;
}

var k=new Array();
var l=0;
var n=0;
for(var j=0;j<total_length;j++){
    var spec_bunch='i_';
    var sub_str='';
    sub_str += '<input type="hidden" name="spec[spec_bunch][goods_id]" ds_type="spec_bunch|id" value="" />';
    for(var i in checked_group){
        
        
        if(typeof(k[checked_group[i]])=='undefined'){
            k[checked_group[i]]=0;
        }
        spec_bunch+=spec_group_checked[checked_group[i]][k[checked_group[i]]][1];
        if (spec_group_checked[checked_group[i]][k[checked_group[i]]][2] != null) { sub_str += '<input type="hidden" name="spec[spec_bunch][color]" value="'+spec_group_checked[checked_group[i]][k[checked_group[i]]][1]+'" />';}
        sub_str +='<td><input type="hidden" name="spec[spec_bunch][sp_value]['+spec_group_checked[checked_group[i]][k[checked_group[i]]][1]+']" value="'+spec_group_checked[checked_group[i]][k[checked_group[i]]][0]+'" />'+spec_group_checked[checked_group[i]][k[checked_group[i]]][0]+'</td>';    
        //checked_group存储选中的规格的键
		//spec_group_checked存储选中的规格的值
		//k表示规格值的指针
		//total_length表示选中规格的总长度
		
		//由最后一个规格开始遍历，如果满了，则前面的规格指针增加，同时当前指针指置0
		
		//最后一个规格项
		//最后规格的指针增加
		//最后一个规格的指针满了
		//从最后的规格开始向前遍历
		//如果规格指针没有满
		//规格指针增加
		//规格指针复位
        if(i==(checked_group.length-1)){
            k[checked_group[i]]++;
            if(k[checked_group[i]]==spec_group_checked[checked_group[i]].length){
                for(var m = (checked_group.length-1);m>=0;m--){
                    if(k[checked_group[m]]<(spec_group_checked[checked_group[m]].length-1)){
                        k[checked_group[m]]++;
						break;
                    }else{
                        k[checked_group[m]]=0;
                    }
                }
            }
        }
    }

    sub_str +='<td><input class="text price" type="text" name="spec[spec_bunch][marketprice]" data_type="marketprice" ds_type="spec_bunch|marketprice" value="" /><em class="add-on"><i class="fa fa-cny"></i></em></td><td><input class="text price" type="text" name="spec[spec_bunch][price]" data_type="price" ds_type="spec_bunch|price" value="" /><em class="add-on"><i class="fa fa-cny"></i></em></td><td><input class="text stock" type="text" name="spec[spec_bunch][stock]" data_type="stock" ds_type="spec_bunch|stock" value="" /></td><td><input class="text stock" type="text" name="spec[spec_bunch][alarm]" data_type="alarm" ds_type="spec_bunch|alarm" value="" /></td><td><input class="text sku" type="text" name="spec[spec_bunch][sku]" ds_type="spec_bunch|sku" value="" /></td></tr>';
    sub_str=sub_str.replace(/spec_bunch/g, spec_bunch);
    str +=sub_str;
}
    //生成字符串结束

    if(str == '<tr>'){
        //  店铺价格 商品库存取消只读
        $('input[name="g_price"]').removeAttr('readonly').css('background','');
        $('input[name="g_storage"]').removeAttr('readonly').css('background','');
        $('dl[ds_type="spec_dl"]').hide();
    }else{
        $('tbody[ds_type="spec_table"]').empty().html(str)
            .find('input[ds_type]').each(function(){
                s = $(this).attr('ds_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[ds_type]').change(function(){
                s = $(this).attr('ds_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) {
echo "var checked_group=new Array();\n";
for($i=0; $i< $sign; $i++){
    echo "if(spec_group_checked['".$i."'].length>0){ checked_group.push('".$i."'); }\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[ds_type="spec_dl"]').show();
	$('dl[dstype="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('ds_type');
		if (!(typeof(E_SP[s]) == 'undefined')){
			$(this).prop('checked',true);
			v = $(this).parents('li').find('span[dstype="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);?>
        
    //生成字符串开始

var total_length=0;
for(var i in checked_group){
$('[data-type=spec_name_'+(i)+']').show();
if(total_length==0){
    total_length=1;
}
total_length=total_length*spec_group_checked[checked_group[i]].length;
}

var k=new Array();
var l=0;
var n=0;
for(var j=0;j<total_length;j++){
    var spec_bunch='i_';
    var sub_str='';
    sub_str += '<input type="hidden" name="spec[spec_bunch][goods_id]" ds_type="spec_bunch|id" value="" />';
    for(var i in checked_group){
        
        
        if(typeof(k[checked_group[i]])=='undefined'){
            k[checked_group[i]]=0;
        }
        spec_bunch+=spec_group_checked[checked_group[i]][k[checked_group[i]]][1];
        if (spec_group_checked[checked_group[i]][k[checked_group[i]]][2] != null) { sub_str += '<input type="hidden" name="spec[spec_bunch][color]" value="'+spec_group_checked[checked_group[i]][k[checked_group[i]]][1]+'" />';}
        sub_str +='<td><input type="hidden" name="spec[spec_bunch][sp_value]['+spec_group_checked[checked_group[i]][k[checked_group[i]]][1]+']" value="'+spec_group_checked[checked_group[i]][k[checked_group[i]]][0]+'" />'+spec_group_checked[checked_group[i]][k[checked_group[i]]][0]+'</td>';    
        
        if(i==(checked_group.length-1)){
            k[checked_group[i]]++;
            if(k[checked_group[i]]==spec_group_checked[checked_group[i]].length){
                for(var m = (checked_group.length-1);m>=0;m--){
                    if(k[checked_group[m]]<(spec_group_checked[checked_group[m]].length-1)){
                        k[checked_group[m]]++;
						break;
                    }else{
                        k[checked_group[m]]=0;
                    }
                }
            }
        }
    }
    
    sub_str +='<td><input class="text price" type="text" name="spec[spec_bunch][marketprice]" data_type="marketprice" ds_type="spec_bunch|marketprice" value="" /><em class="add-on"><i class="fa fa-cny"></i></em></td><td><input class="text price" type="text" name="spec[spec_bunch][price]" data_type="price" ds_type="spec_bunch|price" value="" /><em class="add-on"><i class="fa fa-cny"></i></em></td><td><input class="text stock" type="text" name="spec[spec_bunch][stock]" data_type="stock" ds_type="spec_bunch|stock" value="" /></td><td><input class="text stock" type="text" name="spec[spec_bunch][alarm]" data_type="alarm" ds_type="spec_bunch|alarm" value="" /></td><td><input class="text sku" type="text" name="spec[spec_bunch][sku]" ds_type="spec_bunch|sku" value="" /></td></tr>';
    sub_str=sub_str.replace(/spec_bunch/g, spec_bunch);
    str +=sub_str;
}
    //生成字符串结束
    
    
    if(str == '<tr>'){
        $('dl[ds_type="spec_dl"]').hide();
        $('input[name="g_price"]').removeAttr('readonly').css('background','');
        $('input[name="g_storage"]').removeAttr('readonly').css('background','');
    }else{
        $('tbody[ds_type="spec_table"]').empty().html(str)
            .find('input[ds_type]').each(function(){
                s = $(this).attr('ds_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('ds_type');
                V[s] = $(this).val();
            });
    }
});
<?php }?>
</script> 

  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
</div>  
