|
|
/**
|
|
|
* Created by JiangMin on 2016/4/19.
|
|
|
*/
|
|
|
var $ = require('jquery');
|
|
|
var common = require('../common/common');
|
|
|
var $ = require('jquery'),
|
|
|
common = require('../common/common');
|
|
|
/**
|
|
|
* 列表显示数据
|
|
|
* @type {common.grid}
|
...
|
...
|
@@ -19,29 +19,41 @@ var g = new common.grid({ |
|
|
//列表显示
|
|
|
columns: [
|
|
|
{
|
|
|
display: "创建时间", name: "createTime"
|
|
|
display: "创建时间",
|
|
|
name: "createTime"
|
|
|
},
|
|
|
{display: "发券名称", name: "name"},
|
|
|
{display: "优惠券ID", name: "couponsIds",render:function(item){
|
|
|
var couponsIds=[];
|
|
|
for(var i=0;i<item.couponsIds.length;i++){
|
|
|
couponsIds.push(item.couponsIds[i].id);
|
|
|
{
|
|
|
display: "发券名称",
|
|
|
name: "name"
|
|
|
},
|
|
|
{
|
|
|
display: "优惠券ID",
|
|
|
name: "couponsIds",
|
|
|
render: function (item) {
|
|
|
var couponsIds = [];
|
|
|
for (var i = 0; i < item.couponsIds.length; i++) {
|
|
|
couponsIds.push(item.couponsIds[i].id);
|
|
|
}
|
|
|
return couponsIds.join(",");
|
|
|
}
|
|
|
return couponsIds.join(",");
|
|
|
}},
|
|
|
},
|
|
|
{
|
|
|
display: "token值", name: "couponSendToken", render: function (item) {
|
|
|
return '<div class="col-sm-12"><input class="col-sm-10" style="border: 0px" id="couponSendToken' + item.__index + '" value="' + item.couponSendToken + '" readonly/>' +
|
|
|
'<input class="col-sm-2 btn couponSendToken" value="复制" data-index="' + item.__index + '"/></div>'
|
|
|
}
|
|
|
display: "token值",
|
|
|
name: "couponSendToken",
|
|
|
render: function (item) {
|
|
|
return '<div class="col-sm-12"><input class="col-sm-10" style="border: 0px" id="couponSendToken' + item.__index + '" value="' + item.couponSendToken + '" readonly/>' +
|
|
|
'<input class="col-sm-2 btn couponSendToken" value="复制" data-index="' + item.__index + '"/></div>'
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
display: "操作", name: "", render: function (item) {
|
|
|
var arr = [];
|
|
|
arr.push('<a class="btn btn-info update" data-index="' + item.__index + '">编辑</a>');
|
|
|
arr.push('<a class="btn btn-danger delete" data-index="' + item.__index + '">删除</a>');
|
|
|
return arr.join('');
|
|
|
}
|
|
|
display: "操作",
|
|
|
name: "",
|
|
|
render: function (item) {
|
|
|
var arr = [];
|
|
|
arr.push('<a class="btn btn-info update" data-index="' + item.__index + '">编辑</a>');
|
|
|
arr.push('<a class="btn btn-danger delete" data-index="' + item.__index + '">删除</a>');
|
|
|
return arr.join('');
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
});
|
...
|
...
|
@@ -54,6 +66,7 @@ var Bll = { |
|
|
__render: function (selecter, templater, data) {
|
|
|
$(selecter).html(common.util.__template2($("#" + templater).html(), data));
|
|
|
},
|
|
|
//弹框
|
|
|
toast: function (module, hint) {
|
|
|
Bll.module = module;
|
|
|
var d = new common.dialog({
|
...
|
...
|
@@ -75,7 +88,6 @@ var Bll = { |
|
|
} else {
|
|
|
Bll.module.couponsIds = ids.join(",");
|
|
|
}
|
|
|
//console.log("最终上传数据Bll.module",Bll.module);
|
|
|
if (edit.validate() && flag) {
|
|
|
common.util.__ajax({
|
|
|
url: "/couponSendManager/addOrUpdate",
|
...
|
...
|
@@ -109,19 +121,22 @@ var Bll = { |
|
|
});
|
|
|
}
|
|
|
};
|
|
|
/*监听输入框变化*/
|
|
|
|
|
|
/**
|
|
|
* 监听输入框变化
|
|
|
*/
|
|
|
$(document).on("change", ".observe", function () {
|
|
|
var $this = $(this);
|
|
|
var name = $this.data("field") ? $this.data("field") : $this.data("name");
|
|
|
var name = $this.data("field");
|
|
|
Bll.module = common.util.__buildobj(name, '.', Bll.module, function (obj, name1) {
|
|
|
if (name.indexOf('id') > -1) {
|
|
|
obj[name1] = $this.val();
|
|
|
obj["text"] = $this.find("option[value='" + $this.val() + "']").text();
|
|
|
obj["text"] = $this.find("option[value='" + $this.val() + "']").text();
|
|
|
}
|
|
|
obj[name1] = $this.val();
|
|
|
});
|
|
|
//console.log(" 监听值变化Bll.module", Bll.module);
|
|
|
});
|
|
|
|
|
|
/*添加一行*/
|
|
|
$(document).on("click", ".addBtn", function () {
|
|
|
Bll.module.couponsIds.push({
|
...
|
...
|
@@ -130,13 +145,19 @@ $(document).on("click", ".addBtn", function () { |
|
|
});
|
|
|
Bll.renderDialog("template");
|
|
|
});
|
|
|
/*删除行*/
|
|
|
|
|
|
/**
|
|
|
* 删除行
|
|
|
*/
|
|
|
$(document).on("click", ".delBtn", function () {
|
|
|
var index = $(this).data("index");
|
|
|
Bll.module.couponsIds.splice(index, 1);
|
|
|
Bll.renderDialog("template");
|
|
|
});
|
|
|
//添加--点击事件
|
|
|
|
|
|
/**
|
|
|
* 添加--点击事件
|
|
|
*/
|
|
|
$('#add-content').on('click', function () {
|
|
|
var item = {
|
|
|
"id": "",
|
...
|
...
|
@@ -151,7 +172,10 @@ $('#add-content').on('click', function () { |
|
|
};
|
|
|
Bll.toast(item, "添加");
|
|
|
});
|
|
|
//编辑--点击事件
|
|
|
|
|
|
/**
|
|
|
* 编辑--点击事件
|
|
|
*/
|
|
|
$(document).on('click', '.update', function () {
|
|
|
var item = g.rows[$(this).data("index")];
|
|
|
var item1 = {
|
...
|
...
|
@@ -162,7 +186,10 @@ $(document).on('click', '.update', function () { |
|
|
};
|
|
|
Bll.toast(item1, "修改");
|
|
|
});
|
|
|
//删除--点击事件
|
|
|
|
|
|
/**
|
|
|
* 删除--点击事件
|
|
|
*/
|
|
|
$(document).on('click', '.delete', function () {
|
|
|
var item = g.rows[$(this).data("index")];
|
|
|
common.dialog.confirm("警告",
|
...
|
...
|
@@ -179,11 +206,17 @@ $(document).on('click', '.delete', function () { |
|
|
});
|
|
|
});
|
|
|
});
|
|
|
//查询按钮--点击事件
|
|
|
|
|
|
/**
|
|
|
* 查询按钮--点击事件
|
|
|
*/
|
|
|
$(document).on('click', '#filter-btn', function () {
|
|
|
g.reload(1);
|
|
|
});
|
|
|
//复制token点击事件
|
|
|
|
|
|
/**
|
|
|
* 复制token点击事件
|
|
|
*/
|
|
|
$(document).on('click', '.couponSendToken', function () {
|
|
|
var index = $(this).data("index");
|
|
|
var id = "couponSendToken" + index;
|
...
|
...
|
@@ -192,12 +225,16 @@ $(document).on('click', '.couponSendToken', function () { |
|
|
document.execCommand("Copy"); // 执行浏览器复制命令
|
|
|
common.util.__tip("Token链接已复制好,可贴粘", "success")
|
|
|
});
|
|
|
//查看token使用方法
|
|
|
|
|
|
/**
|
|
|
* 查看token使用方法
|
|
|
*/
|
|
|
$(document).on('click', '#token', function () {
|
|
|
var a = new common.dialog({
|
|
|
title: "<h4>token使用方法</h4>",
|
|
|
width: '50%',
|
|
|
content: '<p>活动开发人员使用Token时,按照对应格式写在页面中,示例代码:</p><a class="yoho-conpon" href="javascript:;" data-token="29-6ea9ab1baa0efb9e19094440c317e21b">领券按钮</a><h5>注:必须引入 JS 插件</h5>'
|
|
|
content: '<p>活动开发人员使用Token时,按照对应格式写在页面中,示例代码:</p><a class="yoho-conpon" ' +
|
|
|
'href="javascript:;" data-token="29-6ea9ab1baa0efb9e19094440c317e21b">领券按钮</a><h5>注:必须引入 JS 插件</h5>'
|
|
|
});
|
|
|
});
|
|
|
|
...
|
...
|
|