初始上传
This commit is contained in:
230
addon/memberrecommend/shop/controller/Memberrecommend.php
Executable file
230
addon/memberrecommend/shop/controller/Memberrecommend.php
Executable file
@@ -0,0 +1,230 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\memberrecommend\shop\controller;
|
||||
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\memberrecommend\model\MemberRecommend as MemberRecommendModel;
|
||||
use addon\coupon\model\CouponType;
|
||||
|
||||
/**
|
||||
* 邀请奖励控制器
|
||||
*/
|
||||
class Memberrecommend extends BaseShop
|
||||
{
|
||||
/**
|
||||
* 活动列表
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$recommend_name = input('recommend_name', '');
|
||||
$status = input('status', '');
|
||||
$condition = [];
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
$condition[] = [ 'recommend_name', 'like', '%' . $recommend_name . '%' ];
|
||||
if ($status != null) {
|
||||
$condition[] = [ 'status', '=', $status ];
|
||||
}
|
||||
$order = 'create_time desc';
|
||||
$field = 'recommend_id,recommend_name,start_time,end_time,create_time,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) ];
|
||||
}
|
||||
|
||||
$memberRecommend_model = new MemberRecommendModel();
|
||||
$res = $memberRecommend_model->getRecommendPageList($condition, $page, $page_size, $order, $field);
|
||||
|
||||
//获取状态名称
|
||||
$recommend_status_arr = $memberRecommend_model->getStatus();
|
||||
foreach ($res[ 'data' ][ 'list' ] as $key => $val) {
|
||||
$res[ 'data' ][ 'list' ][ $key ][ 'status_name' ] = $recommend_status_arr[ $val[ 'status' ] ];
|
||||
//统计查询邀请人数
|
||||
$item_condition = array (
|
||||
[ 'recommend_id', '=', $val[ 'recommend_id' ] ],
|
||||
[ 'site_id', '=', $this->site_id ]
|
||||
);
|
||||
$res[ 'data' ][ 'list' ][ $key ][ 'count' ] = $memberRecommend_model->getRecommendAwardCount($item_condition)[ 'data' ] ?? 0;
|
||||
}
|
||||
return $res;
|
||||
|
||||
} else {
|
||||
//状态
|
||||
$memberRecommend_model = new MemberRecommendModel();
|
||||
$recommend_status_arr = $memberRecommend_model->getStatus();
|
||||
$this->assign('recommend_status_arr', $recommend_status_arr);
|
||||
|
||||
return $this->fetch("recommend/lists");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动添加
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$data = [
|
||||
'site_id' => $this->site_id,
|
||||
'recommend_name' => input('recommend_name', ''),
|
||||
'start_time' => strtotime(input('start_time', '')),
|
||||
'end_time' => strtotime(input('end_time', '')),
|
||||
'point' => input('point', ''),
|
||||
'balance' => input('balance', ''),
|
||||
'coupon' => input('coupon', ''),
|
||||
'max_point' => input('max_point', ''),
|
||||
'max_balance' => input('max_balance', ''),
|
||||
'max_coupon' => input('max_coupon', ''),
|
||||
'remark' => input('remark', ''),
|
||||
'type' => input('type', ''),
|
||||
'max_fetch' => input('max_fetch', 0)
|
||||
];
|
||||
|
||||
$memberRecommend_model = new MemberRecommendModel();
|
||||
return $memberRecommend_model->addRecommend($data);
|
||||
} else {
|
||||
return $this->fetch("recommend/add");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动编辑
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$memberRecommend_model = new MemberRecommendModel();
|
||||
if (request()->isJson()) {
|
||||
|
||||
$data = [
|
||||
'recommend_id' => input('recommend_id', 0),
|
||||
'site_id' => $this->site_id,
|
||||
'recommend_name' => input('recommend_name', ''),
|
||||
'start_time' => strtotime(input('start_time', '')),
|
||||
'end_time' => strtotime(input('end_time', '')),
|
||||
'point' => input('point', ''),
|
||||
'balance' => input('balance', ''),
|
||||
'coupon' => input('coupon', ''),
|
||||
'max_point' => input('max_point', ''),
|
||||
'max_balance' => input('max_balance', ''),
|
||||
'max_coupon' => input('max_coupon', ''),
|
||||
'remark' => input('remark', ''),
|
||||
'type' => input('type', ''),
|
||||
'max_fetch' => input('max_fetch', 0)
|
||||
];
|
||||
return $memberRecommend_model->editRecommend($data);
|
||||
} else {
|
||||
|
||||
$recommend_id = input('recommend_id', 0);
|
||||
$this->assign('recommend_id', $recommend_id);
|
||||
|
||||
$recommend_info = $memberRecommend_model->getRecommendDetail($recommend_id, $this->site_id);
|
||||
if (empty($recommend_info[ 'data' ])) $this->error('未获取到活动数据', href_url('memberrecommend://shop/memberrecommend/lists'));
|
||||
$this->assign('recommend_info', $recommend_info[ 'data' ]);
|
||||
|
||||
return $this->fetch("recommend/edit");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动详情
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$recommend_id = input('recommend_id', 0);
|
||||
$memberRecommend_model = new MemberRecommendModel();
|
||||
$recommend_info = $memberRecommend_model->getRecommendDetail($recommend_id, $this->site_id)[ 'data' ] ?? [];
|
||||
if (empty($recommend_info)) $this->error('未获取到活动数据', href_url('memberrecommend://shop/memberrecommend/lists'));
|
||||
|
||||
//获取状态名称
|
||||
$recommend_status_arr = $memberRecommend_model->getStatus();
|
||||
$recommend_info[ 'status_name' ] = $recommend_status_arr[ $recommend_info[ 'status' ] ];
|
||||
|
||||
$this->assign('info', $recommend_info);
|
||||
|
||||
//获取优惠券列表
|
||||
$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);
|
||||
return $this->fetch('recommend/detail');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动关闭
|
||||
*/
|
||||
public function close()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$recommend_id = input('recommend_id', 0);
|
||||
$memberRecommend_model = new MemberRecommendModel();
|
||||
return $memberRecommend_model->closeRecommend($recommend_id, $this->site_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 活动删除
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$recommend_id = input('recommend_id', 0);
|
||||
$memberRecommend_model = new MemberRecommendModel();
|
||||
return $memberRecommend_model->deleteRecommend($recommend_id, $this->site_id);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 优惠券领取记录
|
||||
* */
|
||||
public function receive()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$recommend_id = input('recommend_id', 0);
|
||||
$recommend_name = input("recommend_name", "");
|
||||
$condition = [];
|
||||
$condition[] = [ 'recommend_id', '=', $recommend_id ];
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
|
||||
if (!empty($recommend_name)) {
|
||||
$condition[] = [ 'member_nickname', 'like', '%' . $recommend_name . '%' ];
|
||||
}
|
||||
|
||||
$memberRecommend_model = new MemberRecommendModel();
|
||||
$res = $memberRecommend_model->getRecommendAwardPageList($condition, $page, $page_size);
|
||||
return $res;
|
||||
} else {
|
||||
$recommend_id = input('recommend_id', 0);
|
||||
$this->assign('recommend_id', $recommend_id);
|
||||
return $this->fetch("recommend/receive");
|
||||
}
|
||||
}
|
||||
}
|
||||
328
addon/memberrecommend/shop/view/recommend/add.html
Executable file
328
addon/memberrecommend/shop/view/recommend/add.html
Executable file
@@ -0,0 +1,328 @@
|
||||
<style>
|
||||
.coupon-box .layui-form{
|
||||
padding: 0!important;
|
||||
}
|
||||
|
||||
.layui-layer-page .layui-layer-content{
|
||||
overflow: auto !important;
|
||||
}
|
||||
|
||||
.del-btn {
|
||||
cursor: pointer;
|
||||
}
|
||||
.level-equity .layui-input {
|
||||
display: inline-block;
|
||||
}
|
||||
.gods-box table:first-of-type{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.gods-box table:last-of-type{
|
||||
margin-top: 0;
|
||||
display: block;
|
||||
max-height: 323px;
|
||||
overflow: auto;
|
||||
}
|
||||
.coupon-box .single-filter-box{
|
||||
padding-top: 0;
|
||||
}
|
||||
.coupon-box .select-coupon-btn{
|
||||
margin-top: 10px;
|
||||
}
|
||||
.layui-layer-page .layui-layer-content{
|
||||
overflow-y: scroll!important;
|
||||
}
|
||||
.num-name{display: inline-block}
|
||||
</style>
|
||||
|
||||
<div class="layui-form">
|
||||
|
||||
<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="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="recommend_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">活动说明:</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea class="layui-textarea len-long" name="remark" maxlength="150"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">规则设置</span>
|
||||
</div>
|
||||
<div class="layui-card-body reward-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>邀请人可得奖励:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="type" value="point" title="积分" lay-skin="primary" lay-filter="type" lay-verify="type" checked>
|
||||
<input type="checkbox" name="type" value="balance" title="余额" lay-skin="primary" lay-filter="type" lay-verify="type">
|
||||
<input type="checkbox" name="type" value="coupon" title="优惠券" lay-skin="primary" lay-filter="type" lay-verify="type">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="point-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励积分:</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="point" value="0" type="number" lay-verify="required|mum" class="layui-input len-short">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="balance-wrap layui-hide">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励红包:</label>
|
||||
<div class="layui-input-block len-long">
|
||||
<input name="balance" value="0" type="number" lay-verify="" class="layui-input len-short" onchange="detectionNumType(this,'positiveNumber')">
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux"><p>红包为储值余额,仅在消费时可用</p></div>
|
||||
</div>
|
||||
|
||||
<div class="coupon-wrap layui-hide">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励优惠券:</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="coupon_list"></div>
|
||||
<div class="word-aux text-color" style="margin-left: 0">
|
||||
<p>活动优惠券发放,不受优惠券自身数量和领取数量的限制</p>
|
||||
</div>
|
||||
<button class="layui-btn" id="select_coupon">选择优惠券</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="max-fetch-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>邀请奖励上限:</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="max_fetch" value="0" type="number" class="layui-input len-short num-name">
|
||||
人
|
||||
<div class="word-aux text-color" style="margin-left: 0">
|
||||
<p>默认0,为不限制</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="STATIC_JS/coupon_select.js"></script>
|
||||
<script>
|
||||
var coupon_id = [], addCoupon,minDate,
|
||||
currentDate = new Date(); //当前时间;
|
||||
var coupon_select = new CouponSelect({
|
||||
tableElem:'#coupon_list',
|
||||
selectElem:'#select_coupon',
|
||||
})
|
||||
|
||||
layui.use(['form', 'laytpl', 'laydate'], function() {
|
||||
var form = layui.form,
|
||||
laytpl = layui.laytpl,
|
||||
laydate = layui.laydate,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
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('checkbox(type)', function(data) {
|
||||
$('[name="type"]').each(function(){
|
||||
var type = $(this).val();
|
||||
if ($(this).is(':checked')) {
|
||||
$('.reward-wrap .' + type + '-wrap').removeClass('layui-hide');
|
||||
if (type == 'point' || type == 'coupon') {
|
||||
$('.reward-wrap .' + type + '-wrap [lay-verify]').attr('lay-verify', 'required|mum');
|
||||
}
|
||||
if (type == 'balance') {
|
||||
$('.reward-wrap .' + type + '-wrap [lay-verify]').attr('lay-verify', 'required|float');
|
||||
}
|
||||
} else {
|
||||
$('.reward-wrap .' + type + '-wrap').addClass('layui-hide');
|
||||
$('.reward-wrap .' + type + '-wrap [lay-verify]').attr('lay-verify', '');
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* 监听保存
|
||||
*/
|
||||
form.on('submit(save)', function(data) {
|
||||
let coupon_selected_ids = coupon_select.getSelectedData().selectedIds;
|
||||
var type = [];
|
||||
$('.reward-wrap [name="type"]:checked').each(function(){
|
||||
type.push($(this).val());
|
||||
})
|
||||
if ($.inArray('coupon', type) != -1 && coupon_selected_ids.length == 0) {
|
||||
layer.msg('请选择优惠券', {icon: 5});
|
||||
return;
|
||||
}
|
||||
|
||||
if(data.field.max_fetch == ''){
|
||||
layer.msg('请输入邀请奖励上限', {icon: 5});
|
||||
return;
|
||||
}else if (data.field.max_fetch < 0){
|
||||
layer.msg('请输入大于或等于0的整数', {icon: 5});
|
||||
return;
|
||||
}
|
||||
|
||||
data.field.type = type.toString();
|
||||
data.field.coupon = coupon_selected_ids.toString();
|
||||
|
||||
if (repeat_flag) return false;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("memberrecommend://shop/memberrecommend/add"),
|
||||
data: data.field,
|
||||
dataType: 'JSON', //服务器返回json格式数据
|
||||
type: 'POST', //http请求类型
|
||||
success: function(res) {
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
layer.confirm('添加成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续添加'],
|
||||
closeBtn: 0,
|
||||
yes: function(index, layero){
|
||||
location.hash = ns.hash("memberrecommend://shop/memberrecommend/lists")
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
type: function(){
|
||||
if ($('.reward-wrap [name="type"]:checked').length == 0) {
|
||||
return '请选择邀请人可得奖励';
|
||||
}
|
||||
},
|
||||
mum: function(value, item){
|
||||
let reg = ns.getRegexp('>0num');
|
||||
if (!reg.test(value)) {
|
||||
return '请输入正整数';
|
||||
}
|
||||
},
|
||||
float: function(value, item){
|
||||
let reg = ns.getRegexp('>0float2');
|
||||
if (!reg.test(value)) {
|
||||
return '请输入大于0的数字,最多保留两位小数';
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function back(){
|
||||
location.hash = ns.hash("memberrecommend://shop/memberrecommend/lists");
|
||||
}
|
||||
//检测数据类型
|
||||
function detectionNumType(el,type){
|
||||
var value = $(el).val();
|
||||
|
||||
//大于零 且 不是小数
|
||||
if (value < 0 && type == 'integral')
|
||||
$(el).val(0);
|
||||
else if(type == 'integral')
|
||||
$(el).val(Math.round(value));
|
||||
|
||||
//大于1 且 不是小数
|
||||
if (value < 1 && type == 'positiveInteger'){
|
||||
$(el).val(1);
|
||||
} else if (type == 'positiveInteger'){
|
||||
var val = Math.round(value);
|
||||
if(Object.is(val,NaN)){
|
||||
$(el).val(1);
|
||||
}else{
|
||||
$(el).val(val);
|
||||
}
|
||||
}
|
||||
|
||||
//大于零可以是小数
|
||||
if (type == 'positiveNumber'){
|
||||
value = parseFloat(value).toFixed(2);
|
||||
if (value < 0)
|
||||
$(el).val(0);
|
||||
else
|
||||
$(el).val(value);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
140
addon/memberrecommend/shop/view/recommend/detail.html
Executable file
140
addon/memberrecommend/shop/view/recommend/detail.html
Executable file
@@ -0,0 +1,140 @@
|
||||
<link rel="stylesheet" href="STATIC_CSS/promotion_detail.css">
|
||||
|
||||
<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>{$info.recommend_name}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>活动状态:</label>
|
||||
<span>{$info.status_name}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>开始时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$info.start_time)}</span>
|
||||
</div>
|
||||
<div class="promotion-view-item">
|
||||
<label>结束时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$info.end_time)}</span>
|
||||
</div>
|
||||
|
||||
<div class="promotion-view-item">
|
||||
<label>添加时间:</label>
|
||||
<span>{:date('Y-m-d H:i:s',$info.create_time)}</span>
|
||||
</div>
|
||||
{if in_array('point', $info['type'])}
|
||||
<div class="promotion-view-item">
|
||||
<label>奖励积分:</label>
|
||||
<span>{$info.point}</span>
|
||||
</div>
|
||||
{/if}
|
||||
{if in_array('balance', $info['type'])}
|
||||
<div class="layui-form-item">
|
||||
<label>奖励红包:</label>
|
||||
<span>{$info.balance}</span>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
</div>
|
||||
{if !empty($info.remark)}
|
||||
<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">{$info.remark}</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
{if in_array('coupon', $info['type']) && !empty($info['coupon_list'])}
|
||||
<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">
|
||||
{{# if(d.image != ''){ }}
|
||||
<img src="{{ ns.img(d.image) }}">
|
||||
{{# }else{ }}
|
||||
<img src="__ROOT__/public/uniapp/game/coupon.png">
|
||||
{{# } }}
|
||||
</div>
|
||||
<p class="promotion-list-item-title-name multi-line-hiding">{{ d.coupon_name }}</p>
|
||||
</div>
|
||||
</script>
|
||||
<script>
|
||||
var promotion_list = {:json_encode($info['coupon_list'] ?? [], JSON_UNESCAPED_UNICODE)};
|
||||
|
||||
layui.use('table', function() {
|
||||
new Table({
|
||||
elem: '#promotion_list',
|
||||
cols: [
|
||||
[{
|
||||
title: '优惠券名称',
|
||||
width: '30%',
|
||||
unresize: 'false',
|
||||
templet: '#promotion_list_item_box_html'
|
||||
}, {
|
||||
title: '类型',
|
||||
templet: function(data) {
|
||||
return data.type == 'reward' ? '满减': '折扣';
|
||||
}
|
||||
}, {
|
||||
title: '优惠金额/折扣',
|
||||
templet: function(data) {
|
||||
return data.type == 'reward' ? data.money : data.discount;
|
||||
}
|
||||
}, {
|
||||
title: '适用商品',
|
||||
templet: function (data) {
|
||||
return data.goods_type_name;
|
||||
}
|
||||
}, {
|
||||
field: 'max_fetch',
|
||||
title: '领取人限制',
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '已领取/发放数',
|
||||
templet: function(data) {
|
||||
return data.count == -1 ? data.lead_count+'/不限量': data.lead_count+'/'+data.count;
|
||||
}
|
||||
}, {
|
||||
field: 'stock',
|
||||
title: '结束时间',
|
||||
unresize: 'false',
|
||||
width:'20%',
|
||||
templet: function(data) {
|
||||
var str = '';
|
||||
switch(data.validity_type) {
|
||||
case 0:
|
||||
str = ns.time_to_date(data.end_time);
|
||||
break;
|
||||
case 1:
|
||||
str = '领取之日起' + data.fixed_term + '天有效';
|
||||
break;
|
||||
default:
|
||||
str = '长期有效';
|
||||
break;
|
||||
}
|
||||
return str;
|
||||
}
|
||||
}]
|
||||
],
|
||||
data: promotion_list
|
||||
});
|
||||
});
|
||||
</script>
|
||||
284
addon/memberrecommend/shop/view/recommend/edit.html
Executable file
284
addon/memberrecommend/shop/view/recommend/edit.html
Executable file
@@ -0,0 +1,284 @@
|
||||
<style>
|
||||
.coupon-box .layui-form{
|
||||
padding: 0!important;
|
||||
}
|
||||
|
||||
.layui-layer-page .layui-layer-content{
|
||||
overflow: auto !important;
|
||||
}
|
||||
|
||||
.del-btn {
|
||||
cursor: pointer;
|
||||
}
|
||||
.level-equity .layui-input {
|
||||
display: inline-block;
|
||||
}
|
||||
.gods-box table:first-of-type{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.gods-box table:last-of-type{
|
||||
margin-top: 0;
|
||||
display: block;
|
||||
max-height: 323px;
|
||||
overflow: auto;
|
||||
}
|
||||
.coupon-box .single-filter-box{
|
||||
padding-top: 0;
|
||||
}
|
||||
.coupon-box .select-coupon-btn{
|
||||
margin-top: 10px;
|
||||
}
|
||||
.layui-layer-page .layui-layer-content{
|
||||
overflow-y: scroll!important;
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="layui-form">
|
||||
|
||||
<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="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>活动名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="recommend_name" value="{$recommend_info.recommend_name}" type="text" lay-verify="required" class="layui-input len-long">
|
||||
</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" {if condition="$recommend_info.status == 1"}disabled {/if} value="{:date('Y-m-d H:i:s', $recommend_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="$recommend_info.status == 1"}disabled {/if} value="{:date('Y-m-d H:i:s', $recommend_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="$recommend_info.status == 1"}
|
||||
<div class="word-aux">
|
||||
<p>活动进行中时间不可更改</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">活动说明:</label>
|
||||
<div class="layui-input-block">
|
||||
<textarea class="layui-textarea len-long" name="remark" maxlength="150">{$recommend_info.remark}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="layui-card-header">
|
||||
<span class="card-title">规则设置</span>
|
||||
</div>
|
||||
<div class="layui-card-body reward-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>邀请人可得奖励:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="type" value="point" title="积分" lay-skin="primary" lay-filter="type" lay-verify="type" {if in_array('point', $recommend_info['type']) }checked{/if}>
|
||||
<input type="checkbox" name="type" value="balance" title="余额" lay-skin="primary" lay-filter="type" lay-verify="type" {if in_array('balance', $recommend_info['type']) }checked{/if}>
|
||||
<input type="checkbox" name="type" value="coupon" title="优惠券" lay-skin="primary" lay-filter="type" lay-verify="type" {if in_array('coupon', $recommend_info['type']) }checked{/if}>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="point-wrap {if !in_array('point', $recommend_info['type']) }layui-hide{/if}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励积分:</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="point" value="{$recommend_info.point}" type="number" lay-verify="{if in_array('point', $recommend_info['type']) }required|num{/if}" class="layui-input len-short">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="balance-wrap {if !in_array('balance', $recommend_info['type']) }layui-hide{/if}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励红包:</label>
|
||||
<div class="layui-input-block len-long">
|
||||
<input name="balance" value="{$recommend_info.balance}" type="number" lay-verify="{if in_array('balance', $recommend_info['type']) }required|float{/if}" class="layui-input len-short">
|
||||
</div>
|
||||
</div>
|
||||
<div class="word-aux"><p>红包为储值余额,仅在消费时可用</p></div>
|
||||
</div>
|
||||
|
||||
<div class="coupon-wrap {if !in_array('coupon', $recommend_info['type']) }layui-hide{/if}">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>奖励优惠券:</label>
|
||||
<div class="layui-input-block">
|
||||
<div id="coupon_list"></div>
|
||||
<div class="word-aux text-color" style="margin-left: 0">
|
||||
<p>活动优惠券发放,不受优惠券自身数量和领取数量的限制</p>
|
||||
</div>
|
||||
<button class="layui-btn" id="select_coupon">选择优惠券</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="max-fetch-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>邀请奖励上限:</label>
|
||||
<div class="layui-input-block">
|
||||
<input name="max_fetch" value="{$recommend_info.max_fetch}" type="number" class="layui-input len-short">
|
||||
<div class="word-aux text-color" style="margin-left: 0">
|
||||
<p>默认0,为不限制</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="recommend_id" value="{$recommend_info.recommend_id}">
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="STATIC_JS/coupon_select.js"></script>
|
||||
<script>
|
||||
var coupon_id = [], addCoupon,
|
||||
currentDate = new Date(); //当前时间;
|
||||
var coupon_select = new CouponSelect({
|
||||
tableElem:'#coupon_list',
|
||||
selectElem:'#select_coupon',
|
||||
selectedIds:'{$recommend_info.coupon}'
|
||||
})
|
||||
|
||||
layui.use(['form', 'laytpl', 'laydate'], function() {
|
||||
var form = layui.form,
|
||||
laytpl = layui.laytpl,
|
||||
laydate = layui.laydate,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
currentDate.setDate(currentDate.getDate() + 30); //当前时间+30之后的时间戳
|
||||
|
||||
laydate.render({
|
||||
elem: '#start_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
laydate.render({
|
||||
elem: '#end_time',
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
form.on('checkbox(type)', function(data) {
|
||||
$('[name="type"]').each(function(){
|
||||
var type = $(this).val();
|
||||
if ($(this).is(':checked')) {
|
||||
$('.reward-wrap .' + type + '-wrap').removeClass('layui-hide');
|
||||
if (type == 'point' || type == 'coupon') {
|
||||
$('.reward-wrap .' + type + '-wrap [lay-verify]').attr('lay-verify', 'required|mum');
|
||||
}
|
||||
if (type == 'balance') {
|
||||
$('.reward-wrap .' + type + '-wrap [lay-verify]').attr('lay-verify', 'required|float');
|
||||
}
|
||||
} else {
|
||||
$('.reward-wrap .' + type + '-wrap').addClass('layui-hide');
|
||||
$('.reward-wrap .' + type + '-wrap [lay-verify]').attr('lay-verify', '');
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
/**
|
||||
* 监听保存
|
||||
*/
|
||||
form.on('submit(save)', function(data) {
|
||||
let coupon_selected_ids = coupon_select.getSelectedData().selectedIds;
|
||||
var type = [];
|
||||
$('.reward-wrap [name="type"]:checked').each(function(){
|
||||
type.push($(this).val());
|
||||
})
|
||||
if ($.inArray('coupon', type) != -1 && coupon_selected_ids.length == 0) {
|
||||
layer.msg('请选择优惠券', {icon: 5});
|
||||
return;
|
||||
}
|
||||
|
||||
if(data.field.max_fetch == ''){
|
||||
layer.msg('请输入邀请奖励上限', {icon: 5});
|
||||
return;
|
||||
}else if (data.field.max_fetch < 0){
|
||||
layer.msg('请输入大于或等于0的整数', {icon: 5});
|
||||
return;
|
||||
}
|
||||
|
||||
data.field.type = type.toString();
|
||||
data.field.coupon = coupon_selected_ids.toString();
|
||||
|
||||
if (repeat_flag) return false;
|
||||
repeat_flag = true;
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("memberrecommend://shop/memberrecommend/edit"),
|
||||
data: data.field,
|
||||
dataType: 'JSON', //服务器返回json格式数据
|
||||
type: 'POST', //http请求类型
|
||||
success: function(res) {
|
||||
repeat_flag = false;
|
||||
if (res.code == 0) {
|
||||
layer.confirm('编辑成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续编辑'],
|
||||
closeBtn: 0,
|
||||
yes: function(index, layero){
|
||||
location.hash = ns.hash("memberrecommend://shop/memberrecommend/lists")
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 表单验证
|
||||
*/
|
||||
form.verify({
|
||||
type: function(){
|
||||
if ($('.reward-wrap [name="type"]:checked').length == 0) {
|
||||
return '请选择邀请人可得奖励';
|
||||
}
|
||||
},
|
||||
mum: function(value, item){
|
||||
if (isNaN(parseInt(value))) {
|
||||
return '请输入大于0的数字,支持小数点后两位';
|
||||
}
|
||||
value = parseInt(value);
|
||||
if (/^\d{0,10}$/.test(value) === false || value <= 0) {
|
||||
return '请输入大于0的整数';
|
||||
}
|
||||
},
|
||||
float: function(value, item){
|
||||
if (isNaN(parseFloat(value))) {
|
||||
return '请输入大于0的数字,支持小数点后两位';
|
||||
}
|
||||
value = parseFloat(value);
|
||||
if (/^\d{0,10}$/.test(value) === false || value <= 0) {
|
||||
return '请输入大于0的数字,支持小数点后两位';
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function back(){
|
||||
location.hash = ns.hash("memberrecommend://shop/memberrecommend/lists");
|
||||
}
|
||||
</script>
|
||||
253
addon/memberrecommend/shop/view/recommend/lists.html
Executable file
253
addon/memberrecommend/shop/view/recommend/lists.html
Executable file
@@ -0,0 +1,253 @@
|
||||
<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="recommend_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="recommend_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="recommend_list" lay-filter="recommend_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="receive">领取记录</a>
|
||||
<a class="layui-btn" lay-event="detail">详情</a>
|
||||
{{# if(d.status == 0) { }}
|
||||
<a class="layui-btn" lay-event="edit">编辑</a>
|
||||
<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 $recommend_status_arr as $recommend_status_k => $recommend_status_v}
|
||||
{{# if(d.status == {$recommend_status_k}){ }}
|
||||
{$recommend_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(recommend_tab)', function(){
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status':this.getAttribute('lay-id')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#recommend_list',
|
||||
url: ns.url("memberrecommend://shop/memberrecommend/lists"),
|
||||
cols: [
|
||||
[{
|
||||
field: 'recommend_name',
|
||||
title: '活动名称',
|
||||
unresize: 'false',
|
||||
width: '25%'
|
||||
}, {
|
||||
title: '活动时间',
|
||||
unresize: 'false',
|
||||
width: '21%',
|
||||
templet: '#time'
|
||||
}, {
|
||||
field: 'status',
|
||||
title: '状态',
|
||||
unresize: 'false',
|
||||
width: '13%',
|
||||
templet: '#status'
|
||||
}, {
|
||||
field: 'count',
|
||||
title: '邀请人数',
|
||||
unresize: 'false',
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
]
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'edit': //编辑
|
||||
location.hash = ns.hash("memberrecommend://shop/memberrecommend/edit", {"recommend_id": data.recommend_id});
|
||||
break;
|
||||
case 'detail': //详情
|
||||
location.hash = ns.hash("memberrecommend://shop/memberrecommend/detail", {"recommend_id": data.recommend_id});
|
||||
break;
|
||||
case 'delete': //删除
|
||||
deleteRecommend(data.recommend_id);
|
||||
break;
|
||||
case 'close': //关闭
|
||||
close(data.recommend_id);
|
||||
break;
|
||||
case 'receive': //关闭
|
||||
location.hash = ns.hash("memberrecommend://shop/memberrecommend/receive", {"recommend_id": data.recommend_id});
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
//开始时间
|
||||
laydate.render({
|
||||
elem: '#start_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
//结束时间
|
||||
laydate.render({
|
||||
elem: '#end_time', //指定元素
|
||||
type: 'datetime'
|
||||
});
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function deleteRecommend(recommend_id) {
|
||||
if (repeat_flag) return false;
|
||||
repeat_flag = true;
|
||||
|
||||
layer.confirm('确定要删除该活动吗?', function(index) {
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("memberrecommend://shop/memberrecommend/delete"),
|
||||
data: {
|
||||
recommend_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(recommend_id) {
|
||||
if (repeat_flag) return false;
|
||||
repeat_flag = true;
|
||||
|
||||
layer.confirm('确定关闭该活动吗?', function(index) {
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("memberrecommend://shop/memberrecommend/close"),
|
||||
data: {
|
||||
recommend_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("memberrecommend://shop/memberrecommend/add");
|
||||
}
|
||||
</script>
|
||||
102
addon/memberrecommend/shop/view/recommend/receive.html
Executable file
102
addon/memberrecommend/shop/view/recommend/receive.html
Executable file
@@ -0,0 +1,102 @@
|
||||
<style>
|
||||
.layui-layer-page .layui-layer-content { padding: 20px 30px; }
|
||||
.layui-form-item{ margin-bottom: 0px; }
|
||||
.form-row { margin: 0px !important; display: inline-block }
|
||||
.screen.layui-collapse { margin-top: 10px }
|
||||
</style>
|
||||
|
||||
<div class="screen layui-collapse" lay-filter="selection_panel">
|
||||
<div class="layui-colla-item">
|
||||
<div 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="recommend_name" placeholder="请输入邀请人" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="search">筛选</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab table-tab">
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="receive_list" lay-filter="receive_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 优惠券列表 -->
|
||||
<script type="text/html" id="coupon_list">
|
||||
{{# layui.each(d.coupon_list, function(index, item){ }}
|
||||
<a href="{{ ns.href('coupon://shop/coupon/detail?coupon_type_id=' + item.coupon_type_id ) }}" target="_blank">{{ item.coupon_name }}</a>
|
||||
{{# }); }}
|
||||
</script>
|
||||
|
||||
<input id="recommend_id" type="hidden" value="{$recommend_id}" />
|
||||
|
||||
<script>
|
||||
layui.use(['form'], function() {
|
||||
var table,
|
||||
form = layui.form,
|
||||
recommend_id = $('#recommend_id').val();
|
||||
|
||||
table = new Table({
|
||||
elem: '#receive_list',
|
||||
url: ns.url("memberrecommend://shop/memberrecommend/receive"),
|
||||
where: {
|
||||
"recommend_id": recommend_id
|
||||
},
|
||||
cols: [
|
||||
[{
|
||||
field: 'member_nickname',
|
||||
title: '邀请人',
|
||||
unresize: 'false',
|
||||
width: '10%'
|
||||
}, {
|
||||
field: 'source_member_nickname',
|
||||
title: '被邀请人',
|
||||
unresize: 'false',
|
||||
width: '10%'
|
||||
}, {
|
||||
field: 'point',
|
||||
title: '奖励积分',
|
||||
unresize: 'false',
|
||||
width: '12.5%'
|
||||
}, {
|
||||
field: 'balance',
|
||||
title: '奖励余额',
|
||||
unresize: 'false',
|
||||
width: '12.5%'
|
||||
}, {
|
||||
title: '奖励优惠券',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
templet:"#coupon_list"
|
||||
}, {
|
||||
field: 'create_time',
|
||||
title: '注册时间',
|
||||
unresize: 'false',
|
||||
width: '20%',
|
||||
templet: function(data) {
|
||||
return ns.time_to_date(data.create_time);
|
||||
}
|
||||
}]
|
||||
],
|
||||
});
|
||||
|
||||
// 搜索
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user