Authored by 姜敏

发券管理--复制功能

... ... @@ -3,6 +3,9 @@
*/
var $ = require('jquery'),
common = require('../common/common');
var ZeroClipboard = require("../util/ZeroClipboard.min");
ZeroClipboard.config({swfPath: "http://cdn.yoho.cn/yohobuy-portal/assets/images/ZeroClipboard.swf"});
/**
* 列表显示数据
* @type {common.grid}
... ... @@ -41,8 +44,8 @@ var g = new common.grid({
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>'
return '<div class="col-sm-12"><input class="col-sm-10" style="border: 0px" value="' + item.couponSendToken + '" readonly/>'
+ '<a data-index="' + item.__index + '" href="JavaScript:;" class="btn btn-xs info-copy" data-clipboard-text="' + item.couponSendToken + '" id="copy-' + item.__index + '">复制链接</a></div>';
}
},
{
... ... @@ -55,7 +58,10 @@ var g = new common.grid({
return arr.join('');
}
}
]
],
complete: function () {
new ZeroClipboard($(".info-copy"));
}
});
g.init("/couponSendManager/queryList1");
/*验证*/
... ... @@ -75,41 +81,41 @@ var Bll = {
width: '70%',
button: [
{
value: "保存",
callback: function () {
var couponIds = Bll.module.couponsIds || [];
var flag = true;
var ids = [];
for (var i = 0; i < couponIds.length; i++) {
ids.push(couponIds[i].id);
}
if (ids.join(",").indexOf("-1") > -1) {
flag = false;
common.util.__tip("请正确选择优惠券ID", "warning");
} else {
Bll.module.couponsIds = ids.join(",");
}
if (edit.validate() && flag) {
common.util.__ajax({
url: "/couponSendManager/addOrUpdate",
data: Bll.module
}, function (res) {
if (res.code == '200') {
g.reload();
d.close();
}
else {
common.util.__tip(res.message, "warning");
}
});
}
return false;
value: "保存",
callback: function () {
var couponIds = Bll.module.couponsIds || [];
var flag = true;
var ids = [];
for (var i = 0; i < couponIds.length; i++) {
ids.push(couponIds[i].id);
}
if (ids.join(",").indexOf("-1") > -1) {
flag = false;
common.util.__tip("请正确选择优惠券ID", "warning");
} else {
Bll.module.couponsIds = ids.join(",");
}
if (edit.validate() && flag) {
common.util.__ajax({
url: "/couponSendManager/addOrUpdate",
data: Bll.module
}, function (res) {
if (res.code == '200') {
g.reload();
d.close();
}
else {
common.util.__tip(res.message, "warning");
}
});
}
return false;
},
css: "btn-primary"
},
css: "btn-primary"
},
{
"value":"取消",
"css":"btn-info"
"value": "取消",
"css": "btn-info"
}
]
});
... ... @@ -157,8 +163,8 @@ $(document).on("click", ".addBtn", function () {
*/
$(document).on("click", ".delBtn", function () {
var index = $(this).data("index");
if(Bll.module.couponsIds.length<=1){
common.util.__tip("至少有一张优惠券","warning")
if (Bll.module.couponsIds.length <= 1) {
common.util.__tip("至少有一张优惠券", "warning")
}
else {
Bll.module.couponsIds.splice(index, 1);
... ... @@ -189,7 +195,7 @@ $('#add-content').on('click', function () {
*/
$(document).on('click', '.update', function () {
var item = g.rows[$(this).data("index")];
var item1= $.extend(true,{},item);
var item1 = $.extend(true, {}, item);
Bll.toast(item1, "修改");
});
... ... @@ -223,12 +229,7 @@ $(document).on('click', '#filter-btn', function () {
/**
* 复制token点击事件
*/
$(document).on('click', '.couponSendToken', function () {
var index = $(this).data("index");
var id = "couponSendToken" + index;
var Url2 = document.getElementById(id);
Url2.select(); // 选择对象
document.execCommand("Copy"); // 执行浏览器复制命令
$(document).on('click', '.info-copy', function () {
common.util.__tip("Token链接已复制好,可贴粘", "success")
});
... ...
... ... @@ -3,7 +3,7 @@
* 发券管理
*/
exports.domain = require('../config/common.js').domain;
//exports.domain ='http://172.16.6.250:8081/platform';//庞洁
//exports.domain = 'http://172.16.6.250:2081/platform';//庞洁
exports.res = [
//主界面
{
... ...