初始上传
This commit is contained in:
221
addon/manjian/shop/controller/Manjian.php
Executable file
221
addon/manjian/shop/controller/Manjian.php
Executable file
@@ -0,0 +1,221 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\manjian\shop\controller;
|
||||
|
||||
use addon\coupon\model\CouponType;
|
||||
use app\model\member\MemberLevel;
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\manjian\model\Manjian as ManjianModel;
|
||||
use think\App;
|
||||
use think\facade\Cache;
|
||||
|
||||
/**
|
||||
* 满减控制器
|
||||
*/
|
||||
class Manjian extends BaseShop
|
||||
{
|
||||
public function __construct(App $app = null)
|
||||
{
|
||||
$this->replace = [
|
||||
'MANJIAN_IMG' => __ROOT__ . '/addon/manjian/shop/view/public/img',
|
||||
'MANJIAN_JS' => __ROOT__ . '/addon/manjian/shop/view/public/js',
|
||||
'MANJIAN_CSS' => __ROOT__ . '/addon/manjian/shop/view/public/css',
|
||||
];
|
||||
parent::__construct($app);
|
||||
}
|
||||
|
||||
/**
|
||||
* 满减列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$manjian_name = input('manjian_name', '');
|
||||
$status = input('status', '');
|
||||
$condition = [];
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
$condition[] = [ 'manjian_name', 'like', '%' . $manjian_name . '%' ];
|
||||
if ($status != null) {
|
||||
$condition[] = [ 'status', '=', $status ];
|
||||
}
|
||||
|
||||
$start_time = input('start_time', '');
|
||||
$end_time = input('end_time', '');
|
||||
|
||||
if ($start_time && !$end_time) {
|
||||
$condition[] = [ 'end_time', '>=', date_to_time($start_time) ];
|
||||
} elseif (!$start_time && $end_time) {
|
||||
$condition[] = [ 'start_time', '<=', date_to_time($end_time) ];
|
||||
} elseif ($start_time && $end_time) {
|
||||
$start_timestamp = date_to_time($start_time);
|
||||
$end_timestamp = date_to_time($end_time);
|
||||
$sql = "start_time between {$start_timestamp} and {$end_timestamp}";
|
||||
$sql .= " or end_time between {$start_timestamp} and {$end_timestamp}";
|
||||
$sql .= " or (start_time <= {$start_timestamp} and end_time >= {$end_timestamp})";
|
||||
$condition[] = [ '', 'exp', \think\facade\Db::raw($sql) ];
|
||||
}
|
||||
|
||||
$order = 'create_time desc';
|
||||
$field = 'manjian_id,manjian_name,start_time,end_time,create_time,status';
|
||||
|
||||
$manjian_model = new ManjianModel();
|
||||
$res = $manjian_model->getManjianPageList($condition, $page, $page_size, $order, $field);
|
||||
|
||||
//获取状态名称
|
||||
$manjian_status_arr = $manjian_model->getManjianStatus();
|
||||
foreach ($res[ 'data' ][ 'list' ] as $key => $val) {
|
||||
$res[ 'data' ][ 'list' ][ $key ][ 'status_name' ] = $manjian_status_arr[ $val[ 'status' ] ];
|
||||
}
|
||||
return $res;
|
||||
|
||||
} else {
|
||||
//满减状态
|
||||
$manjian_model = new ManjianModel();
|
||||
$manjian_status_arr = $manjian_model->getManjianStatus();
|
||||
$this->assign('manjian_status_arr', $manjian_status_arr);
|
||||
|
||||
return $this->fetch("manjian/lists");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 满减添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$member_level_model = new MemberLevel();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'manjian_name' => input('manjian_name', ''),
|
||||
'manjian_type' => input('manjian_type', ''),
|
||||
'type' => input('type', 0),
|
||||
'number' => input('number', 0),
|
||||
'goods_ids' => input('goods_ids', ''),
|
||||
'start_time' => strtotime(input('start_time', '')),
|
||||
'end_time' => strtotime(input('end_time', '')),
|
||||
'rule_json' => input('rule_json', ''),
|
||||
'remark' => input('remark', '')
|
||||
];
|
||||
|
||||
$manjian_model = new ManjianModel();
|
||||
return $manjian_model->addManjian($data);
|
||||
} else {
|
||||
//获取优惠券列表
|
||||
$coupon_model = new CouponType();
|
||||
$condition = [
|
||||
[ 'status', '=', 1 ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
];
|
||||
//优惠券字段
|
||||
$coupon_field = 'coupon_type_id,type,coupon_name,image,money,discount,validity_type,fixed_term,status,is_limit,at_least,count,lead_count,end_time,goods_type,max_fetch';
|
||||
$coupon_list = $coupon_model->getCouponTypeList($condition, $coupon_field);
|
||||
$this->assign('coupon_list', $coupon_list);
|
||||
$this->assign('level_time', $member_level_model->level_time);
|
||||
return $this->fetch("manjian/add");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 满减编辑
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$member_level_model = new MemberLevel();
|
||||
$manjian_model = new ManjianModel();
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'manjian_id' => input('manjian_id', 0),
|
||||
'site_id' => $this->site_id,
|
||||
'manjian_name' => input('manjian_name', ''),
|
||||
'manjian_type' => input('manjian_type', ''),
|
||||
'type' => input('type', 0),
|
||||
'goods_ids' => input('goods_ids', ''),
|
||||
'start_time' => strtotime(input('start_time', '')),
|
||||
'end_time' => strtotime(input('end_time', '')),
|
||||
'rule_json' => input('rule_json', ''),
|
||||
'remark' => input('remark', '')
|
||||
];
|
||||
return $manjian_model->editManjian($data);
|
||||
} else {
|
||||
|
||||
$manjian_id = input('manjian_id', 0);
|
||||
$this->assign('manjian_id', $manjian_id);
|
||||
|
||||
$manjian_info = $manjian_model->getManjianDetail($manjian_id, $this->site_id);
|
||||
if (empty($manjian_info[ 'data' ])) $this->error('未获取到活动数据', href_url('manjian://shop/manjian/lists'));
|
||||
$this->assign('manjian_info', $manjian_info[ 'data' ]);
|
||||
//获取优惠券列表
|
||||
$coupon_model = new CouponType();
|
||||
$condition = [
|
||||
[ 'status', '=', 1 ],
|
||||
[ 'site_id', '=', $this->site_id ],
|
||||
];
|
||||
//优惠券字段
|
||||
$coupon_field = 'coupon_type_id,type,coupon_name,image,money,discount,validity_type,fixed_term,status,is_limit,at_least,count,lead_count,end_time,goods_type,max_fetch';
|
||||
$coupon_list = $coupon_model->getCouponTypeList($condition, $coupon_field);
|
||||
$this->assign('coupon_list', $coupon_list);
|
||||
$this->assign('level_time', $member_level_model->level_time);
|
||||
return $this->fetch("manjian/edit");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 满减详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$manjian_id = input('manjian_id', 0);
|
||||
$manjian_model = new ManjianModel();
|
||||
$manjian_info = $manjian_model->getManjianDetail($manjian_id, $this->site_id);
|
||||
if (empty($manjian_info[ 'data' ])) $this->error('未获取到活动数据', href_url('manjian://shop/manjian/lists'));
|
||||
$this->assign('manjian_info', $manjian_info[ 'data' ]);
|
||||
return $this->fetch('manjian/detail');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 满减关闭
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$manjian_id = input('manjian_id', 0);
|
||||
$manjian_model = new ManjianModel();
|
||||
return $manjian_model->closeManjian($manjian_id, $this->site_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 满减删除
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$manjian_id = input('manjian_id', 0);
|
||||
$manjian_model = new ManjianModel();
|
||||
return $manjian_model->deleteManjian($manjian_id, $this->site_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动冲突商品
|
||||
*/
|
||||
public function conflict()
|
||||
{
|
||||
$key = input('key', '');
|
||||
$conflict_data = Cache::get($key);
|
||||
$this->assign('conflict_data', $conflict_data);
|
||||
return $this->fetch('manjian/conflict');
|
||||
}
|
||||
}
|
||||
452
addon/manjian/shop/view/manjian/add.html
Executable file
452
addon/manjian/shop/view/manjian/add.html
Executable file
@@ -0,0 +1,452 @@
|
||||
<style>
|
||||
.discount { display: flex; justify-content: space-between; height: 34px; line-height: 34px; padding: 5px 15px; background-color: #F6FBFD; border: 1px dashed #BCE8F1; }
|
||||
.manjian-rule .level-head{display: flex;justify-content: space-between;background: #eee;padding: 0 10px;margin-bottom: 15px;}
|
||||
.manjian-rule .title { color: #454545;font-weight: 600; }
|
||||
.manjian-rule .wrap .layui-form-label { width: 140px; }
|
||||
.manjian-rule .wrap .layui-form-label + .layui-input-block { margin-left: 140px }
|
||||
.manjian-rule .wrap .layui-form-checkbox[lay-skin=primary] {margin-top: 0}
|
||||
.manjian-rule .wrap .discount-cont {padding-left: 28px;min-height: 36px}
|
||||
.manjian-rule .discount-item .word-aux {margin-left: 0}
|
||||
.layui-form-item .layui-input-inline.end-time{float: none;}
|
||||
.layui-table-body{max-height: 480px !important;}
|
||||
.goods-title{display: flex;align-items: center;}
|
||||
.goods-title .goods-img{display: flex;align-items: center;justify-content: center;width: 55px;height: 55px;margin-right: 5px;}
|
||||
.goods-title .goods-img img{max-height: 100%;max-width: 100%;}
|
||||
.goods-title .goods-name{flex: 1;line-height: 1.6;}
|
||||
.select-coupon-layer .layui-layer-content{ overflow-y: scroll!important; }
|
||||
.goods-item{height: 325px;overflow: hidden;display: block;overflow-y: auto;}
|
||||
.table-title-name{width: 100px ; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;margin-right: 135px!important;}
|
||||
.coupon-end-time{padding-right: 63px !important;}
|
||||
.word-aux{margin-left: 200px;margin-top: 0}
|
||||
.goods_num {padding-left: 20px;}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="manjian_name" lay-verify="required|len" class="layui-input len-long" autocomplete="off" maxlength="40">
|
||||
</div>
|
||||
|
||||
<div class="word-aux">
|
||||
<p>活动名称最多为25个字符</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动时间:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline len-mid">
|
||||
<input type="text" class="layui-input" name="start_time" lay-verify="required" id="start_time" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<span class="layui-form-mid">-</span>
|
||||
<div class="layui-input-inline len-mid end-time">
|
||||
<input type="text" class="layui-input" name="end_time" lay-verify="required|time" id="end_time" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>条件类型:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="type" lay-filter="type" value="0" title="满N元" checked>
|
||||
<input type="radio" name="type" lay-filter="type" value="1" title="满N件">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form manjian-rule">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>优惠设置:</label>
|
||||
|
||||
<div class="layui-input-block discount-level">
|
||||
<div class="level-item">
|
||||
<div class="level-head">
|
||||
<label class="title">活动层级1:</label>
|
||||
</div>
|
||||
<div class="wrap">
|
||||
<div class="condition">
|
||||
<label class="layui-form-label"><span class="required">*</span>优惠门槛:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="type-0">
|
||||
<div class="layui-form-mid">满</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="money" value="" lay-verify="manjian_money" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
</div>
|
||||
<div class="type-1 layui-hide">
|
||||
<div class="layui-form-mid">满</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="num" value="" lay-verify="manjian_num" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">件</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<label class="layui-form-label"><span class="required">*</span>优惠内容:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="discount-item discount-money">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="discount_money" class="input-checkbox" lay-skin="primary"><span>订单金额优惠</span>
|
||||
</div>
|
||||
<div class="discount-cont layui-hide">
|
||||
<div class="layui-form-mid">减</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" value="" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-item">
|
||||
<div>
|
||||
<input type="checkbox" name="" value="free_shipping" class="input-checkbox" lay-skin="primary"><span>包邮</span>
|
||||
</div>
|
||||
<div class="word-aux" >
|
||||
<p>仅参与该活动的商品包邮,非整单包邮</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-item point">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="point" class="input-checkbox" lay-skin="primary"><span>送积分</span>
|
||||
</div>
|
||||
<div class="discount-cont layui-hide">
|
||||
<div class="layui-form-mid">送</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="" value="" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">积分</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-item coupon">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="coupon" class="input-checkbox" lay-skin="primary"><span>送优惠券</span>
|
||||
</div>
|
||||
<div class="discount-cont layui-hide">
|
||||
<div><a href="javascript:;" class="text-color select-coupon">选择优惠券</a></div>
|
||||
<div class="word-aux">
|
||||
<p>请确认优惠券数量是否充足,优惠券数量不足将导致赠送失败</p>
|
||||
</div>
|
||||
<div>
|
||||
<table class="layui-table" lay-skin="nob">
|
||||
<colgroup>
|
||||
<col width="30%">
|
||||
<col width="30%">
|
||||
<col width="20%">
|
||||
<col width="20%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>优惠券</th>
|
||||
<th>优惠内容</th>
|
||||
<th>赠券数 <i title="每人每次参加该活动赠送的优惠券数量" class="iconfont iconwenhao1"></i> </th>
|
||||
<th style="text-align:center;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" onclick="addDiscountLevel()">添加活动层级</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动商品:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="manjian_type" lay-filter="manjian_type" value="1" title="全部商品参与" checked>
|
||||
<input type="radio" name="manjian_type" lay-filter="manjian_type" value="2" title="指定商品参与">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item goods_list" style="display:none">
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<table id="selected_goods_list"></table>
|
||||
<button class="layui-btn" onclick="addGoods()">选择商品</button> <span class="goods_num">已选商品(<span id="goods_num" class="text-color">0</span>)</span>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="goods_ids" lay-verify="goods_num">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">备注:</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="remark" class="layui-textarea len-long" maxlength="150"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">提交</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backManjianList()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" onclick="delGoods({{d.goods_id}})">删除</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" src="MANJIAN_JS/add.js"></script>
|
||||
|
||||
<!-- 优惠券 -->
|
||||
<script type="text/html" id="couponList">
|
||||
<div class="coupon-box">
|
||||
<div class="single-filter-box">
|
||||
<div class="layui-form">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="coupon_name" placeholder="请输入优惠券名称" class="layui-input">
|
||||
<button type="button" class="layui-btn layui-btn-primary" lay-filter="coupon-search" lay-submit>
|
||||
<i class="layui-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gods-box">
|
||||
<table class="layui-table" lay-skin="line" lay-size="lg">
|
||||
<colgroup>
|
||||
<col width="8%">
|
||||
<col width="50%">
|
||||
<col width="15%">
|
||||
<col width="27%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="check-box">
|
||||
<div class="layui-form">
|
||||
<input type="checkbox" name="" lay-filter="selectAll" lay-skin="primary">
|
||||
</div>
|
||||
</th>
|
||||
<th class="layui-elip">优惠券名称</th>
|
||||
<th class="layui-elip">优惠金额/折扣</th>
|
||||
<th class="layui-elip">结束时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<table class="layui-table" id="goods" lay-skin="line" lay-size="lg">
|
||||
<!-- <colgroup>
|
||||
<col width="8%">
|
||||
<col width="50%">
|
||||
<col width="15%">
|
||||
<col width="27%">
|
||||
</colgroup> -->
|
||||
<tbody class="goods-item">
|
||||
{foreach $coupon_list.data as $coupon_list_k => $coupon_list_v}
|
||||
<tr>
|
||||
<td class="check-box">
|
||||
<div class="layui-form">
|
||||
{{# var a = {$coupon_list_v.coupon_type_id} }}
|
||||
{{# if($.inArray(a.toString(), d.coupon_id) != -1){ }}
|
||||
<input type="checkbox" name="" lay-filter="select{$coupon_list_k}" lay-skin="primary" checked>
|
||||
{{# }else{ }}
|
||||
<input type="checkbox" name="" lay-filter="select{$coupon_list_k}" lay-skin="primary">
|
||||
{{# } }}
|
||||
<input type="hidden" id="coupon_id" value="{$coupon_list_v.coupon_type_id}">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
{if condition="$coupon_list_v.image"}
|
||||
<img src="{:img($coupon_list_v.image)}">
|
||||
{else/}
|
||||
<img src="__ROOT__/public/uniapp/game/coupon.png">
|
||||
{/if}
|
||||
</div>
|
||||
<div class="title-content table-title-name">
|
||||
<p class="multi-line-hiding">{$coupon_list_v.coupon_name}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
{if $coupon_list_v.type == 'reward'}
|
||||
<td class="layui-elip coupon-money">{$coupon_list_v.money}元</td>
|
||||
{else/}
|
||||
<td class="layui-elip coupon-money">{$coupon_list_v.discount}折</td>
|
||||
{/if}
|
||||
{if $coupon_list_v.validity_type == 0}
|
||||
<td class="layui-elip coupon-end-time">{:time_to_date($coupon_list_v.end_time)}</td>
|
||||
{elseif $coupon_list_v.validity_type == 1}
|
||||
<td class="layui-elip coupon-end-time">领取之日起{$coupon_list_v.fixed_term}天有效</td>
|
||||
{else/}
|
||||
<td class="layui-elip coupon-end-time">长期有效</td>
|
||||
{/if}
|
||||
<input type="hidden" name="at_least" value="{$coupon_list_v.at_least}">
|
||||
<input type="hidden" name="type" value="{$coupon_list_v.type}">
|
||||
<input type="hidden" name="discount" value="{$coupon_list_v.discount}">
|
||||
<input type="hidden" name="money" value="{$coupon_list_v.money}">
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<button class="layui-btn" onclick="couponSelected()">确定</button>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 优惠券 -->
|
||||
<script type="text/html" id="couponListSearch">
|
||||
<div class="coupon-box">
|
||||
<div class="single-filter-box">
|
||||
<div class="layui-form">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="coupon_name" placeholder="请输入优惠券名称" class="layui-input">
|
||||
<button type="button" class="layui-btn layui-btn-primary" lay-filter="coupon-search" lay-submit>
|
||||
<i class="layui-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gods-box">
|
||||
<table class="layui-table" lay-skin="line" lay-size="lg">
|
||||
<colgroup>
|
||||
<col width="8%">
|
||||
<col width="50%">
|
||||
<col width="15%">
|
||||
<col width="27%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="check-box">
|
||||
<div class="layui-form">
|
||||
<input type="checkbox" name="" lay-filter="selectAll" lay-skin="primary">
|
||||
</div>
|
||||
</th>
|
||||
<th class="layui-elip">优惠券名称</th>
|
||||
<th class="layui-elip">优惠金额/折扣</th>
|
||||
<th class="layui-elip">结束时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<table class="layui-table" id="goods" lay-skin="line" lay-size="lg">
|
||||
<!-- <colgroup>
|
||||
<col width="8%">
|
||||
<col width="50%">
|
||||
<col width="15%">
|
||||
<col width="27%">
|
||||
</colgroup> -->
|
||||
<tbody class="goods-item">
|
||||
|
||||
{{# layui.each(d.list, function(index, item){ }}
|
||||
<tr>
|
||||
<td class="check-box">
|
||||
<div class="layui-form">
|
||||
{{# var a = item.coupon_type_id }}
|
||||
{{# if($.inArray(a.toString(), d.coupon_id) != -1){ }}
|
||||
<input type="checkbox" name="" lay-filter="select{{item.index}}" lay-skin="primary" checked>
|
||||
{{# }else{ }}
|
||||
<input type="checkbox" name="" lay-filter="select{{item.index}}" lay-skin="primary">
|
||||
{{# } }}
|
||||
<input type="hidden" id="coupon_id" value="{{item.coupon_type_id}}">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
{{#if(item.image) { }}
|
||||
<img src="{{item.image}}">
|
||||
{{# }else{ }}
|
||||
<img src="__ROOT__/public/uniapp/game/coupon.png">
|
||||
{{# } }}
|
||||
</div>
|
||||
<div class="title-content table-title-name">
|
||||
<p class="multi-line-hiding">{{item.coupon_name}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
{{#if(item.type == 'reward') { }}
|
||||
<td class="layui-elip coupon-money">{{item.money}}元</td>
|
||||
{{# }else{ }}
|
||||
<td class="layui-elip coupon-money">{{item.discount}}折</td>
|
||||
{{# } }}
|
||||
{{#if(item.validity_type == 0) { }}
|
||||
|
||||
<td class="layui-elip coupon-end-time">{{layui.util.toDateString(item.end_time * 1000,'yyyy-MM-dd HH:mm:ss')}}</td>
|
||||
{{# }else{ }}
|
||||
<td class="layui-elip coupon-end-time">领取之日起{{item.fixed_term}}天有效</td>
|
||||
{{# } }}
|
||||
<input type="hidden" name="at_least" value="{{item.at_least}}">
|
||||
<input type="hidden" name="type" value="{{item.type}}">
|
||||
<input type="hidden" name="discount" value="{{item.discount}}">
|
||||
<input type="hidden" name="money" value="{{item.money}}">
|
||||
</tr>
|
||||
{{# }); }}
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<button class="layui-btn" onclick="couponSelected()">确定</button>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 优惠券-名称 -->
|
||||
<script type="text/html" id="couponName">
|
||||
<div class="table-tuwen-box">
|
||||
<div class="font-box">
|
||||
<p class="multi-line-hiding">{{d.coupon_name}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 优惠券-操作 -->
|
||||
<script type="text/html" id="couponOperation">
|
||||
|
||||
{{# var select_coupon_list = ','+coupon_list+','}}
|
||||
|
||||
{{# if(select_coupon_list.indexOf(','+d.coupon_type_id+',') != -1){ }}
|
||||
<p title="该优惠券已参加">已添加</p>
|
||||
{{# }else{ }}
|
||||
<a class="layui-btn" lay-event="add">添加</a>
|
||||
{{# } }}
|
||||
|
||||
</script>
|
||||
<!-- 批量操作 -->
|
||||
<script type="text/html" id="batchOperation">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="add">批量添加</button>
|
||||
</script>
|
||||
<script type="text/html" id="addCoupon">
|
||||
{{# for(var i = 0; i < d.length; i++){ }}
|
||||
<tr data-coupon="{{ d[i].coupon_type_id }}">
|
||||
<td>{{d[i].coupon_name}}</td>
|
||||
{{# if(d[i].at_least > 0){}}
|
||||
<td>满{{d[i].at_least}}{{d[i].type == 'discount' ? '打'+ d[i].discount +'折' : '减' + d[i].money}}</td>
|
||||
{{#} else {}}
|
||||
<td>无门槛,{{d[i].type == 'discount' ? '打'+ d[i].discount +'折' : '减' + d[i].money}}</td>
|
||||
{{#}}}
|
||||
<td><input type="number" name="number" value="1" class="layui-input len-short" lay-verify="coupon_num"></td>
|
||||
<td style="text-align:center;">
|
||||
<a href="javascript:;" onClick="deleteCoupon(this, {{i}})" className="text-color">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{# } }}
|
||||
|
||||
</script>
|
||||
<script type="text/javascript">
|
||||
layui.use(['carousel'], function() {
|
||||
var carousel = layui.carousel;
|
||||
carousel.render({
|
||||
elem: '#carousel'
|
||||
, width: '100%' //设置容器宽度
|
||||
, arrow: 'always' //始终显示箭头
|
||||
});
|
||||
})
|
||||
</script>
|
||||
57
addon/manjian/shop/view/manjian/conflict.html
Executable file
57
addon/manjian/shop/view/manjian/conflict.html
Executable file
@@ -0,0 +1,57 @@
|
||||
{if $conflict_data.type == 'goods'}
|
||||
<div class="detail-card tips-wrap">
|
||||
<div class="detail-con">
|
||||
<p class="detail-line">同一活动时间内,同一个商品只可参加一个满减活动,当前活动中有<span class="conflict-num red-color"></span>件商品与以下商品冲突</p>
|
||||
<p class="detail-line">活动类型:{$conflict_data.promotion}</p>
|
||||
<p class="detail-line">当前活动时间:{:time_to_date($conflict_data.start_time)} - {:time_to_date($conflict_data.end_time)}</p>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if $conflict_data.type == 'activity'}
|
||||
<div class="detail-card tips-wrap">
|
||||
<div class="detail-con">
|
||||
<p class="detail-line">同一活动时间内,同一个店铺只能同时存在一个全选商品的满减/送活动</p>
|
||||
<p class="detail-line">当前活动与以下<span class="conflict-num red-color"></span>个活动存在冲突</p>
|
||||
<p class="detail-line">当前活动时间:{:time_to_date($conflict_data.start_time)} - {:time_to_date($conflict_data.end_time)}</p>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<table id="goods_list"></table>
|
||||
|
||||
<script>
|
||||
layui.use(['form'], function() {
|
||||
var table,form = layui.form;
|
||||
form.render();
|
||||
|
||||
var list = {:json_encode($conflict_data.list, JSON_UNESCAPED_UNICODE)};
|
||||
$(".conflict-num").text(list.length);
|
||||
|
||||
table = new Table({
|
||||
elem: '#goods_list',
|
||||
cols: [
|
||||
[
|
||||
{if $conflict_data.type == 'goods'}
|
||||
{
|
||||
field: 'goods_name',
|
||||
title: '商品名称',
|
||||
unresize: 'false',
|
||||
},
|
||||
{/if}
|
||||
{
|
||||
field: 'manjian_name',
|
||||
title: '活动名称',
|
||||
unresize: 'false',
|
||||
}, {
|
||||
title: '活动时间',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
return ns.time_to_date(data.start_time) +'至'+ ns.time_to_date(data.end_time);
|
||||
}
|
||||
}]
|
||||
],
|
||||
data: list
|
||||
});
|
||||
});
|
||||
</script>
|
||||
114
addon/manjian/shop/view/manjian/detail.html
Executable file
114
addon/manjian/shop/view/manjian/detail.html
Executable file
@@ -0,0 +1,114 @@
|
||||
<link rel="stylesheet" href="STATIC_CSS/promotion_detail.css">
|
||||
<style>
|
||||
.discount { justify-content: space-between;line-height: 30px;padding: 0px 15px;background-color: #F6FBFD;border: 1px dashed #BCE8F1; margin-bottom: 5px;}
|
||||
</style>
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">基本信息</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class="promotion-view">
|
||||
<div class="promotion-view-item">
|
||||
<label>活动名称:</label>
|
||||
<span>{$manjian_info.manjian_name}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>开始时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$manjian_info.start_time)}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>结束时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$manjian_info.end_time)}</span>
|
||||
</div>
|
||||
{if $manjian_info.manjian_type == 1}
|
||||
<div class="promotion-view-item">
|
||||
<label>活动商品:</label>
|
||||
<span>全部商品参与</span>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="promotion-view">
|
||||
<div class="promotion-view-item-line">
|
||||
<label class="promotion-view-item-custom-label">满减规则:</label>
|
||||
<div class="promotion-view-item-custom-box">
|
||||
<div class="discount-box">
|
||||
{foreach name="$manjian_info.rule" item="vo"}
|
||||
<div class="discount">
|
||||
<div class="discount-con">
|
||||
<p>单笔订单满
|
||||
{if $manjian_info.type == 0}
|
||||
<span class="red-color money-num">{:sprintf('%.2f', $vo.limit)}</span>元
|
||||
{else/}
|
||||
<span class="red-color money-num">{:number_format($vo.limit)}</span>件
|
||||
{/if}
|
||||
{if isset($vo.discount_money)},减{$vo.discount_money}元 {/if}
|
||||
{if isset($vo.free_shipping)},包邮 {/if}
|
||||
{if isset($vo.point)},送{$vo.point}积分 {/if}
|
||||
{if isset($vo.coupon)}
|
||||
{foreach name="$vo.coupon_data" item="coupon"}
|
||||
,送优惠券<a href="{:href_url('coupon://shop/coupon/detail', ['coupon_type_id' => $coupon.coupon_type_id ])}" target="_blank">【{$coupon.coupon_name}】</a>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{if $manjian_info.manjian_type != 1}
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">活动商品</span>
|
||||
</div>
|
||||
<div class="layui-card-body">
|
||||
<div class='promotion-view-list'>
|
||||
<table id="promotion_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<script type='text/html' id="promotion_list_item_box_html">
|
||||
<div class="promotion-list-item-title">
|
||||
<div class="promotion-list-item-title-icon">
|
||||
<img src="{{ d.goods_image ? ns.img(d.goods_image.split(",")[0],'small') : '' }}" alt="">
|
||||
</div>
|
||||
<p class="promotion-list-item-title-name multi-line-hiding">{{ d.goods_name }}</p>
|
||||
</div>
|
||||
</script>
|
||||
<script>
|
||||
var promotion_list = {:json_encode($manjian_info.goods_list, JSON_UNESCAPED_UNICODE)};
|
||||
|
||||
layui.use('table', function() {
|
||||
|
||||
new Table({
|
||||
elem: '#promotion_list',
|
||||
page: false,
|
||||
limit: Number.MAX_VALUE,
|
||||
cols: [
|
||||
[{
|
||||
field: 'goods_name',
|
||||
title: '商品名称',
|
||||
unresize: 'false',
|
||||
width: '60%',
|
||||
templet: "#promotion_list_item_box_html"
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格(元)',
|
||||
unresize: 'false',
|
||||
align: 'right',
|
||||
width: '40%',
|
||||
templet: function(data) {
|
||||
return '¥' + data.price;
|
||||
}
|
||||
}],
|
||||
],
|
||||
data: promotion_list,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
433
addon/manjian/shop/view/manjian/edit.html
Executable file
433
addon/manjian/shop/view/manjian/edit.html
Executable file
@@ -0,0 +1,433 @@
|
||||
<style>
|
||||
.discount { display: flex; justify-content: space-between; height: 34px; line-height: 34px; padding: 5px 15px; background-color: #F6FBFD; border: 1px dashed #BCE8F1; }
|
||||
.manjian-rule .level-head{display: flex;justify-content: space-between;background: #eee;padding: 0 10px;margin-bottom: 15px;}
|
||||
.manjian-rule .title { color: #454545;font-weight: 600; }
|
||||
.manjian-rule .wrap .layui-form-label { width: 140px; }
|
||||
.manjian-rule .wrap .layui-form-label + .layui-input-block { margin-left: 140px }
|
||||
.manjian-rule .wrap .layui-form-checkbox[lay-skin=primary] {margin-top: 0}
|
||||
.manjian-rule .wrap .discount-cont {padding-left: 28px;min-height: 36px}
|
||||
.manjian-rule .discount-item .word-aux {margin-left: 0}
|
||||
.layui-form-item .layui-input-inline.end-time{float: none;}
|
||||
.layui-table-body{max-height: 480px !important;}
|
||||
.goods-title{display: flex;align-items: center;}
|
||||
.goods-title .goods-img{display: flex;align-items: center;justify-content: center;width: 55px;height: 55px;margin-right: 5px;}
|
||||
.goods-title .goods-img img{max-height: 100%;max-width: 100%;}
|
||||
.goods-title .goods-name{flex: 1;line-height: 1.6;}
|
||||
.select-coupon-layer .layui-layer-content{ overflow-y: scroll!important; }
|
||||
.word-aux{margin-left: 200px;margin-top: 0}
|
||||
.goods_num {padding-left: 20px;}
|
||||
.goods-item{height: 325px;overflow: hidden;display: block;overflow: hidden;overflow-y: auto;}
|
||||
.table-title-name{width: 100px ; overflow: hidden; white-space: nowrap; text-overflow: ellipsis;margin-right: 135px!important;}
|
||||
</style>
|
||||
|
||||
<div class="layui-form form-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="manjian_name" lay-verify="required|len" value="{$manjian_info.manjian_name}" placeholder="请输入活动名称" class="layui-input len-long" autocomplete="off" maxlength="40">
|
||||
</div>
|
||||
<div class="word-aux">
|
||||
<p>活动名称最多为25个字符</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动时间:</label>
|
||||
<div class="layui-inline">
|
||||
<div class="layui-input-inline len-mid">
|
||||
<input type="text" value="{:date('Y-m-d H:i:s', $manjian_info.start_time)}" class="layui-input" name="start_time" lay-verify="required" id="start_time" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<span class="layui-form-mid">-</span>
|
||||
<div class="layui-input-inline len-mid end-time">
|
||||
<!-- <input type="text" {if condition="$manjian_info.status == 1"}disabled {/if} value="{:date('Y-m-d H:i:s', $manjian_info.end_time)}" class="layui-input" name="end_time" lay-verify="required|times" id="end_time" autocomplete="off" readonly> -->
|
||||
<input type="text" value="{:date('Y-m-d H:i:s', $manjian_info.end_time)}" class="layui-input" name="end_time" lay-verify="required|times" id="end_time" autocomplete="off" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
<!-- {if condition="$manjian_info.status == 1"}
|
||||
<div class="word-aux">
|
||||
<p>活动进行中时间不可更改</p>
|
||||
</div>
|
||||
{/if} -->
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>条件类型:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="type" lay-filter="type" value="0" title="满N元" {if $manjian_info.type == 0}checked{/if}>
|
||||
<input type="radio" name="type" lay-filter="type" value="1" title="满N件" {if $manjian_info.type == 1}checked{/if}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form manjian-rule">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>优惠设置:</label>
|
||||
|
||||
<div class="layui-input-block discount-level">
|
||||
{foreach name="$manjian_info.rule" item="vo" index="k"}
|
||||
<div class="level-item">
|
||||
<div class="level-head">
|
||||
<label class="title">活动层级{$k}:</label>
|
||||
{if $k > 1}<a href="javascript:;" class="text-color" onclick="deleteLevel(this)">删除</a>{/if}
|
||||
</div>
|
||||
<div class="wrap">
|
||||
<div class="condition">
|
||||
<label class="layui-form-label"><span class="required">*</span>优惠门槛:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="type-0 {if $manjian_info.type != 0}layui-hide{/if}">
|
||||
<div class="layui-form-mid">满</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="money" value="{:sprintf('%.2f',$vo.limit)}" lay-verify="manjian_money" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
</div>
|
||||
<div class="type-1 {if $manjian_info.type != 1}layui-hide{/if}">
|
||||
<div class="layui-form-mid">满</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="num" value="{:number_format($vo.limit)}" lay-verify="manjian_num" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">件</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<label class="layui-form-label"><span class="required">*</span>优惠内容:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="discount-item discount-money">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="discount_money" class="input-checkbox" lay-skin="primary" {if isset($vo.discount_money)}checked{/if}><span>订单金额优惠</span>
|
||||
</div>
|
||||
<div class="discount-cont {if !isset($vo.discount_money)}layui-hide{/if}">
|
||||
<div class="layui-form-mid">减</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" value="{if isset($vo.discount_money)}{$vo.discount_money}{/if}" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-item">
|
||||
<div>
|
||||
<input type="checkbox" name="" value="free_shipping" class="input-checkbox" lay-skin="primary" {if isset($vo.free_shipping)}checked{/if}><span>包邮</span>
|
||||
</div>
|
||||
<div class="word-aux" >
|
||||
<p>仅参与该活动的商品包邮,非整单包邮</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-item point">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="point" class="input-checkbox" lay-skin="primary" {if isset($vo.point)}checked{/if}><span>送积分</span>
|
||||
</div>
|
||||
<div class="discount-cont {if !isset($vo.point)}layui-hide{/if}">
|
||||
<div class="layui-form-mid">送</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="" value="{if isset($vo.point)}{$vo.point}{/if}" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">积分</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-item coupon">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="coupon" class="input-checkbox" lay-skin="primary" {if isset($vo.coupon)}checked{/if}><span>送优惠券</span>
|
||||
</div>
|
||||
<div class="discount-cont {if !isset($vo.coupon)}layui-hide{/if}">
|
||||
<div><a href="javascript:;" class="text-color select-coupon">选择优惠券</a></div>
|
||||
<div class="word-aux">
|
||||
<p>请确认优惠券数量是否充足,优惠券数量不足将导致赠送失败</p>
|
||||
</div>
|
||||
<div>
|
||||
<table class="layui-table" lay-skin="nob">
|
||||
<colgroup>
|
||||
<col width="30%">
|
||||
<col width="30%">
|
||||
<col width="20%">
|
||||
<col width="20%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="layui-elip">优惠券名称</th>
|
||||
<th class="layui-elip">优惠内容</th>
|
||||
<th class="layui-elip">赠券数</th>
|
||||
<th style="text-align:center;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{if isset($vo.coupon) && isset($vo.coupon_data) && !empty($vo.coupon_data)}
|
||||
{foreach name="$vo.coupon_data" item="coupon_data" key="kk"}
|
||||
<tr data-coupon="{$coupon_data.coupon_type_id}">
|
||||
<td>{$coupon_data.coupon_name }</td>
|
||||
{if $coupon_data.at_least > 0 }
|
||||
<td>满{$coupon_data.at_least }{$coupon_data.type == 'discount' ? '打'. $coupon_data.discount .'折' : '减' . $coupon_data.money }</td>
|
||||
{else/}
|
||||
<td>无门槛,{$coupon_data.type == 'discount' ? '打'. $coupon_data.discount .'折' : '减' . $coupon_data.money }</td>
|
||||
{/if}
|
||||
<td><input type="number" name="number" value="{$vo['coupon_num'][$kk] ?? 1}" class="layui-input len-short"></td>
|
||||
<td style="text-align:center;"><a href="javascript:;" onclick="deleteCoupon(this)" class="text-color">删除</a></td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/foreach}
|
||||
</div>
|
||||
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn" onclick="addDiscountLevel()">添加活动层级</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="layui-form-item">
|
||||
<div class="layui-form">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">满减规则:</label>
|
||||
|
||||
<div class="discount-box">
|
||||
</div>
|
||||
|
||||
<div class="layui-input-block form-row">
|
||||
<span class="layui-form-mid">单笔订单满</span>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" class="layui-input len-short" id="money" lay-verify="num" autocomplete="off">
|
||||
</div>
|
||||
<span class="layui-form-mid">元,立减现金</span>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" class="layui-input len-short" id="discount_money" lay-verify="num" autocomplete="off">
|
||||
</div>
|
||||
<span class="layui-form-mid">元</span>
|
||||
</div>
|
||||
|
||||
<div class="word-aux">
|
||||
<p>价格不能小于0,可保留两位小数</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" onclick="submitRule()">确定规则设置</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动商品:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" name="manjian_type" lay-filter="manjian_type" lay-verify="required|manjian_type" value="1" title="全部商品参与" {if $manjian_info.manjian_type == 1} checked {/if}>
|
||||
<input type="radio" name="manjian_type" lay-filter="manjian_type" lay-verify="required|manjian_type" value="2" title="指定商品参与" {if $manjian_info.manjian_type == 2} checked {/if}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if $manjian_info.manjian_type == 1}
|
||||
<div class="layui-form-item goods_list" style="display:none">
|
||||
{else /}
|
||||
<div class="layui-form-item goods_list">
|
||||
{/if}
|
||||
<label class="layui-form-label"></label>
|
||||
<div class="layui-input-block">
|
||||
<!-- <table class="layui-table" id="goods" lay-skin="line" lay-size="lg">
|
||||
|
||||
<thead>
|
||||
<tr>
|
||||
<th>商品名称</th>
|
||||
<th>商品价格(元)</th>
|
||||
<th>库存</th>
|
||||
<th>编辑</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{if empty($manjian_info.goods_list)}
|
||||
<tr>
|
||||
<td class="goods-empty" colspan="3">
|
||||
<div>该活动还未选择商品</div>
|
||||
</td>
|
||||
</tr>
|
||||
{else /}
|
||||
{foreach $manjian_info.goods_list as $v}
|
||||
<tr data-sku_id="{$v.goods_id}">
|
||||
<td>{$v.goods_name}</td>
|
||||
<td>{$v.price}</td>
|
||||
<td>{$v.goods_stock}</td>
|
||||
<td><button class="layui-btn" onclick="delRule(this)">删除</button></td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
{/if}
|
||||
</tbody>
|
||||
</table> -->
|
||||
<table id="selected_sku_list"></table>
|
||||
|
||||
<button class="layui-btn" onclick="addGoods()">选择商品</button> <span class="goods_num">已选商品(<span id="goods_num" class="text-color">{$manjian_info.goods_list_count}</span>)</span>
|
||||
</div>
|
||||
</div>
|
||||
<input type="hidden" name="goods_ids" lay-verify="goods_num" value = '{$manjian_info.goods_list_count}'>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">备注:</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea name="remark" class="layui-textarea len-long" maxlength="150">{$manjian_info.remark}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backManjianList()">返回</button>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="manjian_id" value="{$manjian_info.manjian_id}" />
|
||||
<input type="hidden" name="rule_json" value='{$manjian_info.rule_json}' id="rule_json" />
|
||||
</div>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" onclick="delGoods({{d.goods_id}})">删除</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
var goods_list = {:json_encode($manjian_info.goods_list, JSON_UNESCAPED_UNICODE)};
|
||||
var coupon_list = {:json_encode($coupon_list.data, JSON_UNESCAPED_UNICODE)};
|
||||
var manjian_info = {:json_encode($manjian_info.rule, JSON_UNESCAPED_UNICODE)};
|
||||
</script>
|
||||
<script type="text/javascript" src="MANJIAN_JS/edit.js"></script>
|
||||
|
||||
<!-- 优惠券 -->
|
||||
<script type="text/html" id="couponList">
|
||||
<div class="coupon-box">
|
||||
<div class="single-filter-box">
|
||||
<div class="layui-form">
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="coupon_name" placeholder="请输入优惠券名称" class="layui-input">
|
||||
<button type="button" class="layui-btn layui-btn-primary" lay-filter="coupon-search" lay-submit>
|
||||
<i class="layui-icon"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gods-box">
|
||||
<table class="layui-table" lay-skin="line" lay-size="lg">
|
||||
<colgroup>
|
||||
<col width="8%">
|
||||
<col width="50%">
|
||||
<col width="15%">
|
||||
<col width="27%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="check-box">
|
||||
<div class="layui-form">
|
||||
<input type="checkbox" name="" lay-filter="selectAll" lay-skin="primary">
|
||||
</div>
|
||||
</th>
|
||||
<th class="layui-elip">优惠券名称</th>
|
||||
<th class="layui-elip">优惠金额/折扣</th>
|
||||
<th class="layui-elip">结束时间</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<table class="layui-table" id="goods" lay-skin="line" lay-size="lg">
|
||||
<colgroup>
|
||||
<col width="8%">
|
||||
<col width="50%">
|
||||
<col width="15%">
|
||||
<col width="27%">
|
||||
</colgroup>
|
||||
<tbody class="goods-item">
|
||||
{foreach $coupon_list.data as $coupon_list_k => $coupon_list_v}
|
||||
<tr>
|
||||
<td class="check-box">
|
||||
|
||||
<div class="layui-form">
|
||||
{{# var a = {$coupon_list_v.coupon_type_id} }}
|
||||
{{# if($.inArray(a, d.coupon_id) != -1){ }}
|
||||
<input type="checkbox" name="" lay-filter="select{$coupon_list_k}" lay-skin="primary" checked>
|
||||
{{# }else{ }}
|
||||
<input type="checkbox" name="" lay-filter="select{$coupon_list_k}" lay-skin="primary">
|
||||
{{# } }}
|
||||
<input type="hidden" id="coupon_id" value="{$coupon_list_v.coupon_type_id}">
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="table-title">
|
||||
<div class="title-pic">
|
||||
{if condition="$coupon_list_v.image"}
|
||||
<img src="{:img($coupon_list_v.image)}">
|
||||
{else/}
|
||||
<img src="__ROOT__/public/uniapp/game/coupon.png">
|
||||
{/if}
|
||||
</div>
|
||||
<div class="title-content table-title-name">
|
||||
<p class="multi-line-hiding">{$coupon_list_v.coupon_name}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
{if $coupon_list_v.type == 'reward'}
|
||||
<td class="layui-elip coupon-money">{$coupon_list_v.money}元</td>
|
||||
{else/}
|
||||
<td class="layui-elip coupon-money">{$coupon_list_v.discount}折</td>
|
||||
{/if}
|
||||
{if $coupon_list_v.validity_type == 0}
|
||||
<td class="layui-elip coupon-end-time">{:time_to_date($coupon_list_v.end_time)}</td>
|
||||
{elseif $coupon_list_v.validity_type == 1}
|
||||
<td class="layui-elip coupon-end-time">领取之日起{$coupon_list_v.fixed_term}天有效</td>
|
||||
{else/}
|
||||
<td class="layui-elip coupon-end-time">长期有效</td>
|
||||
{/if}
|
||||
<input type="hidden" name="at_least" value="{$coupon_list_v.at_least}">
|
||||
<input type="hidden" name="type" value="{$coupon_list_v.type}">
|
||||
<input type="hidden" name="discount" value="{$coupon_list_v.discount}">
|
||||
<input type="hidden" name="money" value="{$coupon_list_v.money}">
|
||||
</tr>
|
||||
{/foreach}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<button class="layui-btn" onclick="couponSelected()">确定</button>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 优惠券-名称 -->
|
||||
<script type="text/html" id="couponName">
|
||||
<div class="table-tuwen-box">
|
||||
<div class="font-box">
|
||||
<p class="multi-line-hiding">{{d.coupon_name}}</p>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<!-- 优惠券-操作 -->
|
||||
<script type="text/html" id="couponOperation">
|
||||
{{# if($.inArray(d.coupon_type_id, coupon_list) != -1){ }}
|
||||
<p title="该优惠券已参加积分兑换活动">已添加</p>
|
||||
{{# }else{ }}
|
||||
<a class="layui-btn" lay-event="add">添加</a>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="addCoupon">
|
||||
{{# for(var i = 0; i < d.length; i++){ }}
|
||||
<tr data-coupon="{{ d[i].coupon_type_id }}">
|
||||
<td>{{d[i].coupon_name}}</td>
|
||||
{{# if(d[i].at_least > 0){}}
|
||||
<td>满{{d[i].at_least}}{{d[i].type == 'discount' ? '打'+ d[i].discount +'折' : '减' + d[i].money}}</td>
|
||||
{{#} else {}}
|
||||
<td>无门槛,{{d[i].type == 'discount' ? '打'+ d[i].discount +'折' : '减' + d[i].money}}</td>
|
||||
{{#}}}
|
||||
<td><input type="number" name="number" value="1" class="layui-input len-short" lay-verify="coupon_num"></td>
|
||||
<td style="text-align:center;">
|
||||
<a href="javascript:;" onClick="deleteCoupon(this, {{i}})" className="text-color">删除</a>
|
||||
</td>
|
||||
</tr>
|
||||
{{# } }}
|
||||
</script>
|
||||
283
addon/manjian/shop/view/manjian/lists.html
Executable file
283
addon/manjian/shop/view/manjian/lists.html
Executable file
@@ -0,0 +1,283 @@
|
||||
<style>
|
||||
.layui-layout-admin .layui-form-item .layui-input-inline{background-color: #fff;}
|
||||
.layui-layout-admin .table-tab .layui-tab-title{margin-bottom: 15px;}
|
||||
</style>
|
||||
|
||||
<div class="single-filter-box">
|
||||
<button class="layui-btn" onclick="add()">添加活动</button>
|
||||
</div>
|
||||
<!-- 搜索框 -->
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<form class="layui-colla-content layui-form layui-show">
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">活动名称:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="manjian_name" placeholder="请输入活动名称" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">活动时间:</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="start_time" placeholder="开始时间" id="start_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
<div class="layui-form-mid">-</div>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" class="layui-input" name="end_time" placeholder="结束时间" id="end_time" readonly>
|
||||
<i class=" iconrili iconfont calendar"></i>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button type="button" class="layui-btn" lay-filter="search" lay-submit>筛选</button>
|
||||
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab table-tab" lay-filter="manjian_tab">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this" lay-id="">所有活动</li>
|
||||
<li lay-id="1">进行中</li>
|
||||
<li lay-id="2">已结束</li>
|
||||
<li lay-id="-1">已关闭</li>
|
||||
<li lay-id="0">未开始</li>
|
||||
</ul>
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="manjian_list" lay-filter="manjian_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="detail">详情</a>
|
||||
{{# if(d.status == 0 || d.status == 1) { }}
|
||||
<a class="layui-btn" lay-event="edit">编辑</a>
|
||||
{{# } }}
|
||||
{{# if(d.status == 0) { }}
|
||||
<a class="layui-btn" lay-event="delete">删除</a>
|
||||
{{# }else if(d.status == 1) { }}
|
||||
<a class="layui-btn" lay-event="close">关闭</a>
|
||||
{{# }else if(d.status == 2 || d.status == -1) { }}
|
||||
<a class="layui-btn" lay-event="delete">删除</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
<!-- 时间 -->
|
||||
<script id="time" type="text/html">
|
||||
<div class="layui-elip">开始:{{ns.time_to_date(d.start_time)}}</div>
|
||||
<div class="layui-elip">结束:{{ns.time_to_date(d.end_time)}}</div>
|
||||
</script>
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="status">
|
||||
{foreach $manjian_status_arr as $manjian_status_k => $manjian_status_v}
|
||||
{{# if(d.status == {$manjian_status_k}){ }}
|
||||
{$manjian_status_v}
|
||||
{{# } }}
|
||||
{/foreach}
|
||||
</script>
|
||||
|
||||
<script>
|
||||
layui.use(['form','element','laydate'], function() {
|
||||
var table,
|
||||
form = layui.form,
|
||||
element = layui.element,
|
||||
laydate = layui.laydate,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
element.on('tab(manjian_tab)', function(){
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status':this.getAttribute('lay-id')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#manjian_list',
|
||||
url: ns.url("manjian://shop/manjian/lists"),
|
||||
cols: [
|
||||
[{
|
||||
field: 'manjian_name',
|
||||
title: '活动名称',
|
||||
unresize: 'false',
|
||||
width: '25%'
|
||||
}, {
|
||||
title: '活动时间',
|
||||
unresize: 'false',
|
||||
width: '21%',
|
||||
templet: '#time'
|
||||
}, {
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
unresize: 'false',
|
||||
width: '13%',
|
||||
templet: '#status'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'edit': //编辑
|
||||
location.hash = ns.hash("manjian://shop/manjian/edit", {"manjian_id": data.manjian_id});
|
||||
break;
|
||||
case 'detail': //详情
|
||||
location.hash = ns.hash("manjian://shop/manjian/detail", {"manjian_id": data.manjian_id});
|
||||
break;
|
||||
case 'delete': //删除
|
||||
deleteManjian(data.manjian_id);
|
||||
break;
|
||||
case 'close': //关闭
|
||||
close(data.manjian_id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function deleteManjian(manjian_id) {
|
||||
if (repeat_flag) return false;
|
||||
repeat_flag = true;
|
||||
|
||||
layer.confirm('确定要删除该满减活动吗?', function(index) {
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("manjian://shop/manjian/delete"),
|
||||
data: {
|
||||
manjian_id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭
|
||||
*/
|
||||
function close(manjian_id) {
|
||||
if (repeat_flag) return false;
|
||||
repeat_flag = true;
|
||||
|
||||
layer.confirm('确定关闭该活动吗?', function(index) {
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("manjian://shop/manjian/close"),
|
||||
data: {
|
||||
manjian_id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function add() {
|
||||
location.hash = ns.hash("manjian://shop/manjian/add");
|
||||
}
|
||||
</script>
|
||||
|
||||
<!-- 详情弹框html -->
|
||||
<script type="text/html" id="detail">
|
||||
<table class="layui-table">
|
||||
<colgroup>
|
||||
<col width="120">
|
||||
<col width="270">
|
||||
</colgroup>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>活动名称</td>
|
||||
<td>{{d.manjian_name}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>开始时间</td>
|
||||
<td>{{ ns.time_to_date(d.start_time, "Y-m-d H:i:s") }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>结束时间</td>
|
||||
<td>{{ ns.time_to_date(d.end_time, "Y-m-d H:i:s") }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td id="rule_name">满减规则</td>
|
||||
<td id="rule">
|
||||
{{# var rule = JSON.parse(d.rule_json); }}
|
||||
{{# for(var key in rule){ }}
|
||||
<p>单笔订单满<span class="money-num">{{ rule[key].money }}</span>元,立减现金<span class="discount_money-num">{{ rule[key].discount_money }}</span>元</p>
|
||||
{{# } }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>备注</td>
|
||||
<td>{{ d.remark }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</script>
|
||||
642
addon/manjian/shop/view/public/js/add.js
Executable file
642
addon/manjian/shop/view/public/js/add.js
Executable file
@@ -0,0 +1,642 @@
|
||||
var goods_list = [], selectedGoodsId = [], goods_id=[], coupon_id = [], addCoupon, currIndex;
|
||||
|
||||
var laytpl, table, form, laydate, repeat_flag = false, //防重复标识
|
||||
currentDate = new Date(), //当前时间
|
||||
minDate = "";
|
||||
|
||||
layui.use(['form', 'laydate', 'laytpl','util'], function() {
|
||||
form = layui.form,
|
||||
laydate = layui.laydate;
|
||||
laytpl = layui.laytpl;
|
||||
util = layui.util;
|
||||
|
||||
form.render();
|
||||
renderTable(goods_list); // 初始化表格
|
||||
|
||||
currentDate.setDate(currentDate.getDate() + 30); //当前时间+30之后的时间戳
|
||||
|
||||
// 开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time' ,//指定元素
|
||||
type: 'datetime',
|
||||
value: new Date(),
|
||||
done: function(value){
|
||||
minDate = value;
|
||||
reRender();
|
||||
}
|
||||
});
|
||||
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time' ,//指定元素
|
||||
type: 'datetime',
|
||||
value: new Date(currentDate)
|
||||
});
|
||||
|
||||
/**
|
||||
* 重新渲染结束时间
|
||||
* */
|
||||
function reRender(){
|
||||
$("#end_time").remove();
|
||||
$(".end-time").html('<input type="text" id="end_time" name="end_time" placeholder="请输入结束时间" lay-verify="required|time" class="layui-input len-mid" autocomplete="off"><i class=" iconrili iconfont calendar"></i>');
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime',
|
||||
min: minDate
|
||||
});
|
||||
}
|
||||
|
||||
//监听活动商品类型
|
||||
form.on('radio(manjian_type)', function(data){
|
||||
var value = data.value;
|
||||
|
||||
if(value == 1){
|
||||
$(".goods_list").hide();
|
||||
}
|
||||
if(value == 2){
|
||||
$(".goods_list").show();
|
||||
}
|
||||
});
|
||||
|
||||
form.on('radio(type)', function(data){
|
||||
var value = data.value;
|
||||
$('.level-item .type-' + value).removeClass('layui-hide').siblings('div').addClass('layui-hide');
|
||||
});
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
len: function(value) {
|
||||
if (value.length > 25) {
|
||||
return "活动名称最多为25个字符!";
|
||||
}
|
||||
},
|
||||
time: function(value) {
|
||||
var now_time = (new Date()).getTime();
|
||||
var start_time = (new Date($("#start_time").val())).getTime();
|
||||
var end_time = (new Date(value)).getTime();
|
||||
if (now_time > end_time) {
|
||||
return '结束时间不能小于当前时间!'
|
||||
}
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
},
|
||||
num: function(value) {
|
||||
if (value == '') {
|
||||
return;
|
||||
}
|
||||
if (value < 0) {
|
||||
return '数字不能小于0!';
|
||||
}
|
||||
if (value * 100 % 1 != 0) {
|
||||
return '数字最多保留两位小数!';
|
||||
}
|
||||
},
|
||||
manjian_money: function(value){
|
||||
var type = $('[name="type"]:checked').val();
|
||||
if (type == 0) {
|
||||
if (!/[\S]+/.test(value)) {
|
||||
return '请输入金额';
|
||||
}
|
||||
if (value < 0) {
|
||||
return '金额不能小于0!';
|
||||
}
|
||||
}
|
||||
},
|
||||
manjian_num: function(value){
|
||||
var type = $('[name="type"]:checked').val();
|
||||
if (type == 1) {
|
||||
if (!/[\S]+/.test(value)) {
|
||||
return '请输入数量';
|
||||
}
|
||||
if (value < 0) {
|
||||
return '数量不能小于0!';
|
||||
}
|
||||
}
|
||||
},
|
||||
coupon_num: function(value){
|
||||
if (!/[\S]+/.test(value)) {
|
||||
return '请输入优惠券赠送数量';
|
||||
}
|
||||
if (value < 1) {
|
||||
return '优惠券赠送数量不能少于一张';
|
||||
}
|
||||
},
|
||||
goods_num:function (value) {
|
||||
var manjian_type = $('[name="manjian_type"]:checked').val();
|
||||
if(manjian_type == 2){
|
||||
if(value == ''){
|
||||
return '请选择活动商品!';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听提交
|
||||
*/
|
||||
form.on('submit(save)', function(data) {
|
||||
var rule = {},
|
||||
verify = true,
|
||||
type = $('[name="type"]:checked').val();
|
||||
$('.manjian-rule .level-item').each(function(i, e) {
|
||||
var limit = parseFloat($(this).find('.type-'+ type +' .layui-input').val()).toFixed(2);
|
||||
if (i > 0) {
|
||||
var prevLimit = $('.manjian-rule .level-item:eq('+ (i - 1) +') .type-'+ type +' .layui-input').val();
|
||||
if (parseFloat(prevLimit) >= parseFloat(limit)) {
|
||||
showErrMsg('优惠门槛需大于上一级优惠门槛', $(this).find('.type-'+ type +' .layui-input'));
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
rule[limit] = {
|
||||
limit: limit
|
||||
};
|
||||
if ($(this).find('[value="discount_money"]').is(':checked')) {
|
||||
var discount_money = $(this).find('.discount-item.discount-money .layui-input').val();
|
||||
if (!/[\S]+/.test(discount_money)) {
|
||||
showErrMsg('请输入优惠金额', $(this).find('.discount-item.discount-money .layui-input'));
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
discount_money = parseFloat(discount_money);
|
||||
if (discount_money <= 0) {
|
||||
showErrMsg('优惠金额不能小于等于0', $(this).find('.discount-item.discount-money .layui-input'));
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type == 0 && discount_money > parseFloat(limit)) {
|
||||
showErrMsg('优惠金额请勿超出优惠门槛', $(this).find('.discount-item.discount-money .layui-input'));
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
rule[limit].discount_money = discount_money;
|
||||
}
|
||||
|
||||
if ($(this).find('[value="free_shipping"]').is(':checked')) {
|
||||
rule[limit].free_shipping = 1;
|
||||
}
|
||||
|
||||
if ($(this).find('[value="point"]').is(':checked')) {
|
||||
var point = $(this).find('.discount-item.point .layui-input').val();
|
||||
rule[limit].point = point;
|
||||
if (!/[\S]+/.test(point)) {
|
||||
showErrMsg('请输入赠送积分数', $(this).find('.discount-item.point .layui-input'));
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
if (point <= 0) {
|
||||
showErrMsg('赠送积分数不能小于等于0', $(this).find('.discount-item.point .layui-input'));
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var coupon = [];
|
||||
var coupon_num = [];
|
||||
if ($(this).find('[value="coupon"]').is(':checked')) {
|
||||
|
||||
$(this).find('tr[data-coupon]').each(function (i, e) {
|
||||
coupon.push($(e).attr('data-coupon'));
|
||||
});
|
||||
$(this).find(".coupon input[name='number']").each(function(j,item){
|
||||
coupon_num.push(item.value);
|
||||
});
|
||||
if (!coupon.length) {
|
||||
showErrMsg('请选择要赠送的优惠券');
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
rule[limit].coupon = coupon.toString();
|
||||
rule[limit].coupon_num = coupon_num.toString();
|
||||
}
|
||||
|
||||
// if ($(this).find('[value="coupon"]').is(':checked')) {
|
||||
// var coupon = $(this).find('.coupon tr[data-coupon]').each(function (i, e) {coupon.push($(e).attr('data-coupon'));})
|
||||
//
|
||||
// if (coupon == undefined) {
|
||||
// showErrMsg('请选择要赠送的优惠券');
|
||||
// verify = false;
|
||||
// return false;
|
||||
// }
|
||||
// rule[limit].coupon = coupon;
|
||||
// }
|
||||
|
||||
if (rule[limit].discount_money == undefined && rule[limit].free_shipping == undefined && rule[limit].point == undefined && rule[limit].coupon == undefined) {
|
||||
showErrMsg('请选择活动层级'+ (i + 1) +'的优惠内容');
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (!verify) return;
|
||||
|
||||
data.field.rule_json = JSON.stringify(rule);
|
||||
|
||||
if(data.field.manjian_type != 1){
|
||||
if(data.field.goods_ids == ''){
|
||||
layer.msg("请选择商品");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ns.url("manjian://shop/manjian/add"),
|
||||
data: data.field,
|
||||
dataType: 'JSON',
|
||||
success: function (res) {
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
layer.confirm('添加成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续添加'],
|
||||
closeBtn: 0,
|
||||
yes: function(index, layero){
|
||||
location.hash = ns.hash("manjian://shop/manjian/lists")
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
} else if (res.code == -10077){
|
||||
var key = res.data.key;
|
||||
layer.confirm('在同一活动时间内,部分商品已参加其他的满减活动', {
|
||||
title:'活动冲突提醒',
|
||||
btn: ['取消', '查看详情'],
|
||||
closeBtn: 0,
|
||||
btn1: function(index, layero){
|
||||
listenerHash(); // 刷新页面
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
location.hash = ns.hash("manjian://shop/manjian/conflict", {"key": key});
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function showErrMsg(msg, e){
|
||||
layer.msg(msg, { icon: 5, shift: 6 });
|
||||
if (e != undefined) {
|
||||
$(e).focus();
|
||||
}
|
||||
}
|
||||
|
||||
form.on('submit(coupon-search)', function(data) {
|
||||
|
||||
data.field.status = 1;
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
dataType: 'JSON',
|
||||
url: ns.url("coupon://shop/coupon/lists"),
|
||||
data: data.field,
|
||||
success: function(res) {
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
coupon_list=res.data;
|
||||
laytpl($("#couponListSearch").html()).render(coupon_list, function (html) {
|
||||
$(".layui-layer-content").html(html);
|
||||
if ($("tbody tr input:checked").length == $(".coupon-box tbody tr").length) {
|
||||
$("input[lay-filter='selectAll']").prop("checked", true);
|
||||
}
|
||||
form.render();
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
});
|
||||
|
||||
// 表格渲染
|
||||
function renderTable(goods_list) {
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#selected_goods_list',
|
||||
page: false,
|
||||
limit: Number.MAX_VALUE,
|
||||
cols: [
|
||||
[{
|
||||
field: 'goods_name',
|
||||
title: '商品名称',
|
||||
unresize: 'false',
|
||||
width: '50%',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
html += `
|
||||
<div class="goods-title">
|
||||
<div class="goods-img">
|
||||
<img src="${data.goods_image ? ns.img(data.goods_image.split(",")[0],'small') : ''}" alt="">
|
||||
</div>
|
||||
<p class="multi-line-hiding goods-name">${data.goods_name}</p>
|
||||
</div>
|
||||
`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格(元)',
|
||||
unresize: 'false',
|
||||
align: 'right',
|
||||
width: '20%',
|
||||
templet: function(data) {
|
||||
return '¥' + data.price;
|
||||
}
|
||||
}, {
|
||||
field: 'goods_stock',
|
||||
title: '库存',
|
||||
unresize: 'false',
|
||||
align: 'center',
|
||||
width: '20%'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}],
|
||||
],
|
||||
data: goods_list,
|
||||
});
|
||||
}
|
||||
|
||||
// 删除选中商品
|
||||
function delGoods(id) {
|
||||
var i, j;
|
||||
$.each(goods_list, function(index, item) {
|
||||
var goods_id = item.goods_id;
|
||||
|
||||
if (id == Number(goods_id)) {
|
||||
i = index;
|
||||
}
|
||||
});
|
||||
goods_list.splice(i, 1);
|
||||
renderTable(goods_list);
|
||||
|
||||
$.each(selectedGoodsId, function(index, item) {
|
||||
if (id == Number(item)) {
|
||||
j = index;
|
||||
}
|
||||
});
|
||||
selectedGoodsId.splice(j, 1);
|
||||
goods_id = selectedGoodsId;
|
||||
$("#goods_num").html(selectedGoodsId.length);
|
||||
$("input[name='goods_ids']").val(goods_id.toString());
|
||||
}
|
||||
|
||||
/* 商品 */
|
||||
function addGoods(){
|
||||
goodsSelect(function (data) {
|
||||
|
||||
goods_id = [];
|
||||
goods_list = [];
|
||||
|
||||
for (var key in data) {
|
||||
goods_id.push(data[key].goods_id);
|
||||
goods_list.push(data[key]);
|
||||
}
|
||||
|
||||
renderTable(goods_list);
|
||||
$("input[name='goods_ids']").val(goods_id.toString());
|
||||
selectedGoodsId = goods_id;
|
||||
$("#goods_num").html(selectedGoodsId.length)
|
||||
}, selectedGoodsId, {mode: "spu"});
|
||||
}
|
||||
|
||||
function backManjianList() {
|
||||
location.hash = ns.hash("manjian://shop/manjian/lists");
|
||||
}
|
||||
|
||||
// 添加优惠层级
|
||||
function addDiscountLevel(){
|
||||
var type = $('[name="type"]:checked').val();
|
||||
length = $('.discount-level .level-item').length;
|
||||
if (length == 5) {
|
||||
layer.msg('最多支持五个活动层级');
|
||||
return;
|
||||
}
|
||||
var template = `<div class="level-item">
|
||||
<div class="level-head">
|
||||
<label class="title">活动层级{{ d.length + 1 }}:</label>
|
||||
<a href="javascript:;" class="text-color" onclick="deleteLevel(this)">删除</a>
|
||||
</div>
|
||||
<div class="wrap">
|
||||
<div class="condition">
|
||||
<label class="layui-form-label"><span class="required">*</span>优惠门槛:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="type-0 {{ d.type != 0 ? 'layui-hide' : '' }}">
|
||||
<div class="layui-form-mid">满</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="money" value="" lay-verify="manjian_money" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
</div>
|
||||
<div class="type-1 {{ d.type != 1 ? 'layui-hide' : '' }}">
|
||||
<div class="layui-form-mid">满</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="num" value="" lay-verify="manjian_num" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">件</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<label class="layui-form-label"><span class="required">*</span>优惠内容:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="discount-item discount-money">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="discount_money" class="input-checkbox" lay-skin="primary"><span>订单金额优惠</span>
|
||||
</div>
|
||||
<div class="discount-cont layui-hide">
|
||||
<div class="layui-form-mid">减</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" value="" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-item">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="free_shipping" class="input-checkbox" lay-skin="primary"><span>包邮</span>
|
||||
</div>
|
||||
<div class="word-aux" style="margin-left: 28px;margin-top: 0">
|
||||
<p>仅参与该活动的商品包邮,非整单包邮</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-item point">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="point" class="input-checkbox" lay-skin="primary"><span>送积分</span>
|
||||
</div>
|
||||
<div class="discount-cont layui-hide">
|
||||
<div class="layui-form-mid">送</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="" value="" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">积分</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-item coupon">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="coupon" class="input-checkbox" lay-skin="primary"><span>送优惠券</span>
|
||||
</div>
|
||||
<div class="discount-cont layui-hide">
|
||||
<div><a href="javascript:;" class="text-color select-coupon">选择优惠券</a></div>
|
||||
<div class="word-aux">
|
||||
<p>请确认优惠券数量是否充足,优惠券数量不足将导致赠送失败</p>
|
||||
</div>
|
||||
<div>
|
||||
<table class="layui-table" lay-skin="nob">
|
||||
<colgroup>
|
||||
<col width="30%">
|
||||
<col width="30%">
|
||||
<col width="20%">
|
||||
<col width="20%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>优惠券</th>
|
||||
<th>优惠内容</th>
|
||||
<th>赠券数</th>
|
||||
<th style="text-align:center;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
laytpl(template).render({
|
||||
length: length,
|
||||
type: type
|
||||
}, function(string){
|
||||
$('.discount-level .level-item:last').after(string);
|
||||
form.render();
|
||||
});
|
||||
}
|
||||
|
||||
// 选择优惠
|
||||
$('body').off('click', '.discount-item .layui-form-checkbox').on('click', '.discount-item .layui-form-checkbox', function(e){
|
||||
if ($(this).prev('[name="discount_type"]').is(':checked')) {
|
||||
$(this).parents('.discount-item').find('.discount-cont').removeClass('layui-hide');
|
||||
} else {
|
||||
$(this).parents('.discount-item').find('.discount-cont').addClass('layui-hide');
|
||||
}
|
||||
});
|
||||
|
||||
$('body').off('click', '.discount-item .select-coupon').on('click', '.discount-item .select-coupon', function(e){
|
||||
currIndex = $(this).parents('.level-item').index();
|
||||
var data = {};
|
||||
data.coupon_id = coupon_id[currIndex] != undefined ? coupon_id[currIndex] : [];
|
||||
|
||||
laytpl($("#couponList").html()).render(data, function(html) {
|
||||
coupon_list = layer.open({
|
||||
title: '优惠券列表',
|
||||
skin: 'layer-tips-class',
|
||||
type: 1,
|
||||
area: ['850px', '600px'],
|
||||
content: html,
|
||||
});
|
||||
|
||||
if ($("tbody tr input:checked").length == $(".coupon-box tbody tr").length) {
|
||||
$("input[lay-filter='selectAll']").prop("checked", true);
|
||||
}
|
||||
|
||||
form.render();
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听全选按钮
|
||||
*/
|
||||
form.on('checkbox(selectAll)', function(data) {
|
||||
if (data.elem.checked) {
|
||||
$("tr .check-box input:checkbox").each(function(index) {
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
} else {
|
||||
$("tr .check-box input:checkbox").each(function() {
|
||||
$(this).prop("checked", false);
|
||||
});
|
||||
}
|
||||
form.render();
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听每一行的多选按钮
|
||||
*/
|
||||
var len = $(".coupon-box tbody tr").length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
form.on('checkbox(select' + i + ')', function(data) {
|
||||
if ($("tbody tr input:checked").length == len) {
|
||||
$("input[lay-filter='selectAll']").prop("checked", true);
|
||||
} else {
|
||||
$("input[lay-filter='selectAll']").prop("checked", false);
|
||||
}
|
||||
|
||||
form.render();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function couponSelected() {
|
||||
if (!$("#goods tbody tr input:checked").length) {
|
||||
layer.msg('请选择优惠券');
|
||||
return;
|
||||
}
|
||||
|
||||
layer.closeAll('page');
|
||||
|
||||
coupon_id[currIndex] = [];
|
||||
|
||||
$("#coupon_selected tbody").empty();
|
||||
|
||||
var data = [];
|
||||
$("#goods tr input:checked").each(function(){
|
||||
var tr = $(this).parents('tr');
|
||||
coupon_id[currIndex].push(tr.find("#coupon_id").val());
|
||||
data.push({
|
||||
coupon_type_id: tr.find("#coupon_id").val(),
|
||||
coupon_name: tr.find(".title-content p").text(),
|
||||
at_least: tr.find('[name="at_least"]').val(),
|
||||
type: tr.find('[name="type"]').val(),
|
||||
discount: tr.find('[name="discount"]').val(),
|
||||
money: tr.find('[name="money"]').val()
|
||||
})
|
||||
});
|
||||
|
||||
laytpl($("#addCoupon").html()).render(data, function(string){
|
||||
$('.level-item:eq('+ currIndex +') .discount-cont tbody').html(string);
|
||||
layer.closeAll();
|
||||
});
|
||||
}
|
||||
|
||||
// 删除优惠层级
|
||||
function deleteLevel(e){
|
||||
$(e).parents('.level-item').remove();
|
||||
}
|
||||
|
||||
// 删除优惠券
|
||||
function deleteCoupon(e,index){
|
||||
index = $(e).parents('.level-item').index();
|
||||
coupon_id[index].splice(index, 1);
|
||||
$(e).parents('tr').remove();
|
||||
}
|
||||
596
addon/manjian/shop/view/public/js/edit.js
Executable file
596
addon/manjian/shop/view/public/js/edit.js
Executable file
@@ -0,0 +1,596 @@
|
||||
var selectedGoodsId = [], goods_id=[], coupon_id = [], addCoupon, currIndex;
|
||||
$.each(goods_list, function(index, item) {
|
||||
var id = item.goods_id;
|
||||
selectedGoodsId.push(id);
|
||||
goods_id.push(id);
|
||||
});
|
||||
|
||||
$("input[name='goods_ids']").val(goods_id.toString());
|
||||
|
||||
Object.values(manjian_info).forEach((item,index)=>{
|
||||
if (item.coupon_data) {
|
||||
var arr = [];
|
||||
item.coupon_data.forEach((subItem,subIndex)=>{
|
||||
arr.push(subItem.coupon_type_id);
|
||||
});
|
||||
coupon_id.push(arr);
|
||||
}
|
||||
});
|
||||
|
||||
var table, form, laydate, laytpl, repeat_flag = false; //防重复标识
|
||||
|
||||
layui.use(['form', 'laydate', 'laytpl'], function() {
|
||||
form = layui.form,
|
||||
laydate = layui.laydate,
|
||||
laytpl = layui.laytpl;
|
||||
|
||||
form.render();
|
||||
|
||||
renderTable(goods_list); // 初始化表格
|
||||
|
||||
laydate.render({
|
||||
elem: '#start_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
//监听活动商品类型
|
||||
form.on('radio(manjian_type)', function(data){
|
||||
var value = data.value;
|
||||
|
||||
if(value == 1){
|
||||
$(".goods_list").hide();
|
||||
}
|
||||
if(value == 2){
|
||||
$(".goods_list").show();
|
||||
}
|
||||
});
|
||||
|
||||
form.on('radio(type)', function(data){
|
||||
var value = data.value;
|
||||
$('.level-item .type-' + value).removeClass('layui-hide').siblings('div').addClass('layui-hide');
|
||||
});
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
len: function(value) {
|
||||
if (value.length > 25) {
|
||||
return "活动名称最多为25个字符!";
|
||||
}
|
||||
},
|
||||
time: function(value) {
|
||||
var now_time = (new Date()).getTime();
|
||||
var time = (new Date(value)).getTime();
|
||||
if (time < now_time) {
|
||||
return '开始时间不能小于当前时间!';
|
||||
}
|
||||
},
|
||||
times: function(value) {
|
||||
var start_time = (new Date($("#start_time").val())).getTime();
|
||||
var end_time = (new Date(value)).getTime();
|
||||
if (start_time > end_time) {
|
||||
return '结束时间不能小于开始时间!';
|
||||
}
|
||||
},
|
||||
num: function(value) {
|
||||
if (value == '') {
|
||||
return;
|
||||
}
|
||||
if (value < 0) {
|
||||
return '数字不能小于0!';
|
||||
}
|
||||
if (value * 100 % 1 != 0) {
|
||||
return '数字最多保留两位小数!';
|
||||
}
|
||||
},
|
||||
manjian_money: function(value){
|
||||
var type = $('[name="type"]:checked').val();
|
||||
if (type == 0) {
|
||||
if (!/[\S]+/.test(value)) {
|
||||
return '请输入金额';
|
||||
}
|
||||
if (value < 0) {
|
||||
return '金额不能小于0!';
|
||||
}
|
||||
}
|
||||
},
|
||||
manjian_num: function(value){
|
||||
var type = $('[name="type"]:checked').val();
|
||||
if (type == 1) {
|
||||
if (!/[\S]+/.test(value)) {
|
||||
return '请输入数量';
|
||||
}
|
||||
if (value < 0) {
|
||||
return '数量不能小于0!';
|
||||
}
|
||||
}
|
||||
},
|
||||
coupon_num: function(value){
|
||||
if (!/[\S]+/.test(value)) {
|
||||
return '请输入优惠券赠送数量';
|
||||
}
|
||||
if (value < 1) {
|
||||
return '优惠券赠送数量不能少于一张';
|
||||
}
|
||||
},
|
||||
goods_num:function (value) {
|
||||
var manjian_type = $('[name="manjian_type"]:checked').val();
|
||||
if(manjian_type == 2){
|
||||
if(value == 0){
|
||||
return '请选择活动商品!';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听提交
|
||||
*/
|
||||
form.on('submit(save)', function(data) {
|
||||
var rule = {},
|
||||
verify = true,
|
||||
type = $('[name="type"]:checked').val();
|
||||
$('.manjian-rule .level-item').each(function(i, e) {
|
||||
var limit = parseFloat($(this).find('.type-'+ type +' .layui-input').val()).toFixed(2);
|
||||
if (i > 0) {
|
||||
var prevLimit = $('.manjian-rule .level-item:eq('+ (i - 1) +') .type-'+ type +' .layui-input').val();
|
||||
if (parseFloat(prevLimit) >= parseFloat(limit)) {
|
||||
showErrMsg('优惠门槛需大于上一级优惠门槛', $(this).find('.type-'+ type +' .layui-input'));
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
rule[limit] = {
|
||||
limit: limit
|
||||
};
|
||||
if ($(this).find('[value="discount_money"]').is(':checked')) {
|
||||
var discount_money = $(this).find('.discount-item.discount-money .layui-input').val();
|
||||
if (!/[\S]+/.test(discount_money)) {
|
||||
showErrMsg('请输入优惠金额', $(this).find('.discount-item.discount-money .layui-input'));
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
discount_money = parseFloat(discount_money);
|
||||
if (discount_money <= 0) {
|
||||
showErrMsg('优惠金额不能小于等于0', $(this).find('.discount-item.discount-money .layui-input'));
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (type == 0 && discount_money > parseFloat(limit)) {
|
||||
showErrMsg('优惠金额请勿超出优惠门槛', $(this).find('.discount-item.discount-money .layui-input'));
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
rule[limit].discount_money = discount_money;
|
||||
}
|
||||
|
||||
if ($(this).find('[value="free_shipping"]').is(':checked')) {
|
||||
rule[limit].free_shipping = 1;
|
||||
}
|
||||
|
||||
if ($(this).find('[value="point"]').is(':checked')) {
|
||||
var point = $(this).find('.discount-item.point .layui-input').val();
|
||||
rule[limit].point = point;
|
||||
if (!/[\S]+/.test(point)) {
|
||||
showErrMsg('请输入赠送积分数', $(this).find('.discount-item.point .layui-input'));
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
if (point <= 0) {
|
||||
showErrMsg('赠送积分数不能小于等于0', $(this).find('.discount-item.point .layui-input'));
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var coupon = [];
|
||||
var coupon_num = [];
|
||||
if ($(this).find('[value="coupon"]').is(':checked')) {
|
||||
|
||||
$(this).find('tr[data-coupon]').each(function (i, e) {
|
||||
coupon.push($(e).attr('data-coupon'));
|
||||
});
|
||||
$(this).find(".coupon input[name='number']").each(function(j,item){
|
||||
coupon_num.push(item.value);
|
||||
});
|
||||
if (!coupon.length) {
|
||||
showErrMsg('请选择要赠送的优惠券');
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
rule[limit].coupon = coupon.toString();
|
||||
rule[limit].coupon_num = coupon_num.toString();
|
||||
}
|
||||
|
||||
if (rule[limit].discount_money == undefined && rule[limit].free_shipping == undefined && rule[limit].point == undefined && rule[limit].coupon == undefined) {
|
||||
showErrMsg('请选择活动层级'+ (i + 1) +'的优惠内容');
|
||||
verify = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
if (!verify) return;
|
||||
|
||||
data.field.rule_json = JSON.stringify(rule);
|
||||
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ns.url("manjian://shop/manjian/edit"),
|
||||
data: data.field,
|
||||
dataType: 'JSON',
|
||||
success: function (res) {
|
||||
repeat_flag = false;
|
||||
|
||||
if (res.code == 0) {
|
||||
layer.confirm('编辑成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续编辑'],
|
||||
yes: function(index, layero){
|
||||
location.hash = ns.hash("manjian://shop/manjian/lists")
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
} else if (res.code == -10077){
|
||||
var key = res.data.key;
|
||||
layer.confirm('在同一活动时间内,部分商品已参加其他的满减活动', {
|
||||
title:'活动冲突提醒',
|
||||
btn: ['取消', '查看详情'],
|
||||
btn1: function(index, layero){
|
||||
listenerHash(); // 刷新页面
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
location.hash = ns.hash("manjian://shop/manjian/conflict", {"key": key});
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function showErrMsg(msg, e){
|
||||
layer.msg(msg, { icon: 5, shift: 6 });
|
||||
if (e != undefined) {
|
||||
$(e).focus();
|
||||
}
|
||||
}
|
||||
|
||||
form.on('submit(coupon-search)', function(data) {
|
||||
couponTable.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
})
|
||||
})
|
||||
});
|
||||
|
||||
// 表格渲染
|
||||
function renderTable(goods_list) {
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#selected_sku_list',
|
||||
page: false,
|
||||
limit: Number.MAX_VALUE,
|
||||
cols: [
|
||||
[{
|
||||
field: 'goods_name',
|
||||
title: '商品名称',
|
||||
unresize: 'false',
|
||||
width: '50%',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
html += `
|
||||
<div class="goods-title">
|
||||
<div class="goods-img">
|
||||
<img src="${data.goods_image ? ns.img(data.goods_image.split(",")[0],'small') : ''}" alt="">
|
||||
</div>
|
||||
<p class="multi-line-hiding goods-name">${data.goods_name}</p>
|
||||
</div>
|
||||
`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格(元)',
|
||||
unresize: 'false',
|
||||
align: 'right',
|
||||
width: '20%',
|
||||
templet: function(data) {
|
||||
return '¥' + data.price;
|
||||
}
|
||||
}, {
|
||||
field: 'goods_stock',
|
||||
title: '库存',
|
||||
unresize: 'false',
|
||||
align: 'center',
|
||||
width: '20%'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}],
|
||||
],
|
||||
data: goods_list,
|
||||
});
|
||||
}
|
||||
|
||||
// 删除选中商品
|
||||
function delGoods(id) {
|
||||
var i, j;
|
||||
$.each(goods_list, function(index, item) {
|
||||
var goods_id = item.goods_id;
|
||||
|
||||
if (id == goods_id) {
|
||||
i = index;
|
||||
}
|
||||
});
|
||||
goods_list.splice(i, 1);
|
||||
renderTable(goods_list);
|
||||
|
||||
$.each(selectedGoodsId, function(index, item) {
|
||||
if (id == item) {
|
||||
j = index;
|
||||
}
|
||||
});
|
||||
selectedGoodsId.splice(j, 1);
|
||||
goods_id = selectedGoodsId;
|
||||
$("#goods_num").html(selectedGoodsId.length);
|
||||
$("input[name='goods_ids']").val(goods_id.toString());
|
||||
}
|
||||
|
||||
function addGoods(){
|
||||
goodsSelect(function (data) {
|
||||
|
||||
goods_id = [];
|
||||
goods_list = [];
|
||||
|
||||
for (var key in data) {
|
||||
goods_id.push(data[key].goods_id);
|
||||
goods_list.push(data[key]);
|
||||
}
|
||||
|
||||
renderTable(goods_list);
|
||||
$("input[name='goods_ids']").val(goods_id.toString());
|
||||
selectedGoodsId = goods_id;
|
||||
$("#goods_num").html(selectedGoodsId.length)
|
||||
}, selectedGoodsId, {mode: "spu"});
|
||||
}
|
||||
|
||||
function backManjianList() {
|
||||
location.hash = ns.hash("manjian://shop/manjian/lists");
|
||||
}
|
||||
|
||||
// 添加优惠层级
|
||||
function addDiscountLevel(){
|
||||
var type = $('[name="type"]:checked').val();
|
||||
length = $('.discount-level .level-item').length;
|
||||
if (length == 5) {
|
||||
layer.msg('最多支持五个活动层级');
|
||||
return;
|
||||
}
|
||||
var template = `<div class="level-item">
|
||||
<div class="level-head">
|
||||
<label class="title">活动层级{{ d.length + 1 }}:</label>
|
||||
<a href="javascript:;" class="text-color" onclick="deleteLevel(this)">删除</a>
|
||||
</div>
|
||||
<div class="wrap">
|
||||
<div class="condition">
|
||||
<label class="layui-form-label"><span class="required">*</span>优惠门槛:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="type-0 {{ d.type != 0 ? 'layui-hide' : '' }}">
|
||||
<div class="layui-form-mid">满</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="money" value="" lay-verify="manjian_money" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
</div>
|
||||
<div class="type-1 {{ d.type != 1 ? 'layui-hide' : '' }}">
|
||||
<div class="layui-form-mid">满</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="num" value="" lay-verify="manjian_num" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">件</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="content">
|
||||
<label class="layui-form-label"><span class="required">*</span>优惠内容:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="discount-item discount-money">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="discount_money" class="input-checkbox" lay-skin="primary"><span>订单金额优惠</span>
|
||||
</div>
|
||||
<div class="discount-cont layui-hide">
|
||||
<div class="layui-form-mid">减</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" value="" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">元</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-item">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="free_shipping" class="input-checkbox" lay-skin="primary"><span>包邮</span>
|
||||
</div>
|
||||
<div class="word-aux" style="margin-left: 28px;margin-top: 0">
|
||||
<p>仅参与该活动的商品包邮,非整单包邮</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-item point">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="point" class="input-checkbox" lay-skin="primary"><span>送积分</span>
|
||||
</div>
|
||||
<div class="discount-cont layui-hide">
|
||||
<div class="layui-form-mid">送</div>
|
||||
<div class="layui-input-inline len-short">
|
||||
<input type="number" name="" value="" placeholder="" autocomplete="off" class="layui-input len-short">
|
||||
</div>
|
||||
<div class="layui-form-mid">积分</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="discount-item coupon">
|
||||
<div>
|
||||
<input type="checkbox" name="discount_type" value="coupon" class="input-checkbox" lay-skin="primary"><span>送优惠券</span>
|
||||
</div>
|
||||
<div class="discount-cont layui-hide">
|
||||
<div><a href="javascript:;" class="text-color select-coupon">选择优惠券</a></div>
|
||||
<div class="word-aux">
|
||||
<p>请确认优惠券数量是否充足,优惠券数量不足将导致赠送失败</p>
|
||||
</div>
|
||||
<div>
|
||||
<table class="layui-table" lay-skin="nob">
|
||||
<colgroup>
|
||||
<col width="30%">
|
||||
<col width="30%">
|
||||
<col width="20%">
|
||||
<col width="20%">
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>优惠券</th>
|
||||
<th>优惠内容</th>
|
||||
<th>赠券数</th>
|
||||
<th style="text-align:center;">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>`;
|
||||
laytpl(template).render({
|
||||
length: length,
|
||||
type: type
|
||||
}, function(string){
|
||||
$('.discount-level .level-item:last').after(string);
|
||||
form.render();
|
||||
});
|
||||
}
|
||||
|
||||
// 选择优惠
|
||||
$('body').off('click', '.discount-item .layui-form-checkbox').on('click', '.discount-item .layui-form-checkbox', function(e){
|
||||
if ($(this).prev('[name="discount_type"]').is(':checked')) {
|
||||
$(this).parents('.discount-item').find('.discount-cont').removeClass('layui-hide');
|
||||
} else {
|
||||
$(this).parents('.discount-item').find('.discount-cont').addClass('layui-hide');
|
||||
}
|
||||
});
|
||||
|
||||
$('body').off('click', '.discount-item .select-coupon').on('click', '.discount-item .select-coupon', function(e){
|
||||
currIndex = $(this).parents('.level-item').index();
|
||||
var data = {};
|
||||
data.coupon_id = coupon_id[currIndex] != undefined ? coupon_id[currIndex] : [];
|
||||
|
||||
laytpl($("#couponList").html()).render(data, function(html) {
|
||||
coupon_list = layer.open({
|
||||
title: '优惠券列表',
|
||||
skin: 'layer-tips-class',
|
||||
type: 1,
|
||||
area: ['850px', '600px'],
|
||||
content: html,
|
||||
});
|
||||
|
||||
if ($("tbody tr input:checked").length == $(".coupon-box tbody tr").length) {
|
||||
$("input[lay-filter='selectAll']").prop("checked", true);
|
||||
}
|
||||
|
||||
form.render();
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听全选按钮
|
||||
*/
|
||||
form.on('checkbox(selectAll)', function(data) {
|
||||
if (data.elem.checked) {
|
||||
$("tr .check-box input:checkbox").each(function(index) {
|
||||
$(this).prop("checked", true);
|
||||
});
|
||||
} else {
|
||||
$("tr .check-box input:checkbox").each(function() {
|
||||
$(this).prop("checked", false);
|
||||
});
|
||||
}
|
||||
form.render();
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听每一行的多选按钮
|
||||
*/
|
||||
var len = $(".coupon-box tbody tr").length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
form.on('checkbox(select' + i + ')', function(data) {
|
||||
if ($("tbody tr input:checked").length == len) {
|
||||
$("input[lay-filter='selectAll']").prop("checked", true);
|
||||
} else {
|
||||
$("input[lay-filter='selectAll']").prop("checked", false);
|
||||
}
|
||||
|
||||
form.render();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
function couponSelected() {
|
||||
layer.closeAll('page');
|
||||
|
||||
coupon_id[currIndex] = [];
|
||||
var _len = $("#goods tbody tr input:checked").length;
|
||||
// if (!_len) {
|
||||
// layer.msg('请选择优惠券');
|
||||
// return;
|
||||
// }
|
||||
|
||||
$("#coupon_selected tbody").empty();
|
||||
|
||||
var data = [];
|
||||
$("#goods tr input:checked").each(function(){
|
||||
var tr = $(this).parents('tr');
|
||||
coupon_id[currIndex].push(tr.find("#coupon_id").val());
|
||||
data.push({
|
||||
coupon_type_id: tr.find("#coupon_id").val(),
|
||||
coupon_name: tr.find(".title-content p").text(),
|
||||
at_least: tr.find('[name="at_least"]').val(),
|
||||
type: tr.find('[name="type"]').val(),
|
||||
discount: tr.find('[name="discount"]').val(),
|
||||
money: tr.find('[name="money"]').val()
|
||||
})
|
||||
});
|
||||
|
||||
laytpl($("#addCoupon").html()).render(data, function(string){
|
||||
$('.level-item:eq('+ currIndex +') .discount-cont tbody').html(string);
|
||||
layer.closeAll();
|
||||
});
|
||||
}
|
||||
// 删除优惠层级
|
||||
function deleteLevel(e){
|
||||
$(e).parents('.level-item').remove();
|
||||
}
|
||||
|
||||
// 删除优惠券
|
||||
function deleteCoupon(e,index){
|
||||
index = $(e).parents('.level-item').index();
|
||||
coupon_id[index].splice(index, 1);
|
||||
$(e).parents('tr').remove();
|
||||
}
|
||||
Reference in New Issue
Block a user