Index.js 3.21 KB
/*
 *@time: 2016.10.10
 *@author: LiQZ
 */
var $ = require('jquery'), common = require('../../../common/common');
require('../../../common/util/datepicker');

//日期插件
$('.hasDatepicker').fdatepicker({
    format: 'yyyy-mm-dd hh:ii:ss',
    pickTime: true
});

var tableGird = new common.grid({

    el: "#table-box",
    size: 30,
    parms: function() {

        var startTime = common.util.__input('starttime');
        var endTime = common.util.__input('endtime');

        return {
            receiveActivityName: common.util.__input('receiveActivityName'),
            beginTime: toSeconds(startTime),
            endTime: toSeconds(endTime)
        };

    },
    columns: [
    { display: "组合套餐号", name: "id" },
    { display: "SKN", render: function(items) {
        return items.productSkn;
    }},
    { display: "有效期", render: function(items) {
        return items.startTime + items.endTime;
    }},
    { display: "折扣", render: function(items) {
        return items.discount;
    }},
    { display: "状态", render: function(items) {
        return '';
    }},
    { display: "操作信息", render: function(items) {
        return '';
    }},
    { display: "操作", render: function(items) {
            var HtmArr = [];
            HtmArr.push('<a href="/activity/yohocoin/update/' + items.id + '" data-id="' + items.id + '" class="btn btn-primary btn-xs">编辑</a>');
            HtmArr.push('<a href="javascript:void(0);" data-id="' + items.id + '" class="btn btn-danger btn-xs delete">删除</a>');
            return HtmArr.join('');
        }
    }]
});

tableGird.init('/product/bundle/list');

$("#filter-btn").click(function() {
    tableGird.reload(1);
});

function toSeconds(strDate) {
    var seconds = new Date(strDate).getTime() / 1000;
    return seconds;
}

function toDate(seconds) {
    if (!$.isNumeric(seconds) || seconds <= 0) { return ''; }
    var date = new Date(seconds * 1000);
    return fixTwo(date.getFullYear()) + '-' + fixTwo((date.getMonth() + 1)) + '-' + fixTwo(date.getDate()) + ' ' + fixTwo(date.getHours()) + ':' + fixTwo(date.getMinutes()) + ':' + fixTwo(date.getSeconds());
}

function fixTwo(number) {
    return number < 10? "0" + number: number;
}

/**
 * 删除--点击事件
 */
$(document).on('click', '.delete', function () {
    var id = $(this).attr("data-id");
    common.dialog.confirm("警告",
        "确认删除?",
        function () {
            common.util.__ajax({
                url: '/yohoCoinActivity/delYohoCoinActivity',
                data: { id: id }
            }, function () {
                tableGird.reload();
            });
        });
});

/*
 * 复制token点击事件
 */
$(document).on('click', '.info-copy', function () {
    common.util.__tip("Token 复制成功", "success")
});

/**
 * 查看token使用方法
 */
$(document).on('click', '#token', function () {
    var a = new common.dialog({
        title: "<h4>token使用方法</h4>",
        width: '50%',
        content: '<p>活动开发人员使用Token时,按照对应格式写在页面中,示例代码:</p><p>&lt;a class="yoho-coin" ' +
        'href="javascript:;" data-token="7173278a4a86"&gt;有货币领取按钮&lt;/a&gt;</p><p><b>注:必须引入 JS 插件</b></p>'
    });
});