# 商品发布与编辑
发布新商品
文件路径:shop/controllers/Seller/GoodsCtl.php;
发布:add();
编辑:online();参数:action=edit\_goods
##### 1、选择分类
显示分类:
```
<pre class="calibre14">```
$Goods_CatModel <span class="token">=</span> <span class="token2">new</span> <span class="token3">Goods_CatModel</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$cat_rows <span class="token">=</span> $Goods_CatModel<span class="token">-</span><span class="token">></span><span class="token3">getCatTreeData</span><span class="token1">(</span><span class="token6">0</span><span class="token1">,</span> <span class="token6">false</span><span class="token1">,</span> <span class="token6">0</span><span class="token1">,</span> <span class="token6">true</span><span class="token1">)</span><span class="token1">;</span>
foreach <span class="token1">(</span>$cat_rows as $cat_id<span class="token">=</span><span class="token">></span>$cat_row<span class="token1">)</span>
<span class="token1">{</span>
<span class="token">?</span><span class="token">></span>
<span class="token"><</span>li id<span class="token">=</span><span class="token4">"<?=$cat_row['cat_id']?>|<?=$cat_row['cat_level']?>"</span> onclick<span class="token">=</span><span class="token4">"selClass(this);"</span> class<span class="token">=</span><span class="token4">""</span><span class="token">></span><span class="token"><</span>a href<span class="token">=</span><span class="token4">"javascript:void(0)"</span><span class="token">></span><span class="token"><</span>i class<span class="token">=</span><span class="token4">"iconfont icon-angle-right"</span><span class="token">></span><span class="token"><</span><span class="token">/</span>i<span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span>$cat_row<span class="token1">[</span><span class="token4">'cat_name'</span><span class="token1">]</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>a<span class="token">></span><span class="token"><</span><span class="token">/</span>li<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php
<span class="token1">}</span>
<span class="token">?</span><span class="token">></span>
```
```
选择分类:
```
<pre class="calibre14">```
<span class="token2">function</span> <span class="token3">selClass</span><span class="token1">(</span>obj<span class="token1">)</span><span class="token1">{</span>
$<span class="token1">(</span><span class="token4">'.item_list'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">css</span><span class="token1">(</span><span class="token4">'background'</span><span class="token1">,</span><span class="token4">''</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span><span class="token4">"#span"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">hide</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span><span class="token4">"#dt"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">show</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span><span class="token4">"#dd"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">show</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span>obj<span class="token1">)</span><span class="token1">.</span><span class="token3">siblings</span><span class="token1">(</span><span class="token4">'li'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">children</span><span class="token1">(</span><span class="token4">'a'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'class'</span><span class="token1">,</span><span class="token4">''</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span>obj<span class="token1">)</span><span class="token1">.</span><span class="token3">children</span><span class="token1">(</span><span class="token4">'a'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'class'</span><span class="token1">,</span><span class="token4">'selected'</span><span class="token1">)</span><span class="token1">;</span>
<span class="token3">tonextClass</span><span class="token1">(</span>obj<span class="token1">.</span>id<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
##### 2、填写商品信息
商品品牌:
```
<pre class="calibre14">```
<span class="token"><</span>select name<span class="token">=</span><span class="token4">"brand_id"</span> class<span class="token">=</span><span class="token4">"w250"</span> onchange<span class="token">=</span><span class="token4">"brandName(this)"</span> <span class="token">></span>
<span class="token"><</span>option value<span class="token">=</span><span class="token4">""</span><span class="token">></span><span class="token"><</span><span class="token">?</span><span class="token">=</span><span class="token3">__</span><span class="token1">(</span><span class="token4">'请选择'</span><span class="token1">)</span><span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>option<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php foreach <span class="token1">(</span> $data<span class="token1">[</span><span class="token4">'brand'</span><span class="token1">]</span> as $key <span class="token">=</span><span class="token">></span> $val <span class="token1">)</span> <span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span>option <span class="token"><</span><span class="token">?</span>php <span class="token2">if</span><span class="token1">(</span><span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$common_data<span class="token1">)</span> <span class="token">&&</span> $common_data<span class="token1">[</span><span class="token4">'brand_id'</span><span class="token1">]</span><span class="token">==</span>$val<span class="token1">[</span><span class="token4">'brand_id'</span><span class="token1">]</span><span class="token1">)</span> echo <span class="token4">'selected'</span><span class="token1">;</span> <span class="token">?</span><span class="token">></span> value<span class="token">=</span><span class="token4">"<?php echo $val['brand_id']; ?>"</span><span class="token">></span><span class="token"><</span><span class="token">?</span>php echo $val<span class="token1">[</span><span class="token4">'brand_name'</span><span class="token1">]</span><span class="token1">;</span> <span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>option<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">/</span>select<span class="token">></span>
<span class="token2">function</span> <span class="token3">brandName</span><span class="token1">(</span>e<span class="token1">)</span> <span class="token1">{</span>
var brandName <span class="token">=</span> $<span class="token1">(</span>e<span class="token1">)</span><span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">':selected'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">html</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span><span class="token4">'input[name="brand_name"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span>brandName<span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
```
```
商品属性:
```
<pre class="calibre14">```
<span class="token"><</span><span class="token">?</span>php foreach <span class="token1">(</span> $data<span class="token1">[</span><span class="token4">'property'</span><span class="token1">]</span> as $key <span class="token">=</span><span class="token">></span> $val <span class="token1">)</span> <span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token2">if</span> <span class="token1">(</span> $val<span class="token1">[</span><span class="token4">'property_format'</span><span class="token1">]</span> <span class="token">==</span> <span class="token4">'select'</span> <span class="token1">)</span> <span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span>tr<span class="token">></span>
<span class="token"><</span>th style<span class="token">=</span><span class="token4">"width: 15%;"</span><span class="token">></span><span class="token"><</span><span class="token">?</span>php echo $val<span class="token1">[</span><span class="token4">'property_name'</span><span class="token1">]</span> <span class="token">?</span><span class="token">></span>:<span class="token"><</span><span class="token">/</span>th<span class="token">></span>
<span class="token"><</span>td<span class="token">></span>
<span class="token"><</span>input type<span class="token">=</span><span class="token4">'hidden'</span> name<span class="token">=</span><span class="token4">'property[property_<?php echo $val['</span>property_id<span class="token4">']; ?>][0]'</span> value<span class="token">=</span><span class="token4">'<?php echo $val['</span>property_name<span class="token4">']; ?>'</span><span class="token">/</span><span class="token">></span>
<span class="token"><</span>input type<span class="token">=</span><span class="token4">'hidden'</span> name<span class="token">=</span><span class="token4">'property[property_<?php echo $val['</span>property_id<span class="token4">']; ?>][2]'</span> value<span class="token">=</span><span class="token4">'select'</span><span class="token">/</span><span class="token">></span>
<span class="token"><</span>select name<span class="token">=</span><span class="token4">'property[property_<?php echo $val['</span>property_id<span class="token4">']; ?>][1]'</span><span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token2">if</span> <span class="token1">(</span> <span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'property_values'</span><span class="token1">]</span><span class="token1">)</span> <span class="token1">)</span> <span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">?</span>php foreach <span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'property_values'</span><span class="token1">]</span> as $k <span class="token">=</span><span class="token">></span> $v<span class="token1">)</span><span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span>option <span class="token"><</span><span class="token">?</span>php <span class="token2">if</span> <span class="token1">(</span> <span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$common_data<span class="token1">)</span> <span class="token">&&</span> $common_data<span class="token1">[</span><span class="token4">'common_property'</span><span class="token1">]</span><span class="token1">[</span><span class="token4">'property_'</span> <span class="token1">.</span> $val<span class="token1">[</span><span class="token4">'property_id'</span><span class="token1">]</span><span class="token1">]</span><span class="token1">[</span><span class="token6">1</span><span class="token1">]</span> <span class="token">==</span> $v<span class="token1">[</span><span class="token4">'property_value_id'</span><span class="token1">]</span> <span class="token1">)</span> <span class="token1">{</span> echo <span class="token4">'selected'</span><span class="token1">;</span> <span class="token1">}</span> <span class="token">?</span><span class="token">></span> value<span class="token">=</span><span class="token4">'<?php echo $v['</span>property_value_id<span class="token4">'] ?>'</span><span class="token">></span><span class="token"><</span><span class="token">?</span>php echo $v<span class="token1">[</span><span class="token4">'property_value_name'</span><span class="token1">]</span><span class="token1">;</span> <span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>option<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">/</span>select<span class="token">></span><span class="token"><</span><span class="token">/</span>td<span class="token">></span><span class="token"><</span><span class="token">/</span>tr<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token2">else</span> <span class="token2">if</span> <span class="token1">(</span> $val<span class="token1">[</span><span class="token4">'property_format'</span><span class="token1">]</span> <span class="token">==</span> <span class="token4">'checkbox'</span> <span class="token1">)</span> <span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span>tr<span class="token">></span>
<span class="token"><</span>th<span class="token">></span><span class="token"><</span><span class="token">?</span>php echo $val<span class="token1">[</span><span class="token4">'property_name'</span><span class="token1">]</span><span class="token1">;</span> <span class="token">?</span><span class="token">></span>:<span class="token"><</span><span class="token">/</span>th<span class="token">></span>
<span class="token"><</span>td<span class="token">></span><span class="token"><</span>dd class<span class="token">=</span><span class="token4">"spec"</span><span class="token">></span><span class="token"><</span>ul<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token2">if</span> <span class="token1">(</span> <span class="token">!</span><span class="token3">empty</span><span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'property_values'</span><span class="token1">]</span><span class="token1">)</span> <span class="token1">)</span> <span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span>input type<span class="token">=</span><span class="token4">'hidden'</span> name<span class="token">=</span><span class="token4">'property[property_<?php echo $val['</span>property_id<span class="token4">']; ?>][0]'</span> value<span class="token">=</span><span class="token4">'<?php echo $val['</span>property_name<span class="token4">']; ?>'</span><span class="token">/</span><span class="token">></span>
<span class="token"><</span>input type<span class="token">=</span><span class="token4">'hidden'</span> name<span class="token">=</span><span class="token4">'property[property_<?php echo $val['</span>property_id<span class="token4">']; ?>][2]'</span> value<span class="token">=</span><span class="token4">'checkbox'</span><span class="token">/</span><span class="token">></span>
<span class="token"><</span><span class="token">?</span>php foreach <span class="token1">(</span>$val<span class="token1">[</span><span class="token4">'property_values'</span><span class="token1">]</span> as $k <span class="token">=</span><span class="token">></span> $v<span class="token1">)</span><span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span>li<span class="token">></span>
<span class="token"><</span>span data<span class="token">-</span>type<span class="token">=</span><span class="token4">"input_checkbox"</span><span class="token">></span>
<span class="token"><</span>input type<span class="token">=</span><span class="token4">"checkbox"</span> value<span class="token">=</span><span class="token4">"<?php echo $v['property_value_id'] ?>"</span> data<span class="token">-</span>type<span class="token">=</span><span class="token4">"<?php echo $v['property_value_id'] ?>"</span> name<span class="token">=</span><span class="token4">"property[property_<?php echo $val['property_id']; ?>][1][<?php echo $v['property_value_id']; ?>]"</span><span class="token">></span>
<span class="token"><</span><span class="token">/</span>span<span class="token">></span>
<span class="token"><</span>span data<span class="token">-</span>type<span class="token">=</span><span class="token4">"pv_name"</span><span class="token">></span><span class="token"><</span><span class="token">?</span>php echo $v<span class="token1">[</span><span class="token4">'property_value_name'</span><span class="token1">]</span><span class="token1">;</span> <span class="token">?</span><span class="token">></span><span class="token"><</span><span class="token">/</span>span<span class="token">></span>
<span class="token"><</span><span class="token">/</span>li<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">/</span>ul<span class="token">></span><span class="token"><</span><span class="token">/</span>dd<span class="token">></span><span class="token"><</span><span class="token">/</span>dl<span class="token">></span><span class="token"><</span><span class="token">/</span>form<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span>tr<span class="token">></span>
<span class="token"><</span>th<span class="token">></span><span class="token"><</span><span class="token">?</span>php echo $val<span class="token1">[</span><span class="token4">'property_name'</span><span class="token1">]</span><span class="token1">;</span> <span class="token">?</span><span class="token">></span>:<span class="token"><</span><span class="token">/</span>th<span class="token">></span>
<span class="token"><</span>td<span class="token">></span>
<span class="token"><</span>input type<span class="token">=</span><span class="token4">'hidden'</span> name<span class="token">=</span><span class="token4">'property[property_<?php echo $val['</span>property_id<span class="token4">']; ?>][0]'</span> value<span class="token">=</span><span class="token4">'<?php echo $val['</span>property_name<span class="token4">']; ?>'</span><span class="token">/</span><span class="token">></span>
<span class="token"><</span>input type<span class="token">=</span><span class="token4">'hidden'</span> name<span class="token">=</span><span class="token4">'property[property_<?php echo $val['</span>property_id<span class="token4">']; ?>][2]'</span> value<span class="token">=</span><span class="token4">'text'</span><span class="token">/</span><span class="token">></span>
<span class="token"><</span>input class<span class="token">=</span><span class="token4">'text'</span> type<span class="token">=</span><span class="token4">'text'</span> name<span class="token">=</span><span class="token4">'property[property_<?php echo $val['</span>property_id<span class="token4">']; ?>][1]'</span> value<span class="token">=</span><span class="token4">'<?php if ( !empty($common_data) ) { echo $common_data['</span>common_property<span class="token4">']['</span>property_<span class="token4">' . $val['</span>property_id<span class="token4">']][1]; } ?>'</span><span class="token">></span>
<span class="token"><</span><span class="token">/</span>td<span class="token">></span><span class="token"><</span><span class="token">/</span>tr<span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token">?</span><span class="token">></span>
<span class="token"><</span><span class="token">?</span>php <span class="token1">}</span> <span class="token">?</span><span class="token">></span>
```
```
添加规格值:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'a[data-type="add-spec"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">click</span><span class="token1">(</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
var _parent <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">parents</span><span class="token1">(</span><span class="token4">'li:first'</span><span class="token1">)</span><span class="token1">;</span>
_parent<span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'div[data-type="add-spec1"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">hide</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
_parent<span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'div[data-type="add-spec2"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">show</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
_parent<span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'input'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">focus</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
```
```
取消规格:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'a[data-type="add-spec-cancel"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">click</span><span class="token1">(</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
var _parent <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">parents</span><span class="token1">(</span><span class="token4">'li:first'</span><span class="token1">)</span><span class="token1">;</span>
_parent<span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'div[data-type="add-spec1"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">show</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
_parent<span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'div[data-type="add-spec2"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">hide</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
_parent<span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'input'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token4">''</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
```
```
提交规格:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'a[data-type="add-spec-submit"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">on</span><span class="token1">(</span><span class="token4">'click'</span><span class="token1">,</span><span class="token2">function</span><span class="token1">(</span><span class="token1">)</span><span class="token1">{</span>
var _parent <span class="token">=</span> $<span class="token1">(</span>this<span class="token1">)</span><span class="token1">.</span><span class="token3">parents</span><span class="token1">(</span><span class="token4">'li:first'</span><span class="token1">)</span><span class="token1">;</span>
<span class="token3">eval</span><span class="token1">(</span><span class="token4">'var data_str = '</span> <span class="token">+</span> _parent<span class="token1">.</span><span class="token3">attr</span><span class="token1">(</span><span class="token4">'data-param'</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
var _input <span class="token">=</span> _parent<span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'input'</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span><span class="token1">(</span>_input<span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token1">)</span><span class="token1">)</span>
<span class="token1">{</span>
var url <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">"?ctl=Seller_Goods_Spec&met=saveSpecValue&typ=json&position=storeAddGoods"</span><span class="token1">;</span>
$<span class="token1">.</span><span class="token3">getJSON</span><span class="token1">(</span>url<span class="token1">,</span> <span class="token1">{</span>class_id <span class="token1">:</span> data_str<span class="token1">.</span>class_id <span class="token1">,</span> spec_id <span class="token1">:</span> data_str<span class="token1">.</span>spec_id <span class="token1">,</span> name <span class="token1">:</span> _input<span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token1">)</span><span class="token1">}</span><span class="token1">,</span> <span class="token2">function</span><span class="token1">(</span>data<span class="token1">)</span><span class="token1">{</span>
<span class="token2">if</span> <span class="token1">(</span>data<span class="token1">.</span>status <span class="token">==</span> <span class="token6">200</span><span class="token1">)</span>
<span class="token1">{</span>
var data <span class="token">=</span> data<span class="token1">.</span>data<span class="token1">;</span>
_parent<span class="token1">.</span><span class="token3">before</span><span class="token1">(</span><span class="token4">'<li><span nctype="input_checkbox" data-type="input_checkbox"><input type="checkbox" name="spec_val['</span> <span class="token">+</span> data_str<span class="token1">.</span>spec_id <span class="token">+</span> <span class="token4">']['</span> <span class="token">+</span> data<span class="token1">.</span>spec_value_id <span class="token">+</span> <span class="token4">']" nc_type="'</span> <span class="token">+</span> data<span class="token1">.</span>spec_value_id <span class="token">+</span> <span class="token4">'" data-type="'</span> <span class="token">+</span> data<span class="token1">.</span>spec_value_id <span class="token">+</span> <span class="token4">'" value="'</span> <span class="token">+</span>_input<span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token1">)</span><span class="token">+</span> <span class="token4">'" /></span><span nctype="pv_name" data-type="pv_name">'</span> <span class="token">+</span> _input<span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token1">)</span> <span class="token">+</span> <span class="token4">'</span></li>'</span><span class="token1">)</span><span class="token1">;</span>
_input<span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token4">''</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
_parent<span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'div[data-type="add-spec1"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">show</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
_parent<span class="token1">.</span><span class="token3">find</span><span class="token1">(</span><span class="token4">'div[data-type="add-spec2"]'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">hide</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//如果存在旧规格</span>
$flag <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>goodsSpecValueModel<span class="token">-</span><span class="token">></span><span class="token3">editSpecValue</span><span class="token1">(</span>$key<span class="token1">,</span> $update_data<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//如果存在新规格</span>
$this<span class="token">-</span><span class="token">></span>goodsSpecValueModel<span class="token">-</span><span class="token">></span><span class="token3">addSpecValue</span><span class="token1">(</span>$update_data<span class="token1">)</span><span class="token1">;</span>
<span class="token5">//商城添加规格值</span>
$spec_value_id <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>goodsSpecValueModel<span class="token">-</span><span class="token">></span><span class="token3">addSpecValue</span><span class="token1">(</span>$update_data<span class="token1">,</span> <span class="token6">true</span><span class="token1">)</span><span class="token1">;</span>
```
```
选择售卖区域:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'#postageButton'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">on</span><span class="token1">(</span><span class="token4">'click'</span><span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span>
var falg <span class="token">=</span> <span class="token6">true</span><span class="token1">;</span>
<span class="token2">if</span> <span class="token1">(</span> falg <span class="token1">)</span> <span class="token1">{</span>
falg <span class="token">=</span> <span class="token6">false</span><span class="token1">;</span>
$<span class="token1">.</span><span class="token3">dialog</span><span class="token1">(</span><span class="token1">{</span>
title<span class="token1">:</span> <span class="token4">'选择售卖区域'</span><span class="token1">,</span>
content<span class="token1">:</span> <span class="token4">'url:'</span> <span class="token">+</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Seller_Transport&met=chooseTranDialog&typ=e'</span><span class="token1">,</span>
data<span class="token1">:</span> <span class="token1">{</span> callback<span class="token1">:</span> callback <span class="token1">}</span><span class="token1">,</span>
width<span class="token1">:</span> <span class="token6">800</span><span class="token1">,</span>
height<span class="token1">:</span> <span class="token6">400</span><span class="token1">,</span>
max<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span>
min<span class="token1">:</span> <span class="token6">false</span><span class="token1">,</span>
lock<span class="token1">:</span> <span class="token6">true</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
<span class="token5">//售卖区域</span>
$data <span class="token">=</span> $type_model<span class="token">-</span><span class="token">></span><span class="token3">getByWhere</span><span class="token1">(</span><span class="token3">array</span><span class="token1">(</span><span class="token4">'shop_id'</span><span class="token">=</span><span class="token">></span>$shop_id<span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
foreach <span class="token1">(</span>$data as $key <span class="token">=</span><span class="token">></span> $value<span class="token1">)</span><span class="token1">{</span>
$area_ids <span class="token">=</span> <span class="token3">array</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token2">if</span><span class="token1">(</span>$value<span class="token1">[</span><span class="token4">'area_ids'</span><span class="token1">]</span> <span class="token">==</span> <span class="token6">0</span><span class="token1">)</span><span class="token1">{</span>
$data<span class="token1">[</span>$key<span class="token1">]</span><span class="token1">[</span><span class="token4">'area_name'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">__</span><span class="token1">(</span><span class="token4">'全国'</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span><span class="token2">else</span><span class="token1">{</span>
$district_name <span class="token">=</span> $type_model<span class="token">-</span><span class="token">></span><span class="token3">getDistrictName</span><span class="token1">(</span>$value<span class="token1">[</span><span class="token4">'area_ids'</span><span class="token1">]</span><span class="token1">)</span><span class="token1">;</span>
$data<span class="token1">[</span>$key<span class="token1">]</span><span class="token1">[</span><span class="token4">'area_name'</span><span class="token1">]</span> <span class="token">=</span> <span class="token3">mb_strimwidth</span><span class="token1">(</span>$district_name<span class="token1">,</span> <span class="token6">0</span><span class="token1">,</span> <span class="token6">20</span><span class="token1">,</span> <span class="token4">'...'</span><span class="token1">,</span> <span class="token4">'utf8'</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
```
```
新增分类:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'#add_sgcategory'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">on</span><span class="token1">(</span><span class="token4">'click'</span><span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span>
$<span class="token1">(</span><span class="token4">".sgcategory:last"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">after</span><span class="token1">(</span>$<span class="token1">(</span><span class="token4">".sgcategory:last"</span><span class="token1">)</span><span class="token1">.</span><span class="token3">clone</span><span class="token1">(</span><span class="token6">true</span><span class="token1">)</span><span class="token1">.</span><span class="token3">val</span><span class="token1">(</span><span class="token6">0</span><span class="token1">)</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
```
```
图片空间:
```
<pre class="calibre14">```
$<span class="token1">(</span><span class="token4">'#image_space'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">on</span><span class="token1">(</span><span class="token4">'click'</span><span class="token1">,</span> <span class="token2">function</span> <span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span>
aloneImage <span class="token">=</span> $<span class="token1">.</span><span class="token3">dialog</span><span class="token1">(</span><span class="token1">{</span>
content<span class="token1">:</span> <span class="token4">'url: '</span> <span class="token">+</span> SITE_URL <span class="token">+</span> <span class="token4">'?ctl=Upload&met=image&typ=e'</span><span class="token1">,</span>
height<span class="token1">:</span> <span class="token6">585</span><span class="token1">,</span>
width<span class="token1">:</span> <span class="token6">900</span><span class="token1">,</span>
data<span class="token1">:</span> <span class="token1">{</span> callback<span class="token1">:</span> <span class="token2">function</span><span class="token1">(</span> list <span class="token1">)</span> <span class="token1">{</span>
<span class="token5">//只取第一张图片</span>
$<span class="token1">(</span><span class="token4">'#goodsImage'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">prop</span><span class="token1">(</span><span class="token4">'src'</span><span class="token1">,</span> list<span class="token1">[</span><span class="token6">0</span><span class="token1">]</span><span class="token1">.</span>src<span class="token1">)</span><span class="token1">;</span>
$<span class="token1">(</span><span class="token4">'#imagePath'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">prop</span><span class="token1">(</span><span class="token4">'value'</span><span class="token1">,</span> list<span class="token1">[</span><span class="token6">0</span><span class="token1">]</span><span class="token1">.</span>src<span class="token1">)</span><span class="token1">.</span><span class="token3">isValid</span><span class="token1">(</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span>
<span class="token1">}</span><span class="token1">)</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
```
```
商品提交:
```
<pre class="calibre14">```
$<span class="token1">.</span><span class="token3">post</span><span class="token1">(</span> SITE_URL <span class="token">+</span> <span class="token4">"?ctl=Seller_Goods&met=addOrEditShopGoods&typ=json"</span><span class="token1">,</span> $<span class="token1">(</span><span class="token4">'#form'</span><span class="token1">)</span><span class="token1">.</span><span class="token3">serialize</span><span class="token1">(</span><span class="token1">)</span><span class="token1">,</span> <span class="token2">function</span><span class="token1">(</span>data<span class="token1">)</span> <span class="token1">{</span>
<span class="token2">if</span><span class="token1">(</span> data<span class="token1">.</span>status <span class="token">==</span> <span class="token6">200</span> <span class="token1">)</span> <span class="token1">{</span>
Public<span class="token1">.</span><span class="token3">tips</span><span class="token1">(</span><span class="token1">{</span> content<span class="token1">:</span> <span class="token4">'保存成功!'</span><span class="token1">,</span> type<span class="token1">:</span> <span class="token6">3</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
<span class="token3">setTimeout</span><span class="token1">(</span><span class="token2">function</span> <span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span>
<span class="token2">if</span> <span class="token1">(</span> data<span class="token1">.</span>data<span class="token1">.</span>action <span class="token">&&</span> data<span class="token1">.</span>data<span class="token1">.</span>action <span class="token">==</span> <span class="token4">'edit'</span> <span class="token1">)</span>
<span class="token1">{</span>
<span class="token2">if</span><span class="token1">(</span>data<span class="token1">.</span>data<span class="token1">.</span>dist_goods<span class="token1">)</span><span class="token1">{</span>
window<span class="token1">.</span>location<span class="token1">.</span>href <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">"?ctl=Seller_Supplier_Goods&met=online&typ=e"</span><span class="token1">;</span>
<span class="token1">}</span><span class="token2">else</span><span class="token1">{</span>
window<span class="token1">.</span>location<span class="token1">.</span>href <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">"?ctl=Seller_Goods&met=online&typ=e"</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span>
window<span class="token1">.</span>location<span class="token1">.</span>href <span class="token">=</span> SITE_URL <span class="token">+</span> <span class="token4">"?ctl=Seller_Goods&met=add&action=goodsImageManage&typ=e&common_id="</span> <span class="token">+</span> data<span class="token1">.</span>data<span class="token1">.</span>common_id<span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span><span class="token1">,</span> <span class="token6">3000</span><span class="token1">)</span><span class="token1">;</span>
<span class="token1">}</span> <span class="token2">else</span> <span class="token1">{</span>
<span class="token2">if</span><span class="token1">(</span>data<span class="token1">.</span>msg<span class="token">==</span><span class="token4">''</span><span class="token1">)</span>
<span class="token1">{</span>
data<span class="token1">.</span>msg <span class="token">=</span> <span class="token4">'保存失败!'</span><span class="token1">;</span>
<span class="token1">}</span>
Public<span class="token1">.</span><span class="token3">tips</span><span class="token1">(</span><span class="token1">{</span> content<span class="token1">:</span> data<span class="token1">.</span>msg<span class="token1">,</span> type<span class="token1">:</span> <span class="token6">1</span> <span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
firstSub <span class="token">=</span> <span class="token6">true</span><span class="token1">;</span>
<span class="token1">}</span>
<span class="token1">}</span><span class="token1">)</span><span class="token1">;</span>
```
```
商品发布提交:
```
<pre class="calibre14">```
$common_id <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>goodsCommonModel<span class="token">-</span><span class="token">></span><span class="token3">addCommon</span><span class="token1">(</span>$common_data<span class="token1">,</span> <span class="token6">true</span><span class="token1">)</span><span class="token1">;</span>
```
```
商品编辑提交:
```
<pre class="calibre14">```
$edit_status <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>goodsCommonModel<span class="token">-</span><span class="token">></span><span class="token3">editCommon</span><span class="token1">(</span>$common_id<span class="token1">,</span> $common_data<span class="token1">)</span><span class="token1">;</span>
```
```
将商品同步到im:
```
<pre class="calibre14">```
$rs <span class="token">=</span> <span class="token3">get_url_with_encrypt</span><span class="token1">(</span>$key<span class="token1">,</span> <span class="token3">sprintf</span><span class="token1">(</span><span class="token4">'%s?ctl=Api_User_Goods&met=addOrEditUserGoods&typ=json'</span><span class="token1">,</span> $url<span class="token1">)</span><span class="token1">,</span> $formvars<span class="token1">)</span><span class="token1">;</span>
```
```
编辑商品详情:
```
<pre class="calibre14">```
添加详情:$this<span class="token">-</span><span class="token">></span>goodsCommonDetailModel<span class="token">-</span><span class="token">></span><span class="token3">addCommonDetail</span><span class="token1">(</span>$common_detail_data<span class="token1">)</span><span class="token1">;</span>
编辑详情:$this<span class="token">-</span><span class="token">></span>goodsCommonDetailModel<span class="token">-</span><span class="token">></span><span class="token3">editCommonDetail</span><span class="token1">(</span>$common_id<span class="token1">,</span> $common_detail_data<span class="token1">)</span><span class="token1">;</span>
```
```
修改库存配置:
```
<pre class="calibre14">```
添加库存:$goods_id <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>goodsBaseModel<span class="token">-</span><span class="token">></span><span class="token3">addBase</span><span class="token1">(</span>$goods_data<span class="token1">,</span> <span class="token6">true</span><span class="token1">)</span><span class="token1">;</span>
修改库存:$goods_id <span class="token">=</span> $this<span class="token">-</span><span class="token">></span>goodsBaseModel<span class="token">-</span><span class="token">></span><span class="token3">editBase</span><span class="token1">(</span>$retain_f_goods_id<span class="token1">,</span> $goods_data<span class="token1">,</span> <span class="token6">false</span><span class="token1">)</span><span class="token1">;</span>
```
```
添加或修改成功后向统计中心发送数据:
```
<pre class="calibre15">```
添加: Yf_Plugin_Manager<span class="token1">:</span><span class="token1">:</span><span class="token3">getInstance</span><span class="token1">(</span><span class="token1">)</span><span class="token">-</span><span class="token">></span><span class="token3">trigger</span><span class="token1">(</span><span class="token4">'analyticsGoodsAdd'</span><span class="token1">,</span>$analytics_data<span class="token1">)</span><span class="token1">;</span>
编辑: Yf_Plugin_Manager<span class="token1">:</span><span class="token1">:</span><span class="token3">getInstance</span><span class="token1">(</span><span class="token1">)</span><span class="token">-</span><span class="token">></span><span class="token3">trigger</span><span class="token1">(</span><span class="token4">'analyticsGoodsEdit'</span><span class="token1">,</span>$analytics_data<span class="token1">)</span><span class="token1">;</span>
```
```
- 序言
- 系统要求
- 版本更新日志
- 远丰商城技术对接说明
- 开发指导
- 框架内容
- 基础
- 开发规范
- 目录结构
- 架构
- 架构总览
- 数据库
- 数据库连接
- 基本使用
- 缓存
- 配置
- 路由
- 数据字典
- ucenter
- shop
- paycenter
- ucenter_admin
- shop_admin
- paycenter_admin
- 通讯内容
- 商家中心
- 顶部导航栏
- 店铺信息栏
- 店铺及商品提示栏
- 交易提示栏
- 销售情况统计栏
- 单品销量排行栏
- 店铺运营推广栏
- 平台联系方式栏
- 订单物流
- 商品
- 商品列表
- 商品详情
- 商品发布与编辑
- 分销商品
- 关联版式
- 商品规格
- 图片空间
- 淘宝导入
- 订单流程
- 交易订单
- 订单退款/退货
- 促销
- 团购管理
- 加价购
- 限时折扣
- 满即送
- 代金券管理
- 分销
- 店铺
- 店铺设置
- 自销产品供应商
- 实体店铺
- 品牌申请
- 店铺信息
- 消费者保障服务
- 门店账号
- 分销商--产品供应商
- 分销明细
- 批发市场
- 售后服务
- 咨询管理
- 投诉管理
- 退款管理
- 退货管理
- 云方案架构
- 负载集群
- 云存储
- 接口
- Api接口说明
- 品牌
- 商品规格
- 商品类型
- 商品分类
- 商品
- 订单
- 商品/店铺收藏
- 足迹
- 退款及退货
- 商家店铺
- 会员
- 入驻协议
- 订单接口
- 商品接口
- 订单物流接口
- 商家中心接口
- 促销接口
- 快递鸟物流接口
- 代金券接口
- 首页版块
- 团购
- 平台红包
- 限时折扣接口
- 拼团接口
- wap首页模板
- 杂项
- 远程上传图片
- JS
- 银联支付
- 多语言
- 商品评分
- 图片加载
- 买家申请退款退货
- 商家退款退货
- 平台退款退货
- 添加发票
- 提交订单
- 确认订单
- 运费销售区域
- 获取会员地址
- 充值
- 导出XLS
- 商城系统集成
- 多语言实现
- 三级分销推广链接发展推广员
- app.ini.php
- 去分销
- 版本更新
- 物流支持
- 运营人员建议
- 业务逻辑
- 统计结算
- 客服消息
- 账号
- 三级分销
- IM
- 配置
- 平台帐号
- 活动数据表说明