初始上传
This commit is contained in:
936
addon/pointexchange/shop/view/exchange/add.html
Executable file
936
addon/pointexchange/shop/view/exchange/add.html
Executable file
@@ -0,0 +1,936 @@
|
||||
<style>
|
||||
.gift-box .layui-form{padding: 0!important;}
|
||||
.exchange-coupon, .exchange-red-packet {display: none;}
|
||||
.form-wrap{margin-top: 0;}
|
||||
.exchange-type {padding: 0 20px; position: relative;}
|
||||
.exchange-type i{position: absolute;bottom: -10px;right: -1px;display: none;}
|
||||
.exchange-type.border-color i{display: block;}
|
||||
|
||||
.layui-input {display: inline-block;}
|
||||
.text-empty {color: #454545;}
|
||||
.js-coupon-discount{display: none;}
|
||||
.layui-table-body{max-height: 480px !important;}
|
||||
.gift-box .layui-table-body{max-height: 350px !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;}
|
||||
.prompt-block .prompt-box{
|
||||
top:unset;bottom:30px;left:-85px;
|
||||
}
|
||||
.layui-table-cell{overflow:inherit;}
|
||||
.layui-table-box{overflow:inherit;}
|
||||
.layui-table-header{overflow:inherit;}
|
||||
.prompt-block .prompt-box:before{
|
||||
transform:rotate(-90deg);left:84px;top:104px;
|
||||
}
|
||||
.prompt-block .prompt-box:after{
|
||||
transform:rotate(-90deg);left:84px;top:103px;
|
||||
}
|
||||
.delivery_model{width:20%;display: inline-block;}
|
||||
.layui-input-block{margin-bottom:16px;}
|
||||
.print.delivery_model .layui-anim-upbit{z-index:1000}
|
||||
.goods_num {padding-left: 20px;}
|
||||
</style>
|
||||
|
||||
<div class="form-wrap">
|
||||
<div class="layui-form">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">兑换类型:</label>
|
||||
<div class="layui-input-block">
|
||||
<button class="layui-btn layui-btn-primary exchange-type border-color" id="gift_btn">商品<i class="iconfont iconxuanzhong text-color"></i></button>
|
||||
<button class="layui-btn layui-btn-primary exchange-type" id="coupon_btn">优惠券<i class="iconfont iconxuanzhong text-color"></i></button>
|
||||
<button class="layui-btn layui-btn-primary exchange-type" id="red_packet_btn">红包<i class="iconfont iconxuanzhong text-color"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 商品 -->
|
||||
<div class="exchange-gift layui-form content">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否上架:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="state" lay-skin="switch" value="1" lay-filter="state" checked>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否免邮:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="is_free_shipping" value="1" lay-filter="shipping" checked class="shipping" lay-skin="switch">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item ems_block" style="display:none;padding-left:100px;">
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="delivery_type" title="按照商品设置" lay-skin="primary" lay-filter="delivery_type" class="delivery_type" value="2">
|
||||
<div class="word-aux" style="margin-left: 28px;margin-top: 0">
|
||||
<p>如果选择按照商品设置,那么积分商城商品将会根据商品中设置的运费模版进行</p>
|
||||
<p>计算运费</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="delivery_type" title="固定运费" lay-skin="primary" lay-filter="delivery_type" class="delivery_type" value="0">
|
||||
<input class="layui-input len-short print" type="number" style="display:none;" name="delivery_price" onblur="checkInput(this)">
|
||||
<div class="word-aux" style="margin-left: 28px;margin-top: 0">
|
||||
<p>如果选择固定运费,积分商城的商品无论购买几件,将会按照设置的固定运费收取,</p>
|
||||
<p>如:固定运费设置为12元,客户兑换A商品时无论一次兑换几件,运费都是12元.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="delivery_type" title="运费模版" lay-skin="primary" lay-filter="delivery_type" class="delivery_type layui-form-label" value="1">
|
||||
<div class="print delivery_model" style="display:none;">
|
||||
<select name="shipping_template" lay-filter="delivery_model">
|
||||
<option value="0">请选择运费模版</option>
|
||||
{foreach name="$express_template_list" item="vo"}
|
||||
<option value="{$vo['template_id']}">{$vo['template_name']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
<div class="word-aux" style="margin-left: 28px;margin-top: 0">
|
||||
<p>如果选择运费模版,积分商城的商品将会按照该处选择的运费模版进行单独计算</p>
|
||||
<p>运费,与商品本身设置的是否包邮以及运费模版无关.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">兑换规则:</label>
|
||||
<div class="layui-input-block special-length">
|
||||
<script id="containerG" name="containerG" type="text/plain" style="width:100%;height:500px;"></script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item goods_list">
|
||||
<label class="layui-form-label"><span class="required">*</span>商品选择:</label>
|
||||
<div class="layui-input-block layui-form">
|
||||
<table id="selected_goods_list" lay-filter="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>
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save_gift">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backPointExchangeList()">返回</button>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="sku_id">
|
||||
<input type="hidden" name="type" value="1">
|
||||
</div>
|
||||
|
||||
<!-- 优惠券 -->
|
||||
<div class="exchange-coupon content layui-form">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>选择优惠券:</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="upload-img-block square">
|
||||
<div class="upload-img-box upload-coupon" id="coupon_img" lay-verify="select">
|
||||
<div class="upload-default">
|
||||
<i class="iconfont iconshangchuan"></i>
|
||||
<p>选择优惠券</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">优惠券名称:</label>
|
||||
<div class="layui-input-block" id="coupon_name">
|
||||
<p class="input-text text-empty">优惠券名称</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item js-coupon-price">
|
||||
<label class="layui-form-label">优惠券面值(元):</label>
|
||||
<div class="layui-input-block" id="coupon_price">
|
||||
<p class="input-text text-empty">¥0.00</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item js-coupon-discount">
|
||||
<label class="layui-form-label">优惠券折扣:</label>
|
||||
<div class="layui-input-block" id="coupon_discount">
|
||||
<p class="input-text text-empty">0.00折</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>兑换积分:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="point" min="0" lay-verify="required|required_point" placeholder="兑换积分数" value="0" onchange="detectionNumType(this,'integral')" class="layui-input len-short expoint">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>可兑换数量:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="stock" min="0" lay-verify="required|required_coupon_stock" placeholder="可兑换数量" value="" onchange="detectionNumType(this,'integral')" class="layui-input len-short stock">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否上架:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="state" lay-skin="switch" value="1" lay-filter="state" checked>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">兑换规则:</label>
|
||||
<div class="layui-input-block special-length">
|
||||
<script id="container" name="content" type="text/plain" style="width: 800px; height: 300px;"></script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save_coupon">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backPointExchangeList()">返回</button>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="coupon_type_id">
|
||||
<input type="hidden" name="type" value="2">
|
||||
</div>
|
||||
|
||||
<!-- 红包 -->
|
||||
<div class="exchange-red-packet content layui-form">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="name" lay-verify="required" placeholder="请输入红包名称" value="" class="layui-input len-long">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">红包封面:</label>
|
||||
<div class="layui-input-inline img-upload">
|
||||
<div class="upload-img-block icon square">
|
||||
<div class="upload-img-box" >
|
||||
<div class="upload-default" id="redPacket">
|
||||
<div class="upload">
|
||||
<i class="iconfont iconshangchuan"></i>
|
||||
<p>点击上传</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="operation">
|
||||
<div>
|
||||
<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
|
||||
<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
|
||||
</div>
|
||||
<div class="replace_img js-replace">点击替换</div>
|
||||
</div>
|
||||
<input type="hidden" name="image" />
|
||||
</div>
|
||||
<!-- <p id="redPacket" class="no-replace">替换</p>
|
||||
<input type="hidden" name="image" />
|
||||
<i class="del">x</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="number" name="point" min="0" lay-verify="required|required_point" placeholder="兑换积分数" value="0" onchange="detectionNumType(this,'integral')" class="layui-input len-short expoint">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>可兑换数量:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="stock" min="0" lay-verify="required|required_balance_stock" placeholder="可兑换数量" value="" onchange="detectionNumType(this,'integral')" class="layui-input len-short stock">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>余额:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="balance" min="0" lay-verify="required|required_balance" placeholder="红包余额" value="" onchange="detectionNumType(this,'positiveNumber')" class="layui-input len-short">
|
||||
</div>
|
||||
<p class="word-aux">兑换的红包会以余额的形式发放给指定会员</p>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否上架:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="state" lay-skin="switch" value="1" lay-filter="state" checked>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">兑换规则:</label>
|
||||
<div class="layui-input-block special-length">
|
||||
<script id="containerT" name="content" type="text/plain" style="width: 800px; height: 300px;"></script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backPointExchangeList()">返回</button>
|
||||
</div>
|
||||
<input type="hidden" name="type" value="3">
|
||||
<input type="hidden" name="" id="redPacketContent" value="" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a id="redPacketImage"></a>
|
||||
|
||||
<script type="text/html" id="toolbarOperation">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="change-number">兑换次数</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="goods-integral">所需积分</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="goods-price">所需金额</button>
|
||||
</script>
|
||||
|
||||
<!-- 商品操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" onclick="delGoods(this,{{d.sku_id}})">删除</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="exchangePoint">
|
||||
<input type="number" class="layui-input len-input exchange_point expoint" onchange="setSkulist('point', {{d.sku_id}}, this , 'integral')" value="{{d.point ? d.point : 0.00}}" lay-verify="exchange_point" min="0.00"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="exchangeLimit">
|
||||
<input type="number" class="layui-input len-input exchange_limit_num expoint" onchange="setSkulist('limit_num', {{d.sku_id}}, this, 'integral')" value="{{d.limit_num ? d.limit_num : 0}}" lay-verify="exchange_point" min="0.00"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="exchangeMoney">
|
||||
<input type="number" class="layui-input len-input exchange_money" value="{{d.exchange_price ? d.exchange_price : 0.00}}" lay-verify="exchange_money" min="0.00" onchange="setSkulist('exchange_price', {{d.sku_id}}, this, 'positiveNumber')"/>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="ems_price">
|
||||
<div>
|
||||
<input type="checkbox" name="delivery_type" lay-filter="is_set_ems" data-id="{{d.sku_id}}" onclick="setSkulist('delivery_type', {{d.sku_id}}, this, 'integral')" lay-skin="primary" checked>单独设置
|
||||
<input type="number" class="set_{{d.sku_id}} layui-input len-input" style="width:50%;margin-left:5%;" onchange="setSkulist('delivery_price', {{d.sku_id}}, this, 'integral')" value="0">
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/ueditor.config.js?time=20240614"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/ueditor.all.js?time=20240614"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/lang/zh-cn/zh-cn.js"></script>
|
||||
|
||||
<script>
|
||||
var giftTable, couponTable, form, laytpl;
|
||||
var goods_id = [], selectedGoodsId = [], sku_list = [];
|
||||
var saveData = null;
|
||||
var totalUploadNum = 0;
|
||||
var completeUploadNum = 0;
|
||||
var coupon_type_id = 0;
|
||||
|
||||
//实例化富文本
|
||||
var ue = UE.getEditor('container'),
|
||||
ue_t = UE.getEditor('containerT'),
|
||||
ue_g = UE.getEditor('containerG'),
|
||||
html = '';
|
||||
|
||||
// 已经添加的兑换列表
|
||||
var gift_list = [];
|
||||
var coupon_list = [];
|
||||
$.ajax({
|
||||
url: ns.url("pointexchange://shop/exchange/lists"),
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function(res) {
|
||||
|
||||
var data = res.data.list;
|
||||
for (var i=0; i<data.length; i++) {
|
||||
if (data[i].type == 1) {
|
||||
gift_list.push(data[i].type_id);
|
||||
}
|
||||
if (data[i].type == 2) {
|
||||
coupon_list.push(data[i].type_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$("#coupon_img").on('click', function (){
|
||||
ns.selectCoupon({
|
||||
select_id:coupon_type_id,
|
||||
max_num:1,
|
||||
min_num:1,
|
||||
success:function (res){
|
||||
coupon_type_id = res[0].coupon_type_id;
|
||||
addcoupon(res[0]);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
function addcoupon(data){
|
||||
var img_path = ns.img(data.image);
|
||||
$("#coupon_name").html("<p class='input-text'>"+data.coupon_name+"</p>");
|
||||
if (data.image) {
|
||||
$("#coupon_img").html('<img src="'+ img_path +'" />');
|
||||
} else {
|
||||
$("#coupon_img").html('<img src="__STATIC__/img/coupon_default.png" />');
|
||||
}
|
||||
if(data.type == "reward"){
|
||||
$(".js-coupon-price").show();
|
||||
$(".js-coupon-discount").hide();
|
||||
$("#coupon_price").html("<p class='input-text'>¥"+data.money+"</p>");
|
||||
}else{
|
||||
$(".js-coupon-price").hide();
|
||||
$(".js-coupon-discount").show();
|
||||
$("#coupon_discount").html("<p class='input-text'>"+data.discount+"折</p>");
|
||||
}
|
||||
$("input[name=coupon_type_id]").val(data.coupon_type_id);
|
||||
}
|
||||
|
||||
layui.use(['form', 'laytpl'], function(){
|
||||
form = layui.form;
|
||||
laytpl = layui.laytpl;
|
||||
form.render();
|
||||
|
||||
renderTable(sku_list);
|
||||
|
||||
$(".exchange-type").click(function() {
|
||||
$(this).addClass("border-color");
|
||||
$(this).siblings("button").removeClass("border-color");
|
||||
|
||||
if ($(this).index() == 0) {
|
||||
$(".exchange-gift").show();
|
||||
$(".exchange-coupon").hide();
|
||||
$(".exchange-red-packet").hide();
|
||||
} else if ($(this).index() == 1) {
|
||||
$(".exchange-coupon").show();
|
||||
$(".exchange-gift").hide();
|
||||
$(".exchange-red-packet").hide();
|
||||
} else if ($(this).index() == 2) {
|
||||
$(".exchange-red-packet").show();
|
||||
$(".exchange-gift").hide();
|
||||
$(".exchange-coupon").hide();
|
||||
}
|
||||
});
|
||||
|
||||
var upload = new Upload({
|
||||
elem: '#redPacket',
|
||||
auto:false,
|
||||
bindAction:'#redPacketImage',
|
||||
callback: function(res) {
|
||||
uploadComplete('image', res.data.pic_path);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 商品列表搜索
|
||||
*/
|
||||
form.on('submit(gift-search)', function(data) {
|
||||
giftTable.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
|
||||
form.on('switch(shipping)', function(data){
|
||||
if(data.elem.checked){
|
||||
$(".ems_block").hide();
|
||||
}else{
|
||||
$(".ems_block").show();
|
||||
}
|
||||
});
|
||||
|
||||
//监听邮费设置
|
||||
form.on('checkbox(delivery_type)', function(data){
|
||||
if(data.elem.checked){
|
||||
$("input[name='delivery_type']").prop("checked", false);
|
||||
$(this).prop("checked", true);
|
||||
form.render('checkbox');
|
||||
$(this).siblings(".print").show();
|
||||
$(this).parent().siblings().children(".print").hide()
|
||||
}else{
|
||||
$(this).siblings(".print").hide();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听表单提交
|
||||
*/
|
||||
form.on('submit(save_gift)', function(data) {
|
||||
if(goodsVerify()) {
|
||||
var sku_ids = [];
|
||||
var goods_data = [];
|
||||
|
||||
$.each(sku_list, function (i, e) {
|
||||
var goods = {};
|
||||
goods.goods_id = e.goods_id;
|
||||
sku_ids.push(e.sku_id);
|
||||
if(goods_data.length == 0){
|
||||
goods_data.push(goods);
|
||||
}else {
|
||||
$.each(goods_data, function(index, event){
|
||||
if(goods_data.length == index+1 && event.goods_id != goods.goods_id){
|
||||
goods_data.push(goods);
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
|
||||
if (sku_ids.length == 0) {
|
||||
layer.msg('请选择兑换商品', {icon: 5, anim: 6});
|
||||
return;
|
||||
}
|
||||
|
||||
$.each(goods_data, function (i, e) {
|
||||
goods_data[i]['sku_list'] = [];
|
||||
$.each(sku_list, function (index, event) {
|
||||
if(event.goods_id == e.goods_id) {
|
||||
goods_data[i]['sku_list'].push(event);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
ue_g.ready(function() { //对编辑器的操作最好在编辑器ready之后再做
|
||||
html = ue_g.getContent(); //获取html内容,返回: <p>hello</p>
|
||||
});
|
||||
|
||||
data.field.content = html;
|
||||
|
||||
data.field.goods_data = goods_data;
|
||||
|
||||
if (data.field.state == undefined) {
|
||||
data.field.state = 0;
|
||||
}
|
||||
saveData = data;
|
||||
ajax_save();
|
||||
}
|
||||
});
|
||||
|
||||
form.on('submit(save_coupon)', function(data) {
|
||||
var _val = $("input[name='coupon_type_id']").val();
|
||||
if (!_val) {
|
||||
layer.msg('请选择兑换优惠券', {icon: 5, anim: 6});
|
||||
return;
|
||||
}
|
||||
|
||||
if (data.field.state == undefined) {
|
||||
data.field.state = 0;
|
||||
}
|
||||
|
||||
ue.ready(function() { //对编辑器的操作最好在编辑器ready之后再做
|
||||
html = ue.getContent(); //获取html内容,返回: <p>hello</p>
|
||||
});
|
||||
|
||||
data.field.content = html;
|
||||
saveData = data;
|
||||
ajax_save();
|
||||
});
|
||||
|
||||
form.on('submit(save)', function(data) {
|
||||
if (data.field.state == undefined) {
|
||||
data.field.state = 0;
|
||||
}
|
||||
|
||||
ue_t.ready(function() { //对编辑器的操作最好在编辑器ready之后再做
|
||||
html = ue_t.getContent(); //获取html内容,返回: <p>hello</p>
|
||||
});
|
||||
|
||||
data.field.content = html;
|
||||
|
||||
// 删除图片
|
||||
// if(!data.field.image) upload.delete();
|
||||
|
||||
saveData = data;
|
||||
var obj = $("img.img_prev[data-prev='1']");
|
||||
totalUploadNum = obj.length;
|
||||
if(totalUploadNum > 0){
|
||||
obj.each(function(){
|
||||
var actionId = $(this).attr('data-action-id');
|
||||
$(actionId).click();
|
||||
})
|
||||
}else{
|
||||
ajax_save();
|
||||
}
|
||||
});
|
||||
|
||||
function uploadComplete(field, pic_path) {
|
||||
saveData.field[field] = pic_path;
|
||||
completeUploadNum += 1;
|
||||
if(completeUploadNum == totalUploadNum){
|
||||
ajax_save();
|
||||
}
|
||||
}
|
||||
|
||||
function goodsVerify(){
|
||||
for (var i in sku_list){
|
||||
if (parseFloat(sku_list[i]['point']) <= 0) {
|
||||
layer.msg('兑换积分不能小于等于0', {icon: 5, anim: 6});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function ajax_save() {
|
||||
var data = saveData.field;
|
||||
// 删除图片
|
||||
if(!data.image) upload.delete();
|
||||
|
||||
var type = $('.exchange-type .border-color').attr('id');
|
||||
if (type == 'gift_btn') {
|
||||
//不免邮
|
||||
if(data.is_free_shipping==undefined){
|
||||
data.is_free_shipping = 0;
|
||||
}
|
||||
if(data.is_free_shipping == 0 && data.type == 1){
|
||||
if(data.delivery_type==undefined){
|
||||
layer.msg('请选择运费类型', {icon: 5, anim: 6});
|
||||
return false;
|
||||
}else if(data.delivery_type==0){
|
||||
if(data.delivery_price==""){
|
||||
layer.msg('请填写固定邮费', {icon: 5, anim: 6});
|
||||
return false;
|
||||
}
|
||||
}else if(data.delivery_type==1){
|
||||
if(data.shipping_template<=0){
|
||||
layer.msg('请选择运费模版', {icon: 5, anim: 6});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
data.delivery_type = "";
|
||||
data.delivery_price = "";
|
||||
data.shipping_template = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("pointexchange://shop/exchange/add"),
|
||||
data: data,
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function (res) {
|
||||
if (res.code == 0) {
|
||||
layer.confirm('添加成功', {
|
||||
title:'操作提示',
|
||||
btn: ['返回列表', '继续添加'],
|
||||
closeBtn: 0,
|
||||
yes: function(index, layero){
|
||||
location.hash = ns.hash("pointexchange://shop/exchange/lists")
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.message, {icon: 5, anim: 6});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//监听兑换方式
|
||||
form.on('radio(pay_type)', function(data){
|
||||
var value = data.value;
|
||||
var html = '';
|
||||
if(value == 1){
|
||||
html = '<input type="number" name="point" min="0" lay-verify="required_point" autocomplete="off" class="layui-input len-short"> 积分' +
|
||||
' + <input type="number" name="price" min="0" lay-verify="required_money" autocomplete="off" class="layui-input len-short"> 元';
|
||||
}
|
||||
if(value == 0){
|
||||
html = '<input type="number" name="point" min="0" lay-verify="required" autocomplete="off" class="layui-input len-short"> 积分';
|
||||
}
|
||||
$('.pay_price').html(html);
|
||||
});
|
||||
|
||||
form.verify({
|
||||
required_point: function(value) {
|
||||
if (value == "") {
|
||||
return '积分不能为空';
|
||||
}
|
||||
if (Number(value) <= 0){
|
||||
return '积分必须大于0!';
|
||||
}
|
||||
},
|
||||
required_money: function(value) {
|
||||
if (value == "") {
|
||||
return '金额不能为空';
|
||||
}
|
||||
if (Number(value) <= 0){
|
||||
return '价格必须大于0!';
|
||||
}
|
||||
},
|
||||
required_limit: function(value) {
|
||||
if (Number(value) < 1){
|
||||
return '兑换限制不能小于1!';
|
||||
}
|
||||
},
|
||||
required_coupon_stock: function(value) {
|
||||
if (Number(value) <= 0){
|
||||
return '可兑换数量必须大于0!';
|
||||
}
|
||||
},
|
||||
required_balance_stock: function(value) {
|
||||
if (Number(value) <= 0){
|
||||
return '可兑换数量必须大于0!';
|
||||
}
|
||||
},
|
||||
required_balance: function(value) {
|
||||
if (Number(value) <= 0){
|
||||
return '红包余额必须大于0!';
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function delGoods(obj,id) {
|
||||
var goods_ids = [];
|
||||
for (let i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == parseInt(id)){
|
||||
sku_list.splice(i,1);
|
||||
}
|
||||
}
|
||||
for (let i = 0; i < sku_list.length; i++){
|
||||
goods_ids.push(sku_list[i].goods_id);
|
||||
}
|
||||
$(obj).parents("tr").remove();
|
||||
$("#goods_num").html(sku_list.length);
|
||||
selectedGoodsId = goods_ids.toString();
|
||||
}
|
||||
|
||||
// 表格渲染
|
||||
function renderTable(sku_list) {
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#selected_goods_list',
|
||||
page: false,
|
||||
limit: Number.MAX_VALUE,
|
||||
cols: [
|
||||
[{
|
||||
width: "3%",
|
||||
type: 'checkbox',
|
||||
unresize: 'false'
|
||||
},{
|
||||
field: 'sku_name',
|
||||
title: '商品名称',
|
||||
width: '23%',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
html += `
|
||||
<div class="goods-title">
|
||||
<div class="goods-img">
|
||||
<img layer-src src="${data.sku_image ? ns.img(data.sku_image) : ''}" alt="">
|
||||
</div>
|
||||
<p class="multi-line-hiding goods-name" data-goods_id="${data.goods_id}" data-sku_id="${data.sku_id}" title="${data.sku_name}">${data.sku_name}</p>
|
||||
</div>
|
||||
`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格',
|
||||
unresize: 'false',
|
||||
align: 'left',
|
||||
width: '10%',
|
||||
templet: function(data) {
|
||||
return '<p class="line-hiding" title="'+ data.price +'">¥<span>' + data.price +'</span></p>';
|
||||
}
|
||||
}, {
|
||||
field: 'stock',
|
||||
title: '库存',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function(data) {
|
||||
return '<p class="stock">' + data.stock +'</p>';
|
||||
}
|
||||
}, {
|
||||
title: '<span title="兑换次数(0为不限次)">兑换次数(0为不限次)</span>',
|
||||
unresize: 'false',
|
||||
width: '14%',
|
||||
templet: '#exchangeLimit'
|
||||
}, {
|
||||
title: '<span title="兑换所需积分">所需积分</span>',
|
||||
unresize: 'false',
|
||||
width: '12%',
|
||||
templet: '#exchangePoint'
|
||||
}, {
|
||||
title: '<span title="兑换所需金额">所需金额</span>',
|
||||
unresize: 'false',
|
||||
width: '12%',
|
||||
templet: '#exchangeMoney'
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
],
|
||||
callback:function(){
|
||||
form.render();
|
||||
},
|
||||
data: sku_list,
|
||||
toolbar: '#toolbarOperation'
|
||||
});
|
||||
|
||||
table.toolbar(function(obj) {
|
||||
|
||||
if (obj.data.length < 1) {
|
||||
layer.msg('请选择要操作的数据');
|
||||
return;
|
||||
}
|
||||
switch (obj.event) {
|
||||
case "change-number":
|
||||
editInput(0,obj);
|
||||
break;
|
||||
case "goods-integral":
|
||||
editInput(1,obj);
|
||||
break;
|
||||
case "goods-price":
|
||||
editInput(2,obj);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
function editInput(textIndex=0,data) {
|
||||
var text = [{
|
||||
name: '兑换次数',
|
||||
value: 'limit_num',
|
||||
type: 'integral',
|
||||
},{
|
||||
name: '所需积分',
|
||||
value: 'point',
|
||||
type: 'integral',
|
||||
},{
|
||||
name: '所需金额',
|
||||
value: 'exchange_price',
|
||||
type: 'positiveNumber',
|
||||
}];
|
||||
layer.open({
|
||||
type: 1,
|
||||
title:"修改"+text[textIndex].name,
|
||||
area:['600px'],
|
||||
btn:["保存","返回"],
|
||||
content: `
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>${text[textIndex].name}:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="bargain_edit_input" lay-verify="required" autocomplete="off" onchange="detectionNumType(this,'${text[textIndex].type}')" class="layui-input len-mid" placeholder="请输入${text[textIndex].name}">
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
yes: function(index, layero){
|
||||
var val = $("input[name='bargain_edit_input']").val();
|
||||
if (!val){
|
||||
layer.msg("请输入" + text[textIndex].name);
|
||||
return false;
|
||||
}
|
||||
data.data.forEach(function (item,index) {
|
||||
sku_list.forEach(function (skuItem,skuIndex) {
|
||||
if (item.sku_id == skuItem.sku_id){
|
||||
sku_list[skuIndex][text[textIndex].value] = val;
|
||||
}
|
||||
})
|
||||
});
|
||||
renderTable(sku_list);
|
||||
layer.closeAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* 商品 */
|
||||
function addGoods(){
|
||||
goodsSelect(function (data) {
|
||||
|
||||
goods_id = [];
|
||||
sku_list = [];
|
||||
|
||||
for (var key in data) {
|
||||
for (var sku in data[key].sku_list) {
|
||||
var item = data[key].sku_list[sku];
|
||||
item.exchange_price = 0;
|
||||
item.point = 0;
|
||||
item.limit_num = 0;
|
||||
goods_id.push(item.goods_id);
|
||||
sku_list.push(item);
|
||||
}
|
||||
}
|
||||
renderTable(sku_list);
|
||||
selectedGoodsId = goods_id;
|
||||
$("#goods_num").html(sku_list.length)
|
||||
}, selectedGoodsId);
|
||||
}
|
||||
|
||||
function setSkulist(type, sku_id, obj,num_type){
|
||||
var value = $(obj).val();
|
||||
//大于零 且 不是小数
|
||||
if (value < 0 && num_type == 'integral')
|
||||
$(obj).val(0);
|
||||
else if (num_type == 'integral')
|
||||
$(obj).val(Math.round(value));
|
||||
|
||||
//大于1 且 不是小数
|
||||
if (value < 1 && num_type == 'positiveInteger')
|
||||
$(obj).val(1);
|
||||
else if (num_type == 'positiveInteger')
|
||||
$(obj).val(Math.round(value));
|
||||
//大于零可以是小数
|
||||
if (num_type == 'positiveNumber') {
|
||||
value = parseFloat(value).toFixed(2);
|
||||
if (value < 0)
|
||||
$(obj).val(0);
|
||||
else
|
||||
$(obj).val(value);
|
||||
}
|
||||
$.each(sku_list, function (i, e) {
|
||||
if(sku_id == e.sku_id){
|
||||
sku_list[i][type] = $(obj).val();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//返回
|
||||
function backPointExchangeList() {
|
||||
location.hash = ns.hash("pointexchange://shop/exchange/lists");
|
||||
}
|
||||
$("body").off('keyup', '.stock').on('keyup', '.stock', function() {
|
||||
var value = $(this).val();
|
||||
if(value % 1 !== 0){
|
||||
layer.msg("红包数量请输入整数");
|
||||
$(this).val(0);
|
||||
}
|
||||
});
|
||||
|
||||
$("body").off('keyup', '.expoint').on('keyup', '.expoint', function() {
|
||||
var value = $(this).val() ;
|
||||
if(value % 1 !== 0){
|
||||
layer.msg("兑换积分请输入整数");
|
||||
$(this).val(0);
|
||||
}
|
||||
});
|
||||
|
||||
//检测数据类型
|
||||
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')
|
||||
$(el).val(Math.round(value));
|
||||
//大于零可以是小数
|
||||
if (type == 'positiveNumber') {
|
||||
value = parseFloat(value).toFixed(2);
|
||||
if (value < 0)
|
||||
$(el).val(0);
|
||||
else
|
||||
$(el).val(value);
|
||||
}
|
||||
}
|
||||
function checkInput(obj){
|
||||
$(obj).val(Math.abs($(obj).val()));
|
||||
}
|
||||
</script>
|
||||
858
addon/pointexchange/shop/view/exchange/edit.html
Executable file
858
addon/pointexchange/shop/view/exchange/edit.html
Executable file
@@ -0,0 +1,858 @@
|
||||
<style>
|
||||
.gift-box{padding: 20px;}
|
||||
.gift-box .layui-form{padding: 0!important;}
|
||||
.form-wrap{margin-top: 0;}
|
||||
.layui-input {display: inline-block;}
|
||||
.forbidden {cursor: not-allowed;}
|
||||
.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;}
|
||||
.forbidden{cursor:not-allowed;background-color: #eee;}
|
||||
.prompt-block .prompt-box{
|
||||
top:unset;bottom:30px;left:-85px;
|
||||
}
|
||||
.layui-table-cell{overflow:inherit;}
|
||||
.layui-table-box{overflow:inherit;}
|
||||
.layui-table-header{overflow:inherit;}
|
||||
.prompt-block .prompt-box:before{
|
||||
transform:rotate(-90deg);left:84px;top:104px;
|
||||
}
|
||||
.prompt-block .prompt-box:after{
|
||||
transform:rotate(-90deg);left:84px;top:103px;
|
||||
}
|
||||
.delivery_model{width:20%;display: inline-block;}
|
||||
.layui-input-block{margin-bottom:16px;}
|
||||
.print.delivery_model .layui-anim-upbit{z-index:1000}
|
||||
</style>
|
||||
|
||||
{if $exchange_info['type'] == 1}
|
||||
<!-- 商品 -->
|
||||
<div class="exchange-gift content layui-form form-wrap">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品图片:</label>
|
||||
<div class="layui-input-block img-upload">
|
||||
<div class="upload-img-block square">
|
||||
<div class="upload-img-box">
|
||||
{if condition="$exchange_info.image"}
|
||||
<img layer-src src="{:img($exchange_info.image)}" >
|
||||
{else/}
|
||||
<img layer-src src="__STATIC__/img/shape.png" />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">商品名称:</label>
|
||||
<div class="layui-input-block">
|
||||
<p class="input-text">{$exchange_info.name}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否上架:</label>
|
||||
<div class="layui-input-block">
|
||||
<p class="input-text len-long"><input id="state" type="checkbox" name="state" lay-skin="switch" {if $exchange_info['state'] == 1}checked {/if} value="1" lay-filter="state"></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否免邮:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="is_free_shipping" {if $exchange_info['exchange_goods'][0]['is_free_shipping'] == 1}checked {/if} value="1" lay-filter="shipping" class="shipping" lay-skin="switch" >
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item ems_block" style="display:{if $exchange_info['exchange_goods'][0]['is_free_shipping'] == 1}none{else/}block{/if};padding-left:100px;">
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="delivery_type" title="按照商品设置" lay-skin="primary" lay-filter="delivery_type" class="delivery_type" value="2" {if $exchange_info['exchange_goods'][0]['delivery_type'] == 2}checked {/if}>
|
||||
<div class="word-aux" style="margin-left: 28px;margin-top: 0">
|
||||
<p>如果选择按照商品设置,那么积分商城商品将会根据商品中设置的运费模版进行</p>
|
||||
<p>计算运费</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="delivery_type" title="固定运费" lay-skin="primary" lay-filter="delivery_type" class="delivery_type" value="0" {if $exchange_info['exchange_goods'][0]['delivery_type'] == 0}checked {/if}>
|
||||
<input class="layui-input len-short print" type="number" style="display:{if $exchange_info['exchange_goods'][0]['delivery_type'] == 0}inline-block{else/}none{/if};" name="delivery_price" {if $exchange_info['exchange_goods'][0]['delivery_type'] == 0}value="{$exchange_info['exchange_goods'][0]['delivery_price']}"{/if} onblur="checkInput(this)">
|
||||
<div class="word-aux" style="margin-left: 28px;margin-top: 0">
|
||||
<p>如果选择固定运费,积分商城的商品无论购买几件,将会按照设置的固定运费收取,</p>
|
||||
<p>如:固定运费设置为12元,客户兑换A商品时无论一次兑换几件,运费都是12元.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-input-block">
|
||||
<input type="checkbox" name="delivery_type" title="运费模版" lay-skin="primary" lay-filter="delivery_type" class="delivery_type layui-form-label" value="1" {if $exchange_info['exchange_goods'][0]['delivery_type'] == 1}checked {/if}>
|
||||
<div class="print delivery_model" style="display:{if $exchange_info['exchange_goods'][0]['delivery_type'] == 1}inline-block{else/}none{/if};">
|
||||
<select name="shipping_template" lay-filter="delivery_model">
|
||||
<option value="0">请选择运费模版</option>
|
||||
{foreach name="$express_template_list" item="vo"}
|
||||
<option value="{$vo['template_id']}" {if $exchange_info['exchange_goods'][0]['shipping_template'] == $vo['template_id']} selected {/if}>{$vo['template_name']}</option>
|
||||
{/foreach}
|
||||
</select>
|
||||
</div>
|
||||
<div class="word-aux" style="margin-left: 28px;margin-top: 0">
|
||||
<p>如果选择运费模版,积分商城的商品将会按照该处选择的运费模版进行单独计算</p>
|
||||
<p>运费,与商品本身设置的是否包邮以及运费模版无关.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">兑换规则:</label>
|
||||
<div class="layui-input-block special-length">
|
||||
<script id="containerG" name="containerG" type="text/plain" style="width:100%;height:500px;"></script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item goods_list">
|
||||
<label class="layui-form-label"><span class="required">*</span>规格选择:</label>
|
||||
<div class="layui-input-block">
|
||||
<table id="selected_goods_list" lay-filter="selected_goods_list"></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="backPointExchangeOrderList()">返回</button>
|
||||
</div>
|
||||
|
||||
<!-- 操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
{{# if (d.is_select == 1){ }}
|
||||
<a class="layui-btn no-participation" >不参与</a>
|
||||
{{# }else{ }}
|
||||
<a class="layui-btn participation" >参与</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="exchangePoint">
|
||||
{{# if (d.is_select == 1){ }}
|
||||
<input type="number" class="layui-input len-input exchange_point expoint" onchange="setSkulist('point', {{d.sku_id}}, this , 'integral')" value="{{d.point ? d.point : 0.00}}" lay-verify="exchange_point" min="0.00"/>
|
||||
{{# }else{ }}
|
||||
<input type="number" class="layui-input len-input exchange_point forbidden" disabled="disabled" onchange="setSkulist('point', {{d.sku_id}}, this, 'integral')" value="{{d.point ? d.point : 0.00}}" lay-verify="exchange_point" min="0.00"/>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="exchangeLimit">
|
||||
{{# if (d.is_select == 1){ }}
|
||||
<input type="number" class="layui-input len-input exchange_limit_num expoint" onchange="setSkulist('limit_num', {{d.sku_id}}, this, 'integral')" value="{{d.limit_num ? d.limit_num : 0}}" lay-verify="exchange_point" min="0.00"/>
|
||||
{{# }else{ }}
|
||||
<input type="number" class="layui-input len-input exchange_limit_num forbidden" disabled="disabled" onchange="setSkulist('limit_num', {{d.sku_id}}, this, 'integral')" value="{{d.limit_num ? d.limit_num : 0}}" lay-verify="exchange_point" min="0.00"/>
|
||||
{{# } }}
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="exchangeMoney">
|
||||
|
||||
{{# if (d.is_select == 1){ }}
|
||||
<input type="number" class="layui-input len-input exchange_money" onchange="setSkulist('exchange_price', {{d.sku_id}}, this, 'positiveNumber')" value="{{d.exchange_price ? d.exchange_price : 0.00}}" lay-verify="exchange_money" min="0.00"/>
|
||||
{{# }else{ }}
|
||||
<input type="number" class="layui-input len-input exchange_money forbidden" disabled="disabled" onchange="setSkulist('exchange_price', {{d.sku_id}}, this, 'positiveNumber')" value="{{d.exchange_price ? d.exchange_price : 0.00}}" lay-verify="exchange_money" min="0.00"/>
|
||||
{{# } }}
|
||||
|
||||
</script>
|
||||
<input type="hidden" name="type" value="1">
|
||||
<input type="hidden" name="id" value="{$exchange_info.id}">
|
||||
<input type="hidden" id="contentG" value="{$exchange_info.rule}" />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if $exchange_info['type'] == 2}
|
||||
<!-- 优惠券 -->
|
||||
<div class="exchange-coupon content layui-form form-wrap">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">优惠券图片:</label>
|
||||
<div class="layui-input-block img-upload">
|
||||
<div class="upload-img-block square">
|
||||
<div class="upload-img-box">
|
||||
{if condition="$exchange_info.image"}
|
||||
<img layer-src src="{:img($exchange_info.image)}" id="exchange_type_2_img">
|
||||
{else/}
|
||||
<img layer-src src="__STATIC__/img/shape.png" />
|
||||
{/if}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">优惠券名称:</label>
|
||||
<div class="layui-input-block" id="exchange_type_2_name">
|
||||
<p class="input-text">{$exchange_info.name}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{if condition="$exchange_info['coupon_type'] == 'reward'"}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">优惠券面值:</label>
|
||||
<div class="layui-input-block" id="exchange_type_2_price">
|
||||
<p class="input-text">¥{$exchange_info.market_price}</p>
|
||||
</div>
|
||||
</div>
|
||||
{elseif condition="$exchange_info['coupon_type'] == 'discount'"}
|
||||
<div class="layui-form-item js-coupon-discount">
|
||||
<label class="layui-form-label">优惠券折扣:</label>
|
||||
<div class="layui-input-block" id="coupon_discount">
|
||||
<p class="input-text text-empty">{$exchange_info.market_price}折</p>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>兑换积分:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="point" lay-verify="required|required_point" placeholder="请输入所需的兑换积分数" value="{$exchange_info.point}" onchange="detectionNumType(this,'integral')" class="layui-input len-short expoint">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>可兑换数量:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="stock" min="0" lay-verify="required|required_coupon_stock" placeholder="可兑换数量" value="{$exchange_info.stock}" onchange="detectionNumType(this,'integral')" class="layui-input len-short stock">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否上架:</label>
|
||||
<div class="layui-input-block">
|
||||
<input id="state" type="checkbox" name="state" lay-skin="switch" {if $exchange_info['state'] == 1}checked {/if} value="1" lay-filter="state">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">兑换规则:</label>
|
||||
<div class="layui-input-block special-length">
|
||||
<script id="container" name="content" type="text/plain" style="width: 800px; height: 300px;"></script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backPointExchangeOrderList()">返回</button>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="type" value="2">
|
||||
<input type="hidden" name="id" value="{$exchange_info.id}">
|
||||
<input type="hidden" name="coupon_type_id" value="{$exchange_info.type_id}">
|
||||
<input type="hidden" id="content" value="{$exchange_info.content}" />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{if $exchange_info['type'] == 3}
|
||||
<!-- 红包 -->
|
||||
<div class="exchange-red-packet content 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="name" lay-verify="required" placeholder="请输入红包名称" value="{$exchange_info.name}" class="layui-input len-long">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">红包封面:</label>
|
||||
<div class="layui-input-inline img-upload">
|
||||
<div class="upload-img-block icon square">
|
||||
<div class="upload-img-box {if condition="$exchange_info.image"}hover{/if}">
|
||||
<div class="upload-default" id="redPacket">
|
||||
{if condition="$exchange_info.image"}
|
||||
<div id="preview_redPacket" class="preview_img">
|
||||
<img src="{:img($exchange_info.image)}" alt="" class="img_prev">
|
||||
</div>
|
||||
{else/}
|
||||
<div class="upload">
|
||||
<i class="iconfont iconshangchuan"></i>
|
||||
<p>点击上传</p>
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
<div class="operation">
|
||||
<div>
|
||||
<i title="图片预览" class="iconfont iconreview js-preview" style="margin-right: 20px;"></i>
|
||||
<i title="删除图片" class="layui-icon layui-icon-delete js-delete"></i>
|
||||
</div>
|
||||
|
||||
<div class="replace_img js-replace">点击替换</div>
|
||||
</div>
|
||||
<input type="hidden" name="image" value="{$exchange_info.image}" />
|
||||
</div>
|
||||
|
||||
<!-- <p id="redPacket" class='{if condition="$exchange_info.image"}replace {else/} no-replace{/if}'>替换</p>
|
||||
<i class="del {if condition="$exchange_info.image"}show{/if}">x</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="number" name="point" lay-verify="required|required_point" placeholder="请输入所需的兑换积分数" value="{$exchange_info.point}" onchange="detectionNumType(this,'integral')" class="layui-input len-short expoint">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>可兑换数量:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="stock" min="0" lay-verify="required|required_balance_stock" placeholder="可兑换数量" value="{$exchange_info.stock}" onchange="detectionNumType(this,'integral')" class="layui-input len-short stock">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>余额:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="balance" lay-verify="required|required_balance" placeholder="请输入红包余额" value="{$exchange_info.balance}" onchange="detectionNumType(this,'positiveNumber')" class="layui-input len-short">
|
||||
</div>
|
||||
<p class="word-aux">兑换的红包会以余额的形式发放给指定会员</p>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否上架:</label>
|
||||
<div class="layui-input-block">
|
||||
<input id="state" type="checkbox" name="state" lay-skin="switch" {if $exchange_info['state'] == 1}checked {/if} value="1" lay-filter="state">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">兑换规则:</label>
|
||||
<div class="layui-input-block special-length">
|
||||
<script id="containerT" name="content" type="text/plain" style="height: 300px;"></script>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-row">
|
||||
<button class="layui-btn" lay-submit lay-filter="save">保存</button>
|
||||
<button class="layui-btn layui-btn-primary" onclick="backPointExchangeOrderList()">返回</button>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="type" value="3">
|
||||
<input type="hidden" name="id" value="{$exchange_info.id}">
|
||||
<input type="hidden" id="contentT" value="{$exchange_info.content}" />
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<input type="hidden" id="type" value="{$exchange_info.type}" />
|
||||
<a id="redPacketImage"></a>
|
||||
|
||||
<script type="text/html" id="toolbarOperation">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="change-number">兑换次数</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="goods-integral">所需积分</button>
|
||||
<button class="layui-btn layui-btn-primary" lay-event="goods-price">所需金额</button>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/ueditor.config.js?time=20240614"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/ueditor.all.js?time=20240614"></script>
|
||||
<script type="text/javascript" charset="utf-8" src="STATIC_EXT/ueditor/lang/zh-cn/zh-cn.js"></script>
|
||||
<script>
|
||||
var _type = $("#type").val();
|
||||
var saveData = null;
|
||||
var totalUploadNum = 0;
|
||||
var completeUploadNum = 0;
|
||||
var upload;
|
||||
|
||||
//实例化富文本
|
||||
var ue, html = '';
|
||||
if (_type == 2) {
|
||||
ue = UE.getEditor('container');
|
||||
ue.ready(function() { //对编辑器的操作最好在编辑器ready之后再做
|
||||
var con = $("#content").val();
|
||||
ue.setContent(con); //获取html内容,返回: <p>hello</p>
|
||||
});
|
||||
} else if (_type == 3) {
|
||||
ue = UE.getEditor('containerT');
|
||||
ue.ready(function() { //对编辑器的操作最好在编辑器ready之后再做
|
||||
var con = $("#contentT").val();
|
||||
ue.setContent(con); //获取html内容,返回: <p>hello</p>
|
||||
});
|
||||
} else if(_type == 1){
|
||||
ue = UE.getEditor('containerG');
|
||||
ue.ready(function() { //对编辑器的操作最好在编辑器ready之后再做
|
||||
var con = $("#contentG").val();
|
||||
ue.setContent(con); //获取html内容,返回: <p>hello</p>
|
||||
});
|
||||
}
|
||||
|
||||
var giftTable, couponTable, form, laytpl,sku_list;
|
||||
{if $exchange_info['type'] == 1}
|
||||
sku_list = {:json_encode($exchange_info.goods_sku, JSON_UNESCAPED_UNICODE)};
|
||||
{/if}
|
||||
|
||||
layui.use(['form', 'laytpl'], function() {
|
||||
form = layui.form;
|
||||
laytpl = layui.laytpl;
|
||||
form.render();
|
||||
|
||||
upload = new Upload({
|
||||
elem: '#redPacket',
|
||||
auto:false,
|
||||
bindAction:'#redPacketImage',
|
||||
callback: function(res) {
|
||||
uploadComplete('image', res.data.pic_path);
|
||||
}
|
||||
});
|
||||
|
||||
renderTable(sku_list);
|
||||
|
||||
//监听兑换方式
|
||||
form.on('radio(pay_type)', function(data){
|
||||
var value = data.value;
|
||||
var html = '';
|
||||
if(value == 1){
|
||||
html = '<input type="number" name="point" min="0" lay-verify="required_point" autocomplete="off" class="layui-input len-short"> 积分' +
|
||||
' + <input type="number" name="price" min="0" lay-verify="required_money" autocomplete="off" class="layui-input len-short"> 元';
|
||||
}
|
||||
if(value == 0){
|
||||
html = '<input type="number" name="point" min="0" lay-verify="required_point" autocomplete="off" class="layui-input len-short"> 积分';
|
||||
}
|
||||
$('.pay_price').html(html);
|
||||
});
|
||||
|
||||
/**
|
||||
* 商品列表搜索
|
||||
*/
|
||||
form.on('submit(gift-search)', function(data) {
|
||||
giftTable.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
|
||||
form.on('switch(shipping)', function(data){
|
||||
if(data.elem.checked){
|
||||
$(".ems_block").hide();
|
||||
}else{
|
||||
$(".ems_block").show();
|
||||
}
|
||||
});
|
||||
|
||||
//监听邮费设置
|
||||
form.on('checkbox(delivery_type)', function(data){
|
||||
if(data.elem.checked){
|
||||
$("input[name='delivery_type']").prop("checked", false);
|
||||
$(this).prop("checked", true);
|
||||
form.render('checkbox');
|
||||
$(this).siblings(".print").show();
|
||||
$(this).parent().siblings().children(".print").hide()
|
||||
}else{
|
||||
$(this).siblings(".print").hide();
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* 监听表单提交
|
||||
*/
|
||||
form.on('submit(save)', function(data) {
|
||||
|
||||
if (_type == 1) {
|
||||
var goods_list = [];
|
||||
|
||||
for (var i in sku_list){
|
||||
if(sku_list[i]['is_select'] == 1){
|
||||
goods_list.push(sku_list[i]);
|
||||
}
|
||||
}
|
||||
if(goods_list.length == 0){
|
||||
layer.msg('请选择商品', {icon: 5, anim: 6});
|
||||
return false;
|
||||
}
|
||||
|
||||
for (var i in sku_list){
|
||||
if (parseFloat(sku_list[i]['point']) <= 0 && sku_list[i]['is_select'] == 1) {
|
||||
layer.msg('兑换积分不能小于等于0', {icon: 5, anim: 6});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
data.field.goods_data = goods_list;
|
||||
ue.ready(function() { //对编辑器的操作最好在编辑器ready之后再做
|
||||
html = ue.getContent(); //获取html内容,返回: <p>hello</p>
|
||||
});
|
||||
|
||||
}else if (_type == 2) {
|
||||
ue.ready(function() { //对编辑器的操作最好在编辑器ready之后再做
|
||||
html = ue.getContent(); //获取html内容,返回: <p>hello</p>
|
||||
});
|
||||
} else if (_type == 3) {
|
||||
ue.ready(function() { //对编辑器的操作最好在编辑器ready之后再做
|
||||
html = ue.getContent(); //获取html内容,返回: <p>hello</p>
|
||||
});
|
||||
}
|
||||
|
||||
data.field.content = html;
|
||||
//不免邮
|
||||
if(data.field.is_free_shipping==undefined){
|
||||
data.field.is_free_shipping = 0;
|
||||
}
|
||||
if(data.field.is_free_shipping == 0 && data.field.type == 1){
|
||||
data.field.delivery_type = $('[name="delivery_type"]:checked').val();
|
||||
if(data.field.delivery_type==undefined){
|
||||
layer.msg('请选择运费类型', {icon: 5, anim: 6});
|
||||
return false;
|
||||
}else if(data.field.delivery_type==0){
|
||||
if(data.field.delivery_price==""){
|
||||
layer.msg('请填写固定邮费', {icon: 5, anim: 6});
|
||||
return false;
|
||||
}
|
||||
}else if(data.field.delivery_type==1){
|
||||
if(data.field.shipping_template<=0){
|
||||
layer.msg('请选择运费模版', {icon: 5, anim: 6});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
data.field.delivery_type = "";
|
||||
data.field.delivery_price = "";
|
||||
data.field.shipping_template = 0;
|
||||
}
|
||||
saveData = data;
|
||||
var obj = $("img.img_prev[data-prev='1']");
|
||||
totalUploadNum = obj.length;
|
||||
if(totalUploadNum > 0){
|
||||
obj.each(function(){
|
||||
var actionId = $(this).attr('data-action-id');
|
||||
$(actionId).click();
|
||||
})
|
||||
}else{
|
||||
saveFunc();
|
||||
}
|
||||
});
|
||||
|
||||
function uploadComplete(field, pic_path) {
|
||||
saveData.field[field] = pic_path;
|
||||
completeUploadNum += 1;
|
||||
if(completeUploadNum == totalUploadNum){
|
||||
saveFunc();
|
||||
}
|
||||
}
|
||||
|
||||
function saveFunc(){
|
||||
var data = saveData;
|
||||
// 删除图片
|
||||
if(!data.field.image) upload.delete();
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("pointexchange://shop/exchange/edit"),
|
||||
data: data.field,
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function(res) {
|
||||
if (res.code == 0) {
|
||||
layer.confirm('编辑成功', {
|
||||
title: '操作提示',
|
||||
btn: ['返回列表', '继续操作'],
|
||||
yes: function(index, layero) {
|
||||
location.hash = ns.hash("pointexchange://shop/exchange/lists")
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function(index, layero) {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.close(index);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
form.verify({
|
||||
required_point: function(value) {
|
||||
if (value == "") {
|
||||
return '积分不能为空';
|
||||
}
|
||||
if (Number(value) <= 0){
|
||||
return '积分必须大于0!';
|
||||
}
|
||||
},
|
||||
required_money: function(value) {
|
||||
if (value == "") {
|
||||
return '金额不能为空';
|
||||
}
|
||||
if (Number(value) <= 0){
|
||||
return '价格必须大于0!';
|
||||
}
|
||||
},
|
||||
required_limit: function(value) {
|
||||
if (Number(value) < 1){
|
||||
return '兑换限制不能小于1!';
|
||||
}
|
||||
},
|
||||
required_coupon_stock: function(value) {
|
||||
if (Number(value) <= 0){
|
||||
return '可兑换数量必须大于0!';
|
||||
}
|
||||
},
|
||||
required_balance_stock: function(value) {
|
||||
if (Number(value) <= 0){
|
||||
return '可兑换数量必须大于0!';
|
||||
}
|
||||
},
|
||||
required_balance: function(value) {
|
||||
if (Number(value) <= 0){
|
||||
return '红包余额必须大于0!';
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
function setSelect(status,id) {
|
||||
for (var i = 0; i < sku_list.length; i++){
|
||||
if (sku_list[i].sku_id == parseInt(id)){
|
||||
sku_list[i]['is_select'] = status;
|
||||
}
|
||||
}
|
||||
renderTable(sku_list);
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
// 表格渲染
|
||||
function renderTable(sku_list) {
|
||||
|
||||
//展示已知数据
|
||||
table = new Table({
|
||||
elem: '#selected_goods_list',
|
||||
page: false,
|
||||
limit: Number.MAX_VALUE,
|
||||
cols: [
|
||||
[{
|
||||
width: "3%",
|
||||
type: 'checkbox',
|
||||
unresize: 'false'
|
||||
},{
|
||||
field: 'sku_name',
|
||||
title: '商品名称',
|
||||
width: '23%',
|
||||
unresize: 'false',
|
||||
templet: function(data) {
|
||||
var html = '';
|
||||
html += `
|
||||
<div class="goods-title">
|
||||
<div class="goods-img">
|
||||
<img layer-src src="${data.sku_image ? ns.img(data.sku_image) : ''}" alt="">
|
||||
</div>
|
||||
<p class="multi-line-hiding goods-name" data-goods_id="${data.goods_id}" data-sku_id="${data.sku_id}" title="${data.sku_name}">${data.sku_name}</p>
|
||||
</div>
|
||||
`;
|
||||
return html;
|
||||
}
|
||||
}, {
|
||||
field: 'price',
|
||||
title: '商品价格',
|
||||
unresize: 'false',
|
||||
align: 'left',
|
||||
width: '10%',
|
||||
templet: function(data) {
|
||||
return '<p class="line-hiding" title="'+ data.price +'">¥<span>' + data.price +'</span></p>';
|
||||
}
|
||||
}, {
|
||||
field: 'stock',
|
||||
title: '库存',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function(data) {
|
||||
return '<p class="stock">' + data.stock +'</p>';
|
||||
}
|
||||
}, {
|
||||
title: '<span title="兑换次数(0为不限次)">兑换次数(0为不限次)</span>',
|
||||
unresize: 'false',
|
||||
width: '14%',
|
||||
templet: '#exchangeLimit'
|
||||
}, {
|
||||
title: '<span title="兑换所需积分">所需积分</span>',
|
||||
unresize: 'false',
|
||||
width: '12%',
|
||||
templet: '#exchangePoint'
|
||||
}, {
|
||||
title: '<span title="兑换所需金额">所需金额</span>',
|
||||
unresize: 'false',
|
||||
width: '12%',
|
||||
templet: '#exchangeMoney'
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
align:'right'
|
||||
}]
|
||||
],
|
||||
data: sku_list,
|
||||
toolbar: '#toolbarOperation'
|
||||
});
|
||||
table.toolbar(function(obj) {
|
||||
|
||||
if (obj.data.length < 1) {
|
||||
layer.msg('请选择要操作的数据');
|
||||
return;
|
||||
}
|
||||
switch (obj.event) {
|
||||
case "change-number":
|
||||
editInput(0,obj);
|
||||
break;
|
||||
case "goods-integral":
|
||||
editInput(1,obj);
|
||||
break;
|
||||
case "goods-price":
|
||||
editInput(2,obj);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
function editInput(textIndex=0,data) {
|
||||
var text = [{
|
||||
name: '兑换次数',
|
||||
value: 'limit_num',
|
||||
type: 'integral',
|
||||
},{
|
||||
name: '所需积分',
|
||||
value: 'point',
|
||||
type: 'integral',
|
||||
},{
|
||||
name: '所需金额',
|
||||
value: 'exchange_price',
|
||||
type: 'positiveNumber',
|
||||
}];
|
||||
layer.open({
|
||||
type: 1,
|
||||
title:"修改"+text[textIndex].name,
|
||||
area:['600px'],
|
||||
btn:["保存","返回"],
|
||||
content: `
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label"><span class="required">*</span>${text[textIndex].name}:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="bargain_edit_input" lay-verify="required" autocomplete="off" onchange="detectionNumType(this,'${text[textIndex].type}')" class="layui-input len-mid" placeholder="请输入${text[textIndex].name}">
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
yes: function(index, layero){
|
||||
var val = $("input[name='bargain_edit_input']").val();
|
||||
if (!val){
|
||||
layer.msg("请输入" + text[textIndex].name);
|
||||
return false;
|
||||
}
|
||||
data.data.forEach(function (item,index) {
|
||||
sku_list.forEach(function (skuItem,skuIndex) {
|
||||
if (item.sku_id == skuItem.sku_id){
|
||||
sku_list[skuIndex][text[textIndex].value] = val;
|
||||
}
|
||||
})
|
||||
});
|
||||
renderTable(sku_list);
|
||||
layer.closeAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function setSkulist(type, sku_id, obj, num_type){
|
||||
var value = $(obj).val();
|
||||
//大于零 且 不是小数
|
||||
if (value < 0 && num_type == 'integral')
|
||||
$(obj).val(0);
|
||||
else if (num_type == 'integral')
|
||||
$(obj).val(Math.round(value));
|
||||
|
||||
//大于1 且 不是小数
|
||||
if (value < 1 && num_type == 'positiveInteger')
|
||||
$(obj).val(1);
|
||||
else if (num_type == 'positiveInteger')
|
||||
$(obj).val(Math.round(value));
|
||||
//大于零可以是小数
|
||||
if (num_type == 'positiveNumber') {
|
||||
value = parseFloat(value).toFixed(2);
|
||||
if (value < 0)
|
||||
$(obj).val(0);
|
||||
else
|
||||
$(obj).val(value);
|
||||
}
|
||||
$.each(sku_list, function (i, e) {
|
||||
if(sku_id == e.sku_id){
|
||||
sku_list[i][type] = $(obj).val();
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
$("body").off("click",".no-participation").on("click",".no-participation",function(){
|
||||
$(this).text("参与");
|
||||
$(this).parents("tr").find("input").each(function (index,item) {
|
||||
$(item).attr("readonly",true);
|
||||
$(item).attr("disabled",true);
|
||||
$(item).addClass("forbidden");
|
||||
$(item).attr("lay-verify","");
|
||||
});
|
||||
|
||||
// pintuan_price promotion_price lay-verify
|
||||
$(this).addClass("participation").removeClass("no-participation");
|
||||
sku_list[$(this).parents("tr").attr("data-index")].is_select = 0;
|
||||
});
|
||||
|
||||
$("body").off("click",".participation").on("click",".participation",function(){
|
||||
$(this).text("不参与");
|
||||
$(this).parents("tr").find("input").each(function (index,item) {
|
||||
$(item).attr("readonly",false);
|
||||
$(item).attr("disabled",false);
|
||||
$(item).removeClass("forbidden");
|
||||
// if($(item).hasClass(".pintuan-price")){
|
||||
// $(item).attr("lay-verify","pintuan_price");
|
||||
// }else{
|
||||
// $(item).attr("lay-verify","promotion_price");
|
||||
// }
|
||||
// console.log($(item))
|
||||
});
|
||||
|
||||
$(this).removeClass("participation").addClass("no-participation");
|
||||
sku_list[$(this).parents("tr").attr("data-index")].is_select = 1;
|
||||
});
|
||||
|
||||
//返回
|
||||
function backPointExchangeOrderList() {
|
||||
location.hash = ns.hash("pointexchange://shop/exchange/lists");
|
||||
}
|
||||
$("body").off('keyup', '.stock').on('keyup', '.stock', function() {
|
||||
var value = $(this).val();
|
||||
if(value % 1 !== 0){
|
||||
layer.msg("红包数量请输入整数");
|
||||
$(this).val(0);
|
||||
}
|
||||
});
|
||||
|
||||
$("body").off('keyup', '.expoint').on('keyup', '.expoint', function() {
|
||||
var value = $(this).val() ;
|
||||
if(value % 1 !== 0){
|
||||
layer.msg("兑换积分请输入整数");
|
||||
$(this).val(0);
|
||||
}
|
||||
});
|
||||
|
||||
//检测数据类型
|
||||
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')
|
||||
$(el).val(Math.round(value));
|
||||
//大于零可以是小数
|
||||
if (type == 'positiveNumber') {
|
||||
value = parseFloat(value).toFixed(2);
|
||||
if (value < 0)
|
||||
$(el).val(0);
|
||||
else
|
||||
$(el).val(value);
|
||||
}
|
||||
}
|
||||
function checkInput(obj){
|
||||
$(obj).val(Math.abs($(obj).val()));
|
||||
}
|
||||
</script>
|
||||
443
addon/pointexchange/shop/view/exchange/lists.html
Executable file
443
addon/pointexchange/shop/view/exchange/lists.html
Executable file
@@ -0,0 +1,443 @@
|
||||
<style>
|
||||
.edit-sort{width: 70px !important;}
|
||||
.contraction span{cursor: pointer;display: inline-block;width: 17px;height: 17px;text-align: center;line-height: 14px;user-select: none;}
|
||||
.contraction-disable span{cursor: pointer;display: inline-block;width: 17px;height: 17px;text-align: center;line-height: 14px;user-select: none;}
|
||||
.sku-list{overflow: hidden;padding: 0 45px;max-width: 100%;}
|
||||
.sku-list li .img-wrap{vertical-align: middle;margin-right: 8px;width: 120px;height: 120px;text-align: center;line-height: 120px;}
|
||||
.sku-list li .img-wrap img{max-width: 100%;max-height: 100%;}
|
||||
.sku-list li .info-wrap span.sku-name{-webkit-line-clamp: 2;margin-bottom: 5px;}
|
||||
.sku-list li .info-wrap span{display: -webkit-box;margin-bottom: 5px;overflow: hidden;text-overflow: ellipsis;white-space: normal;word-break: break-all;-webkit-box-orient: vertical;-webkit-line-clamp: 1;}
|
||||
.sku-list li{float: left;display: flex;padding: 10px;margin-right: 10px;margin-bottom: 10px;border: 1px solid #EFEFEF;width: 294px;height: 180px;align-items: center;}
|
||||
.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="search_text" placeholder="兑换商品名称" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-inline">
|
||||
<label class="layui-form-label">商品状态:</label>
|
||||
<div class="layui-input-inline">
|
||||
<select name="state" lay-filter="state">
|
||||
<option value="">全部</option>
|
||||
<option value="1">上架</option>
|
||||
<option value="0">下架</option>
|
||||
</select>
|
||||
</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="type_name">
|
||||
<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="3">红包</li>
|
||||
</ul>
|
||||
|
||||
<div class="layui-tab-content">
|
||||
<!-- 列表 -->
|
||||
<table id="exchange_list" lay-filter="exchange_list"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 兑换信息 -->
|
||||
<script type="text/html" id="exchange_info">
|
||||
|
||||
<div class="table-title">
|
||||
{{# if(d.type == 1){ }}
|
||||
<div class="contraction" data-id="{{d.id}}" data-open="0">
|
||||
<span>+</span>
|
||||
</div>
|
||||
{{# }else{ }}
|
||||
<div class="contraction-disable">
|
||||
<span></span>
|
||||
</div>
|
||||
{{# } }}
|
||||
{{# if(d.type == 1){ }}
|
||||
<div class="title-pic">
|
||||
{{# if(d.image){ }}
|
||||
<img layer-src="{{ns.img(d.image.split(',')[0],'big')}}" src="{{ns.img(d.image.split(',')[0],'small')}}"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
{{# } }}
|
||||
{{# if(d.type == 2){ }}
|
||||
<div class="title-pic">
|
||||
{{# if(d.image){ }}
|
||||
<img layer-src src="{{ns.img(d.image)}}"/>
|
||||
{{# }else{ }}
|
||||
<img layer-src src="__STATIC__/img/coupon_default.png"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
{{# } }}
|
||||
{{# if(d.type == 3){ }}
|
||||
<div class="title-pic">
|
||||
{{# if(d.image){ }}
|
||||
<img layer-src src="{{ns.img(d.image)}}"/>
|
||||
{{# }else{ }}
|
||||
<img layer-src src="__STATIC__/img/hongbao_default.png"/>
|
||||
{{# } }}
|
||||
</div>
|
||||
{{# } }}
|
||||
<div class="contraction-disable">
|
||||
<span></span>
|
||||
</div>
|
||||
<div class="title-content">
|
||||
{{# if(d.type == 1){ }}
|
||||
<a href="javascript:;" class="multi-line-hiding text-color-sub" title="{{d.name}}">{{d.g_name}}</a>
|
||||
{{# }else{ }}
|
||||
<a href="javascript:;" class="multi-line-hiding text-color-sub" title="{{d.name}}">{{d.name}}</a>
|
||||
{{# } }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</script>
|
||||
|
||||
<!-- 状态 -->
|
||||
<script type="text/html" id="state">
|
||||
{{d.state == 1?'上架':'下架'}}
|
||||
</script>
|
||||
|
||||
<!-- 批量操作 -->
|
||||
<script type="text/html" id="toolbarAction">
|
||||
<button class="layui-btn layui-btn-primary" lay-event="delete">批量删除</button>
|
||||
</script>
|
||||
|
||||
<!-- 编辑删除操作 -->
|
||||
<script type="text/html" id="operation">
|
||||
<div class="table-btn">
|
||||
<a class="layui-btn" lay-event="order">兑换记录</a>
|
||||
<a class="layui-btn" lay-event="edit">编辑</a>
|
||||
<a class="layui-btn" lay-event="delete">删除</a>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="skuList">
|
||||
<tr class="js-list-{{d.index}}" id="sku_img_{{d.index}}">
|
||||
<td colspan="10">
|
||||
<ul class="sku-list">
|
||||
{{# for(var i=0; i<d.list.length; i++){ }}
|
||||
<li>
|
||||
<div class="img-wrap">
|
||||
<img layer-src src="{{ns.img(d.list[i].sku_image)}}">
|
||||
</div>
|
||||
<div class="info-wrap">
|
||||
<span class="sku-name" title="{{d.list[i].sku_name}}">{{d.list[i].sku_name}}</span>
|
||||
<span class="price">商品价格:¥{{d.list[i].market_price}}</span>
|
||||
|
||||
{{# if(d.list[i].price != 0 ){ }}
|
||||
<span class="sale_num">兑换:{{d.list[i].point}}积分 + {{d.list[i].price}}元 </span>
|
||||
{{# }else{ }}
|
||||
<span class="sale_num">兑换:{{d.list[i].point}}积分 </span>
|
||||
{{# } }}
|
||||
|
||||
<span class="price">库存:{{d.list[i].stock}}</span>
|
||||
</div>
|
||||
</li>
|
||||
{{# } }}
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</script>
|
||||
|
||||
<!-- 编辑排序 -->
|
||||
<script type="text/html" id="editSort">
|
||||
<input name="sort" type="number" onchange="editSort({{d.id}}, this)" value="{{d.sort}}" class="layui-input edit-sort len-short">
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var table,laytpl;
|
||||
$("body").off("click", ".contraction").on("click", ".contraction", function () {
|
||||
var exchange_id = $(this).attr("data-id");
|
||||
var open = $(this).attr("data-open");
|
||||
var tr = $(this).parent().parent().parent().parent();
|
||||
var index = tr.attr("data-index");
|
||||
if (open == 1) {
|
||||
$(this).children("span").text("+");
|
||||
$(".js-list-" + index).remove();
|
||||
} else {
|
||||
$(this).children("span").text("-");
|
||||
$.ajax({
|
||||
url: ns.url("pointexchange://shop/exchange/getSkuList"),
|
||||
data: {exchange_id: exchange_id},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
async: false,
|
||||
success: function (res) {
|
||||
var sku_list = $("#skuList").html();
|
||||
var data = {
|
||||
list: res.data,
|
||||
index: index
|
||||
};
|
||||
laytpl(sku_list).render(data, function (html) {
|
||||
tr.after(html);
|
||||
});
|
||||
layer.photos({
|
||||
photos: '.img-wrap',
|
||||
anim: 5
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
$(this).attr("data-open", (open == 0 ? 1 : 0));
|
||||
});
|
||||
|
||||
layui.use(['form', 'element', 'laytpl'], function() {
|
||||
laytpl = layui.laytpl;
|
||||
var form = layui.form,
|
||||
element = layui.element,
|
||||
repeat_flag = false; //防重复标识
|
||||
form.render();
|
||||
|
||||
//监听Tab切换
|
||||
element.on('tab(type_name)', function(data) {
|
||||
var type = $(this).attr("lay-id");
|
||||
table.reload( {
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
'type': type
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
table = new Table({
|
||||
elem: '#exchange_list',
|
||||
url: ns.url("pointexchange://shop/exchange/lists"),
|
||||
cols: [
|
||||
[{
|
||||
type: 'checkbox',
|
||||
width: '3%',
|
||||
},{
|
||||
field: 'name',
|
||||
title: '兑换信息',
|
||||
unresize: 'false',
|
||||
width: '30%',
|
||||
templet: '#exchange_info'
|
||||
}, {
|
||||
field: 'type_name',
|
||||
title: '兑换类型',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
}, {
|
||||
title: '兑换价格',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
templet: function(data) {
|
||||
if(data.pay_type == 1){
|
||||
return data.point+'积分 + '+data.price + "元";
|
||||
}else{
|
||||
return data.point+'积分';
|
||||
}
|
||||
}
|
||||
}, {
|
||||
field: 'create_time',
|
||||
title: '添加时间',
|
||||
unresize: 'false',
|
||||
width: '15%',
|
||||
align: 'center',
|
||||
templet: function(data) {
|
||||
return ns.time_to_date(data.create_time);
|
||||
}
|
||||
}, {
|
||||
field: 'state',
|
||||
title: '状态',
|
||||
unresize: 'false',
|
||||
width: '10%',
|
||||
align: 'center',
|
||||
templet: '#state',
|
||||
}, {
|
||||
field: 'sort',
|
||||
unresize:'false',
|
||||
title: '排序',
|
||||
width: '10%',
|
||||
align: 'center',
|
||||
templet: '#editSort',
|
||||
sort: true
|
||||
}, {
|
||||
title: '操作',
|
||||
toolbar: '#operation',
|
||||
unresize: 'false',
|
||||
width: '12%',
|
||||
align:'right'
|
||||
}]
|
||||
],
|
||||
toolbar: '#toolbarAction'
|
||||
});
|
||||
|
||||
// 监听工具栏操作
|
||||
table.toolbar(function (obj) {
|
||||
var data = obj.data;
|
||||
if(data.length <= 0) return;
|
||||
var exchangeIdAll = [];
|
||||
for (var i in data){
|
||||
exchangeIdAll.push(data[i].id);
|
||||
}
|
||||
|
||||
switch (obj.event) {
|
||||
case 'delete':
|
||||
deleteExchangeAll(exchangeIdAll)
|
||||
break;
|
||||
}
|
||||
})
|
||||
|
||||
function deleteExchangeAll(data){
|
||||
layer.confirm('确定要删除商品吗?', function(index) {
|
||||
if (repeat_flag) return false;
|
||||
repeat_flag = true;
|
||||
|
||||
layer.close(index);
|
||||
|
||||
$.ajax({
|
||||
url: ns.url("pointexchange://shop/exchange/deleteAll"),
|
||||
data: {exchange_id: data},
|
||||
dataType: 'JSON',
|
||||
type: 'POST',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
repeat_flag = false;
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
}, function () {
|
||||
layer.close();
|
||||
repeat_flag = false;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 监听工具栏操作
|
||||
*/
|
||||
table.tool(function(obj) {
|
||||
var data = obj.data;
|
||||
switch (obj.event) {
|
||||
case 'order': //管理
|
||||
location.hash = ns.hash("pointexchange://shop/pointexchange/lists?exchange_id=" + data.id);
|
||||
break;
|
||||
case 'edit': //管理
|
||||
location.hash = ns.hash("pointexchange://shop/exchange/edit?id=" + data.id);
|
||||
break;
|
||||
case 'delete': //删除
|
||||
deleteGift(data.id);
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
table.on("sort",function (obj) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: {
|
||||
order:obj.field,
|
||||
sort:obj.type
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*/
|
||||
function deleteGift(id) {
|
||||
if (repeat_flag) return false;
|
||||
repeat_flag = true;
|
||||
|
||||
layer.confirm('确定要删除该商品吗?', function(index) {
|
||||
layer.close(index);
|
||||
$.ajax({
|
||||
url: ns.url("pointexchange://shop/exchange/delete"),
|
||||
data: {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;
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 搜索功能
|
||||
*/
|
||||
form.on('submit(search)', function(data) {
|
||||
table.reload({
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function add() {
|
||||
location.hash = ns.hash("pointexchange://shop/exchange/add");
|
||||
}
|
||||
|
||||
// 监听单元格编辑
|
||||
function editSort(id, event){
|
||||
var data = $(event).val();
|
||||
|
||||
if (data == '') {
|
||||
$(event).val(0);
|
||||
data = 0;
|
||||
}
|
||||
|
||||
if(!new RegExp("^-?[0-9]\\d*$").test(data)){
|
||||
layer.msg("排序号只能是整数");
|
||||
return ;
|
||||
}
|
||||
if(data<0){
|
||||
layer.msg("排序号必须大于0");
|
||||
return ;
|
||||
}
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ns.url("pointexchange://shop/exchange/modifySort"),
|
||||
data: {
|
||||
sort: data,
|
||||
id: id
|
||||
},
|
||||
dataType: 'JSON',
|
||||
success: function(res) {
|
||||
layer.msg(res.message);
|
||||
if(res.code==0){
|
||||
table.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
161
addon/pointexchange/shop/view/exchange_order/delivery_action.html
Executable file
161
addon/pointexchange/shop/view/exchange_order/delivery_action.html
Executable file
@@ -0,0 +1,161 @@
|
||||
<!-- 订单物流发货 -->
|
||||
<style>
|
||||
|
||||
.layui-table-body {
|
||||
overflow: unset;
|
||||
}
|
||||
|
||||
.delivery-content {
|
||||
padding: 7px 0 !important;
|
||||
}
|
||||
|
||||
.layui-table-view {
|
||||
border-top: 1px solid #eee;
|
||||
/*border-bottom: 1px solid #eee;*/
|
||||
}
|
||||
|
||||
.order-delivery .layui-table {
|
||||
/*margin-bottom: 30px;*/
|
||||
}
|
||||
|
||||
.layui-form #order_goods_list thead th, .layui-form #order_goods_list tbody tr {
|
||||
border-bottom: 1px solid #E6E6E6;
|
||||
}
|
||||
|
||||
.layui-form #order_goods_list thead th {
|
||||
background-color: #F5F5F5;
|
||||
line-height: 30px;
|
||||
}
|
||||
|
||||
.order-delivery .input-text {
|
||||
height: auto;
|
||||
min-height: 34px;
|
||||
}
|
||||
</style>
|
||||
<!--发货订单弹出框-->
|
||||
<script type="text/html" id="order_delivery_html">
|
||||
<div class="order-delivery">
|
||||
<div class="layui-form">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">收货地址:</label>
|
||||
<div class="layui-input-block">
|
||||
<p class="input-text len-long"> {{ d.full_address }}{{ d.address }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">发货编号:</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="delivery_code" lay-verify="required" placeholder="" autocomplete="off" class="layui-input len-mid">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<input type="hidden" name="order_id" value="{{ d.order_id }}" class="layui-input" />
|
||||
<div class="form-row">
|
||||
<button type="button" class="layui-btn" lay-submit id="button_delivery_order" lay-filter="button_delivery_order" style="display:none;">保存
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
/**
|
||||
* 外卖配送订单发货
|
||||
*/
|
||||
var submitting = false;
|
||||
|
||||
function orderDelivery(data) {
|
||||
layui.use(['form', 'laytpl'], function () {
|
||||
var laytpl = layui.laytpl, form = layui.form;
|
||||
form.render();
|
||||
//获取模板
|
||||
var getTpl = $("#order_delivery_html").html();
|
||||
|
||||
laytpl(getTpl).render(data, function (html) {
|
||||
layer.open({
|
||||
type: 1,
|
||||
shadeClose: true,
|
||||
shade: 0.3,
|
||||
fixed: false,
|
||||
scrollbar: false,
|
||||
title: "订单发货",
|
||||
area: '800px',
|
||||
btn: ['保存'],
|
||||
yes: function (index, layero) {
|
||||
$("#button_delivery_order").click();
|
||||
},
|
||||
content: html,
|
||||
cancel: function (index, layero) {
|
||||
//右上角关闭回调
|
||||
layer.close(index);
|
||||
//return false 开启该代码可禁止点击该按钮关闭
|
||||
},
|
||||
success: function (layero, index) {
|
||||
form.render();
|
||||
|
||||
form.on('submit(button_delivery_order)', function (data) {
|
||||
if (submitting) return false;
|
||||
submitting = true;
|
||||
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: ns.url("pointexchange://shop/pointexchange/delivery"),
|
||||
async: true,
|
||||
dataType: 'json',
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
layer.msg(res.message, {}, function () {
|
||||
submitting = false;
|
||||
if (res.code == 0) {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.closeAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
function delivery(order_info){
|
||||
//只有商品订单才需要发货
|
||||
if(order_info.type == 1){
|
||||
if(order_info.delivery_type == 'express'){
|
||||
orderDelivery(order_info);
|
||||
}else if(order_info.delivery_type == 'store'){
|
||||
deliveryAction(order_info.order_id);
|
||||
}else if(order_info.delivery_type == 'local'){
|
||||
deliveryAction(order_info.order_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 配送操作
|
||||
* @param order_id
|
||||
*/
|
||||
function deliveryAction(order_id){
|
||||
$.ajax({
|
||||
type: "post",
|
||||
url: ns.url("pointexchange://shop/pointexchange/delivery"),
|
||||
async: true,
|
||||
dataType: 'json',
|
||||
data: {order_id:order_id},
|
||||
success: function (res) {
|
||||
layer.msg(res.message, {}, function () {
|
||||
if (res.code == 0) {
|
||||
listenerHash(); // 刷新页面
|
||||
layer.closeAll();
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
104
addon/pointexchange/shop/view/exchange_order/detail.html
Executable file
104
addon/pointexchange/shop/view/exchange_order/detail.html
Executable file
@@ -0,0 +1,104 @@
|
||||
<style>
|
||||
.input-text {
|
||||
height: auto;
|
||||
}
|
||||
</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="layui-form-item">
|
||||
<label class="layui-form-label mid">订单编号</label>
|
||||
<div class="layui-input-block">
|
||||
<p class="input-text len-long">{$order_info.order_no}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label mid">支付流水号</label>
|
||||
<div class="layui-input-block">
|
||||
<p class="input-text len-long">{$order_info.out_trade_no}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label mid">兑换积分数</label>
|
||||
<div class="layui-input-block">
|
||||
<p class="input-text len-mid">{$order_info.point}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label mid">兑换价格</label>
|
||||
<div class="layui-input-block">
|
||||
<p class="input-text len-mid">{$order_info.exchange_price}</p>
|
||||
</div>
|
||||
</div>
|
||||
{if $order_info.buyer_message != ''}
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label mid">买家留言</label>
|
||||
<div class="layui-input-block">
|
||||
<p class="input-text len-mid">{$order_info.buyer_message}</p>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
</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">
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label mid">兑换商品名称</label>
|
||||
<div class="layui-input-block">
|
||||
<p class="input-text len-long">{$order_info.exchange_name}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label mid">兑换商品图片</label>
|
||||
<div class="layui-input-block img-upload">
|
||||
<div class="upload-img-block square">
|
||||
<div class="upload-img-box">
|
||||
<img layer-src src="{:img($order_info.exchange_image)}" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label mid">兑换数量</label>
|
||||
<div class="layui-input-block">
|
||||
<p class="input-text len-mid">{$order_info.num}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label mid">类型名称</label>
|
||||
<div class="layui-input-block">
|
||||
<p class="input-text len-mid">{$order_info.type_name}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card card-common card-brief">
|
||||
<div class="form-row mid">
|
||||
<button type="button" class="layui-btn layui-btn-primary" onclick="backPointExchangeList()">返回</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
layui.use('form', function() {
|
||||
var form = layui.form;
|
||||
form.render();
|
||||
});
|
||||
|
||||
function backPointExchangeList() {
|
||||
location.hash = ns.hash("pointexchange://shop/pointexchange/lists")
|
||||
}
|
||||
</script>
|
||||
333
addon/pointexchange/shop/view/exchange_order/lists.html
Executable file
333
addon/pointexchange/shop/view/exchange_order/lists.html
Executable file
@@ -0,0 +1,333 @@
|
||||
<link rel="stylesheet" href="POINTEXCHANGE_CSS/order_list.css"/>
|
||||
<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="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="search_text" 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" name="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" name="mobile" placeholder="请输入会员电话" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<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="order_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="3">红包</li>
|
||||
</ul>
|
||||
|
||||
<div class="layui-tab-content">
|
||||
<div id="order_list"></div>
|
||||
</div>
|
||||
<div id="order_page"></div>
|
||||
</div>
|
||||
|
||||
<script src="POINTEXCHANGE_JS/order_list.js"></script>
|
||||
<script>
|
||||
var form,laypage,element,laydate;
|
||||
var is_refresh = false;
|
||||
|
||||
var order_type_status_json = {'1': '商品', '2': '优惠券', '3': '红包'};
|
||||
layui.use(['laypage','laydate','form', 'element'], function(){
|
||||
form = layui.form;
|
||||
laypage = layui.laypage;
|
||||
element = layui.element;
|
||||
laydate = layui.laydate;
|
||||
form.render();
|
||||
|
||||
// 支付时间
|
||||
laydate.render({
|
||||
elem: '#start_time'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
laydate.render({
|
||||
elem: '#end_time'
|
||||
,type: 'datetime'
|
||||
,change: function(value, date, endDate){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
}
|
||||
});
|
||||
|
||||
//监听Tab切换,以改变地址hash值
|
||||
element.on('tab(order_tab)', function(){
|
||||
$(".all-selected-checkbox input").prop("checked",false);
|
||||
var type = this.getAttribute('lay-id');
|
||||
|
||||
var hash_data = getHashList();
|
||||
hash_data.type = type;
|
||||
hash_data.page = 1;
|
||||
setHashOrderList(hash_data);
|
||||
});
|
||||
|
||||
//监听筛选事件
|
||||
form.on('submit(search)', function(data){
|
||||
is_refresh = true;
|
||||
data.field.page = 1;
|
||||
resetOrderStatus(data.field.order_type, 2);
|
||||
setHashOrderList(data.field);
|
||||
setOrderStatusTab(data.field.order_status);
|
||||
return false;
|
||||
});
|
||||
|
||||
getHashData();
|
||||
getOrderList();//筛选
|
||||
});
|
||||
|
||||
var order = new Order();
|
||||
function getOrderList(){
|
||||
var url = ns.url("pointexchange://shop/pointexchange/lists", getHashArr().join('&'));
|
||||
|
||||
$.ajax({
|
||||
type : 'get',
|
||||
dataType: 'json',
|
||||
url :url,
|
||||
success : function(res){
|
||||
if(res.code == 0){
|
||||
order.setData(res.data);
|
||||
$("#order_list").html(order.fetch());
|
||||
form.render();
|
||||
|
||||
laypage_util = new Page({
|
||||
elem: 'order_page',
|
||||
count: res.data.count,
|
||||
curr: getHashPage(),
|
||||
limit:getHashData()['page_size'] || 10,
|
||||
callback: function(obj){
|
||||
var hash_data = getHashData();
|
||||
hash_data.page = obj.curr;
|
||||
hash_data.page_size = obj.limit;
|
||||
setHashOrderList(hash_data);
|
||||
}
|
||||
});
|
||||
|
||||
}else{
|
||||
layer.msg(res.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 通过hash获取页数
|
||||
function getHashPage(){
|
||||
var page = 1;
|
||||
var startTime = '';
|
||||
var endTime = '';
|
||||
var hash_arr = getHashArr();
|
||||
$.each(hash_arr,function(index, itemobj){
|
||||
var item_arr = itemobj.split("=");
|
||||
if(item_arr.length == 2){
|
||||
switch(item_arr[0]){
|
||||
case "page":
|
||||
page = item_arr[1];
|
||||
break;
|
||||
case "start_time":
|
||||
startTime = ns.date_to_time(item_arr[1].split("%")[0]);
|
||||
break;
|
||||
case "end_time":
|
||||
endTime = ns.date_to_time(item_arr[1].split("%")[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var _time = (endTime - startTime) / (24 * 60 * 60);
|
||||
if (_time == 6) {
|
||||
$(".date-picker-btn-seven").addClass("selected");
|
||||
$(".date-picker-btn-thirty").removeClass("selected");
|
||||
} else if (_time == 29) {
|
||||
$(".date-picker-btn-thirty").addClass("selected");
|
||||
$(".date-picker-btn-seven").removeClass("selected");
|
||||
} else {
|
||||
$(".date-picker-btn-seven").removeClass("selected");
|
||||
$(".date-picker-btn-thirty").removeClass("selected");
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
//从hash中获取数据
|
||||
function getHashData(){
|
||||
var hash_arr = getHashArr();
|
||||
var form_json = {
|
||||
"start_time" : "",
|
||||
"end_time" : "",
|
||||
"nickname" : "",
|
||||
"order_no" : "",
|
||||
"type" : "",
|
||||
'page_size':'',
|
||||
"page" : ""
|
||||
};
|
||||
if(hash_arr.length > 0){
|
||||
$.each(hash_arr,function(index, itemobj){
|
||||
var item_arr = itemobj.split("=");
|
||||
if(item_arr.length == 2){
|
||||
$.each(form_json,function(key, form_val){
|
||||
if(item_arr[0] == key){
|
||||
form_json[key] = item_arr[1];
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
resetOrderStatus(form_json.type, 2);
|
||||
setOrderStatusTab(form_json.type);
|
||||
return form_json;
|
||||
}
|
||||
function getHashList(){
|
||||
var hash_arr = getHashArr();
|
||||
var form_json = {
|
||||
"start_time" : "",
|
||||
"end_time" : "",
|
||||
"nickname" : "",
|
||||
"order_no" : "",
|
||||
"type" : "",
|
||||
'page_size':'',
|
||||
"page" : ""
|
||||
};
|
||||
if(hash_arr.length > 0){
|
||||
$.each(hash_arr,function(index, itemobj){
|
||||
var item_arr = itemobj.split("=");
|
||||
if(item_arr.length == 2){
|
||||
$.each(form_json,function(key, form_val){
|
||||
if(item_arr[0].indexOf(key) != "-1"){
|
||||
form_json[key] = item_arr[1];
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return form_json;
|
||||
}
|
||||
|
||||
function setOrderStatusTab(order_status){
|
||||
$(".layui-tab-title li").removeClass("layui-this");
|
||||
$(".layui-tab-title li").each(function(){
|
||||
var status = $(this).attr("lay-id");
|
||||
if(status == order_status){
|
||||
$(this).addClass("layui-this")
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//重置状态tab 选项卡
|
||||
function resetOrderStatus(order_type, is_tab){
|
||||
var hash_order_type = getHashOrderType();
|
||||
if(hash_order_type != order_type || is_refresh == false){
|
||||
if(is_tab != 1 || is_refresh == false) {
|
||||
$(".layui-tab-title li").not(':first').remove();
|
||||
$(".layui-tab-title li:first").addClass("layui-this");
|
||||
}
|
||||
$.each(order_type_status_json,function(index, itemobj){
|
||||
if(is_tab != 1 || is_refresh == false) {
|
||||
$(".layui-tab-title").append('<li lay-id="' + index + '">' + itemobj + '</li>');
|
||||
}
|
||||
});
|
||||
form.render('select');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取哈希值order_type
|
||||
*/
|
||||
function getHashOrderType(){
|
||||
var hash_arr = getHashArr();
|
||||
var type = "";
|
||||
if(hash_arr.length > 0){
|
||||
$.each(hash_arr,function(index, itemobj){
|
||||
var item_arr = itemobj.split("=");
|
||||
if(item_arr.length == 2){
|
||||
if(item_arr[0].indexOf("type") != "-1") {
|
||||
type = item_arr[1];
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
function setHashOrderList(data){
|
||||
localStorage.setItem('formSubmit','search'); // 表单搜索标识,防止页面重新加载
|
||||
var hash = ['url=pointexchange://shop/pointexchange/lists'];
|
||||
for (let key in data) {
|
||||
if (data[key] != '' && data[key] != 'all') {
|
||||
hash.push(`${key}=${data[key]}`)
|
||||
}
|
||||
}
|
||||
location.hash = hash.join('&');
|
||||
getOrderList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 七天时间
|
||||
*/
|
||||
function datePick(date_num,event_obj){
|
||||
$(".date-picker-btn").removeClass("selected");
|
||||
$(event_obj).addClass('selected');
|
||||
Date.prototype.Format = function (fmt,date_num) { //author: meizz
|
||||
this.setDate(this.getDate()-date_num);
|
||||
var o = {
|
||||
"M+": this.getMonth() + 1, //月份
|
||||
"d+": this.getDate(), //日
|
||||
"H+": this.getHours(), //小时
|
||||
"m+": this.getMinutes(), //分
|
||||
"s+": this.getSeconds(), //秒
|
||||
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
|
||||
"S": this.getMilliseconds() //毫秒
|
||||
};
|
||||
if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
||||
for (var k in o)
|
||||
if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
||||
return fmt;
|
||||
};
|
||||
var now_time = new Date().Format("yyyy-MM-dd 23:59:59",0);//当前日期
|
||||
var before_time = new Date().Format("yyyy-MM-dd 00:00:00",date_num-1);//前几天日期
|
||||
$("input[name=start_time]").val(before_time,0);
|
||||
$("input[name=end_time]").val(now_time,date_num-1);
|
||||
}
|
||||
|
||||
</script>
|
||||
76
addon/pointexchange/shop/view/public/css/order_list.css
Executable file
76
addon/pointexchange/shop/view/public/css/order_list.css
Executable file
@@ -0,0 +1,76 @@
|
||||
.layui-table {margin-top: 15px;}
|
||||
.layui-table thead tr {background-color: #F8F6F9;}
|
||||
.layui-table th {border-width: 0; font-size: 14px!important;}
|
||||
.layui-table td {padding: 8px 15px;}
|
||||
.layui-table .header-row {border-top: 1px solid #e6e6e6;background: #f7f7f7;}
|
||||
.layui-table .header-row:hover{background: #f7f7f7 !important;}
|
||||
.separation-row hr {margin: 0;}
|
||||
|
||||
/* .layui-layout-admin .layui-body{min-width:1100px} */
|
||||
/*.date-picker-btn.selected{background-color:#0d73f9;color:#fff}*/
|
||||
.layui-table td,.layui-table th,.layui-table-fixed-r,.layui-table-header,.layui-table-page,.layui-table-tips-main,.layui-table-tool,.layui-table-view,.layui-table[lay-skin=line],.layui-table[lay-skin=row]{border-color:#f1f1f1 !important;}
|
||||
.layui-table thead th{border-bottom:none;padding-left:0;padding-right:0;}
|
||||
.order-list-table .separation-row td{padding:10px 20px;border: 0;}
|
||||
.order-list-table .separation-row:hover{background-color: #fff;}
|
||||
.order-list-table .header-row td{padding: 8px 15px!important;}
|
||||
.order-list-table .header-row td:nth-child(1){border-right: 0;}
|
||||
.order-list-table .header-row td:nth-child(2){text-align:center;border-left: 0;}
|
||||
.order-list-table .header-row span{vertical-align:middle}
|
||||
.order-list-table .header-row td .order-item-header{text-align:left;color:#333;}
|
||||
.order-list-table .header-row td .order-item-header.more{cursor: pointer;overflow: hidden;position: relative;}
|
||||
.order-list-table .header-row td .more-operation{display: none;font-size: 14px;line-height: 20px;background-color: #fff;border-radius: 2px;box-shadow: 0 2px 8px 0 rgba(200,201,204,.5);position: absolute;z-index: 2000;padding: 10px;top: 28px;transform: translateX(10px);left: -12px;width: 200px;}
|
||||
.order-list-table .header-row td .more-operation:before{left: 8px;top: -14px;border: solid transparent;content: "";height: 0;width: 0;position: absolute;pointer-events: none;border-color: transparent;border-bottom-color: #fff;border-width: 8px;}
|
||||
.order-list-table .header-row td .more-operation span{color:#333;}
|
||||
|
||||
.order-list-table .checkbox-all .layui-table-cell{padding:0;text-align:center;}
|
||||
.order-list-table .product-info .layui-table-cell{padding:0 5px}
|
||||
.order-list-table .content-row:hover{background-color:#fff !important;}
|
||||
.order-list-table .content-row .product-info{border-right: 0;}
|
||||
.order-list-table .content-row .product-info .img-block{width:60px;height:60px;float:left;border:1px solid #e2e2e2;display: flex;align-items: center;justify-content: center;}
|
||||
.order-list-table .content-row .product-info .img-block>img{max-width:100%;max-height:100%;}
|
||||
.order-list-table .content-row .product-info .info{margin-left:70px}
|
||||
.order-list-table .content-row .product-info .info p{color:#8e8c8c;font-size:12px}
|
||||
.order-list-table .content-row .order-price{border-left: 0;}
|
||||
.order-list-table .content-row .product-list{border-right-width:1px}
|
||||
.order-list-table .content-row .product-list p{font-size:12px}
|
||||
.order-list-table .content-row .transaction-status{line-height: 24px;}
|
||||
.order-list-table .content-row .buyers{line-height: 24px;}
|
||||
.order-list-table .operation a{font-size: 14px;}
|
||||
.order-list-table .text-tile{color:rgb(164,164,164);}
|
||||
.order-no-data-block ul{width:200px;margin:20px auto; padding-bottom: 20px;}
|
||||
.order-no-data-block ul li{text-align:center;color:#c2c2c2}
|
||||
.order-no-data-block ul li:first-child{height:70px;line-height:70px}
|
||||
.order-no-data-block ul li:first-child i{font-size:35px}
|
||||
.footer-row{border:1px solid #f2f2f2}
|
||||
.screen{margin-top: 0;}
|
||||
|
||||
/*.order-money span {color: red;}*/
|
||||
#order_page {text-align: right;}
|
||||
.bottom-row{color:#e0a723;background: #fffbec;}
|
||||
.bottom-row:hover{background: #fffbec!important;}
|
||||
|
||||
.table-tab .layui-tab-content {padding-top: 0;}
|
||||
.line-hiding{ cursor : default; -webkit-line-clamp: 2 !important;}
|
||||
.address_box{width:87%; display: inline-block}
|
||||
.address_input{width: 1px;height: 0px;overflow: hidden;border: 0px}
|
||||
.screen .layui-colla-title .layui-colla-icon{color:var(--base-color) !important}
|
||||
.screen .layui-colla-title .text-color{position: absolute;right: 45px;font-size: 14px;padding: 5px;}
|
||||
.operation .operation-type{display: block;}
|
||||
.operation .operation-type .layui-btn{display: inline;text-align: left;line-height: 23px;padding: 0px;margin: 0px;padding-left:8px;}
|
||||
.layui-colla-title .put-open{position: absolute;right: 40px;padding: 5px;color: var(--base-color) ;}
|
||||
.content-row .order-price {
|
||||
border-left: 0;
|
||||
}
|
||||
.content-row .card-info {
|
||||
border-right: 0;
|
||||
}
|
||||
/*订单顶部的一行*/
|
||||
.order-list-top-line{justify-content:flex-end;}
|
||||
.order-list-top-line a{padding-right: 0px !important;}
|
||||
|
||||
.order-list-table .order-goods{align-items: flex-start !important;}
|
||||
.order-list-table .order-goods .info{margin-top: 3px;}
|
||||
.order-list-table .order-goods , .order-list-table .order-goods-item{display: flex;align-items: center;}
|
||||
.order-list-table .order-goods .img-block{margin-right: 10px;width: 60px;height: 60px;flex-shrink: 0;border: 1px solid #e2e2e2;display: flex;align-items: center;justify-content: center;}
|
||||
.order-list-table .order-goods .img-block img{max-width: 100%;max-height: 100%;}
|
||||
.order-list-table .order-goods-item{margin-top: 10px;}
|
||||
BIN
addon/pointexchange/shop/view/public/img/point_site.png
Executable file
BIN
addon/pointexchange/shop/view/public/img/point_site.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 1.3 KiB |
276
addon/pointexchange/shop/view/public/js/order_list.js
Executable file
276
addon/pointexchange/shop/view/public/js/order_list.js
Executable file
@@ -0,0 +1,276 @@
|
||||
/**
|
||||
* 渲染订单列表
|
||||
*/
|
||||
Order = function () {};
|
||||
|
||||
/**
|
||||
* 设置数据集
|
||||
*/
|
||||
Order.prototype.setData = function (data) {
|
||||
Order.prototype.data = data;
|
||||
};
|
||||
|
||||
/**
|
||||
* 列名数据
|
||||
*/
|
||||
Order.prototype.cols = [
|
||||
{
|
||||
type: 'checkbox',
|
||||
fixed: 'left',
|
||||
width: '3%',
|
||||
merge: true,
|
||||
template: function (orderitem, order) {
|
||||
var json = {}
|
||||
json.order_id = order.order_id;
|
||||
json.order_no = order.order_no;
|
||||
json.giftcard_id = order.giftcard_id;
|
||||
var h = '<div class="sub-selected-checkbox" data-json='+ JSON.stringify(json) +' data-id='+ order.order_id +' >';
|
||||
h += '<input type="checkbox" lay-skin="primary" lay-filter="subCheckbox" name="" >';
|
||||
h += '</div>';
|
||||
return h;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '<span>兑换内容</span>',
|
||||
width: "30%",
|
||||
align: "left",
|
||||
className: "card-info",
|
||||
template: function (orderitem, order) {
|
||||
var h = '';
|
||||
var img = orderitem.exchange_image ? ns.img(orderitem.exchange_image.split(",")[0]) : '__STATIC__/img/shape.png'
|
||||
|
||||
h += '<div class="order-goods">';
|
||||
h += '<div class="img-block">';
|
||||
h += '<img layer-src="' + img + '" src="' + img + '">';
|
||||
h += '</div>';
|
||||
h += '<div class="info">';
|
||||
h += '<span title="' + orderitem.exchange_name + '" class="multi-line-hiding text-color-sub">' + orderitem.exchange_name + '</span>';
|
||||
h += '</div>';
|
||||
h += '</div>';
|
||||
|
||||
return h;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "数量",
|
||||
width: "6%",
|
||||
align: "center",
|
||||
className: "order-price",
|
||||
template: function (orderitem, order) {
|
||||
var h = '<div style="text-align: center;">';
|
||||
h += '<span>' + orderitem.num + '件</span>';
|
||||
h += '</div>';
|
||||
return h;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "兑换类型",
|
||||
width: "10%",
|
||||
align: "left",
|
||||
className: "card-right-type",
|
||||
template: function (orderitem, order) {
|
||||
var h = '<div style="padding-left: 15px;">';
|
||||
h += '<span>' + orderitem.type_name + '</span>';
|
||||
h += '</div>';
|
||||
return h;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "积分价格",
|
||||
width: "14%",
|
||||
align: "left",
|
||||
className: "order-money",
|
||||
merge: true,
|
||||
template: function (orderitem, order) {
|
||||
var h = '<div style="padding-left: 15px;">';
|
||||
h += '<div>积分:' + orderitem.point + '</div>';
|
||||
if(orderitem.exchange_price > 0) {
|
||||
h += '<div>实付:' + orderitem.exchange_price + '元</div>';
|
||||
}
|
||||
h += '</div>';
|
||||
return h;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "买家",
|
||||
width: "14%",
|
||||
align: "left",
|
||||
className: "table-member-td",
|
||||
template: function (orderitem, order) {
|
||||
var h = '';
|
||||
h += '<p>';
|
||||
h += '<a class="text-color" target="_blank" href="' + ns.href("shop/member/editmember?member_id=") + order.member_id + '">' + order.nickname + '</a>';
|
||||
h += '</p>';
|
||||
h += '<p>';
|
||||
h += '<span>' + order.name + ' </span>';
|
||||
h += '<span style="">' + order.mobile + '</span>';
|
||||
h += '</p>';
|
||||
h += '<span class="line-hiding address_box" title="' + order.full_address + ' ' + order.address + '">' + order.full_address + " " + order.address +'</span>';
|
||||
return h;
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "状态",
|
||||
width: "10%",
|
||||
align: "left",
|
||||
className: "transaction-status",
|
||||
merge: true,
|
||||
template: function (orderitem, order) {
|
||||
switch (orderitem.order_status){
|
||||
case 0:
|
||||
return '<div style="padding-left: 15px;">待支付</div>';
|
||||
case 1:
|
||||
return '<div style="padding-left: 15px;">已支付</div>';
|
||||
case -1:
|
||||
return '<div style="padding-left: 15px;">已关闭</div>';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title : "兑换时间",
|
||||
width : "15%",
|
||||
align : "center",
|
||||
className : "create-time",
|
||||
merge : true,
|
||||
template : function(orderitem,order){
|
||||
return '<div>' + ns.time_to_date(order.pay_time) + '</div>';
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
align: "right",
|
||||
className: "operation",
|
||||
merge: true,
|
||||
template: function (orderitem, order) {
|
||||
var html='';
|
||||
html += '<div>';
|
||||
html += '<a class="layui-btn text-color" href="'+ns.href("pointexchange://shop/pointexchange/detail", {order_id: orderitem.order_id}) +'">详情</a>';
|
||||
if(orderitem.relate_order_id > 0){
|
||||
html += '<a class="layui-btn text-color" href="'+ns.href("shop/order/detail", {order_id: orderitem.relate_order_id}) +'">查看订单</a>';
|
||||
}
|
||||
html += '</div>';
|
||||
return html;
|
||||
|
||||
}
|
||||
}
|
||||
];
|
||||
/**
|
||||
* 渲染表头
|
||||
*/
|
||||
Order.prototype.header = function (hasThead) {
|
||||
var colgroup = '<colgroup>';
|
||||
var thead = '';
|
||||
if (hasThead) thead = '<thead><tr>';
|
||||
|
||||
for (var i = 0; i < this.cols.length; i++) {
|
||||
var align = this.cols[i].align ? "text-align:" + this.cols[i].align : "";
|
||||
|
||||
colgroup += '<col width="' + this.cols[i].width + '">';
|
||||
if (hasThead) {
|
||||
thead += '<th style="' + align + '" class="' + (this.cols[i].className || "") + '">';
|
||||
thead += '<div class="layui-table-cell">';
|
||||
if(this.cols[i].type){
|
||||
thead += '<div class="all-selected-checkbox">';
|
||||
thead += '<input type="checkbox" lay-skin="primary" lay-filter="allCheckbox" name="">';
|
||||
thead += '</div>';
|
||||
}else{
|
||||
thead += this.cols[i].title;
|
||||
}
|
||||
thead += '</div>';
|
||||
thead += '</th>';
|
||||
}
|
||||
}
|
||||
colgroup += '</colgroup>';
|
||||
if (hasThead) thead += '</tr></thead>';
|
||||
return colgroup + thead;
|
||||
};
|
||||
|
||||
/**
|
||||
* 渲染内容
|
||||
*/
|
||||
Order.prototype.tbody = function () {
|
||||
|
||||
var tbody = '<tbody>';
|
||||
for (var i = 0; i < this.data.list.length; i++) {
|
||||
|
||||
var order = this.data.list[i];
|
||||
if (i > 0) {
|
||||
//分割行
|
||||
tbody += '<tr class="separation-row">';
|
||||
tbody += '<td colspan="' + this.cols.length + '"></td>';
|
||||
tbody += '</tr>';
|
||||
}
|
||||
|
||||
//订单项头部
|
||||
tbody += '<tr class="header-row">';
|
||||
tbody += '<td colspan="9">';
|
||||
tbody += '<span class="order-item-header" style="margin-right:10px;">订单号:' + order.order_no + '</span>';
|
||||
tbody += '<span class="order-item-header text-color more" style="margin-right:50px;" onclick="showMore(' + order.order_id + ')">更多';
|
||||
tbody += '<div class="more-operation" data-order-id="' + order.order_id + '">';
|
||||
tbody += '<span>支付流水号:' + order.out_trade_no + '</span>';
|
||||
tbody += '</div></span>';
|
||||
|
||||
tbody += '<span class="order-item-header" style="margin-right:50px;">下单时间:' + ns.time_to_date(order.create_time) + '</span>';
|
||||
|
||||
tbody += '<span class="order-item-header" style="margin-right:50px;">订单来源:'+ order.order_from_name + (order.is_video_number ? '(视频号)' : '') +'</span>';
|
||||
|
||||
tbody += '</td>';
|
||||
tbody += '</tr>';
|
||||
|
||||
var orderitemHtml = '';
|
||||
loadImgMagnify();
|
||||
orderitemHtml += '<tr class="content-row">';
|
||||
for (var k = 0; k < this.cols.length; k++) {
|
||||
orderitemHtml += '<td class="' + (this.cols[k].className || "") + '" align="' + (this.cols[k].align || "") + '" style="' + (this.cols[k].style || "") + '" rowspan="1">';
|
||||
orderitemHtml += this.cols[k].template(order, order);
|
||||
orderitemHtml += '</td>';
|
||||
}
|
||||
orderitemHtml += '</tr>';
|
||||
|
||||
tbody += orderitemHtml;
|
||||
|
||||
if(order.buyer_message != '') {
|
||||
//订单项底部
|
||||
tbody += '<tr class="bottom-row">';
|
||||
tbody += '<td colspan="9">';
|
||||
tbody += '<span class="order-item-header" style="margin-right:10px;">买家备注:' + order.buyer_message + '</span>';
|
||||
tbody += '</td>';
|
||||
tbody += '</tr>';
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
tbody += '</tbody>';
|
||||
return tbody;
|
||||
};
|
||||
|
||||
/**
|
||||
* 渲染表格
|
||||
*/
|
||||
Order.prototype.fetch = function () {
|
||||
if (this.data.list.length > 0) {
|
||||
return '<table class="layui-table layui-form">' + this.header(true) + '</table><table class="layui-table order-list-table layui-form">' + this.header(false) + this.tbody() + '</table>';
|
||||
} else {
|
||||
return '<table class="layui-table order-list-table layui-form">' + this.header(true) + '</table>' + '<div class="order-no-data-block"><ul><li><i class="layui-icon layui-icon-tabs"></i> </li><li>暂无订单</li></ul></div>';
|
||||
}
|
||||
};
|
||||
|
||||
function showMore(order_id) {
|
||||
$(".more-operation[data-order-id]").hide();
|
||||
$(".more-operation[data-order-id='" + order_id + "']").show();
|
||||
$("body").bind('click',function (e) {
|
||||
if (!$(e.target).closest(".order-item-header.more").length) {
|
||||
$(".more-operation[data-order-id='" + order_id + "']").hide();
|
||||
$("body").unbind('click');
|
||||
}
|
||||
});
|
||||
}
|
||||
$(".layui-colla-title").on("click", function(){
|
||||
if($(".layui-colla-title>i").hasClass("layui-icon-down") === false && $(".layui-colla-title>i").hasClass("layui-icon-up") === false){
|
||||
$(".layui-colla-title .put-open").html("展开");
|
||||
}else if($(".layui-colla-title>i").hasClass("layui-icon-down") === true){
|
||||
$(".layui-colla-title .put-open").html("展开");
|
||||
}else if($(".layui-colla-title>i").hasClass("layui-icon-up") === true){
|
||||
$(".layui-colla-title .put-open").html("收起");
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user