vipamount.js 1.98 KB
'use strict';
var $ = require('jquery'),
    common=require('../common/common');

var g = new common.grid({
    el: '#basicTable',
    parms: function(){
    	return {
            type: 1
        };
    },
    columns:[
    	{display: '活动名称', name: 'title'},
    	{display: '活动类型', render: function(item) {
    		return '积分翻倍';
    	}},
    	{display: '倍数', name: 'num'},
    	{display: '活动时间', render: function(item) {
    		var startTime = new Date(item.startTime * 1000),
    			endTime = new Date(item.endTime * 1000);

    		return startTime.getFullYear() + '-' + (startTime.getMonth() + 1) + '-' + startTime.getDate() + ' ' + 
    				startTime.getHours() + ':' + startTime.getMinutes() + ':' + startTime.getSeconds() + '至' + 
    				endTime.getFullYear() + '-' + (endTime.getMonth() + 1) + '-' + endTime.getDate() + ' ' + 
    				endTime.getHours() + ':' + endTime.getMinutes() + ':' + endTime.getSeconds();
    	}},
    	{display: '创建人员', name: 'addUserName'},
    	{display: '活动创建时间', render: function(item) {
    		var date = new Date(item.createTime * 1000);
            return date.getFullYear() + '-' + (date.getMonth() + 1) + '-' + date.getDate() + ' ' 
                + date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
    	}},
    	{display: '操作', render: function(item) {
    		var date = new Date();
    		if (date.getTime() / 1000 >= item.endTime) {
    			return '活动已结束';
    		} else {
    			$('#add-btn').addClass('disabled');
    			return '<a class="btn btn-info end-btn" data-id="' + item.id + '" href="javascript:;">结束</a>';
    		}
    		
    	}}
    ]
});
g.init($("#gridurl").val());

$('#basicTable').on('click', '.end-btn', function() {
	var activeId = $(this).data('id');
	common.util.__ajax({
        url:'/market/vipamount/save',
        data:{
        	status: 1,
        	id: activeId
        }
    }, function(res){
        $('#add-btn').removeAttr('disabled');
        g.reload();
    });
});