初始上传
This commit is contained in:
111
addon/freeshipping/shop/controller/Freeshipping.php
Executable file
111
addon/freeshipping/shop/controller/Freeshipping.php
Executable file
@@ -0,0 +1,111 @@
|
||||
<?php
|
||||
/**
|
||||
* Niushop商城系统 - 团队十年电商经验汇集巨献!
|
||||
* =========================================================
|
||||
* Copy right 2019-2029 杭州牛之云科技有限公司, 保留所有权利。
|
||||
* ----------------------------------------------
|
||||
* 官方网址: https://www.niushop.com
|
||||
* =========================================================
|
||||
*/
|
||||
|
||||
namespace addon\freeshipping\shop\controller;
|
||||
|
||||
use app\shop\controller\BaseShop;
|
||||
use addon\freeshipping\model\Freeshipping as FreeshippingModel;
|
||||
|
||||
class Freeshipping extends BaseShop
|
||||
{
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$model = new FreeshippingModel();
|
||||
|
||||
$condition[] = [ 'site_id', '=', $this->site_id ];
|
||||
if (request()->isJson()) {
|
||||
$page = input('page', 1);
|
||||
$page_size = input('page_size', PAGE_LIST_ROWS);
|
||||
$list = $model->getFreeshippingPageList($condition, $page, $page_size, 'price asc');
|
||||
return $list;
|
||||
} else {
|
||||
return $this->fetch('freeshipping/lists');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加活动
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
if (request()->isJson()) {
|
||||
|
||||
$price = input('price', '');
|
||||
$json = input('json', '');
|
||||
$surplus_area_ids = input('surplus_area_ids', '');
|
||||
|
||||
$json_data = json_decode($json, true);
|
||||
$data = $json_data[ '1' ];
|
||||
$data[ 'price' ] = $price;
|
||||
$data[ 'site_id' ] = $this->site_id;
|
||||
$data[ 'surplus_area_ids' ] = $surplus_area_ids;
|
||||
$model = new FreeshippingModel();
|
||||
$result = $model->addFreeshipping($data);
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
|
||||
// 地区等级设置 将来从配置中查询数据
|
||||
$area_level = 3;
|
||||
$this->assign('area_level', $area_level);//地址级别
|
||||
return $this->fetch('freeshipping/add');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑活动
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$model = new FreeshippingModel();
|
||||
$freeshipping_id = input('freeshipping_id', 0);
|
||||
if (request()->isJson()) {
|
||||
|
||||
$price = input('price', '');
|
||||
$json = input('json', '');
|
||||
$surplus_area_ids = input('surplus_area_ids', '');
|
||||
|
||||
$json_data = json_decode($json, true);
|
||||
$data = $json_data[ '1' ];
|
||||
$data[ 'price' ] = $price;
|
||||
$data[ 'site_id' ] = $this->site_id;
|
||||
$data[ 'surplus_area_ids' ] = $surplus_area_ids;
|
||||
$data[ 'freeshipping_id' ] = $freeshipping_id;
|
||||
|
||||
$result = $model->editFreeshipping($data);
|
||||
return $result;
|
||||
|
||||
} else {
|
||||
$this->assign('freeshipping_id', $freeshipping_id);
|
||||
// 地区等级设置 将来从配置中查询数据
|
||||
$area_level = 3;
|
||||
$this->assign('area_level', $area_level);//地址级别
|
||||
|
||||
$info = $model->getFreeshippingInfo([ [ 'freeshipping_id', '=', $freeshipping_id ], [ 'site_id', '=', $this->site_id ] ])[ 'data' ];
|
||||
$this->assign('info', $info);
|
||||
return $this->fetch('freeshipping/edit');
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 删除
|
||||
*/
|
||||
public function delete()
|
||||
{
|
||||
$freeshipping_id = input('freeshipping_id', '');
|
||||
$site_id = $this->site_id;
|
||||
|
||||
$model = new FreeshippingModel();
|
||||
return $model->deleteFreeshipping($freeshipping_id, $site_id);
|
||||
}
|
||||
|
||||
}
|
||||
150
addon/freeshipping/shop/view/freeshipping/add.html
Executable file
150
addon/freeshipping/shop/view/freeshipping/add.html
Executable file
@@ -0,0 +1,150 @@
|
||||
<style>
|
||||
.add-distribution{cursor: pointer;}
|
||||
.area-modal{
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
padding: 25px 0;
|
||||
}
|
||||
.area-modal .area-list{
|
||||
width: 255px;
|
||||
height: 375px;
|
||||
align-items: center;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
.area-modal .title{
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
text-align: center;
|
||||
}
|
||||
.area-modal .add{
|
||||
background-color: transparent;
|
||||
border: 1px solid #ccc;
|
||||
padding: 5px 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.area-modal .box{
|
||||
overflow-y: auto;
|
||||
padding: 10px 0;
|
||||
height: 340px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.modal-operation{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 50px;
|
||||
}
|
||||
.area-list .box{
|
||||
height: 314px;
|
||||
margin: 10px 0;
|
||||
overflow-y:auto;
|
||||
overflow-x:hidden;
|
||||
}
|
||||
.area-list .box ul li{
|
||||
line-height: 30px;
|
||||
cursor: pointer;
|
||||
background-color:#fff;
|
||||
}
|
||||
.area-list .box ul li .title-div{
|
||||
position:relative;
|
||||
padding-left:20px;
|
||||
}
|
||||
.area-list .box ul li[data-level='2'] .title-div{
|
||||
margin-left:10px;
|
||||
}
|
||||
.area-list .box ul li[data-level='3'] .title-div{
|
||||
margin-left:20px;
|
||||
}
|
||||
.area-list .box ul li[data-level='4'] .title-div{
|
||||
margin-left:30px;
|
||||
}
|
||||
.area-list.all-area .box ul li.selected{
|
||||
background: #d7d7d7;
|
||||
}
|
||||
.area-list .area-btn,.area-list .area-btn-null,.area-list .area-delete{
|
||||
position:absolute;
|
||||
top:9px;
|
||||
display:block;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
border-radius: 50%;
|
||||
background-color: #d7d7d7;
|
||||
color: #fff;
|
||||
line-height: 15px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
.area-list .area-btn{
|
||||
left:3px;
|
||||
}
|
||||
.area-list .area-btn-null{
|
||||
background-color:transparent;
|
||||
left:3px;
|
||||
}
|
||||
.area-list .area-delete{
|
||||
right:6px;
|
||||
}
|
||||
.area-list.all-area .area-delete{
|
||||
display:none;
|
||||
}
|
||||
.area-list.all-area .area-btn.selected{
|
||||
background-color: #fff;
|
||||
color: #d7d7d7;
|
||||
}
|
||||
.right-opt {
|
||||
float: right;
|
||||
}
|
||||
.right-opt span {
|
||||
cursor: pointer;
|
||||
}
|
||||
.bg-color-gray {
|
||||
background-color: #E5E5E5!important;
|
||||
}
|
||||
.area-table {width: 800px;}
|
||||
.layui-table .area-selected {border-right: 0;}
|
||||
.layui-table .area-btn {border-left: 0;}
|
||||
</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 name="price" type="number" min="0" placeholder="请输入金额" lay-verify="required" class="layui-input len-long" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>指定地区:</label>
|
||||
<div class="layui-input-block area-table">
|
||||
<table id="distributionArea" class="layui-table">
|
||||
<colgroup>
|
||||
<col width="92%" />
|
||||
<col width="8%" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="area-selected">指定地区</th>
|
||||
<th class="area-btn"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="2" class="text-color add-distribution js-add-record">选择地区</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick=" window.history.go(-1);">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" value='{$area_level}' id="area_level"/><!-- 配送地区等级 -->
|
||||
<input type="hidden" value="" id="surplus_area_ids">
|
||||
<input type="hidden" value="" id="freeshipping_id">
|
||||
|
||||
<script type='text/javascript' src='SHOP_JS/freeshipping_template.js'></script>
|
||||
160
addon/freeshipping/shop/view/freeshipping/edit.html
Executable file
160
addon/freeshipping/shop/view/freeshipping/edit.html
Executable file
@@ -0,0 +1,160 @@
|
||||
|
||||
|
||||
<style>
|
||||
.area-modal{
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
padding: 25px 0;
|
||||
}
|
||||
.area-modal .area-list{
|
||||
width: 255px;
|
||||
height: 375px;
|
||||
align-items: center;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
.area-modal .title{
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
text-align: center;
|
||||
}
|
||||
.area-modal .add{
|
||||
background-color: transparent;
|
||||
border: 1px solid #ccc;
|
||||
padding: 5px 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.area-modal .box{
|
||||
overflow-y: auto;
|
||||
padding: 10px 0;
|
||||
height: 340px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.modal-operation{
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 50px;
|
||||
}
|
||||
.area-list .box{
|
||||
height: 314px;
|
||||
margin: 10px 0;
|
||||
overflow-y:auto;
|
||||
overflow-x:hidden;
|
||||
}
|
||||
.area-list .box ul li{
|
||||
line-height: 30px;
|
||||
cursor: pointer;
|
||||
background-color:#fff;
|
||||
}
|
||||
.area-list .box ul li .title-div{
|
||||
position:relative;
|
||||
padding-left:20px;
|
||||
}
|
||||
.area-list .box ul li[data-level='2'] .title-div{
|
||||
margin-left:10px;
|
||||
}
|
||||
.area-list .box ul li[data-level='3'] .title-div{
|
||||
margin-left:20px;
|
||||
}
|
||||
.area-list .box ul li[data-level='4'] .title-div{
|
||||
margin-left:30px;
|
||||
}
|
||||
.area-list.all-area .box ul li.selected{
|
||||
background: #d7d7d7;
|
||||
}
|
||||
.area-list .area-btn,.area-list .area-btn-null,.area-list .area-delete{
|
||||
position:absolute;
|
||||
top:9px;
|
||||
display:block;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
border-radius: 50%;
|
||||
background-color: #d7d7d7;
|
||||
color: #fff;
|
||||
line-height: 15px;
|
||||
text-align: center;
|
||||
cursor: pointer;
|
||||
}
|
||||
.area-list .area-btn{
|
||||
left:3px;
|
||||
}
|
||||
.area-list .area-btn-null{
|
||||
background-color:transparent;
|
||||
left:3px;
|
||||
}
|
||||
.area-list .area-delete{
|
||||
right:6px;
|
||||
}
|
||||
.area-list.all-area .area-delete{
|
||||
display:none;
|
||||
}
|
||||
.area-list.all-area .area-btn.selected{
|
||||
background-color: #fff;
|
||||
color: #d7d7d7;
|
||||
}
|
||||
.right-opt {
|
||||
float: right;
|
||||
}
|
||||
.right-opt span {
|
||||
cursor: pointer;
|
||||
}
|
||||
.bg-color-gray {
|
||||
background-color: #E5E5E5!important;
|
||||
}
|
||||
.area-table {width: 800px;}
|
||||
.layui-table .area-selected {border-right: 0;}
|
||||
.layui-table .area-btn {border-left: 0;}
|
||||
</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 value="{$info['price']}" name="price" type="number" min="0" placeholder="请输入金额" lay-verify="required" class="layui-input len-long" autocomplete="off">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>指定地区:</label>
|
||||
<div class="layui-input-block area-table">
|
||||
<table id="distributionArea" class="layui-table">
|
||||
<colgroup>
|
||||
<col width="92%" />
|
||||
<col width="8%" />
|
||||
</colgroup>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="area-selected">指定地区</th>
|
||||
<th class="area-btn"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr data-selected="1">
|
||||
<td class="area-selected">
|
||||
<p class="area-show">{$info.area_names}</p>
|
||||
</td>
|
||||
<td class="area-btn">
|
||||
<span class="right-opt">
|
||||
<span class="opt-update text-color" data-selected="1">修改</span>
|
||||
</span>
|
||||
</td>
|
||||
<input type="hidden" value="{$info.area_ids}" data-selected="1" class="area_ids" data-name="{$info.area_names}">
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick=" window.history.go(-1);">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" value="{$info['freeshipping_id']}" id="freeshipping_id"/><!-- 模板id 添加为0 -->
|
||||
<input type="hidden" value="{$area_level}" id="area_level"/><!-- 配送地区等级 -->
|
||||
<input type="hidden" value="0" id="opt_total"/><!-- 模板项的总数 在修改的时候作为操作序列的起点 -->
|
||||
<input type="hidden" value="{$info['surplus_area_ids']}" id="surplus_area_ids"/>
|
||||
|
||||
<script type='text/javascript' src='SHOP_JS/freeshipping_template.js'></script>
|
||||
164
addon/freeshipping/shop/view/freeshipping/lists.html
Executable file
164
addon/freeshipping/shop/view/freeshipping/lists.html
Executable file
@@ -0,0 +1,164 @@
|
||||
<style>
|
||||
.layui-table-cell{
|
||||
height:auto;
|
||||
overflow:visible;
|
||||
text-overflow:inherit;
|
||||
white-space:normal;
|
||||
}
|
||||
.layui-layout-admin .single-filter-box{padding: 0;}
|
||||
</style>
|
||||
|
||||
<!-- 搜索框 -->
|
||||
<div class="single-filter-box">
|
||||
<button class="layui-btn" onclick="add()">添加满额包邮规则</button>
|
||||
</div>
|
||||
|
||||
<div class="layui-tab table-tab" lay-filter="groupbuy_tab">
|
||||
|
||||
<div class="layui-tab-content">
|
||||
<table id="freeshipping_list" lay-filter="freeshipping_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn" lay-event="del">删除</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
layui.use(['form', 'element'], function() {
|
||||
var table,
|
||||
form = layui.form,
|
||||
element = layui.element,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
element.on('tab(groupbuy_tab)', function() {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': this.getAttribute('data-status')
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#freeshipping_list',
|
||||
url: ns.url("freeshipping://shop/freeshipping/lists"),
|
||||
cols: [
|
||||
[{
|
||||
field: 'area_names',
|
||||
title: '包邮地区',
|
||||
unresize: 'false',
|
||||
width: '63%'
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '包邮金额',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
align: 'right',
|
||||
templet: function(data) {
|
||||
return '¥'+ data.price;
|
||||
}
|
||||
}, {
|
||||
title: '创建时间',
|
||||
unresize: 'false',
|
||||
width: '17%',
|
||||
templet: function(data) {
|
||||
return ns.time_to_date(data.create_time);
|
||||
}
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align : 'right'
|
||||
}]
|
||||
],
|
||||
|
||||
});
|
||||
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
|
||||
//监听Tab切换
|
||||
element.on('tab(status)', function(data) {
|
||||
var status = $(this).attr("data-status");
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'status': status
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'edit': //编辑
|
||||
location.hash = ns.hash("freeshipping://shop/freeshipping/edit", {"freeshipping_id": data.freeshipping_id});
|
||||
break;
|
||||
case 'del': //删除
|
||||
deleteFreeshipping(data.freeshipping_id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function deleteFreeshipping(freeshipping_id) {
|
||||
layer.confirm('确定要删除吗?', function(index) {
|
||||
if (repeat_flag) return;
|
||||
repeat_flag = true;
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("freeshipping://shop/freeshipping/delete"),
|
||||
data: {
|
||||
freeshipping_id: freeshipping_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 add() {
|
||||
location.hash = ns.hash("freeshipping://shop/freeshipping/add");
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user