Authored by 姜敏

优惠券相关--联调修复

... ... @@ -77,11 +77,11 @@ var util = {
if (typeof lastargs === "function") {
options.after_open = setTimeout(function() {
lastargs && lastargs();
}, 600);
}, 3000);
}
}
options.sticky = false;
options.time = 1000;
options.time = 10000;
$.gritter.add(options);
},
... ...
... ... @@ -21,19 +21,17 @@ var ENUM = {
status: {0: '待审核', 1: '审核通过', 2: '驳回', '-1': '过期', 3: '作废'},//全部
tips: {"0": 0, "1": 0, "2": 0, "3": 0, "4": 0, "all": 0}
};
var columnname="all";
var couponIds = {};
var columnname = "all";
/**
* 初始化下拉框
*/
new common.dropDown({el: '#filter-dep'});
common.util.__ajax({
url: "/coupon/queryList",//获取所有优惠券ID
data: {size:1000}
data: {size: 1000}
}, function (res) {
$("#couponsIds").html(common.util.__template2($("#search-coupon").html(), res));
new common.dropDown({el: "#choose-coupon"});
couponIds = res.data;
}, true);
/**
... ... @@ -45,22 +43,26 @@ var t = new common.tab({
columnname = $(this).find('a').attr('columnname');
g.options.columns[6].hidden = true;
g.options.columns[7].hidden = true;
switch (columnname){
case "1":{
switch (columnname) {
case "1":
{
g.options.columns[8].hidden = true;
}
break;
case "2":{
case "2":
{
g.options.columns[6].hidden = false;
g.options.columns[8].hidden = true;
}
break;
case "3":{
case "3":
{
g.options.columns[7].hidden = false;
g.options.columns[8].hidden = true;
}
break;
case "all":{
case "all":
{
g.options.columns[8].hidden = false;
}
break;
... ... @@ -96,7 +98,7 @@ var g = new common.grid({
display: "基本信息", render: function (item) {
var arr = [];
arr.push("<p>名称:" + item.couponName + "</p>");
arr.push("<p>类型:" + couponTypes[item.couponType-1] + "</p>");
arr.push("<p>类型:" + couponTypes[item.couponType - 1] + "</p>");
arr.push("<p>优惠结果:" + item.couponAmount + "</p>");
arr.push("<p>数量:" + item.couponNum + "</p>");
arr.push("<p>部门:" + departments[item.department - 1] + "</p>");
... ... @@ -123,14 +125,18 @@ var g = new common.grid({
},
{display: "优惠券说明", name: "explains"},
{display: "申请人", name: "proposer"},
{display:"驳回理由",hidden:true,name:"rejectReason",render:function(item){
return "<p style='color: red'>"+item.rejectReason+"</p>"
}},
{display:"作废理由",hidden:true,name:"invalidReason",render:function(item){
return "<p style='color: red'>"+item.invalidReason+"</p>"
}},
{
display: '状态',render: function (item) {
display: "驳回理由", hidden: true, name: "rejectReason", render: function (item) {
return "<p style='color: red'>" + item.rejectReason + "</p>"
}
},
{
display: "作废理由", hidden: true, name: "invalidReason", render: function (item) {
return "<p style='color: red'>" + item.invalidReason + "</p>"
}
},
{
display: '状态', render: function (item) {
var html = ENUM.status[item.status] || '全部';
if (item.reason) {
if (item.status == 2 || item.status == 4) {
... ... @@ -159,21 +165,21 @@ var Bll = {
var t = new Date(time * 1000);
return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
},
toast: function (content, url,data) {
toast: function (content, url, data) {
common.dialog.confirm("温馨提示", content, function () {
common.util.__ajax({
url:url,
data:data()
url: url,
data: data()
}, function () {
g.reload();
});
});
},
toastPass: function (content, url,data) {
toastPass: function (content, url, data) {
common.dialog.confirm("温馨提示", content, function () {
common.util.__ajax({
url:url,
data:data
url: url,
data: data
}, function () {
g.reload();
});
... ... @@ -186,7 +192,7 @@ var Bll = {
width: "60%",
button: [{
value: '取消',
css:"btn btn-primary"
css: "btn btn-primary"
}
]
... ... @@ -197,8 +203,8 @@ var Bll = {
var buttons = [
'<a class="btn btn-warning btn-xs apply-back" data-index="' + index + '" >驳回</a>',
'<a class="btn btn-primary btn-xs apply-success" data-index="' + index + '" >通过</a>',
'<a data-index="' + index + '" class="btn btn-info btn-xs coupon-info">查看详情</a>',
'<a data-index="' + index + '"class="btn btn-info btn-xs apply-modify" href="/market/couponList/update/'+id +'">修改</a>',
'<a class="btn btn-info btn-xs coupon-info" data-index="' + index + '">查看详情</a>',
'<a class="btn btn-info btn-xs apply-modify" data-index="' + index + '" href="/market/couponList/update/' + id + '">修改</a>',
'<a class="btn btn-danger btn-xs apply-cancel" data-index="' + index + '" >作废</a>'
];
for (var i = 0; i < array.length; i++) {
... ... @@ -217,10 +223,10 @@ $("#filter-btn").click(function () {
//审核通过
$(document).on('click', '.apply-success', function () {
var item = g.rows[$(this).data("index")];
var data ={
couponId: item.id
var data = {
couponId: item.id
};
Bll.toastPass("确定要通过该申请吗?", "/coupon/approve",data);
Bll.toastPass("确定要通过该申请吗?", "/coupon/approve", data);
});
//驳回
$(document).on('click', '.apply-back', function () {
... ... @@ -235,7 +241,7 @@ $(document).on('click', '.apply-back', function () {
rejectReason: reason
};
};
Bll.toast(common.util.__template2($("#template").html(), {name: "你确定要驳回该申请吗?"}),"/coupon/reject", data);
Bll.toast(common.util.__template2($("#template").html(), {name: "你确定要驳回该申请吗?"}), "/coupon/reject", data);
});
//作废
$(document).on('click', '.apply-cancel', function () {
... ... @@ -247,10 +253,10 @@ $(document).on('click', '.apply-cancel', function () {
}
return {
couponId: item.id,
invalidReason:reason
invalidReason: reason
};
};
Bll.toast(common.util.__template2($("#template").html(), {name: "你确定要作废此限购码吗?"}),"/coupon/invalid", data);
Bll.toast(common.util.__template2($("#template").html(), {name: "你确定要作废此限购码吗?"}), "/coupon/invalid", data);
});
/**
* 查看详情
... ...
... ... @@ -10,7 +10,7 @@ var type = $("#basicForm").attr("role"),//类型 新增或修改
action = $("#basicForm").data("action");//路由
var startTimeObj;
var endTimeObj;
var customType=[];
var customType = [];
/**
* 监听输入值的变化
... ... @@ -26,10 +26,8 @@ $(document).on("change", ".observe", function () {
* 全局对象
*/
var Bll = {
Brands: [],
Brands1: {},
Brdata: [],
getBrands: function () {
Brands: [],//品牌数据
getBrands: function () {//获取品牌数据
var Brand = {};
$.get("/ajax/yohosearch", function (res) {
if (!res.data || !res.data.brands) {
... ... @@ -47,7 +45,6 @@ var Bll = {
var item = res.data.brands[key][key2];
Brand[name] = Brand[name] || [];
Brand[name].push(item);
Bll.Brands1[item.id] = item;
}
}
for (var i in Brand) {
... ... @@ -62,41 +59,16 @@ var Bll = {
name: i,
items: Brand[i]
});
}
});
},
renderBrandPic: function (Brdata) {
var map2 = {};
Brdata.forEach(function (item) {
map2[item.id] = item;
});
Brdata = [];
for (var key in map2) {
Brdata.push(map2[key]);
}
var Brands2 = [];
Brdata.forEach(function (item, index) {
if (!item.brandIco) {
var a = Bll.Brands1[item.id];
if (a.brandIco) {
a.brandIco = common.util.__joinImg("brandLogo", a.brand_ico);
}
Brands2.push(a);
} else {
item.brandIco = common.util.__template(item.brandIco, {width: 110, height: 150});
Brands2.push(item);
}
});
return Brdata;
},
getTime: function (time) {
getTime: function (time) {//时间格式转换
var t = new Date(time * 1000);
return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");
},
__render: function (item,type) {
__render: function (item, type) {//渲染界面
$("#basicForm").html(common.util.__template2($("#couponListAdd-template").html(), item));
e.init();
startTimeObj = $("#startTime").fdatepicker({
... ... @@ -109,12 +81,12 @@ var Bll = {
}).data("datepicker");
new common.dropDown({el: '#filter-couponType'});
new common.dropDown({el: '#filter-department'});
if(type=='update'){
if(couponBean.customType){
customType=couponBean.customType.split(',');
for(var i=0;i<customType.length;i++){
if (type == 'update') {
if (couponBean.customType) {
customType = couponBean.customType.split(',');
for (var i = 0; i < customType.length; i++) {
var custom = "custom-" + customType[i];
$("input ." + custom).attr("checked","checked");
$("input ." + custom).attr("checked", "checked");
}
}
}
... ... @@ -132,7 +104,7 @@ var Bll = {
* 根据type判断界面
*/
if (type == 'add') {
Bll.__render(couponBean,type);
Bll.__render(couponBean, type);
} else {
var id = location.href.substring(location.href.lastIndexOf("/") + 1);
common.util.__ajax({
... ... @@ -142,26 +114,65 @@ if (type == 'add') {
couponBean = res.data.list[0];
couponBean.startTime = Bll.getTime(couponBean.startTime);
couponBean.endTime = Bll.getTime(couponBean.endTime);
Bll.__render(couponBean,type)
Bll.__render(couponBean, type)
}, true);
}
/**
* 优惠条件
*/
$(document).on("change", "#useLimitType", function () {
Bll.__render(couponBean,type);
Bll.__render(couponBean, type);
});
/**
* 适用范围
*/
$(document).on("change", "#useRange", function () {
couponBean.useRange = $(this).val();
Bll.__render(couponBean,type);
Bll.__render(couponBean, type);
});
/**
* 会员身份
*/
$(document).on("click", "input[name='customType']", function () {
if ($(this).is(':checked')) {
customType.push($(this).val());
} else {
for (var i = 0; i < customType.length; i++) {
if ($(this).val() == customType[i]) {
customType.splice(i, 1)
}
}
}
couponBean.customType = customType.join(",");
});
//输入限制
$(document).on("keyup", ".number", function () {
$(this).val($(this).val().replace(/\D/g, ''));
});
/**
* 保存
*/
$(document).on("click", "#save_brand", function () {
// console.log(couponBean);
if (e.validate()) {
delete couponBean.useRange;
common.util.__ajax({
url: action,
data: couponBean
}, function (res) {
location.href = "/market/couponList/index";
});
}
return false;
});
var tabTreeArr = [];
var tabTree;
/********************************************************分类相关****************************************/
var tabTreeArr = [], tabTree;
//选择分类
$(document).on('click',"#addSorts",function(){
$(document).on('click', "#addSorts", function () {
var data = {};
common.dialog({
title: "选择分类",
... ... @@ -212,48 +223,10 @@ $(document).on('click', '.del-sort-btn', function () {
tabTreeArr.splice(sortIndex, 1);
Bll.checkSortNum();
});
/**
* 会员身份
*/
$(document).on("click", "input[name='customType']", function () {
if ($(this).is(':checked')) {
customType.push($(this).val());
} else {
for (var i = 0; i < customType.length; i++) {
if ($(this).val() == customType[i]) {
customType.splice(i, 1)
}
}
}
couponBean.customType = customType.join(",");
});
//输入限制
$(document).on("keyup", ".number", function () {
$(this).val($(this).val().replace(/\D/g, ''));
});
/**
* 保存
*/
$(document).on("click", "#save_brand", function () {
console.log(couponBean);
if (e.validate()) {
delete couponBean.useRange;
common.util.__ajax({
url: action,
data: couponBean
}, function (res) {
location.href = "/market/couponList/index";
});
}
return false;
});
/********************************************************品牌相关****************************************/
//获取品牌
Bll.getBrands();
Bll.renderBrandPic(Bll.Brdata);
/**
* 添加品牌
*/
... ... @@ -261,16 +234,9 @@ $(document).on("click", "#addBrands", function () {
var e = new common.edit("#brandForm");
common.dialog.confirm("选择品牌", common.util.__template2($("#template5").html(), {
Brands: Bll.Brands,
Brdata: Bll.Brdata.join(',')
Brdata: couponBean.brandLimit
}), function () {
$("#brandCheckBox").val().split('|').forEach(function (item) {
Bll.Brdata.push({
"brandCategory": "1",
"id": item
});
});
couponBean.brandLimit = $("#brandCheckBox").val().split('|').join(",");
Bll.Brdata = Bll.renderBrandPic(Bll.Brdata);
});
e.init();
});
... ... @@ -282,6 +248,7 @@ $(document).on('click', '.brand-index', function () {
$(document).on("focus", "#brandsearch", function () {
$('.brand-wrap').find('[name="brandsearch"]').show().siblings().hide();
});
//品牌搜索输入
$(document).on("keyup", "#brandsearch", function () {
var txt = $(this).val();
var regex = new RegExp(txt);
... ... @@ -296,5 +263,5 @@ $(document).on("keyup", "#brandsearch", function () {
$("#brandsearchwrap").html(bs.join(''));
var e = new common.edit("#brandForm");
e.init();
});
... ...
... ... @@ -56,8 +56,10 @@ var g = new common.grid({
}}
]
});
g.init("/couponLogs/queryUserCouponLogsList");
/**
* 通用对象
* @type {{toast: Bll.toast}}
*/
var Bll = {
toast:function(item, url, title) {
common.dialog.confirm(title,common.util.__template2($("#template-delay").html(), item),function(){
... ... @@ -77,7 +79,7 @@ var Bll = {
};
$(document).on("click", "#filter-btn", function() {
g.reload(1);
g.init("/couponLogs/queryUserCouponLogsList");
});
//延长有效期
... ... @@ -96,3 +98,8 @@ $(document).on("click", ".cancelCoupon", function() {
g.reload();
});
});
//输入限制
$(document).on("keyup", ".number", function () {
$(this).val($(this).val().replace(/\D/g, ''));
});
... ...
... ... @@ -37,9 +37,22 @@ $(document).on("click", "#sendCoupon", function() {
couponId:couponId,
uids:uids
}
}, function () {
location.href = location.href;
});
}, function (res) {
var msg1=[],msg2=[];
res.data.forEach(function (result) {
if(result.flag==false){
msg1.push('<p>'+result.uid+':'+result.errMsg + ';'+'</p>');
}else{
msg2.push('<p>'+result.uid+':发放成功;</p>');
}
});
if(msg1.length>0){
common.util.__tip(msg1.join(""), 'warning');
}
if(msg2.length>0){
common.util.__tip(msg2.join(""), 'success');
}
},true);
} else {
common.util.__tip("请输入UID", "warning");
}
... ...
... ... @@ -48,3 +48,8 @@ $(document).on('click', '#export-btn', function() {
var queryConf = JSON.stringify({couponId:couponId});
window.open("/ajax/down?queryConf=" + queryConf + "&type=couponLogsExport");
});
//输入限制
$(document).on("keyup", ".number", function () {
$(this).val($(this).val().replace(/\D/g, ''));
});
... ...
... ... @@ -6,7 +6,6 @@ var $ = require('jquery'),
common=require('../common/common');
new common.dropDown({el: "#filter-status"});
var couponId = location.href.substring(location.href.lastIndexOf("/") + 1);
$("#filter-couponId").val(couponId);
//grid
var g = new common.grid({
... ... @@ -49,3 +48,8 @@ $(document).on('click', '#export-btn', function() {
var queryConf = JSON.stringify({couponId:couponId});
window.open("/ajax/down?queryConf=" + queryConf + "&type=useCouponLogsExport");
});
//输入限制
$(document).on("keyup", ".number", function () {
$(this).val($(this).val().replace(/\D/g, ''));
});
... ...
... ... @@ -3,8 +3,8 @@ exports.domain = require('../config/common.js').domain;
//exports.domain = 'http://172.16.6.162:8088/platform';
//exports.domain = 'http://172.16.6.108:8088/platform';//谭玲
//exports.domain = 'http://172.16.6.201:8088/platform';//谭玲
//exports.domain = 'http://172.16.6.250:2081/platform';//庞洁
//exports.domain = 'http://172.16.6.189:8088/platform';//李建
// exports.domain = 'http://172.16.6.250:2081/platform';//庞洁
// exports.domain = 'http://172.16.6.189:8088/platform';//李建
//营销管理路由配置
exports.res = [
... ... @@ -701,7 +701,8 @@ exports.res = [
{name: "couponName", type: "string"},
{name: "couponId", type: "number"},
{name: "orderCode", type: "number"},
{name: "uid", type: "number"}
{name: "uid", type: "number"},
{name:"status",type:"number"}
]
},
{
... ...
... ... @@ -15,10 +15,9 @@ var errBackMsg = {
};
//var domain = 'http://172.16.6.227:8088/platform'; //马力
// var domain = 'http://172.16.6.162:8088/platform';
//var domain = 'http://172.16.6.240:8088/platform';
//var domain= 'http://172.16.6.189:8088/platform';//李建
// var domain= 'http://172.16.6.189:8088/platform';//李建
//var domain ='http://172.16.6.120:8088/platform';//曹燕
//var domain ='http://172.16.6.250:2081/platform';//庞洁
/**
* 获取请求头
* @param req
... ... @@ -82,7 +81,7 @@ exports.uploadFile = function (req, res) {
else if(req.body.__type == "import-txt"){
req.body.file = fs.createReadStream(req.files[req.body.filename].path);
request.post({
url: "http://172.16.6.250:2081/platform/couponSendFile/upload",
url: domain+"/couponSendFile/upload",
formData: req.body,
headers: headers
}, function optionalCallback(error, httpResponse, body) {
... ...
... ... @@ -156,9 +156,20 @@
<input type="text" class="form-control" value="[[useLimitType]]" readonly>
</div>
</div>
[[if useLimitType!='无限制']]
<div class="form-group">
<label class="col-sm-2 control-label">优惠条件</label>
[[if useLimitType=='货物件数限制']]
<div class="col-sm-4">
<label class="col-sm-3 control-label">件数满</label>
<div class="col-sm-8">
<input type="text" class="form-control" value="[[useLimit]]" readonly>
</div>
<label class="col-sm-1 control-label"></label>
</div>
[[/if]]
[[if useLimitType=='订单金额限制']]
<div class="col-sm-4">
<label class="col-sm-3 control-label">金额满</label>
... ... @@ -167,7 +178,9 @@
</div>
<label class="col-sm-1 control-label"></label>
</div>
[[/if]]
</div>
[[/if]]
<div class="form-group">
<label class="col-sm-2 control-label">优惠结果</label>
... ...
... ... @@ -94,7 +94,7 @@
<div class="col-sm-8">
<input type="text" placeholder="数量" prompt="数量" class="form-control observe number" data-field="couponNum"
required value="[[couponNum]]">
required value="[[couponNum]]" >
</div>
</div>
... ... @@ -103,7 +103,7 @@
<div class="col-sm-8">
<input type="text" placeholder="使用次数" class="form-control observe number" data-field="useNum"
required value="[[useNum]]">
required value="[[useNum]]" >
</div>
</div>
... ... @@ -170,11 +170,11 @@
</select>&emsp;&emsp;
[[if useLimitType=='2']]
<label class="control-label">金额满</label>
<input value="[[useLimit]]" class="form-control input-form observe" data-field="useLimit">
<input value="[[useLimit]]" class="form-control input-form observe number" data-field="useLimit" >
[[/if]]
[[if useLimitType=='1']]
<label class="control-label">件数满</label>
<input value="[[useLimit]]" class="form-control input-form observe" data-field="useLimit">
<input value="[[useLimit]]" class="form-control input-form observe number" data-field="useLimit" >
[[/if]]
</div>
... ... @@ -185,8 +185,8 @@
<label class="col-sm-2 control-label">面额</label>
<div class="col-sm-8">
<input type="text" class="form-control observe" data-field="couponAmount"
value="[[couponAmount]]">
<input type="text" class="form-control observe number" data-field="couponAmount"
value="[[couponAmount]]" >
</div>
<label class="col-sm-2 control-label"></label>
</div>
... ... @@ -219,7 +219,7 @@
<div class="panel-body">
<div class="row">
<div class="form-group">
<label class="col-sm-2 control-label">会员身份<i class="red">*</i></label>
<label class="col-sm-2 control-label">会员身份</label>
<div class="col-sm-10">
<label class="checkbox-inline">
... ... @@ -239,7 +239,7 @@
</label>
</div>
<input type="hidden" value="[[customType]]" id="customType" for="checkbox" required
<input type="hidden" value="[[customType]]" id="customType" for="checkbox"
placeholder="会员身份">
</div>
</div>
... ... @@ -264,7 +264,7 @@
<div class="row">
<div class="col-sm-4 col-sm-offset-4">
<button id="save_brand" type="button" data-loading-text="保存中..." class="btn btn-primary">提交</button>
<button id="save_brand" type="button" class="btn btn-primary">提交</button>
<a href="javascript:;" onclick="history.go(-1);" class="btn btn-default">取消</a>
</div>
</div>
... ...
... ... @@ -27,16 +27,17 @@
<input type="text" class="form-control" id="filter-couponCode" placeholder="单券号">
</div>
<div class="panel-col">
<input type="text" class="form-control" id="filter-uid" placeholder="用户ID">
<input type="text" class="form-control number" id="filter-uid" placeholder="用户ID">
</div>
<div class="panel-col">
<input type="text" class="form-control" id="filter-orderCode" placeholder="订单号">
<input type="text" class="form-control number" id="filter-orderCode" placeholder="订单号">
</div>
<div class="panel-col">
<input type="text" class="form-control" id="filter-couponName" placeholder="优惠券名称">
</div>
<a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>
<a id="all-btn" href="" class="btn btn-info">全部</a>
<div class="panel-col">
<a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>
</div>
</div>
</div>
</div>
... ...
... ... @@ -28,10 +28,10 @@
<input type="hidden" id="filter-couponId" value="">
</div>
<div class="panel-col">
<input type="text" class="form-control" id="filter-uid" placeholder="用户ID">
<input type="text" class="form-control number" id="filter-uid" placeholder="用户ID">
</div>
<div class="panel-col">
<input type="text" class="form-control" id="filter-orderCode" placeholder="订单号">
<input type="text" class="form-control number" id="filter-orderCode" placeholder="订单号">
</div>
<div class="panel-col">
<select id="filter-status" tabindex="-1" class="select2-offscreen brandBtn-group">
... ...