作者 anyv
1 个管道 的构建 通过 耗费 3 秒

4

... ... @@ -136,6 +136,9 @@ class SalesmanController extends AdminBaseController{
public function salesman_goods_add(){
if($this -> request -> isPost()){
if($_POST['money'] > $_POST['price']){
$this -> error('佣金不能大于售价');
}
$goods_data = Db::name('goods') -> where('uid',$_POST['uid']) -> select() -> toArray();
if(count($goods_data) >= 8){
$this -> error('添加失败');
... ... @@ -182,6 +185,9 @@ class SalesmanController extends AdminBaseController{
public function salesman_goods_edit(){
if($this -> request -> isPost()){
if($_POST['money'] > $_POST['price']){
$this -> error('佣金不能大于售价');
}
if(!empty($_POST['det_img'])){
$_POST['det_img'] = json_encode($_POST['det_img']);
$_POST['det_name'] = json_encode($_POST['det_name']);
... ...
... ... @@ -101,6 +101,14 @@ class SalesmangoodsController extends WeChatBaseController{
public function Salesman_goods_add(){
if($this -> request -> isPost()){
$uid = cmf_get_current_user_id();
$salesman_goods = Db::name('goods') -> where("uid=".$uid." and type = 2") -> select();
if(count($salesman_goods)>=8){
return 3;
}
if($_POST['money']>$_POST['price']){
return 2;
}
$data['show_img'] = $_POST['show_img'];
$data['thumbnail'] = $_POST['thumbnail'];
$data['book_name'] = $_POST['book_name'];
... ...
... ... @@ -33,7 +33,7 @@
<li><a href="{:url('Salesman/salesman_goods_list',array('uid'=>$good_uid))}">商品管理列表</a></li>
<li class="active"><a href="#">添加商品</a></li>
</ul>
<form action="{:url('Salesman/salesman_goods_add')}" method="post" class="form-horizontal js-ajax-form margin-top-20">
<form id="AddProductPicture" action="{:url('Salesman/salesman_goods_add')}" method="post" class="form-horizontal js-ajax-form margin-top-20" >
<div class="row">
<div class="col-md-9">
<table class="table table-bordered">
... ... @@ -56,11 +56,7 @@
<td><input class="form-control" type="text" name="price" id="source" value=""
placeholder="请输入售价"></td>
</tr>
<tr>
<th>定价</th>
<td><input class="form-control" type="text" name="pricing" value=""
placeholder="请输入定价"></td>
</tr>
<tr>
<th>商品说明</th>
<td>
... ... @@ -144,6 +140,11 @@
class="btn btn-default btn-sm">选择图片</a>
</td>
</tr>
<tr>
<th>定价</th>
<td><input class="form-control" type="text" name="pricing" value=""
placeholder="请输入定价"></td>
</tr>
</table>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
... ... @@ -185,6 +186,7 @@
</div>
</td>
</tr>
</table>
</div>
</div>
... ... @@ -197,29 +199,7 @@
</script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__STATIC__/js/ueditor/ueditor.all.min.js"></script>
<script type="text/javascript">
$(function () {
editorcontent = new baidu.editor.ui.Editor();
editorcontent.render('content');
try {
editorcontent.sync();
} catch (err) {
}
$('.btn-cancel-thumbnail').click(function () {
$('#thumbnail-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnail').val('');
});
});
$(function () {
$('.btn-cancel-thumbnails').click(function () {
$('#thumbnails-preview').attr('src', '__TMPL__/public/assets/images/default-thumbnail.png');
$('#thumbnails').val('');
});
});
<script>
</script>
</body>
... ...
... ... @@ -55,11 +55,7 @@
<td><input class="form-control" type="text" name="price" id="source" value="{$data.price}"
placeholder="请输入售价"></td>
</tr>
<tr>
<th>定价</th>
<td><input class="form-control" type="text" name="pricing" value="{$data.pricing}"
placeholder="请输入定价"></td>
</tr>
<tr>
<th>商品说明</th>
<td>
... ... @@ -162,6 +158,11 @@
class="btn btn-default btn-sm">选择图片</a>
</td>
</tr>
<tr>
<th>定价</th>
<td><input class="form-control" type="text" name="pricing" value="{$data.pricing}"
placeholder="请输入定价"></td>
</tr>
</table>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
... ... @@ -215,6 +216,7 @@
</div>
</td>
</tr>
</table>
</div>
</div>
... ...
... ... @@ -503,7 +503,11 @@
}
$.post("{:url('Salesmangoods/Salesman_goods_add')}",{show_img:show_img,thumbnail:thumbnail,book_name:book_name,money:money,price:price,pricing:pricing,instr:instr,book_number:book_number,paper:paper,book_size:book_size,binding:binding,author:author,press:press,press_time:press_time,suit:suit,grade:grade,img0:img0,img1:img1,img2:img2,printing:printing},function(data){
if(data){
if(data == 3){
alert('添加失败,业务员书籍不能超过8本');
}else if(data == 2){
alert('佣金不能大于售价');
}else if(data){
window.location.href = "{:url('salesmangoods/salesman_goods')}";
}else{
alert('添加失败');
... ...