Authored by wangwei

优惠券-店铺关联

module.exports = function (app) {
/***********************************品牌优惠券*************************************/
//列表页
app.get("/shopCoupons/index", "marketing.ShopCoupon.Index", function () {
this.$extend = {
moduleName: '营销管理',
pageName: '店铺优惠券'
}
});
//列表数据
app.post("/shopCoupon/queryList", "ShopCoupon_queryList");
//新增
app.post("/shopCoupon/add", "ShopCoupon_add");
//编辑
app.post("/shopCoupon/update", "ShopCoupon_update");
//单个
app.post("/shopCoupon/queryById", "ShopCoupon_queryById");
}
\ No newline at end of file
... ...
/**
* Created by yoho on 2016/6/21.
*/
module.exports = {
namespace: "ShopCoupon",
apis: {
/************************************店铺优惠券*************************************/
queryList: {
title: "店铺优惠券数据",
url: '/shopCoupon/queryList',
params: {
shopId: {type: String},
status: {type: Number},
couponsId: {type: Number},
page: {type: Number},
size: {type: Number}
}
},
queryById: {
title: "单个优惠券",
url: '/shopCoupon/queryById',
params: {
id: {type: Number}
}
},
add: {
title: "新增店铺优惠券",
url: '/shopCoupon/add',
params: {
shopName: {type: String},
status: {type: Number},
shopId: {type: Number},
couponsId: {type: Number}
}
},
update: {
title: "编辑店铺优惠券",
url: '/shopCoupon/update',
params: {
shopName: {type: String},
status: {type: Number},
id: {type: Number},
shopId: {type: Number},
couponsId: {type: Number}
}
}
}
};
\ No newline at end of file
... ...
<%include '../../../common/views/__ui/header'%>
<%include '../../../common/views/__partail/ListHeader'%>
<div class="contentpanel">
<div class="panel panel-default" style="margin-bottom:10px;">
<div class="panel-body" style="padding-bottom: 0">
<a id="add-btn" href="javascript:;" class="btn btn-success"><i class="fa fa-plus"></i> 添加店铺优惠券</a>
</div>
<div class="panel-body">
<div class="row">
<div class="panel-col">
<select id="sel-shopName" class="form-control" >
<option value="-1">选择店铺名称</option>
</select>
</div>
<div class="panel-col">
<select id="sel-status" class="form-control">
<option value="-1">是否生效</option>
<option value="1">失效</option>
<option value="2">有效</option>
</select>
</div>
<div class="panel-col">
<input type="number" id="sel-couponsId" class="form-control" placeholder="输入优惠券ID" style="height: 39px;"/>
</div>
<div class="panel-col">
<a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>
<a id="all-btn" href="" class="btn btn-info">全部</a>
</div>
</div>
</div>
</div>
<div class="panel panel-primary-head">
<div id="basicTable_wrapper" class="dataTables_wrapper no-footer">
<div class="dataTables_length" id="basicTable">
</div>
<nav>
<ul id="pagination" class="pagination pagination-lg"></ul>
</nav>
</div>
</div>
</div>
<script type="text/template" id="template">
<div class="form-group">
<label class="col-sm-2 control-label">优惠券ID<span style="color: red;"> *</span></label>
<div class="col-sm-10">
<input type="text" match="numbers" value="[[couponsId]]" class="form-control observe" placeholder="优惠券ID" required="required" data-field="couponsId">
</div>
</div>
<div class="form-group" id="maxsord">
<label for="shopId" class="col-sm-2 control-label">店铺<span style="color: red;"> *</span></label>
<div class="col-sm-10">
<input type="hidden" name="" value="[[id]]" id="id" class="form-control observe" data-field="shopId">
<select id="shopId" value="[[shopId]]" class="form-control observe" data-field="shopId">
<option value="[[shopId||-1]]">[[shopName||"请选择店铺"]]</option>
</select>
</div>
</div>
<div class="form-group">
<label for="status" class="col-sm-2 control-label">是否生效<span style="color: red;"> *</span></label>
<div class="radio">
<label><input type="radio" value="1" class=" observe" name="status" kl_vkbd_parsed="true" data-field="status" checked>失效</label>
<label><input type="radio" value="2" class=" observe" name="status" kl_vkbd_parsed="true" data-field="status">有效</label>
</div>
<input id="status" type="hidden" required="required" class="form-control observe" value="[[status||'1']]" for="radio" kl_vkbd_parsed="true" data-field="status">
</div>
</script>
<%include '../../../common/views/__ui/footer'%>
\ No newline at end of file
... ...
/**
* Created by Arthur on 16/5/26.
* 店铺发券管理
*/
var $ = require('jquery');
common = require('../../../common/common');
var ENUM = {
StatusEnum: {
1: '失效',
2: '有效'
}
};
//下拉框
new common.dropDown({
el: "#sel-status"
});
new common.dropDown({
el: "#sel-shopName",
ajax: 'shopsRest'
});
var g = new common.grid({
el: '#basicTable',
size: 10,
parms: function () {
return {
shopId: common.util.__input('sel-shopName'),
status: common.util.__input('sel-status'),
couponsId: common.util.__input('sel-couponsId')
};
},
columns: [
{
display: '店铺名称',
name: "shopName"
},
{
display: '优惠券ID',
name: "couponsId"
}, {
display: '状态',
render: function (item) {
return "<p>" + ENUM.StatusEnum[item.status] + "</p>";
}
}, {
display: "创建时间",
render: function (item) {
if (item.createTime && item.createTime !== 0) {
var t = new Date(item.createTime * 1000);
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm");
return "<p>" + formatted + "</p>";
}
else {
return "";
}
}
}, {
display: "修改时间",
render: function (item) {
if (item.updateTime && item.updateTime !== 0) {
var t = new Date(item.updateTime * 1000);
var formatted = common.util.__dateFormat(t, "yyyy-MM-dd hh:mm");
return "<p>" + formatted + "</p>";
}
else {
return "";
}
}
}, {
display: '操作',
name: "status",
render: function (items) {
var HtmArr = [];
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-primary btn-xs info-modify">编辑</a>');
return HtmArr.join('');
}
}]
});
g.init('/shopCoupon/queryList');
//==================== 按钮点击事件 =====================//
$("#filter-btn").click(function () {
g.reload(1);
});
/**
* 监听输入框变化
*/
$(document).on("change", ".observe", function () {
var $this = $(this);
var name = $this.data("field");
Bll.module = common.util.__buildobj(name, '.', Bll.module, function (obj, name1) {
obj[name1] = $this.val();
});
Bll.module.shopName = $('#shopId').find("option[value='" + Bll.module.shopId + "']").text();
});
/*验证*/
var edit = new common.edit2(".modal-body");
var Bll = {
module: null,
//弹框
toast: function (module, hint, url) {
Bll.module = module;
var d = new common.dialog({
title: hint + "店铺优惠券",
content: common.util.__template2($("#template").html(), Bll.module),
width: '40%',
button: [
{
value: "保存",
callback: function () {
if (edit.validate()) {
common.util.__ajax({
url: url,
data: Bll.module
}, function (res) {
if (res.code == '200') {
g.reload();
d.close();
}
else {
common.util.__tip(res.message, "warning");
}
}, true);
}
return false;
},
css: "btn-primary"
},
{
"value": "取消",
"css": "btn-info"
}
]
});
Bll.__editRender();
},
__editRender: function () {
edit.init();
new common.dropDown({
el: "#shopId",
ajax: 'shopsRest'
});
}
};
/**
* 添加--点击事件
*/
$(document).on('click', '#add-btn', function () {
var item = {
"couponsId": "",
"shopId": "",
"shopName": "",
"status": 1
};
Bll.toast(item, "添加", '/shopCoupon/add');
});
/**
* 编辑--点击事件
*/
$(document).on('click', '.info-modify', function () {
var item = g.rows[$(this).data("index")];
console.log("id:",item.id);
common.util.__ajax({
url: "/shopCoupon/queryById",
data: {id: item.id}
}, function (res) {
Bll.toast(res.data, "修改", '/shopCoupon/update');
}, true);
});
\ No newline at end of file
... ...