operations.webshare.Index.js 2.82 KB
webpackJsonp([119],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	/**
	 * Created by ty on 2016/7/6.
	 * 活动分享管理
	 */

	var $ = __webpack_require__(1),
	    common = __webpack_require__(2);

	new common.dropDown({el:"#status-filter"});

	var statusEnum = ["开启", "关闭"];

	var g = new common.grid({
	    el: '#content-list',
	    parms: function () {
	        return {
	            id: common.util.__input("shareId-filter"),
	            status: common.util.__input("status-filter"),
	            title: common.util.__input("title-filter")
	        };
	    },
	    columns: [
	        {display: "ID", name: "id"},
	        {display: "标题", name: "title"},
	        {display: "分享主标题", name: "shareTitleMain"},
	        {display: "分享副标题", name: "shareTitleSub"},
	        {display: "分享图片", render: function (item) {
	            if(item.shareImage) {
	                var src = item.shareImage.replace("{mode}", "2").replace("{width}", "80").replace("{height}", "80");
	                return '<img src="'+ src +'" width="80px" height="80px" />';
	            }
	        }},
	        {display: "状态", render: function (item) {
	            if(item.status == 1) {
	                return "已开启";
	            } else {
	                return "已关闭";
	            }
	        }},
	        {display: "创建时间", render: function (item) {
	            return common.util.__dateFormat(new Date(item.createTime * 1000), "yyyy-MM-dd hh:mm:ss");
	        }},
	        {
	            display: '操作',
	            render: function (item) {
	                var HtmArr = [];
	                HtmArr.push('<a href="/operations/webshare/edit/'+ item.id +'" class="btn btn-primary btn-xs">编辑</a>');
	                if(item.status==0){
	                    HtmArr.push('<a data-index="'+ item.__index +'" class="btn btn-success btn-xs auditStatus">'+ statusEnum[item.status] +'</a>');
	                }else{
	                    HtmArr.push('<a data-index="'+ item.__index +'" class="btn btn-danger btn-xs auditStatus">'+ statusEnum[item.status] +'</a>');
	                }
	                return HtmArr.join('');
	            }
	        }
	    ]
	});

	/**
	 * 全局对象
	 */
	var Bll = {
	    getTime: function (time) {//时间格式转换
	        var t = new Date(time * 1000);
	        return common.util.__dateFormat(t, "yyyy-MM-dd hh:mm:ss");

	    }
	};


	g.init("/webShare/getWebShareList");



	//筛选
	$(document).on("click", "#filter-btn", function () {
	    g.reload(1);
	});

	//更改状态
	$(document).on("click", ".auditStatus", function () {
	    var item = g.rows[$(this).data("index")];
	    item.status = 1 - item.status;
	    common.util.__ajax({
	        url: "/webShare/updateWebShare",
	        data: item
	    }, function () {
	        g.reload();
	    });
	});

/***/ }
]);