作者 sgj
1 个管道 的构建 失败 耗费 2 秒

提交信息

... ... @@ -19,7 +19,7 @@ class GoodsModel extends Model
}
$info['pic']=cmf_get_image_url($info['pic']);
//is_json($info['banner']);
$info['banner']=json_decode($info['banner']);
$info['banner']=json_decode($info['banner'],true);
if (!empty($info['banner']) && is_array($info['banner'])){
foreach ($info['banner'] as $k=>$v) {
... ...
... ... @@ -37,6 +37,11 @@ class GoodController extends AdminBaseController
public function edit(){
$id=input('id');
$data=db('goods')->where('id',$id)->find();
$data['banner']=json_decode($data['banner']);
$data['banner_name']=json_decode($data['banner_name']);
foreach ($data['banner'] as $k=>$v){
$data['banner'][$k]=cmf_get_image_url($v);
}
$this->assign('data',$data);
return $this->fetch();
}
... ... @@ -47,7 +52,18 @@ class GoodController extends AdminBaseController
public function editPost(){
$id=input('id');
$data=input();
$banner=input('banner/a');
$banner_name=input('banner_name/a');
if (empty($banner)){
}else{
unset($data['banner']);
unset($data['banner_name']);
$data['banner']=json_encode($banner,true);
$data['banner_name']=json_encode($banner_name,true);
}
$info=db('goods')->where('id',$id)->update($data);
if (!empty($info)){
$this->success('编辑成功!');
}else{
... ... @@ -67,6 +83,16 @@ class GoodController extends AdminBaseController
*/
public function addPost(){
$data=input();
$banner=input('banner/a');
$banner_name=input('banner_name/a');
if (empty($banner)){
}else{
unset($data['banner']);
unset($data['banner_name']);
$data['banner']=json_encode($banner,true);
$data['banner_name']=json_encode($banner_name,true);
}
$info=db('goods')->insert($data);
if (!empty($info)){
$this->success('编辑成功!');
... ...
... ... @@ -39,6 +39,36 @@
</td>
</tr>
<tr>
<th>相册</th>
<td>
<ul id="photos" class="pic-list list-unstyled form-inline">
<notempty name="data.banner">
<foreach name="data.banner" item="vo">
<php>$img_url=cmf_get_image_preview_url($vo);</php>
<li id="saved-image{$key}">
<input id="photo-{$key}" type="hidden" name="banner[]"
value="{$vo}">
<input class="form-control" id="photo-{$key}-name" type="text"
name="banner_name[]"
value="{$data.banner_name[$key]|default=''}" style="width: 200px;" title="图片名称">
<img id="photo-{$key}-preview"
src="{:cmf_get_image_preview_url($vo)}"
style="height:36px;width: 36px;"
onclick="parent.imagePreviewDialog(this.src);">
<a href="javascript:uploadOneImage('图片上传','#photo-{$key}');">替换</a>
<a href="javascript:(function(){$('#saved-image{$key}').remove();})();">移除</a>
</li>
</foreach>
</notempty>
</ul>
<a href="javascript:uploadMultiImage('图片上传','#photos','photos-item-tpl');"
class="btn btn-sm btn-default">选择图片</a>
</td>
</tr>
</table>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
... ...