330 lines
13 KiB
HTML
330 lines
13 KiB
HTML
{extend name="common/base"/}
|
||
{block name="style"}
|
||
<style type="text/css">
|
||
.editormd-code-toolbar select {
|
||
display: inline-block
|
||
}
|
||
|
||
.editormd li {
|
||
list-style: inherit;
|
||
}
|
||
</style>
|
||
{/block}
|
||
<!-- 主体 -->
|
||
{block name="body"}
|
||
<form class="layui-form p-4">
|
||
<h3 class="pb-3">添加</h3>
|
||
<table class="layui-table layui-table-form">
|
||
|
||
<tr>
|
||
<td class="layui-td-gray">商品名称<font>*</font></td>
|
||
<td colspan="7"><input type="text" name="store_name" lay-verify="required" lay-reqText="请输入商品名称"
|
||
autocomplete="off" placeholder="请输入商品名称" class="layui-input"></td>
|
||
</tr>
|
||
<!-- <tr>-->
|
||
<!-- <td class="layui-td-gray">平台商品分类<font>*</font></td>-->
|
||
<!-- <td colspan="3">-->
|
||
<!-- <div class="layui-col-md6">-->
|
||
<!-- <select name="cate_id" lay-verify="required" lay-search="">-->
|
||
<!-- <option value="" >请选择</option>-->
|
||
<!-- {volist name=':set_recursion(get_store_category())' id='vo'}-->
|
||
<!-- <option value="{$vo.id}" >{$vo.title}</option>-->
|
||
<!-- {/volist}-->
|
||
<!-- </select>-->
|
||
<!-- </div>-->
|
||
<!-- </td>-->
|
||
<!-- </tr>-->
|
||
<!-- <tr>-->
|
||
<!-- <td class="layui-td-gray">平台商品分类<font>*</font></td>-->
|
||
<!-- <td colspan="3">-->
|
||
<!-- <div class="layui-col-md6">-->
|
||
<!-- <select name="cate_id" lay-verify="required" lay-search="">-->
|
||
<!-- <option value="" >请选择</option>-->
|
||
<!-- {volist name=':set_recursion(get_store_category())' id='vo'}-->
|
||
<!-- <option value="{$vo.id}" >{$vo.title}</option>-->
|
||
<!-- {/volist}-->
|
||
<!-- </select>-->
|
||
<!-- </div>-->
|
||
<!-- </td>-->
|
||
<!-- </tr>-->
|
||
|
||
<!-- <tr>-->
|
||
<!-- <td class="layui-td-gray">品牌选择<font>*</font></td>-->
|
||
<!-- <td colspan="3">-->
|
||
<!-- <div class="layui-col-md6">-->
|
||
<!-- <select name="brand_id" lay-verify="required" lay-search="">-->
|
||
<!-- <option value="" >请选择</option>-->
|
||
<!-- {volist name='store_brand' id='vo'}-->
|
||
<!-- <option value="{$vo.brand_id}" >{$vo.brand_name}</option>-->
|
||
<!-- {/volist}-->
|
||
<!-- </select>-->
|
||
<!-- </div>-->
|
||
<!-- </td>-->
|
||
<!-- </tr>-->
|
||
<tr>
|
||
<td class="layui-td-gray">平台商品分类<font>*</font>
|
||
</td>
|
||
<td>
|
||
<div id="cate_id"></div>
|
||
</td>
|
||
<!-- <td class="layui-td-gray">品牌选择<font>*</font>-->
|
||
<!-- </td>-->
|
||
<!-- <td colspan="6">-->
|
||
<!-- <select name="brand_id" lay-verify="required" lay-search="">-->
|
||
<!-- <option value="">请选择</option>-->
|
||
<!-- {volist name='store_brand' id='vo'}-->
|
||
<!-- <option value="{$vo.brand_id}">{$vo.brand_name}</option>-->
|
||
<!-- {/volist}-->
|
||
<!-- </select>-->
|
||
<!-- </td>-->
|
||
</tr>
|
||
<!-- <tr>-->
|
||
<!-- <td class="layui-td-gray">商户分类<font>*</font>-->
|
||
<!-- </td>-->
|
||
<!-- <td colspan="3">-->
|
||
<!-- <div id="mer_cate_id"></div>-->
|
||
<!-- </td>-->
|
||
<!-- </tr>-->
|
||
|
||
<tr>
|
||
<td class="layui-td-gray" style="vertical-align:top;">商品封面图</td>
|
||
<td>
|
||
<div class="layui-upload">
|
||
<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb">
|
||
上传缩略图(尺寸:750x750)
|
||
</button>
|
||
<div class="layui-upload-list" id="upload_box_thumb"
|
||
style=" overflow: hidden;">
|
||
<img src=""
|
||
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
|
||
width="100" style="max-width: 100%; height:66px;"/>
|
||
<input type="hidden" name="image" value="">
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td class="layui-td-gray" style="vertical-align:top;">商品轮播图</td>
|
||
<td>
|
||
<div class="layui-upload">
|
||
<button type="button" class="layui-btn layui-btn-sm" id="upload_btn_thumb2">
|
||
上传商品轮播图
|
||
</button>
|
||
|
||
<div class="layui-upload-list" id="upload_box_thumb2"
|
||
style="overflow: hidden;">
|
||
<input type="hidden" name="slider_image" value="">
|
||
</div>
|
||
</div>
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td class="layui-td-gray">单位<font>*</font></td>
|
||
<td colspan="7"><input type="text" name="unit_name" lay-verify="required" lay-reqText="请输入单位"
|
||
autocomplete="off" placeholder="请输入单位" class="layui-input"></td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td class="layui-td-gray">商品关键字<font>*</font></td>
|
||
<td colspan="7"><input type="text" name="keyword" lay-verify="required" lay-reqText="请输入商品关键字"
|
||
autocomplete="off" placeholder="请输入商品关键字" class="layui-input"></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="layui-td-gray">售价<font>*</font></td>
|
||
<td colspan="7"><input type="text" name="price" lay-verify="required|number" lay-reqText="请输入售价"
|
||
autocomplete="off" placeholder="请输入售价" class="layui-input"></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="layui-td-gray">成本价<font>*</font></td>
|
||
<td colspan="7"><input type="text" name="cost" lay-verify="required|number" lay-reqText="请输入成本价"
|
||
autocomplete="off" placeholder="请输入成本价" class="layui-input"></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="layui-td-gray">市场价<font>*</font></td>
|
||
<td colspan="7"><input type="text" name="ot_price" lay-verify="required|number" lay-reqText="请输入市场价"
|
||
autocomplete="off" placeholder="请输入市场价" class="layui-input"></td>
|
||
</tr>
|
||
<tr>
|
||
<td class="layui-td-gray">库存<font>*</font></td>
|
||
<td colspan="7"><input type="text" name="stock" lay-verify="required|number" lay-reqText="请输入库存"
|
||
autocomplete="off" placeholder="请输入库存" class="layui-input"></td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td class="layui-td-gray" style="text-align:left">商品简介</td>
|
||
<td colspan="6">
|
||
<textarea class="layui-textarea" name="store_info"></textarea>
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td class="layui-td-gray" style="text-align:left">商品详情</td>
|
||
<td colspan="6">
|
||
<textarea class="layui-textarea" id="container_content"></textarea>
|
||
</td>
|
||
</tr>
|
||
|
||
</table>
|
||
<div class="pt-3">
|
||
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
|
||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||
</div>
|
||
</form>
|
||
{/block}
|
||
<!-- /主体 -->
|
||
|
||
<!-- 脚本 -->
|
||
{block name="script"}
|
||
<script src="/static/assets/js/xm-select.js"></script>
|
||
<script>
|
||
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
|
||
var group_access = "{:session('gougu_admin')['group_access']}"
|
||
|
||
var multiple_images = [];
|
||
//单击图片删除图片 【注册全局函数】
|
||
function delMultipleImgs(this_img){
|
||
//获取下标
|
||
var subscript=$("#upload_box_thumb2 img").index(this_img);
|
||
//删除图片
|
||
this_img.remove();
|
||
//删除数组
|
||
multiple_images.splice(subscript, 1);
|
||
//重新排序
|
||
multiple_images.sort();
|
||
$('#upload_box_thumb2 input').attr('value', multiple_images);
|
||
//返回
|
||
return ;
|
||
}
|
||
|
||
function gouguInit() {
|
||
var form = layui.form, tool = layui.tool, tagspicker = layui.tagpicker;
|
||
|
||
//上传缩略图
|
||
var upload_thumb = layui.upload.render({
|
||
elem: '#upload_btn_thumb',
|
||
url: '/admin/api/upload',
|
||
done: function (res) {
|
||
//如果上传失败
|
||
if (res.code == 1) {
|
||
return layer.msg('上传失败');
|
||
}
|
||
//上传成功
|
||
$('#upload_box_thumb input').attr('value', res.data.filepath);
|
||
$('#upload_box_thumb img').attr('src', res.data.filepath);
|
||
}
|
||
});
|
||
//上传商品轮播图
|
||
var upload_thumb = layui.upload.render({
|
||
elem: '#upload_btn_thumb2',
|
||
url: '/admin/api/upload',
|
||
multiple: true,
|
||
before: function(obj){
|
||
//预读本地文件示例,不支持ie8
|
||
obj.preview(function(index, file, result){
|
||
$('#upload_box_thumb2').append(`
|
||
<img src="${result}"
|
||
onerror="javascript:this.src='{__GOUGU__}/gougu/images/nonepic600x360.jpg';this.onerror=null;"
|
||
width="100" style="max-width: 100%; height:66px;" alt="${file.name}" onclick="delMultipleImgs(this)" title="点击删除"/>
|
||
`)
|
||
});
|
||
},
|
||
done: function (res) {
|
||
//如果上传失败
|
||
if (res.code == 1) {
|
||
return layer.msg('上传失败');
|
||
}
|
||
//上传成功
|
||
//追加图片成功追加文件名至图片容器
|
||
multiple_images.push(res.data.filepath);
|
||
$('#upload_box_thumb2 input').attr('value', multiple_images);
|
||
// $('#upload_box_thumb2 img').attr('src', res.data.filepath);
|
||
}
|
||
});
|
||
|
||
function demo_cate_id () {
|
||
var demo_cate = xmSelect.render({
|
||
name: 'cate_id',
|
||
el: '#cate_id',
|
||
autoRow: true,
|
||
radio: true,
|
||
cascader: {
|
||
show: true,
|
||
indent: 200,
|
||
},
|
||
prop: {
|
||
name: 'name',
|
||
value: 'id',
|
||
},
|
||
data: [],
|
||
})
|
||
$.get('/admin/product.product/category_arr', function (result) {
|
||
demo_cate.update({
|
||
data: result.data
|
||
})
|
||
});
|
||
}
|
||
demo_cate_id()
|
||
function demo_mer_cate_id () {
|
||
var demo_cate = xmSelect.render({
|
||
name: 'mer_cate_id',
|
||
el: '#mer_cate_id',
|
||
autoRow: true,
|
||
cascader: {
|
||
show: true,
|
||
indent: 200,
|
||
},
|
||
prop: {
|
||
name: 'name',
|
||
value: 'id',
|
||
},
|
||
data: [],
|
||
radio: true,
|
||
})
|
||
$.get('/admin/product.product/category_arr?id=4', function (result) {
|
||
demo_cate.update({
|
||
data: result.data
|
||
})
|
||
});
|
||
}
|
||
demo_mer_cate_id();
|
||
|
||
var editor = layui.tinymce;
|
||
var edit = editor.render({
|
||
selector: "#container_content",
|
||
height: 500
|
||
});
|
||
//监听提交
|
||
form.on('submit(webform)', function (data) {
|
||
data.field.content = tinyMCE.editors['container_content'].getContent();
|
||
if (data.field.content == '') {
|
||
layer.msg('请先完善商品详情');
|
||
return false;
|
||
}
|
||
|
||
if (data.field.cate_id == '') {
|
||
layer.msg('请先选择平台分类');
|
||
return false;
|
||
}
|
||
|
||
// if (data.field.mer_cate_id == '') {
|
||
// layer.msg('请先选择商户分类');
|
||
// return false;
|
||
// }
|
||
|
||
let callback = function (e) {
|
||
layer.msg(e.msg);
|
||
if (e.code == 0) {
|
||
tool.tabRefresh(71);
|
||
tool.sideClose(1000);
|
||
}
|
||
}
|
||
tool.post('/admin/store_product/add', data.field, callback);
|
||
return false;
|
||
});
|
||
|
||
}
|
||
</script>
|
||
{/block}
|
||
<!-- /脚本 --> |