Files
orico-official-website-old/app/admin/view/product/edit.html
2024-10-29 17:57:44 +08:00

1802 lines
112 KiB
HTML
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!-- Select2 -->
<link rel="stylesheet" href="__PUBLIC__/adminlte/bower_components/select2/dist/css/select2.min.css">
<style>
.select2-container--default .select2-selection--single {
background-color: #fff;
border: 1px solid #d2d6de;
border-radius: 0;
}
.select2-container .select2-selection--single{height:34px;}
</style>
<!-- Select2 -->
<script src="__PUBLIC__/adminlte/bower_components/select2/dist/js/select2.full.min.js"></script>
<script src="https://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
编辑产品
</h1>
<ol class="breadcrumb">
<li><a href="<?php echo url('/admin');?>"><i class="fa fa-dashboard"></i> 首页</a></li>
<li><a href="<?php echo url('/admin/product/lists');?>"> 产品列表</a></li>
<li class="active"> 产品</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-md-10">
<form class="form-horizontal" action="<?php echo url('/admin/product/update');?>" method="post" name="productform">
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active"><a href="#navfirst" data-toggle="tab"><i class="fa fa-edit text-green"></i> 基本信息</a></li>
<li><a href="#navthird" data-toggle="tab">图片信息</a></li>
<li><a href="#navsecond" data-toggle="tab">详细内容</a></li>
<li><a href="#navseventh" data-toggle="tab">相关信息及下载</a></li>
</ul>
<div class="tab-content" style="background: #f3f3f3;">
<div class="active tab-pane" id="navfirst">
<div class="form-group grid-margin stretch-card" style="margin-left:0; margin-right:0;">
<div class="card">
<div class="card-body">
<div class="form-group row">
<label for="name" class="col-sm-2 control-label">产品名称<em style="color:red;">*</em></label>
<div class="col-sm-8">
<input type="text" class="form-control" name="name" id="name" required value='<?php echo $product['name']; ?>'>
</div>
</div>
<div class="form-group">
<label for="shortname" class="col-sm-2 control-label">副标题名称</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="shortname" id="shortname" value="<?php echo $product['shortname'];?>">
</div>
<div class="col-sm-2">
<span class="help-block">(副标题名称)</span>
</div>
</div>
<div class="form-group">
<label for="brand_id" class="col-sm-2 control-label">商品型号<em style="color:red;">*</em></label>
<div class="col-sm-8">
<input readonly type="text" class="form-control" onblur="chickbrandid()" name="brand_id" id="brand_id" value="<?php echo $product['brand_id'];?>">
</div>
<div class="col-sm-2">
<span class="help-block">图片上传目录<br><?php echo strtoupper(str_replace("ORICO-","",$product['brand_id']));?></span>
</div>
</div>
<div class="form-group">
<label for="cid" class="col-sm-2 control-label">所属分类<em style="color:red;">*</em></label>
<div class="col-sm-8">
<select class="form-control select2" style="width: 100%;" name="cid" id="cid">
<option value="0">默认值</option>
<?php echo $categoryOptions;?>
</select>
</div>
<div class="col-sm-2">
<span class="help-block">(所属分类)</span>
</div>
</div>
</div>
</div>
</div>
<div class="form-group grid-margin stretch-card" style="margin-left:0; margin-right:0;">
<div class="card">
<div class="card-body">
<div class="form-group">
<label for="videopath" class="col-sm-2 control-label">视频文件</label>
<div class="col-sm-5">
<div class="input-group">
<input type="text" class="form-control" name="videopath" id="videopath" value="<?php echo $product['videopath'];?>">
<span class="input-group-btn">
<button class="btn btn-primary" type="button" onclick="webuploader_modal('videopath', '', 'media', 'video', 'file_call_back')"><i class="fa fa-fw fa-folder-open-o"></i></button>
<!-- <button class="btn btn-primary" type="button" id="btn-product-video"><i class="fa fa-table"></i></button>-->
</span>
</div>
</div>
<div class="col-sm-5">
<span class="help-block">(视频文件)</span>
</div>
</div>
<div class="form-group">
<label for="shortname" class="col-sm-2 control-label">产品参数</label>
<div class="col-sm-8">
<?php
$str = "";
if ($product['product_view'])
{
$product_views = unserialize($product['product_view']);
$tmp_product_views = [];
foreach ($product_views as $key => $value) {
$tmp_product_views[] = $value['desc_title'] . ':' . $value['desc_desc'];
}
foreach ($tmp_product_views as $key => $value) {
$str .= $value . "#\r\n";
}
}
?>
<textarea rows="6" class="form-control" id="product_view" name="product_view"><?php echo $str; ?></textarea>
</div>
<div class="col-sm-2">
<span class="help-block"></span>
</div>
</div>
<div class="form-group">
<label for="sort" class="col-sm-2 control-label">产品排序<em style="color:red;">*</em></label>
<div class="col-sm-2">
<input type="text" class="form-control" name="sort" id="sort" value="<?php echo $product['sort'];?>">
</div>
<div class="col-sm-5 col-sm-offset-3">
<span class="help-block">(产品排序)</span>
</div>
</div>
</div>
</div>
</div>
<div class="form-group grid-margin stretch-card" style="margin-left:0; margin-right:0;">
<div class="card">
<div class="card-body">
<?php if($country_code== 'ZH'):?>
<div class="form-group">
<label for="url_tm" class="col-sm-2 control-label">天猫链接</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="url_tm" value="<?php echo $product['url_tm'];?>">
</div>
<div class="col-sm-2">
<span class="help-block">(天猫链接)</span>
</div>
</div>
<div class="form-group">
<label for="url_jd" class="col-sm-2 control-label">京东链接</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="url_jd" value="<?php echo $product['url_jd'];?>">
</div>
<div class="col-sm-2">
<span class="help-block">(京东链接)</span>
</div>
</div>
<?php else:?>
<div class="form-group">
<label for="url_shopify" class="col-sm-2 control-label">Shopiry链接</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="url_shopify" value="<?php echo $product['url_shopify'];?>">
</div>
<div class="col-sm-2">
<span class="help-block">(独立站链接)</span>
</div>
</div>
<div class="form-group">
<label for="url_amazon" class="col-sm-2 control-label">Amazon链接</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="url_amazon" value="<?php echo $product['url_amazon'];?>">
</div>
<div class="col-sm-2">
<span class="help-block">(亚马逊链接)</span>
</div>
</div>
<?php endif;?>
<div class="form-group">
<label for="isnew" class="col-sm-2 control-label">是否新品</label>
<div class="col-sm-8">
<label class="radio-inline">
<input name="isnew" type="radio" value="1" <?php if($product['isnew']):?>checked=""<?php endif;?>/> 是
</label>
<label class="radio-inline">
<input name="isnew" type="radio" value="0" <?php if(!$product['isnew']):?>checked=""<?php endif;?>/> 否
</label>
</div>
<div class="col-sm-2">
<span class="help-block">(是否新品)</span>
</div>
</div>
<div class="form-group">
<label for="ishot" class="col-sm-2 control-label">是否热门</label>
<div class="col-sm-8">
<label class="radio-inline">
<input name="ishot" type="radio" value="1" <?php if($product['ishot']):?>checked=""<?php endif;?>/> 是
</label>
<label class="radio-inline">
<input name="ishot" type="radio" value="0" <?php if(!$product['ishot']):?>checked=""<?php endif;?>/> 否
</label>
</div>
<div class="col-sm-2">
<span class="help-block">(是否热门)</span>
</div>
</div>
<div class="form-group">
<label for="recommend" class="col-sm-2 control-label">是否爆款</label>
<div class="col-sm-8">
<label class="radio-inline">
<input name="recommend" type="radio" value="1" <?php if($product['recommend']):?>checked=""<?php endif;?>/> 是
</label>
<label class="radio-inline">
<input name="recommend" type="radio" value="0" <?php if(!$product['recommend']):?>checked=""<?php endif;?>/> 否
</label>
</div>
<div class="col-sm-2">
<span class="help-block">(是否爆款)</span>
</div>
</div>
<div class="form-group">
<label for="isfeatured" class="col-sm-2 control-label">是否特色</label>
<div class="col-sm-8">
<label class="radio-inline">
<input name="isfeatured" type="radio" value="1" <?php if($product['isfeatured']):?>checked=""<?php endif;?>/> 是
</label>
<label class="radio-inline">
<input name="isfeatured" type="radio" value="0" <?php if(!$product['isfeatured']):?>checked=""<?php endif;?>/> 否
</label>
</div>
<div class="col-sm-2">
<span class="help-block">(Is Featured)</span>
</div>
</div>
<div class="form-group">
<label for="onelist" class="col-sm-2 control-label">是否一级列表显示</label>
<div class="col-sm-8">
<label class="radio-inline">
<input type="radio" name="onelist" value="1" <?php if($product['onelist']):?>checked=""<?php endif;?>> 是
</label>
<label class="radio-inline">
<input type="radio" name="onelist" value="0" <?php if(!$product['onelist']):?>checked=""<?php endif;?>> 否
</label>
</div>
<div class="col-sm-2">
<span class="help-block">(是否一级列表)</span>
</div>
</div>
</div>
</div>
</div>
<div class="form-group grid-margin stretch-card" style="margin-left:0; margin-right:0;">
<div class="card">
<div class="card-body">
<div class="form-group">
<label for="seo_title" class="col-sm-2 control-label">SEO标题</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="seo_title" value="<?php echo $product['seo_title'];?>">
</div>
<div class="col-sm-2">
<span class="help-block">(SEO标题)</span>
</div>
</div>
<div class="form-group">
<label for="seo_keyword" class="col-sm-2 control-label">SEO关键词</label>
<div class="col-sm-8">
<input type="text" class="form-control" name="seo_keyword" value="<?php echo $product['seo_keyword'];?>">
</div>
<div class="col-sm-2">
<span class="help-block">(SEO关键词)</span>
</div>
</div>
<div class="form-group">
<label for="seo_description" class="col-sm-2 control-label">SEO描述</label>
<div class="col-sm-8">
<textarea class="form-control" id="seo_description" name="seo_description"><?php echo $product['seo_description'];?></textarea>
</div>
<div class="col-sm-2">
<span class="help-block">(SEO描述)</span>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /.tab-pane -->
<div class="tab-pane" id="navthird">
<div class="form-group grid-margin stretch-card" style="margin-left:0; margin-right:0;">
<div class="card">
<div class="card-body">
<div class="form-group">
<label for="seo_title" class="col-sm-2 control-label">封面图</label>
<div class="col-sm-8">
<a href="javascript:void(0);" id="thumb-one-bk-image" data-toggle="image" data-folder="<?php echo $filepath;?>" class="img-thumbnail"><img class="img-responsive" src="<?php echo empty($product['list_bk_img'])?'/uploads/nopic.jpg':$product['list_bk_img'];?>"/></a>
<input type="hidden" name="list_bk_img" value="<?php echo $product['list_bk_img'];?>" id="input-one-bk-image" />
</div>
<div class="col-sm-2">
<span class="help-block">(800X800<br>高宽度比例1:1)</span>
</div>
</div>
</div>
</div>
</div>
<div class="form-group grid-margin stretch-card" style="margin-left:0; margin-right:0;">
<div class="card">
<div class="card-body">
<label class="card-title">二级列表主图</label>
<p class="card-description"><button type="button" onclick="addProduct();" title="添加图片" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></p>
<div class="col-sm-12">
<div class="table-responsive">
<table id="product" class="table">
<thead>
<tr>
<th class="text-left" width="30%">主图</th>
<th class="text-center" width="20%">颜色[色值/色块名称]</th>
<th class="text-center" width="30%">描述</th>
<th class="text-left" width="10%">操作</th>
</tr>
</thead>
<tbody>
<?php
$product_row = 0;
$selectColorObj = config("product_color");
foreach ($product_two_img as $k => $product_image):
$product_row=$product_image['id'];
$sltclrOption='';
foreach ($selectColorObj as $c=>$v) {
$sltclrOption .= $c==$product_image['image_color']?'<option value="'.$c .'" selected="">' .$v.'</option>':'<option value="'.$c .'">' .$v.'</option>';
}
?>
<tr id="product_row<?php echo $product_row; ?>">
<td class="text-left"><a href="" id="thumb-two-image<?php echo $product_row; ?>" data-toggle="image" data-folder="<?php echo $filepath;?>" class="img-thumbnail"><img class="img-responsive" src="<?php echo $product_image['image_url'];?>"></a><input name="product_product[<?php echo $product_row; ?>][image_url]" value="<?php echo $product_image['image_url'];?>" id="input-two-image<?php echo $product_row; ?>" type="hidden"></td>
<td class="text-center">
<?php
if(strlen($product_image["image_color"]) ==2 || $product_image["image_color"] == ''){
echo '<select class="form-control" name="product_product['.$product_row.'][image_color]"><option value="">请选择</option>';
foreach($productColor as $clroption => $proColor) {
echo '<option value="'.$clroption.'"'.($clroption==$product_image['image_color'] ? "selected": "").'>'.$proColor.'</option>';
}
echo '</select>';
}
else{
echo '<input name="product_product['.$product_row.'][image_color]" value="'. $product_image["image_color"].'" placeholder="背景颜色" class="form-control" size="2" type="text">';
}
?>
</td>
<!--td class="text-center"><input name="product_product[<?php echo $product_row; ?>][image_bk_color]" value="<?php echo $product_image['image_bk_color'];?>" class="form-control" id="input-two-color-image<?php echo $product_row; ?>" type="text"></td-->
<td class="text-right"><input name="product_product[<?php echo $product_row; ?>][image_desc]" value="<?php echo $product_image['image_desc']; ?>" placeholder="颜色描述" class="form-control" size="2" type="text"></td>
<td class="text-left"><button type="button" onclick="$('#product_row<?php echo $product_row; ?>').remove();" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
</tr>
<?php
endforeach;
$product_row++;
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="form-group grid-margin stretch-card" style="margin-left:0; margin-right:0;">
<div class="card">
<div class="card-body">
<label class="card-title">多属性</label>
<p class="card-description"><button type="button" onclick="addMultiAttribute();" title="添加属性" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></p>
<div class="col-sm-12">
<div class="table-responsive">
<table id="multi-attribute" class="table product_attrs">
<thead>
<tr>
<th class="text-left" width="40%">属性名称</th>
<th class="text-center" width="10%">操作</th>
</tr>
</thead>
<tbody>
<?php $attr_row = 1;
$defaultColor = ($country_code == 'ZH' ? "颜色": 'Color');
if (!empty($product_attr)): ?>
<?php foreach ($product_attr as $ka => $attr): ?>
<tr id="attr_row<?php echo $ka;?>">
<td class="text-right "><input type="text" name="product_attr[]" onblur="changeMultAlbum('#attr_row<?php echo $ka;?>')" value="<?php echo $attr;?>" class="form-control product_attr" size="2"/></td>
<td class="text-center"><button type="button" onclick="delAlbumAttributeColumn('#attr_row<?php echo $ka;?>')" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
</tr>
<?php $attr_row++; endforeach; ?>
<?php endif; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="form-group grid-margin stretch-card" style="margin-left:0; margin-right:0;">
<div class="card">
<div class="card-body">
<label class="card-title">相册图片</label>
<span class="right"><a href="#"><span class="business-button" >颜色说明</span></a></span>
<!--弹出框-->
<div class="business-close">
<div class="marsk-container"style="display: none;">
<div class="popup-quick" >
<div class="business-close"><i class="fa fa-close"></i></div>
<div class="popup-app">
<table>
<tr>
<td>颜色(Color)</td>
<td >中文名称</td>
<td >英文名称</td>
</tr>
<tr>
<td>BK</td>
<td ></td>
<td >Black</td>
</tr>
<tr>
<td>WH</td>
<td ></td>
<td >White</td>
</tr>
<tr>
<td>SV</td>
<td ></td>
<td >Sivler</td>
</tr>
<tr>
<td>GD</td>
<td ></td>
<td >Gold</td>
</tr>
<tr>
<td>GY</td>
<td ></td>
<td >Grey</td>
</tr>
<tr>
<td>BL</td>
<td ></td>
<td >Blue</td>
</tr>
<tr>
<td>RD</td>
<td ></td>
<td >Red</td>
</tr>
<tr>
<td>YL</td>
<td ></td>
<td >Yellow</td>
</tr>
<tr>
<td>OR</td>
<td ></td>
<td >Orange</td>
</tr>
<tr>
<td>PK</td>
<td ></td>
<td >Pink</td>
</tr>
<tr>
<td>GR</td>
<td >绿</td>
<td >Green</td>
</tr>
<tr>
<td>PU</td>
<td ></td>
<td >Purple</td>
</tr>
<tr>
<td>CF</td>
<td >咖啡</td>
<td >Coffee</td>
</tr>
<tr>
<td>RG</td>
<td >玫瑰金</td>
<td >Rose Gold</td>
</tr>
<tr>
<td>CO</td>
<td >多彩</td>
<td >Colorful</td>
</tr>
<tr>
<td>CR</td>
<td >透明</td>
<td >Cleaner</td>
</tr>
<tr>
<td>WD</td>
<td >木纹</td>
<td >Wood Texture</td>
</tr>
</table>
<div class="tips-text">温馨提示:只需要参考第一列颜色名称,后面两列是对应的中英文翻译.</div>
</div>
</div>
</div>
</div>
<!--弹出框-->
<p class="card-description"><button type="button" onclick="addAlbum();" title="添加相册图片" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></p>
<div class="col-sm-12">
<div class="table-responsive">
<table id="albums" class="table product_attrs">
<thead>
<tr>
<th class="text-left" width="30%">图片</th>
<?php
if (!empty($product_attr)){
foreach ($product_attr as $ka => $attr){
if($attr){
?>
<th class="text-center 22 attr_column attr_<?php echo $attr;?>" width="10%" data-type="<?php echo $attr;?>"><?php echo $attr;?></th>
<th class="text-center sort_<?php echo $attr;?>" width="10%" data-type="<?php echo $attr;?>"><?php echo $attr;?>排序</th>
<?php }
}
}
elseif (!empty($product_images)){
echo '<th class="text-center 11 attr_column attr_color" data-type="color" width="10%" >颜色</th>';
echo '<th class="text-center sort_color" data-type="color" width="10%" >颜色排序</th>';
}
?>
<th class="text-center" width="10%">SKU</th>
<th class="text-center" width="5%">操作</th>
</tr>
</thead>
<tbody>
<?php
if (!empty($product_images)):
foreach ($product_images as $key => $value):
$key = empty($key) ? 0 : $key;
?>
<tr id="image-row<?php echo $key; ?>">
<td class="text-left">
<ul class="listbox">
<?php
if(isset($value['image_url']) && is_array($value['image_url'])){
foreach ($value['image_url'] as $ka => $img){
?>
<li data-feed='2' id="thumb-image<?php echo $key; ?>" draggable="true" data-toggle="image" data-folder="<?php echo $filepath;?>" class="img-thumbnail">
<img draggable="true" class="img-responsive input-image<?php echo $key; ?>" src="<?php echo htmlspecialchars_decode($img);?>"/>
</li>
<?php
}
} else{
foreach ($value as $k => $v):
?>
<li data-feed='1' id="thumb-image<?php echo $key; ?>" draggable="true" data-toggle="image" data-folder="<?php echo $filepath;?>" class="img-thumbnail">
<img draggable="true" class="img-responsive input-image<?php echo $key; ?>" src="<?php echo $v['image_url'];?>"/>
</li>
<?php endforeach; ?>
<?php } ?>
</ul>
</td>
<?php
if (!empty($product_attr)){
foreach ($product_attr as $ka => $attr){
$productAttr = json_decode($value['image_color'], true);
if($attr){
?>
<td class="text-right attr_row album_attr" data-type="<?php echo $attr; ?>">
<?php
if(strtolower($attr) == 'color' || $attr == '颜色'){
echo '<select class="form-control" name="product_image['.$key.'][type]['.$ka.']"><option value="">请选择</option>';
foreach($productColor as $clroption => $proColor) {
$selected = '';
if(isset($productAttr[$ka][$attr]) && $clroption==$productAttr[$ka][$attr]) {
$selected = 'selected';
}
echo '<option value="'.$clroption .'" '.$selected.'>'.$proColor . '</option>';
}
echo '</select>';
}
else{
?>
<input type="text" data-type="attribute" name="product_image[<?php echo $key; ?>][type][<?php echo $ka; ?>]" value="<?php echo isset($productAttr[$ka][$attr]) ? $productAttr[$ka][$attr] : ''; ?>" class="form-control" size="2"/>
<?php } ?>
</td>
<td class="text-right attr_row" data-type="<?php echo $attr; ?>"><input type="text" data-type="sort" name="product_image[<?php echo $key; ?>][sort][<?php echo $ka; ?>]" value="<?php echo isset($productAttr[$ka]['sort']) ? $productAttr[$ka]['sort'] : ''; ?>" class="form-control" size="2"/></td>
<?php
}
}
}elseif (!empty($product_images)){
?>
<td class="text-right 33 attr_row" data-type="color"><input type="text" name="product_image[<?php echo $key; ?>][type][0]" value="<?php if(isset($value['image_url'])) { echo $value['image_color'];} else{ echo $value[0]['image_color'];}?>" data-type="attribute" class="form-control" size="2"/></td>
<td class="text-right attr_row" data-type="color"><input type="text" name="product_image[<?php echo $key; ?>][sort][0]" value="<?php if(isset($value['image_url'])) { echo $value['image_sort'];} else{ echo $value[0]['image_sort'];}?>" data-type="sort" class="form-control" size="2"/></td>
<?php } ?>
<td class="text-right">
<input name="product_image[<?php echo $key; ?>][sku]" value="<?php if(isset($value['image_url'])) { echo $value['sku'];} else{ echo $value[0]['sku'];} ?>" placeholder="SKU" class="form-control form-sku" size="2" type="text">
</td>
<td class="text-left">
<button type="button" onclick="remove_imgs(<?php echo $key; ?>);" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button>
</td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
<?php
if (!empty($product_images)){
foreach ($product_images as $key => $value){
if(isset($value['image_url']) && is_array($value['image_url'])){
foreach ($value['image_url'] as $ka => $img){
echo '<input type="hidden" class="image_111" name="arr_product_img['.$key.'][]" value="'.htmlspecialchars_decode($img).'">';
}
}
else{
foreach ($value as $k => $v){
echo '<input type="hidden" class="image_111" name="arr_product_img['.$key.'][]" value="'.$v['image_url'].'">';
}
}
}
}
?>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /.tab-pane -->
<div class="tab-pane" id="navsecond">
<div class="form-group grid-margin stretch-card" style="margin-left:0; margin-right:0;">
<div class="card">
<div class="card-body">
<label class="card-title">产品描述</label>
<p class="card-description"><button type="button" onclick="addDesc()" title="添加描述" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></p>
<div class="col-sm-12">
<div class="table-responsive">
<table id="descs" class="table">
<thead>
<tr>
<th class="text-center" width="45%">标题</th>
<th class="text-center" width="45%">详情</th>
<th class="text-left" width="10%">操作</th>
</tr>
</thead>
<tbody>
<?php
$desc_row = 0;
if($product['product_desc']){
$product_descs = unserialize($product['product_desc']);
if($product_descs){
foreach ($product_descs as $product_desc): ?>
<tr id="desc-row<?php echo $desc_row; ?>">
<td class="text-left"><input name="product_desc[<?php echo $desc_row; ?>][desc_title]" value="<?php echo $product_desc['desc_title']; ?>" placeholder="标题" class="form-control" size="2" type="text"></td>
<td class="text-left"><input name="product_desc[<?php echo $desc_row; ?>][desc_desc]" value="<?php echo $product_desc['desc_desc']; ?>" placeholder="详情" class="form-control" size="2" type="text"></td>
<td class="text-left"><button type="button" onclick="$('#desc-row<?php echo $desc_row; ?>').remove();" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
</tr>
<?php
$desc_row++;
endforeach;
}
}
?>
</tbody>
<tfoot></tfoot>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-12 grid-margin stretch-card">
<div class="card">
<div class="card-body">
<div class="form-group row">
<label for="exampleInputUsername2" class="">详情描述</label>
<div class="col-sm-12">
<textarea id="content" style="width: 100%;height:500px;" name="ld_md_content" rows="10" cols="80" placeholder="请输入内容..."><?php echo $product['ld_md_content'];?></textarea>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /.tab-pane -->
<div class="tab-pane" id="navseventh">
<div class="form-group grid-margin stretch-card" style="margin-left:0; margin-right:0;">
<div class="card">
<div class="card-body">
<label class="card-title">相关产品</label>
<p class="card-description"><button type="button" data-cod="related" data-callback="addRelated" title="添加相关产品" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></p>
<div class="col-sm-12">
<div class="table-responsive">
<table id="relateds" class="table">
<thead>
<tr>
<th class="text-left" width="60%">产品名称</th>
<th class="text-center" width="10%">排序</th>
<th class="text-center" width="20%">相关说明</th>
<th class="text-left" width="10%">操作</th>
</tr>
</thead>
<tbody class="related_list">
<?php
$related_row = 0;
foreach ($product_relateds as $k => $product_related):
$related_row=$product_related['related_id'];
?>
<tr id="related-row<?php echo $related_row; ?>" draggable="true">
<td class="text-left"><p class="form-control-static"><?php echo $product_related['name']; ?></p><input type="hidden" name="product_related[<?php echo $related_row; ?>][related_product_id]" value="<?php echo $product_related['related_product_id']; ?>"></div></td>
<td class="text-right"><input name="product_related[<?php echo $related_row; ?>][related_sort]" value="<?php echo $product_related['related_sort']; ?>" placeholder="排序" class="form-control" size="2" type="text"></td>
<td class="text-right"><input name="product_related[<?php echo $related_row; ?>][related_desc]" value="<?php echo $product_related['related_desc']; ?>" placeholder="相关说明" class="form-control" size="2" type="text"></td>
<td class="text-left"><button type="button" onclick="$('#related-row<?php echo $related_row; ?>').remove();" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
</tr>
<?php
endforeach;
$related_row++;
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="form-group grid-margin stretch-card" style="margin-left:0; margin-right:0;">
<div class="card">
<div class="card-body">
<label class="card-title">相关下载</label>
<p class="card-description"><button type="button" onclick="addDl();" title="添加下载" class="btn btn-primary"><i class="fa fa-plus-circle"></i></button></p>
<div class="col-sm-12">
<div class="table-responsive">
<table id="dls" class="table">
<thead>
<tr>
<th class="text-left" width="40%">文件</th>
<th class="text-center" width="20%">分类</th>
<th class="text-center" width="10%">排序</th>
<th class="text-center" width="20%">名称</th>
<th class="text-left" width="10%">操作</th>
</tr>
</thead>
<tbody>
<?php
$dl_row = 0;
$selectTypeObj = config("product_dltype");
foreach ($product_dls as $k => $product_dl):
$dl_row=$product_dl['id'];
$sltdltOption='';
foreach ($selectTypeObj as $c=>$v) {
$sltdltOption .= $c==$product_dl['dl_type']?'<option value="'.$c .'" selected="">' .$v.'</option>':'<option value="'.$c .'">' .$v.'</option>';
}
?>
<tr id="dl-row<?php echo $dl_row; ?>">
<td class="text-left"><div class="input-group"><input type="text" class="form-control" name="product_dl[<?php echo $dl_row; ?>][dl_url]" value="<?php echo $product_dl['dl_url']; ?>" id="input-dl<?php echo $dl_row; ?>"><span class="input-group-btn"><button class="btn btn-primary" type="button" onclick="webuploader_modal('input-dl<?php echo $dl_row; ?>', '', 'download', 'file', 'file_call_back')"><i class="fa fa-fw fa-download"></i></button></span></div></td>
<td class="text-right"><select class="form-control" name="product_dl[<?php echo $dl_row; ?>][dl_type]"><?php echo $sltdltOption;?></select></td>
<td class="text-right"><input name="product_dl[<?php echo $dl_row; ?>][dl_sort]" value="<?php echo $product_dl['dl_sort']; ?>" placeholder="排序" class="form-control" size="2" type="text"></td>
<td class="text-right"><input name="product_dl[<?php echo $dl_row; ?>][dl_name]" value="<?php echo $product_dl['dl_name']; ?>" placeholder="名称" class="form-control" size="2" type="text"></td>
<td class="text-left"><button type="button" onclick="$('#dl-row<?php echo $dl_row; ?>').remove();" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>
</tr>
<?php endforeach;$dl_row++;?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /.tab-pane -->
<!-- /.tab-content -->
<div class="nav-footer row">
<input name="id" value="<?php echo $product['id'];?>" type="hidden">
<div class="col-sm-2 col-sm-offset-2">
<p><button id="reset-btn" type="button" class="btn btn-warning btn-block">重置</button></p>
</div>
<div class="col-sm-2">
<p><button id="submit-btn" type="submit" class="btn btn-danger btn-block">提交</button></p>
</div>
<!-- /. row -->
</div>
</div>
<!-- /.nav-tabs-custom -->
</form>
</div>
</form>
</div>
<div class="col-md-2">
<div class="box box-primary">
<div class="box-header">
<h3 class="box-title">快捷入口</h3>
</div>
<div class="box-body">
<a href="<?php echo url('/admin/product/lists');?>" class="btn btn-block btn-primary">产品列表</a>
<a href="<?php echo url('/admin/product_category/lists');?>" class="btn btn-block btn-primary">产品分类</a>
<a href="<?php echo url('/admin/product/create');?>" class="btn btn-block btn-primary">添加产品</a>
</div>
</div>
</div>
</div>
</section>
<!-- /.content -->
</div>
<style>
.table thead > tr > td, .table tbody > tr > td {
vertical-align: middle;
}
.tab-pane{background: #f3f3f3;}
.card .card-description {
margin-bottom: .875rem;
font-weight: 400;
color: #76838f;
float: right;
padding-right: 10px;
}
.table thead th {
border-top: 0;
border-bottom-width: 1px;
font-weight: 500;
}
.table thead th {
vertical-align: bottom;
border-bottom: 2px solid #f3f3f3;
border-bottom-width: 2px;
}
.table th, .table td {
vertical-align: middle;
line-height: 1;
}
.table th, .table td {
padding: 1.25rem 0.9375rem;
vertical-align: top;
border-top: 1px solid #f3f3f3;
}
#navfifth img{max-width:100px;}
.stretch-card {
display: -webkit-flex;
display: flex;
-webkit-align-items: stretch;
align-items: stretch;
-webkit-justify-content: stretch;
justify-content: stretch;
}
.stretch-card > .card {
width: 100%;
min-width: 100%;
}
.grid-margin {
margin-bottom: 1.875rem;
margin-left:0;
margin-right:0;
}
.card {
position: relative;
display: flex;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: border-box;
/*border: 1px solid #e7eaed;*/
border-radius: 0;
}
.card .card-body {
padding: 1.5rem 1.875rem;
}
.card .card-title {
color: #4a4a4a;
margin-bottom: 1.5rem;
text-transform: uppercase;
font-weight: bold;
}
/*相册图片*/
#albums a{float:left; padding:5px;border:0; display:block;}
#albums img{border: 1px solid #ddd;}
/*点击弹框*/
.popup-quick {width:400px; position: fixed; top:50%;margin-top:-235px; left:50%; margin-left:-235px; background-color:#FFF; z-index:9999; box-shadow: 0px 2px 5px rgba(255,255,255,0.2); color:#333; border-radius: 0.05rem;}
.popup-quick .popup-app {font-size:14px;color:#333;line-height: 22px; padding:10px; text-align: center;}
.popup-app table {padding: 10px;width:100%}
.popup-app td {width:33%;}
.popup-quick .business-close{width:0.13rem; height:0.13rem; position: absolute; top:0.3rem; right:1.5rem; cursor: pointer;}
.title-text {font-size:16px;padding-top:14px;padding-left:22px;color:#ff0000;}
.marsk-container{background:rgba(0,0,0,.8); display: none;position: absolute;position: fixed; top: 0; right: 0; left: 0; bottom: 0px; z-index:999;}
.popup-bor {border-bottom: 1px solid #EBEBEB; padding-top:10px;}
.business-button {padding-left: 10px;}
.tips-text {font-size: 11px;color:#ff0000; text-align:left;
padding: 10px 0;width:94%;margin: auto; }
</style>
<!-- /.content-wrapper -->
<?php echo editor('#content');?>
<script type="text/javascript">
function parseInt_value(ele) {
elementObj = document.forms['productform'].elements[ele];
elementObj.value = parseInt(elementObj.value);
}
function mathRound_value(ele) {
elementObj = document.forms['productform'].elements[ele];
elementObj.value = Math.round(elementObj.value);//Math.floor() Math.ceil()
}
function toFixed_value(ele) {
elementObj = document.forms['productform'].elements[ele];
elementObj.value = elementObj.value.toFixed(2);
}
function addSpec(obj)
{
var trObj = obj.parentNode.parentNode;
var idx = trObj.rowIndex;
var tableObj = document.getElementById('type_attr_table');
var row = tableObj.insertRow(idx + 1);
var cell1 = row.insertCell(-1);
var cell2 = row.insertCell(-1);
var cell3 = row.insertCell(-1);
cell1.innerHTML = trObj.childNodes[0].innerHTML;
cell2.innerHTML = trObj.childNodes[1].innerHTML.replace(/readOnly([^\s|>]*)/i, '');
cell3.innerHTML = trObj.childNodes[2].innerHTML.replace(/(.*)(addSpec)(.*)(fa-plus-circle)/i, "$1removeSpec$3fa-minus-circle");
}
function removeSpec(obj)
{
var trObj = obj.parentNode.parentNode;
var idx = trObj.rowIndex;
var tableObj = document.getElementById('type_attr_table');
tableObj.deleteRow(idx);
}
</script>
<script type="text/javascript">
var selectColorObj = JSON.parse('<?php echo json_encode($productColor);?>');
$(function() {
$("#reset-btn").click(function(e) {
if (confirm('确认重置所有表单项吗?')) {
this.form.reset();
checkMultAlbum();
}
});
$("form.form-horizontal").submit(function(e) {
var nameObj = document.getElementById('name');
if (isNull(nameObj.value)) {
alert('名称必须填写');
nameObj.focus();
return false;
}
var sortObj = document.getElementById('sort');
if (isNaN(sortObj.value)) {
alert('排序值必须是数字');
sortObj.focus();
return false;
}
var cidObj = document.getElementById('cid');
if (isNaN(cidObj.value) || !parseInt(cidObj.value)) {
alert('所属分类值无效');
cidObj.focus();
return false;
}
$('.product_attr').each(function(){
if(!$(this).val()){
alert('属性名称不能为空');
e.preventDefault();
$(this).focus();
return false;
}
});
changeAlbumImagesSort();
if(!$("#albums input").hasClass("image_111")){
alert('属性相册图片不能为空');
$('.image_111').focus();
e.preventDefault();
return false;
}
var skus = [];
$('.form-sku').each(function(){
if($(this).val()){
skus.push($(this).val());
}
else{
alert('属性SKU不能为空');
e.preventDefault();
return false;
}
});
if(skus.length != quchong(skus).length) {
alert('属性SKU名称存在相同名称');
$('.form-sku').focus();
e.preventDefault();
}
$('.album_attr').find('select').each(function(){
var selectColor = $(this).val();
if(selectColor == '' || selectColor==undefined){
alert('相册选项属性不能为空');
$(this).focus();
e.preventDefault();
return false;
}
});
$('.album_attr input').each(function(){
if($(this).val()=='' || $(this).val()==undefined) {
alert('相册属性名称不能为空');
$(this).focus();
e.preventDefault();
return false;
}
});
});
$("[data-cod='related']").click(function(event) {
var param = {};
param.callback = $(this).data('callback');
//var $element = $(this).parent().parent();
//param.inputid = $element.find('input[type=hidden]').attr('id');
//param.titleid = $element.find('input[type=text]').attr('id');
$('#modal-product').remove();
$.ajax({
url: "<?php echo url('/admin/product/modallists');?>",
data: param,
dataType: 'html',
success: function(html) {
$('body').append('<div id="modal-product" class="modal fade">' + html + '</div>');
$('#modal-product').modal({show: true, backdrop: 'static'});
}
});
});
//Initialize Select2 Elements
$('.select2').select2();
});
</script>
<script type="text/javascript">
var arr_product_img = [];
var image_rows = [];
var k = 0;
<?php if (!empty($product_images)): ?>
<?php foreach ($product_images as $key => $value): ?>
image_rows.push(k);
var tmp_product_img = [];
<?php foreach ($value as $k => $v): ?>
tmp_product_img.push('<?php echo $v['image_url']; ?>');
k++;
<?php endforeach; ?>
arr_product_img.push(tmp_product_img);
<?php endforeach; ?>
<?php endif; ?>
var image_row = '<?php echo $image_row;?>';
var filePath = '<?php echo $filepath;?>';
//ajax无刷新方式校验产品型号
function chickbrandid() {
var id = document.getElementById('brand_id').value
if (id != '') {
$.ajax({
url: "/admin/product/chickbrandid/id/" +id,
dataType: 'html',
success: function (html) {
alert(html);
filePath = '<?php echo $filepath;?>/' + id.toUpperCase().replace('ORICO-', '');
$('.home_image').attr('data-folder',filePath);
}
})
}
}
function addImage() {
//获取arr_product_img数组长度
var imageRow = arr_product_img.length;
var sltclrOption = '<select class="form-control" name="product_image[' + imageRow + '][image_color]">';
for (clroption in selectColorObj) {
sltclrOption += '<option value="' + clroption + '">' + selectColorObj[clroption] + '</option>';
}
sltclrOption += '</select>';
var html = '<tr id="image-row' + imageRow + '">';
html += ' <td class="text-left"><a href="" id="thumb-image' + image_row + '"data-toggle="image" data-folder="' + filePath + '" class="img-thumbnail"><img class="img-responsive" src="/uploads/nopic.jpg"/></a><input type="hidden" name="product_image[' + image_row + '][image_url]" value="" id="input-image' + image_row + '"/></td>';
html += ' <td class="text-right">' + sltclrOption + '</td>';
//html += ' <td class="text-right"><a href="" id="thumb-color-image' + image_row + '"data-toggle="image" data-folder="' + filePath + '" class="img-thumbnail"><img class="img-responsive" src="/uploads/nopic.jpg"/></a><input type="hidden" name="product_image[' + imageRow + '][image_color]" value="" id="input-color-image' + image_row + '"/></td>';
html += ' <td class="text-right"><input type="text" name="product_image[' + imageRow + '][image_sort]" value="" placeholder="排序" class="form-control" size="2"/></td>';
html += ' <td class="text-right"><input type="text" name="product_image[' + imageRow + '][image_desc]" value="" placeholder="描述" class="form-control" size="2"/></td>';
html += ' <td class="text-left"><button type="button" onclick="remove_imgs(' + imageRow + ');" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
html += '</tr>';
$('#albums tbody').append(html);
image_rows.push(image_row);
image_row++;
}
function changeAlbumImagesSort(){
var productImages = [];
$('[id^="image-row"]').each(function(){
var rowIds = $(this).attr('id');
var rowID = rowIds.replace("image-row",'');
var feed = [];
var elementImgs = $(this).find('img');
elementImgs.each(function(){
feed.push($(this).attr('src'));
});
productImages.push(feed);
});
$("#albums").children('.image_111').remove();
for (var j=0; j<productImages.length; j++){
for (var k=0; k<productImages[j].length; k++)
{
var tmp_html = '<input type="hidden" class="image_111" name="arr_product_img[' + j + '][]" value="' + productImages[j][k] + '">';
$("#albums").append(tmp_html);
}
}
}
function remove_imgs(row)
{
var len = image_rows.length;
for (var i=0; i<len; i++)
{
if (row == image_rows[i])
{
arr_product_img.splice(i, 1);
image_rows.splice(i, 1);
}
}
$('#image-row' + row).remove();
$("#albums").children('.image_111').remove();
for (var j=0; j<arr_product_img.length; j++)
{
for (var k=0; k<arr_product_img[j].length; k++)
{
var tmp_html = '<input type="hidden" class="image_111" name="arr_product_img[' + j + '][]" value="' + arr_product_img[j][k] + '">';
$("#albums").append(tmp_html);
}
}
}
/*二级列表主图*/
var product_row = "<?php echo '0';?>";
function addProduct() {
var sltclrOption = '<select class="form-control" name="product_product[' + product_row + '][image_color]"><option value="">请选择</option>';
for (clroption in selectColorObj) {
sltclrOption += '<option value="' + clroption + '">' + selectColorObj[clroption] + '</option>';
}
sltclrOption += '</select>';
var html = '<tr id="product_row' + product_row + '">';
html += ' <td class="text-left"><a href="" id="thumb-two-image' + product_row + '"data-toggle="image" data-folder="' + filePath + '" class="img-thumbnail"><img class="img-responsive" src="/uploads/nopic.jpg"/></a><input type="hidden" name="product_product[' + product_row + '][image_url]" value="" id="input-two-image' + product_row + '"/></td>';
html += ' <td class="text-right">' + sltclrOption + '</td>';
//html += ' <td class="text-right"><input type="hidden" name="product_product[' + product_row + '][image_color]" value="" id="input-two-color-image' + product_row + '"/></td>';
//html += ' <td class="text-right"><input type="text" name="product_product[' + product_row + '][image_bkcolor]" value="" placeholder="颜色" class="form-control" size="2"/></td>';
html += ' <td class="text-right"><input type="text" name="product_product[' + product_row + '][image_desc]" value="" placeholder="描述" class="form-control" size="2"/></td>';
html += ' <td class="text-left"><button type="button" onclick="$(\'#product_row' + product_row + '\').remove();" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
html += '</tr>';
$('#product tbody').append(html);
product_row++;
}
/*爆款主图*/
var bkimg_row = "<?php echo '0';?>";
function addBkimg() {
var html = '<tr id="bkimg_row' + bkimg_row + '">';
html += ' <td class="text-left"><a href="" id="thumb-bk-image' + bkimg_row + '"data-toggle="image" data-folder="' + filePath + '" class="img-thumbnail"><img class="img-responsive" src="/uploads/nopic.jpg"/></a><input type="hidden" name="bkimg_row[' + bkimg_row + '][image_url]" value="" id="input-bk-image' + bkimg_row + '"/></td>';
// html += ' <td class="text-right">' + sltclrOption + '</td>';
html += ' <td class="text-right"><a href="" id="thumb-bk-color-image' + bkimg_row + '"data-toggle="image" data-folder="' + filePath + '" class="img-thumbnail"><img class="img-responsive" src="/uploads/nopic.jpg"/></a><input type="hidden" name="bkimg_row[' + bkimg_row + '][image_color]" value="" id="input-bk-color-image' + bkimg_row + '"/></td>';
html += ' <td class="text-right"><input type="text" name="bkimg_row[' + bkimg_row + '][image_bkcolor]" value="" placeholder="背景色" class="form-control" size="2"/></td>';
/* html += ' <td class="text-right"><input type="text" name="bkimg_row[' + bkimg_row + '][image_desc]" value="" placeholder="描述" class="form-control" size="2"/></td>';*/
html += ' <td class="text-left"><button type="button" onclick="$(\'#bkimg_row' + bkimg_row + '\').remove();" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
html += '</tr>';
$('#bkimg tbody').append(html);
bkimg_row++;
}
var dltoption, selectTypeObj = JSON.parse('<?php echo json_encode(config("product_dltype"));?>');
var dl_row = '<?php echo $dl_row;?>';
function addDl() {
var sltdltOption = '<select class="form-control" name="product_dl[' + dl_row + '][dl_type]">';
for (dltoption in selectTypeObj) {
sltdltOption += '<option value="' + dltoption + '">' + selectTypeObj[dltoption] + '</option>';
}
sltdltOption += '</select>';
var html = '<tr id="dl-row' + dl_row + '">';
html += ' <td class="text-left"><div class="input-group"><input type="text" class="form-control" name="product_dl[' + dl_row + '][dl_url]" value="" id="input-dl' + dl_row + '"><span class="input-group-btn"><button class="btn btn-primary" type="button" onclick="webuploader_modal(\'input-dl' + dl_row + '\', \'\', \'download\', \'file\', \'file_call_back\')"><i class="fa fa-fw fa-download"></i></button></span></div></td>';
html += ' <td class="text-right">' + sltdltOption + '</td>';
html += ' <td class="text-right"><input type="text" name="product_dl[' + dl_row + '][dl_sort]" value="" placeholder="排序" class="form-control" size="2"/></td>';
html += ' <td class="text-right"><input type="text" name="product_dl[' + dl_row + '][dl_name]" value="" placeholder="名称" class="form-control" size="2"/></td>';
html += ' <td class="text-left"><button type="button" onclick="$(\'#dl-row' + dl_row + '\').remove();" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
html += '</tr>';
$('#dls tbody').append(html);
dl_row++;
}
var related_row = '<?php echo $related_row;?>';
var related_list = [];
var addRelated = function (id, title) {
if(inArray(id,related_list)===false){
var html = '<tr id="related-row_' + id + '" draggable="true">';
html += ' <td class="text-left" draggable="true"><p class="form-control-static">' + title + '</p><input type="hidden" name="product_related[' + related_row + '][related_product_id]" value="' + id + '"/></td>';
html += ' <td class="text-right" draggable="true"><input type="text" name="product_related[' + related_row + '][related_sort]" value="" placeholder="排序" class="form-control" size="2"/></td>';
html += ' <td class="text-right" draggable="true"><input type="text" name="product_related[' + related_row + '][related_desc]" value="" placeholder="相关说明" class="form-control" size="2"/></td>';
html += ' <td class="text-left" draggable="true"><button type="button" onclick="delRelated(\'' + id + '\')" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
html += '</tr>';
$('#relateds tbody').append(html);
related_list.push(id);
related_row++;
}
}
var delRelated = function (id) {
// var isin = inArray(id,related_list);
var index = related_list.indexOf(id);
if(index > -1){
related_list.splice(index, 1);
}
$('#related-row_' + id ).remove();
}
function inArray(need,array) {
if(typeof array !="object"){
return false;
}
var index;
for (index in array){
if(index == need){
return index;
}
}
return false;
}
var desc_row = '<?php echo $desc_row;?>';
function addDesc() {
html = '<tr id="desc-row' + desc_row + '">';
html += ' <td class="text-left"><input type="text" name="product_desc[' + desc_row + '][desc_title]" value="" placeholder="标题" class="form-control" size="2"/></td>';
html += ' <td class="text-left"><input type="text" name="product_desc[' + desc_row + '][desc_desc]" value="" placeholder="详情" class="form-control" size="2"/></td>';
html += ' <td class="text-left"><button type="button" onclick="$(\'#desc-row' + desc_row + '\').remove();" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
html += '</tr>';
$('#descs tbody').append(html);
desc_row++;
}
function addView() {
html = '<tr id="desc-row' + view_row + '">';
html += ' <td class="text-left"><input type="text" name="product_view[' + view_row + '][desc_title]" value="" placeholder="参数" class="form-control" size="2"/></td>';
html += ' <td class="text-left"><input type="text" name="product_view[' + view_row + '][desc_desc]" value="" placeholder="参数值" class="form-control" size="2"/></td>';
html += ' <td class="text-left"><button type="button" onclick="$(\'#desc-row' + view_row + '\').remove();" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
html += '</tr>';
$('#view tbody').append(html);
view_row++;
}
var product_id = "<?php echo $product['id'];?>";
function typeChanged(obj, target) {
var type_id = obj.options[obj.selectedIndex].value;
if (type_id && target) {
$.ajax({
url: "<?php echo url('/admin/product/getHtmlAttr');?>",
dataType: 'html',
data: {"type_id": type_id, "product_id": product_id},
success: function(html) {
$('#' + target).html(html);
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert("上传失败,请检查网络后重试");
}
});
}
}
$(function() {
$("#btn-product-video").click(function(e) {
//var param = {};
//param.callback = $(this).data('callback');
//var $element = $(this).parent().parent();
//param.inputid = $element.find('input[type=hidden]').attr('id');
//param.titleid = $element.find('input[type=text]').attr('id');
$('#modal-video').remove();
$.ajax({
url: "<?php echo url('/admin/video/modallists');?>?inputid=videopath",
dataType: 'html',
success: function(html) {
$('body').append('<div id="modal-video" class="modal fade">' + html + '</div>');
$('#modal-video').modal({show: true, backdrop: 'static'});
}
});
});
});
//属性去重
function quchong(array){
var temp = []; //一个新的临时数组
for(var i = 0; i < array.length; i++){
if(temp.indexOf(array[i]) == -1){
temp.push(array[i]);
}
}
return temp;
}
//相册图片
var product_attrs = [];
function addAlbum() {
var inputFeed = [];
$("input[name='product_attr[]']").each(function () {
// 在这里可以对每个input元素执行相应的操作
inputFeed.push($(this).val());
});
var htmlHeader = ' <tr><th class="text-left" width="30%">图片</th>';
var html = '<tr id="image-row' + image_row + '">';
html += ' <td class="text-left "><ul class="listbox"><li id="thumb-image' + image_row + '" draggable="true" data-toggle="image" data-folder="' + filePath + '" class="img-thumbnail"><img draggable="true" class="img-responsive input-image' + image_row + '" src="/uploads/nopic.jpg"/></li></td>';
inputFeed.forEach(function(atrVal,atrKey) {
if(atrVal){
var sltclrOption = '<select class="form-control" name="product_image[' + image_row + '][type][' + atrKey + ']"><option value="">请选择</option>';
for (clroption in selectColorObj) {
sltclrOption += '<option value="' + clroption + '">' + selectColorObj[clroption] + '</option>';
}
sltclrOption += '</select>';
if(atrVal.toLowerCase()== 'color' || atrVal.toLowerCase()== '颜色'){
html += ' <td class="text-right attr_row album_attr" data-type="' + atrVal + '">'+ sltclrOption +'</td>';
}
else{
html += ' <td class="text-right attr_row album_attr" data-type="' + atrVal + '"><input type="text" name="product_image[' + image_row + '][type][' + atrKey + ']" value="" class="form-control" size="2"/></td>';
}
html += ' <td class="text-right attr_row" data-type="' + atrVal + '"><input type="text" name="product_image[' + image_row + '][sort][' + atrKey + ']" value="" class="form-control" size="2"/></td>';
htmlHeader += '<th class="text-center attr_column attr_' + atrVal + '" width="10%" data-type="' + atrVal + '">' + atrVal + '</th>';
htmlHeader += '<th class="text-center sort_' + atrVal + '" width="8%" data-type="' + atrVal + '">' + atrVal + '排序</th>';
}
});
html += ' <td class="text-right"><input type="text" name="product_image[' + image_row + '][sku]" value="" placeholder="SKU" class="form-control form-sku" size="2"/></td>';
html += ' <td class="text-left"><button type="button" onclick="remove_imgs(' + image_row + ');" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
html += '</tr>';
htmlHeader += '<th class="text-center" width="10%">SKU</th>';
htmlHeader += '<th class="text-left" width="5%">操作</th><tr> ';
$('#albums thead').html(htmlHeader);
$('#albums tbody').append(html);
image_rows.push(image_row);
image_row++;
$(".listbox").sortable({
// cursor: "move",
items: "li", //仅仅是li能够拖动
opacity: 0.7, //拖动时透明度为0.6
revert: true, //释放时,添加动画
update: function () { //更新排序之后
changeAlbumImagesSort();
}
});
}
$(".listbox").sortable({
// cursor: "move",
items: "li", //仅仅是li能够拖动
opacity: 0.7, //拖动时透明度为0.6
revert: true, //释放时,添加动画
update: function () { //更新排序之后
changeAlbumImagesSort();
// $(this).sortable("toArray");
}
});
//调整相册属性数据项
function changeAlbumAttribute(option,typeIndex,attrValue, diffAttr){
$('[id^="image-row"]').each(function(){
var rowId = $(this).attr('id');
var rowSort = rowId.replace("image-row",'');
var elements = $(this).find('.attr_row');
var html = '';
var addHtml = '';
if(option == 'delete'){
console.log('Del' + attrValue);
$(this).find('[data-type="'+ attrValue +'"]').remove();
$(this).find('[data-type="'+ attrValue +'"]').remove();
}
else{
if(attrValue){
var sltclrOption = '<select class="form-control" name="product_image[' + rowSort + '][type][' + typeIndex + ']"><option value="">请选择</option>';
for (clroption in selectColorObj) {
sltclrOption += '<option value="' + clroption + '">' + selectColorObj[clroption] + '</option>';
}
sltclrOption += '</select>';
if(attrValue.toLowerCase()== 'color' || attrValue.toLowerCase()== '颜色'){
html += sltclrOption;
addHtml += ' <td class="text-right attr_row album_attr" data-type="' + attrValue + '">'+ sltclrOption +'</td>';
}
else{
html += ' <input type="text" data-type="attribute" name="product_image[' + rowSort + '][type][' + typeIndex + ']" value="" class="form-control" size="2"/>';
addHtml += ' <td class="text-right attr_row album_attr" data-type="' + attrValue + '"><input type="text" data-type="attribute" name="product_image[' + rowSort + '][type][' + typeIndex + ']" value="" class="form-control" size="2"/></td>';
}
var html2= ' <td class="text-right attr_row" data-type="' + attrValue + '"><input type="text" data-type="sort" name="product_image[' + rowSort + '][sort][' + typeIndex + ']" value="" class="form-control" size="2"/></td>';
addHtml += ' <td class="text-right attr_row" data-type="' + attrValue + '"><input type="text" data-type="sort" name="product_image[' + rowSort + '][sort][' + typeIndex + ']" value="" class="form-control" size="2"/></td>';
}
if(option == 'add'){
//console.log(((typeIndex+1)*2-1) + '---Add----');
$(this).find('td:eq('+ ((typeIndex+1)*2-2) +')').after(addHtml);
}
else{
//console.log(diffAttr + 'diff');
$(this).find('.album_attr[data-type="'+ diffAttr +'"]').html(html);
$(this).find('[data-type="'+ diffAttr +'"]').attr('data-type',attrValue);
}
}
//console.log(typeIndex +'++++'+attrValue);
/*if(diffAttr){
console.log(diffAttr + 'diff');
//console.log(diffAttr);
var element =$(this).find('[data-type="'+ diffAttr +'"]');
if(attrValue){
element.data('type',attrValue);
console.log('Update');
$(this).find('.album_attr[data-type="'+ diffAttr +'"]').html(html);
$(this).find('[data-type="'+ diffAttr +'"]').attr('data-type',attrValue);
//console.log(html);
}
else{
console.log('Del');
$(this).find('[data-type="'+ diffAttr +'"]').remove();
$(this).find('[data-type="'+ diffAttr +'"]').remove();
}
//console.log('diff feed');
//$(this).find('td:eq('+ (elements.length) +')').after(html);
}
else{
console.log(((typeIndex+1)*2-1) + '---Add----');
/*if(elements.length>1){
//console.log(elements.length);
$(this).find('td:eq('+ ((typeIndex+1)*2-1) +')').attr('data-type',attrValue);
$(this).find('td:eq('+ ((typeIndex+1)*2-1) +')').html(html);
$(this).find('td:eq('+ ((typeIndex+1)*2) +')').attr('data-type',attrValue);
//$(this).find('td:eq('+ ((typeIndex+1)*2) +')').html(html2);
}else{
console.log(0);
$(this).find('td:eq(0)').after(html);
}
$(this).find('td:eq('+ ((typeIndex+1)*2-2) +')').after(addHtml);
}*/
});
}
function checkMultAlbum(){
var inputFeed = [];
var product_attrs = [];
$("input[name='product_attr[]']").each(function (index) {
// 在这里可以对每个input元素执行相应的操作
if($(this).val()){
inputFeed.push($(this).val());
}
});
product_attr = quchong(inputFeed);
$(".attr_column").each(function (index) {
// 在这里可以对每个input元素执行相应的操作
product_attrs.push($(this).data('type').toString());
});
//属性存在重复数据
if(product_attr.length == inputFeed.length) {
var htmlHeader = ' <tr><th class="text-left" width="30%">图片</th>';
inputFeed.forEach(function(atrVal,atrKey) {
if(atrVal){
htmlHeader += '<th class="text-center attr_column attr_' + atrVal + '" width="10%" data-type="' + atrVal + '">' + atrVal + '</th>';
htmlHeader += '<th class="text-center sort_' + atrVal + '" width="8%" data-type="' + atrVal + '">' + atrVal + '排序</th>';
}
});
//计算新旧属性的差集
var diffAttr = product_attrs.filter(function(v){ return product_attr.indexOf(v) == -1 });
if(product_attr.length < quchong(product_attrs).length){
diffAttr.forEach(function(difVal,difKey) {
$("#albums").find('[data-type="'+ difVal +'"]').detach();
$("#albums").find('[data-type="'+ difVal +'"]').detach();
});
}
htmlHeader += '<th class="text-center" width="10%">SKU</th>';
htmlHeader += '<th class="text-left" width="5%">操作</th><tr> ';
$('#albums thead').html(htmlHeader);
}
}
function changeMultAlbum(object){
//获取当前所有属性
var attrValue = $(object + ' input').val();
var rowIndex = object.replace("#attr_row",'');
var inputFeed = [];
var product_attrs = [];
$("input[name='product_attr[]']").each(function (index) {
// 在这里可以对每个input元素执行相应的操作
if($(this).val()){
inputFeed.push($(this).val());
}
});
product_attr = quchong(inputFeed);
console.log(inputFeed);
console.log('************');
console.log(product_attr);
$(".attr_column").each(function (index) {
// 在这里可以对每个input元素执行相应的操作
product_attrs.push($(this).data('type').toString());
});
console.log('Old');
console.log(product_attrs);
//属性存在重复数据
if(product_attr.length == inputFeed.length) {
var htmlHeader = ' <tr><th class="text-left" width="30%">图片</th>';
inputFeed.forEach(function(atrVal,atrKey) {
if(atrVal){
htmlHeader += '<th class="text-center attr_column attr_' + atrVal + '" width="10%" data-type="' + atrVal + '">' + atrVal + '</th>';
htmlHeader += '<th class="text-center sort_' + atrVal + '" width="8%" data-type="' + atrVal + '">' + atrVal + '排序</th>';
}
});
//计算新旧属性的差集
var diffAttr = product_attrs.filter(function(v){ return product_attr.indexOf(v) == -1 });
console.log('---DiffAttr---');
console.log(diffAttr);
//判断当前属性是否存在
var typeIndex = $.inArray(attrValue, product_attrs);
if(product_attr.length == quchong(product_attrs).length) {
//替换指定列
var typeOldIndex = $.inArray(diffAttr[0], product_attrs);
changeAlbumAttribute('update',rowIndex,attrValue, diffAttr[0]);
console.log(rowIndex + '==update=>' + attrValue);
}
else if(product_attr.length < quchong(product_attrs).length){
console.log('==delete=>' + diffAttr[0]);
changeAlbumAttribute('delete',0,diffAttr[0]);
}
else{
//判断当前属性下标
var typeNewIndex = $.inArray(attrValue, product_attr);
changeAlbumAttribute('add',typeNewIndex,attrValue);
console.log(typeNewIndex + '==add => ' + attrValue);
}
htmlHeader += '<th class="text-center" width="10%">SKU</th>';
htmlHeader += '<th class="text-left" width="5%">操作</th><tr> ';
$('#albums thead').html(htmlHeader);
}
else{
console.log(product_attr.length +'=='+ inputFeed.length);
alert("属性重复,请修改重复属性名称重试");
}
product_attrs = product_attr;
}
var attr_row = '<?php echo $attr_row;?>';
//添加属性
function addMultiAttribute() {
var html = '<tr id="attr_row' + attr_row + '">';
html += ' <td class="text-right "><input type="text" name="product_attr[]" onblur="changeMultAlbum(\'#attr_row' + attr_row + '\')" value="" placeholder="属性名称" class="form-control product_attr" size="2"/></td>';
html += ' <td class="text-center"><button type="button" onclick="delAlbumAttributeColumn(\'#attr_row' + attr_row + '\')" title="删除" class="btn btn-danger"><i class="fa fa-minus-circle"></i></button></td>';
html += '</tr>';
$('#multi-attribute tbody').append(html);
attr_row++;
}
//删除相册属性列+排序
function delAlbumAttributeColumn (object){
var delValue = $(object + ' input').val();
if(delValue){
//删除指定列
$('#albums').find('[data-type="'+ delValue +'"]').remove();
$('#albums').find('[data-type="'+ delValue +'"]').remove();
}
$(object).remove();
}
</script>
<script type="text/javascript">
$(function() {
$('.business-button,.busniess-joinus-btn').click(function() {
$(".marsk-container").show();
});
});
// 弹出框关闭
$(function() {
$('.business-close').click(function() {
$(".marsk-container").hide();
});
});
</script>