edit修改后台内容
This commit is contained in:
parent
4264cd8902
commit
48c9040186
@ -67,12 +67,15 @@ class CommonGoodsEditForm extends Model
|
||||
public $date;
|
||||
public $signing_foot_img;
|
||||
public $signing_head_img;
|
||||
public $video_url_data_title;
|
||||
public $video_url_data_url;
|
||||
public $video_url_data_img;
|
||||
|
||||
public function rules()
|
||||
{
|
||||
return [
|
||||
[['name', 'subtitle', 'detail', 'cover_pic', 'video_url', 'unit', 'plugin_sign', 'goods_no',], 'trim'],
|
||||
[['name', 'subtitle', 'detail', 'price', 'cover_pic', 'video_url', 'video_banner_urls', 'banner_urls', 'unit', 'plugin_sign', 'goods_no', 'date', 'signing_head_img', 'signing_foot_img'], 'string'],
|
||||
[['name', 'subtitle','video_url_data_url','video_url_data_title','video_url_data_img', 'detail', 'price', 'cover_pic', 'video_url', 'video_banner_urls', 'banner_urls', 'unit', 'plugin_sign', 'goods_no', 'date', 'signing_head_img', 'signing_foot_img'], 'string'],
|
||||
[['original_price', 'cost_price', 'goods_weight'], 'number'],
|
||||
[['type', 'use_attr', 'goods_stock', 'virtual_sales', 'confine_count', 'freight_id', 'sort', 'cx_mch_id'], 'integer'],
|
||||
|
||||
@ -185,6 +188,18 @@ class CommonGoodsEditForm extends Model
|
||||
$goods_hub = new GoodsHub();
|
||||
$goods_hub->cx_mch_id = $this->cx_mch_id;
|
||||
}
|
||||
$video_url_data_arr = [];
|
||||
if(!empty($this->video_url_data_url)){
|
||||
$video_url_data_arr[0]['url'] = $this->video_url_data_url;
|
||||
}
|
||||
if(!empty($this->video_url_data_title)){
|
||||
$video_url_data_arr[0]['title'] = $this->video_url_data_title;
|
||||
}
|
||||
if(!empty($this->video_url_data_img)){
|
||||
$video_url_data_arr[0]['img'] = $this->video_url_data_img;
|
||||
}
|
||||
|
||||
$goods_hub->video_url_data = json_encode($video_url_data_arr,JSON_UNESCAPED_UNICODE);
|
||||
$goods_hub->name = $this->name;
|
||||
$goods_hub->subtitle = $this->subtitle;
|
||||
// $goods_hub->original_price = $this->original_price ? $this->original_price : $this->price;
|
||||
@ -333,6 +348,9 @@ class CommonGoodsEditForm extends Model
|
||||
|
||||
private function addAttrGroupsId($list, &$id = 1)
|
||||
{
|
||||
if(!is_array($list)){
|
||||
return [];
|
||||
}
|
||||
$newId = 1;
|
||||
foreach ($list as $key => $item) {
|
||||
if (isset($item['attr_list'])) {
|
||||
@ -401,7 +419,7 @@ class CommonGoodsEditForm extends Model
|
||||
];
|
||||
|
||||
// 未使用规格情况下,要把上一次的规格ID 存回去,不然规格记录会重复添加
|
||||
if (count($this->attr) === 1 && isset($this->attr[0]['id'])) {
|
||||
if (!empty($this->attr) && count($this->attr) === 1 && isset($this->attr[0]['id'])) {
|
||||
$newAttrs[0]['id'] = $this->attr[0]['id'];
|
||||
}
|
||||
|
||||
|
||||
@ -219,8 +219,16 @@ class GoodsController extends Controller
|
||||
$attr[$index] = $item;
|
||||
}
|
||||
}
|
||||
$video_url_data_url = "";
|
||||
$video_url_data_title = "";
|
||||
$video_url_data_img = "";
|
||||
if(!empty($model->goodsHub->video_url_data)){
|
||||
$json_decode = json_decode($model->goodsHub->video_url_data,true);
|
||||
$video_url_data_url = $json_decode[0]['url'];
|
||||
$video_url_data_title = $json_decode[0]['title'];
|
||||
$video_url_data_img = $json_decode[0]['img'];
|
||||
|
||||
|
||||
}
|
||||
|
||||
return $this->render('edit', [
|
||||
'cat_list' => $cat_list,
|
||||
@ -232,6 +240,9 @@ class GoodsController extends Controller
|
||||
'attr_groups' => $attr_groups,
|
||||
'model' => $model,
|
||||
'return_url' => $return_url,
|
||||
'video_url_data_url' => $video_url_data_url,
|
||||
'video_url_data_title' => $video_url_data_title,
|
||||
'video_url_data_img' => $video_url_data_img,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@ -198,7 +198,7 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
foreach ($json_de as $key => $val) {
|
||||
$explode = explode('/', $val);
|
||||
$end = end($explode);
|
||||
//
|
||||
//12G
|
||||
$temp_arr[] = [
|
||||
'name' => $end,
|
||||
'url' => $val,
|
||||
@ -208,13 +208,44 @@ $this->params['breadcrumbs'][] = $this->title;
|
||||
}
|
||||
?>
|
||||
|
||||
<?= PickFile::widget([
|
||||
'accept' => 'video',
|
||||
'multiple' => false,
|
||||
'id' => 'video_url_data_url',
|
||||
'name' => 'video_url_data_url',
|
||||
'label' => '冠军视频',
|
||||
'value' => $video_url_data_url ? $video_url_data_url : '',
|
||||
'tip' => '视频最大50M',
|
||||
'required' => false
|
||||
]) ?>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">冠军视频标题</label>
|
||||
<div class="layui-input-inline">
|
||||
<input name="video_url_data_title" placeholder="请输入视频标题" autocomplete="off"
|
||||
class="layui-input" value="<?= $video_url_data_title ?>"
|
||||
>
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
</div>
|
||||
|
||||
<?= PickFile::widget([
|
||||
'accept' => 'images',
|
||||
'id' => 'video_url_data_img',
|
||||
'name' => 'video_url_data_img',
|
||||
'label' => '冠军视频图片',
|
||||
'value' => $video_url_data_img,
|
||||
// 'tip' => '图片大小750×750',
|
||||
|
||||
'imageCompressEnable' => 1,
|
||||
'imageCompressBorder' => 750,
|
||||
]) ?>
|
||||
|
||||
<?= PickFile::widget([
|
||||
'accept' => 'file',
|
||||
'multiple' => true,
|
||||
'id' => 'video_url',
|
||||
'name' => 'video_url',
|
||||
'label' => '冠军视频',
|
||||
'label' => '冠军视频列表',
|
||||
'value' => $model->goodsHub ? $model->goodsHub->video_url : '',
|
||||
'tip' => '视频最大50M',
|
||||
'required' => false
|
||||
|
||||
@ -144,7 +144,7 @@ class GoodsController extends Controller
|
||||
$form->cx_mch_id = $this->cx_mch_id;
|
||||
$form->status = Goods::STATUS_ONLINE;
|
||||
$form->plugin_sign = SysConst::$cxPluginSceneIntegralMall;
|
||||
$form->setFields('g.id,g.price,g.date,g.sort,gh.subtitle,gh.banner_urls,g.created_at,gh.name,gh.cover_pic,gh.video_url,gh.pic_urls,gh.video_banner_urls');
|
||||
$form->setFields('g.id,g.price,g.date,g.sort,gh.subtitle,gh.banner_urls,g.created_at,gh.name,gh.cover_pic,gh.video_url,gh.pic_urls,gh.video_banner_urls,gh.video_url_data');
|
||||
$data = $form->search();
|
||||
|
||||
foreach ($data['data'] as $key => $value) {
|
||||
@ -160,15 +160,25 @@ class GoodsController extends Controller
|
||||
$data['data'][$key]['pic_arr'] = $pic_arr;
|
||||
}
|
||||
}
|
||||
$video = [];
|
||||
$i = 0;
|
||||
$video[$i] = [];
|
||||
if(!empty($value['video_url_data'])){
|
||||
$json_de = json_decode($value['video_url_data'],true);
|
||||
if(!empty($json_de[0]['url'])){
|
||||
$video[$i]['img'] = $json_de[0]['img']??'';
|
||||
$video[$i]['video_url'] = $json_de[0]['url']??'';
|
||||
$video[$i]['title'] = $json_de[0]['title']??'';
|
||||
}
|
||||
}
|
||||
$data['data'][$key]['video_arr'] = [];
|
||||
if ($value['video_url'] != null) {
|
||||
$video_arr = json_decode($value['video_url'], true);
|
||||
$video_banner_urls = json_decode($value['video_banner_urls'], true);
|
||||
|
||||
$video = [];
|
||||
foreach ($video_arr as $key1 => $value1) {
|
||||
$video[$key1]['img'] = $video_banner_urls[$key1] ?? '';
|
||||
$video[$key1]['video_url'] = $value1 ?? '';
|
||||
$i++;
|
||||
$video[$i]['img'] = $video_banner_urls[$key1] ?? '';
|
||||
$video[$i]['video_url'] = $value1 ?? '';
|
||||
}
|
||||
$data['data'][$key]['video_arr'] = $video;
|
||||
}
|
||||
|
||||
Binary file not shown.
@ -5,12 +5,12 @@
|
||||
* @description KISS
|
||||
* @date 2021年10月7日
|
||||
* @version 1.0.0
|
||||
*
|
||||
*
|
||||
* _____LOG_____
|
||||
*
|
||||
*
|
||||
*/
|
||||
?>
|
||||
<style>
|
||||
<style>
|
||||
.input-control-group .btn-control,
|
||||
.input-control-group .input-wrap,
|
||||
.input-control-group .label {
|
||||
@ -18,7 +18,7 @@
|
||||
height: 30px;
|
||||
line-height: 30px;
|
||||
padding: 0 10px;
|
||||
font-size: 12px;
|
||||
font-size: 12px;
|
||||
border: 1px solid #C9C9C9;
|
||||
background-color: #fff;
|
||||
color: #555;
|
||||
@ -40,12 +40,12 @@
|
||||
}
|
||||
</style>
|
||||
<div class="layui-form-item attr-group-panel" id="<?=$id?>" lay-ignore>
|
||||
<label class="layui-form-label">业务类型</label>
|
||||
<label class="layui-form-label">规格组与规格值</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="input-control-group">
|
||||
<label class="label">业务组</label>
|
||||
<label class="label">规格组</label>
|
||||
<div class="input-wrap">
|
||||
<input type="text" name="" required="" placeholder="请输入业务" autocomplete="off" class="input-control" v-model="attr_group_name">
|
||||
<input type="text" name="" required="" placeholder="请输入如颜色" autocomplete="off" class="input-control" v-model="attr_group_name">
|
||||
</div>
|
||||
<span class="btn-control" v-on:click="add_attr_group"><i class="layui-icon"></i>添加</span>
|
||||
</div>
|
||||
@ -55,65 +55,120 @@
|
||||
<div class="layui-btn-group">
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm">{{attr_group['attr_group_name']}}</button>
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="remove_attr_group(index)"><i class="layui-icon">ဆ</i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-mt-15">
|
||||
<div class="input-control-group">
|
||||
<label class="label">{{attr_group['attr_group_name']}}</label>
|
||||
<div class="input-wrap">
|
||||
<input type="text" name="" required="" placeholder="请输入规格值" autocomplete="off" class="input-control" v-model="attr_group.attr_name">
|
||||
<input type="text" name="" required="" placeholder="请输入规格值" autocomplete="off" class="input-control" v-model="attr_group.attr_name">
|
||||
</div>
|
||||
<span class="btn-control" v-on:click="add_attr_name(index)"><i class="layui-icon"></i>添加</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-row">
|
||||
<button class="layui-btn layui-btn-sm layui-btn-normal layui-mt-15" v-for="(attr_item,i) in attr_group['attr_list']" v-on:click="remove_attr_name(index,i)">{{attr_item['attr_name']}} <i class="layui-icon"></i> </button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-input-block" v-show="attr_groups.length > 0">
|
||||
<table class="layui-table">
|
||||
<thead>
|
||||
<th v-for="attr_group in attr_groups" v-show="attr_group['attr_list'].length > 0">{{attr_group['attr_group_name']}}</th>
|
||||
<th>
|
||||
<div class="layui-inline">价格</div>
|
||||
<div class="layui-inline">
|
||||
<input class="layui-input" type="text" placeholder="批量设置价格" name="batch_price" v-model="batch_price" style="margin-right: 0;height: 34px;line-height: 34px;width:120px"/>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="batch_set_goods_price()" >设置</button>
|
||||
</div>
|
||||
</th>
|
||||
<th>
|
||||
<div class="layui-inline">库存</div>
|
||||
<div class="layui-inline">
|
||||
<input class="layui-input" type="text" placeholder="批量设置库存" name="batch_stock" v-model="batch_stock" style="margin-right: 0;height: 34px;line-height: 34px;width:120px"/>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="batch_set_goods_stock()" >设置</button>
|
||||
</div>
|
||||
</th>
|
||||
<?php if($open_integral):?>
|
||||
<th>
|
||||
<div class="layui-inline">价格</div>
|
||||
<div class="layui-inline">积分</div>
|
||||
<div class="layui-inline">
|
||||
<input class="layui-input" type="text" placeholder="批量设置价格" name="batch_price" v-model="batch_price" style="margin-right: 0;height: 34px;line-height: 34px;width:120px"/>
|
||||
<input class="layui-input" type="number" placeholder="批量设置积分" name="batch_integral_num" v-model="batch_integral_num" style="margin-right: 0;height: 34px;line-height: 34px;width:120px"/>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="batch_set_goods_price()" >设置</button>
|
||||
</div>
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm" v-on:click="batch_set_goods_integral_num()" >设置</button>
|
||||
</div>
|
||||
</th>
|
||||
|
||||
<?php endif;?>
|
||||
<th>
|
||||
<div class="layui-inline">货号</div>
|
||||
</th>
|
||||
<th>
|
||||
<div class="layui-inline">重量</div>
|
||||
</th>
|
||||
<th>
|
||||
<div class="layui-inline">图片</div>
|
||||
</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="(goods_attr,index) in attr">
|
||||
<td v-for="attr_val in goods_attr['attr_list']">{{attr_val.attr_name}}</td>
|
||||
<td><input class="layui-input" type="number" placeholder="" name="" v-model="attr[index]['price']" style="margin-right: 0;height: 34px;line-height: 34px;"/></td>
|
||||
|
||||
</tr>
|
||||
<tr v-for="(goods_attr,index) in attr">
|
||||
<td v-for="attr_val in goods_attr['attr_list']">{{attr_val.attr_name}}</td>
|
||||
<td><input class="layui-input" type="number" placeholder="" name="" v-model="attr[index]['price']" style="margin-right: 0;height: 34px;line-height: 34px;"/></td>
|
||||
<td><input class="layui-input" type="number" placeholder="" name="" v-model="attr[index]['stock']" style="margin-right: 0;height: 34px;line-height: 34px;"/></td>
|
||||
<?php if($open_integral):?>
|
||||
<td><input class="layui-input" type="number" placeholder="" name="" v-model="attr[index]['integral_num']" style="margin-right: 0;height: 34px;line-height: 34px;"/></td>
|
||||
<?php endif;?>
|
||||
<td><input class="layui-input" type="text" placeholder="" name="" v-model="attr[index]['serial_no']" style="margin-right: 0;height: 34px;line-height: 34px;width:88px"/></td>
|
||||
<td><input class="layui-input" type="number" placeholder="" name="" v-model="attr[index]['weight']" style="margin-right: 0;height: 34px;line-height: 34px;width:88px"/></td>
|
||||
<td>
|
||||
<div class="layui-inline">
|
||||
<img v-bind:src="attr[index]['cover_pic']" style="width:34px;height:34px;">
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<input class="layui-input" type="text" placeholder="" name="" v-model="attr[index]['cover_pic']" style="margin-right: 0;height: 34px;line-height: 34px;"/>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<button class="layui-btn layui-btn-primary layui-btn-sm " v-on:click="upload_goods_cover_pic(index)"><i class="layui-icon"></i></button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-mid layui-word-aux"></div>
|
||||
<div class="layui-hide" id="uploadCoverPicBtn"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
<?php $this->beginBlock('js_script_wrap') ?>
|
||||
<?php $this->beginBlock('js_script_wrap') ?>
|
||||
var _attr_<?=$id?> = JSON.parse('<?=$attr?>');
|
||||
var _attr_groups_<?=$id?> = JSON.parse('<?=$attr_groups?>');
|
||||
function fixAttrGroups(action){
|
||||
var data = {};
|
||||
data.attr_groups = _attr_groups_<?=$id?>;
|
||||
data.attr = _attr_<?=$id?>;
|
||||
$.each(data.attr_groups,function(index,item){
|
||||
if(action){
|
||||
item.attr_name = '';
|
||||
} else {
|
||||
delete item.attr_name;
|
||||
}
|
||||
data.attr_groups[index] = item;
|
||||
});
|
||||
|
||||
if( 'object' == typeof data.attr_groups ){
|
||||
$.each(data.attr_groups,function(index,item){
|
||||
if(action){
|
||||
item.attr_name = '';
|
||||
} else {
|
||||
delete item.attr_name;
|
||||
}
|
||||
data.attr_groups[index] = item;
|
||||
});
|
||||
}
|
||||
// $.each(data.attr_groups,function(index,item){
|
||||
// if(action){
|
||||
// item.attr_name = '';
|
||||
// } else {
|
||||
// delete item.attr_name;
|
||||
// }
|
||||
// data.attr_groups[index] = item;
|
||||
// });
|
||||
$.each(data.attr,function(index,item){
|
||||
if(!action && item.integral_num){
|
||||
item.integral_num = item.integral_num * 1;
|
||||
@ -155,7 +210,7 @@
|
||||
else {
|
||||
return doubleArrays[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
function hasExistAttr(mark, attr){
|
||||
for(var i in attr){
|
||||
var _mark = '';
|
||||
@ -203,7 +258,7 @@
|
||||
vm.attr_groups.push({
|
||||
'attr_group_name':attr_group_name,
|
||||
'attr_list':[],
|
||||
});
|
||||
});
|
||||
}
|
||||
vm.attr_group_name = '';
|
||||
vm.update_attr();
|
||||
@ -213,7 +268,7 @@
|
||||
attr_groups.splice(index,1);
|
||||
vm.attr_groups = attr_groups;
|
||||
vm.update_attr();
|
||||
},
|
||||
},
|
||||
add_attr_name:function(index){
|
||||
var attr_list = vm.attr_groups[index]['attr_list'];
|
||||
var attr_name = vm.attr_groups[index]['attr_name'];
|
||||
@ -241,7 +296,7 @@
|
||||
attr_list.splice(attr_list_index,1);
|
||||
vm.attr_groups[index]['attr_list'] = attr_list;
|
||||
vm.update_attr();
|
||||
},
|
||||
},
|
||||
update_attr(){
|
||||
vm.handle_attr_groups();
|
||||
var attr_temp = vm.attr;
|
||||
@ -278,12 +333,16 @@
|
||||
item.sign_id = sign_ids.join(':');
|
||||
item.attr_list = attr_list;
|
||||
item.price = '';
|
||||
item.stock = 0;
|
||||
item.cover_pic = '';
|
||||
item.serial_no = '';
|
||||
item.weight = '';
|
||||
<?php if($open_integral):?>
|
||||
item.integral_num = 0;
|
||||
item.integral_num = 0;
|
||||
<?php endif;?>
|
||||
attr.push(item);
|
||||
}
|
||||
vm.attr = attr;
|
||||
vm.attr = attr;
|
||||
vm.remit();
|
||||
},
|
||||
handle_attr_groups:function(){
|
||||
@ -301,46 +360,46 @@
|
||||
vm.attr_groups = attr_groups;
|
||||
},
|
||||
batch_set_goods_price(){
|
||||
var price = vm.batch_price;
|
||||
if(price * 1 < 0){
|
||||
return;
|
||||
}
|
||||
var attr = vm.attr;
|
||||
$.each(attr,function(index,item){
|
||||
item.price = price;
|
||||
attr[index] = item;
|
||||
});
|
||||
vm.batch_price = '';
|
||||
vm.attr = attr;
|
||||
vm.remit();
|
||||
var price = vm.batch_price;
|
||||
if(price * 1 < 0){
|
||||
return;
|
||||
}
|
||||
var attr = vm.attr;
|
||||
$.each(attr,function(index,item){
|
||||
item.price = price;
|
||||
attr[index] = item;
|
||||
});
|
||||
vm.batch_price = '';
|
||||
vm.attr = attr;
|
||||
vm.remit();
|
||||
},
|
||||
batch_set_goods_stock(){
|
||||
var stock = vm.batch_stock;
|
||||
if(stock * 1 < 0){
|
||||
return;
|
||||
}
|
||||
var attr = vm.attr;
|
||||
$.each(attr,function(index,item){
|
||||
item.stock = stock;
|
||||
attr[index] = item;
|
||||
});
|
||||
vm.batch_stock = '';
|
||||
vm.attr = attr;
|
||||
vm.remit();
|
||||
var stock = vm.batch_stock;
|
||||
if(stock * 1 < 0){
|
||||
return;
|
||||
}
|
||||
var attr = vm.attr;
|
||||
$.each(attr,function(index,item){
|
||||
item.stock = stock;
|
||||
attr[index] = item;
|
||||
});
|
||||
vm.batch_stock = '';
|
||||
vm.attr = attr;
|
||||
vm.remit();
|
||||
},
|
||||
batch_set_goods_integral_num(){
|
||||
var integral_num = vm.batch_integral_num;
|
||||
if(integral_num * 1 < 0){
|
||||
return;
|
||||
}
|
||||
var attr = vm.attr;
|
||||
$.each(attr,function(index,item){
|
||||
item.integral_num = integral_num;
|
||||
attr[index] = item;
|
||||
});
|
||||
vm.batch_integral_num = '';
|
||||
vm.attr = attr;
|
||||
vm.remit();
|
||||
var integral_num = vm.batch_integral_num;
|
||||
if(integral_num * 1 < 0){
|
||||
return;
|
||||
}
|
||||
var attr = vm.attr;
|
||||
$.each(attr,function(index,item){
|
||||
item.integral_num = integral_num;
|
||||
attr[index] = item;
|
||||
});
|
||||
vm.batch_integral_num = '';
|
||||
vm.attr = attr;
|
||||
vm.remit();
|
||||
},
|
||||
upload_goods_cover_pic(index){
|
||||
vm.upload_cover_pic_index = index;
|
||||
@ -351,41 +410,41 @@
|
||||
layui.use(['upload', 'element'],function(){
|
||||
var uploader = layui.upload;
|
||||
setTimeout(function(){
|
||||
uploader.render({
|
||||
elem: '#uploadCoverPicBtn'
|
||||
, url: '<?= $url ?>'
|
||||
, accept: 'images'
|
||||
, exts:'png|jpg|jpeg|gif|ico|bmp'
|
||||
, before: function (obj) {
|
||||
//预读本地文件示例,不支持ie8
|
||||
obj.preview(function (index, file, result) {
|
||||
console.log(result)
|
||||
if(vm.upload_cover_pic_index != -1){
|
||||
vm.attr[vm.upload_cover_pic_index]['cover_pic'] = result;
|
||||
}
|
||||
});
|
||||
}
|
||||
, progress: function(n, elem){
|
||||
}
|
||||
, done: function (res) {
|
||||
//如果上传失败
|
||||
if (res.code != 0) {
|
||||
return layer.msg(res.msg);
|
||||
}
|
||||
uploader.render({
|
||||
elem: '#uploadCoverPicBtn'
|
||||
, url: '<?= $url ?>'
|
||||
, accept: 'images'
|
||||
, exts:'png|jpg|jpeg|gif|ico|bmp'
|
||||
, before: function (obj) {
|
||||
//预读本地文件示例,不支持ie8
|
||||
obj.preview(function (index, file, result) {
|
||||
console.log(result)
|
||||
if(vm.upload_cover_pic_index != -1){
|
||||
vm.attr[vm.upload_cover_pic_index]['cover_pic'] = res.data.url;
|
||||
vm.upload_cover_pic_index = -1;
|
||||
vm.attr[vm.upload_cover_pic_index]['cover_pic'] = result;
|
||||
}
|
||||
});
|
||||
}
|
||||
, progress: function(n, elem){
|
||||
}
|
||||
, done: function (res) {
|
||||
//如果上传失败
|
||||
if (res.code != 0) {
|
||||
return layer.msg(res.msg);
|
||||
}
|
||||
, error: function () {
|
||||
if(vm.upload_cover_pic_index != -1){
|
||||
vm.attr[vm.upload_cover_pic_index]['cover_pic'] = res.data.url;
|
||||
vm.upload_cover_pic_index = -1;
|
||||
}
|
||||
}
|
||||
, error: function () {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
},1000);
|
||||
})
|
||||
})
|
||||
|
||||
})($,layui,layer);
|
||||
<?php $this->endBlock(); ?>
|
||||
<?php $this->endBlock(); ?>
|
||||
</script>
|
||||
<?php $this->registerJs($this->blocks['js_script_wrap'], \yii\web\View::POS_END); ?>
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user