operations.officialAccounts.Index.js 2.63 KB
webpackJsonp([117],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	/*
	 *@time: 2016.09.13
	 *@author: LiQZ
	 */
	var $ = __webpack_require__(1), common = __webpack_require__(2);

	var locations = [];
	locations["guang_detail_wechat"] = "逛页面";
	locations["pay_success_wechat"] = "支付完成页";
	locations["yoho_sign_wechat"] = "YOHO币页面";

	var tableGird = new common.grid({

	    el: "#officialAccounts-table-box",
	    parms: function() {
	      return {
	            module: "wechat"
	        }  
	    },
	    columns: [
	    { display: "ID", name: "id" },
	    { display: "公众号名称", render: function(items) {
	        var data = JSON.parse(items.contentData);
	        var item = [];
	        for (var i = 0, l = data.length; i < l; i++) {
	            var v = data[i];
	            item.push(v.wechat_name);
	        }
	        return item.join(',');
	    }},
	    { display: "微信号", render: function(items) {
	        var data = JSON.parse(items.contentData);
	        var item = [];
	        for (var i = 0, l = data.length; i < l; i++) {
	            var v = data[i];
	            item.push(v.wechat_id);
	        }
	        return item.join(',');
	    }},
	    { display: "页面", render: function(items) {
	        return locations[items.templateKey];
	    }},
	    { display: "操作", render: function(items) {
	            var HtmArr = [];
	            if (items.status) {
	                HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-danger btn-xs close-btn">关闭</a>');
	            } else {
	                HtmArr.push('<a href="javascript:;" data-id="' + items.id + '" class="btn btn-success btn-xs open-btn">开启</a>');
	            }
	            HtmArr.push('<a href="/resources/officialAccounts/' + items.id + '" data-id="' + items.id + '" class="btn btn-primary btn-xs">编辑</a>');
	            return HtmArr.join('');
	        }
	    }]
	});

	tableGird.init('/resources/listSingleResource');

	//开启公众号
	$('#officialAccounts-table-box').on('click', '.open-btn', function() {
	    var param = {
	        id: $(this).data('id'),
	        status: '1'
	    }
	    common.util.__ajax({
	        url: '/resources/triggerSingleResource',
	        data: param

	    }, function(res) {
	        tableGird.reload();
	    });
	});

	//关闭公众号
	$('#officialAccounts-table-box').on('click', '.close-btn', function() {
	    var param = {
	        id: $(this).data('id'),
	        status: '0'
	    }
	    common.util.__ajax({
	        url: '/resources/triggerSingleResource',
	        data: param

	    }, function(res) {
	        tableGird.reload();
	    });
	});



/***/ }
]);