vip.Index.js 8.45 KB
webpackJsonp([189],[
/* 0 */
/***/ function(module, exports, __webpack_require__) {

	
	'use strict';
	var $ = __webpack_require__(1),
	    common=__webpack_require__(2);

	// 初始化筛选框
	new common.dropDown({el: "#shopId", ajax: "shopsRest"});
	new common.dropDown({el: "#brandId", ajax: "brand"});
	/**
	 * 商品VIP列表
	 * @type {common.grid}
	 */
	var g = new common.grid({
	    el: '#productVipTable',
	    parms: function () {
	        return {
	            productSkn: common.util.__input('productSkn'),
	            shopId: common.util.__input('shopId'),
	            brandId: common.util.__input('brandId'),
	            vipDiscountType: common.util.__input('vipDiscountType'),
	            vipReturnCoinStatus: common.util.__input('vipReturnCoinStatus')
	        };
	    },
	    columns: [
	        {
	            display: "复选框",
	            width: 90,
	            render: function (item) {
	                var HtmArr = [];
	                    HtmArr.push('<label><input name="choose" type="checkbox" value="'+item.productSKN+'"/></label>');
	                return HtmArr.join('');
	            }
	        },
	        {
	            display: "SKN",
	            name: "productSKN"
	        }, {
	            display: "店铺",
	            name: "shopName"
	        }, {
	            display: "品牌",
	            name: "brandName"
	        },{
	            display: "价格",
	            name: "price"
	        },{
	            display: "VIP价格<a title='*只有正价商品才能开启VIP价格,VIP折扣根据不同品牌供应商有不同折扣' id='tip1' href='#' ><img src='/static/assets/images/help.png'/></a>",
	            name: "vipPrice",
	            render :  function (item, row, value, col) {
	                if(item.vipDiscountType != 3){
	                    value.tdStyle  = "background-color:#5bc0de;";
	                } else {
	                    value.tdStyle  = "";
	                }
	                return item.vipPrice;
	            }
	        },{
	            display: "返币数量<a title='*前台按商品成交支付金额及对应会员等级进行返币。返币比例白金:50%  金卡:30%  银卡:30%,100有货币=1元' id='tip2' href='#' ><img src='/static/assets/images/help.png'/></a>",
	            name: "vipCoin",
	            render :  function (item, row, value, col) {
	                if(item.vipReturnCoinStatus == 1){
	                    value.tdStyle  = "background-color:#5bc0de;";
	                } else {
	                    value.tdStyle  = "";
	                }
	                return item.vipCoin;
	            }
	        }, {
	            display: '价格操作',
	            render: function (item) {
	                var HtmArr = [];
	                if(item.vipDiscountType == 3){
	                    HtmArr.push('<a onclick="changeStatus('+item.productSKN+',1)" href="javascript:;" class="btn btn-info btn-xs edit-btn">开启价格</a>');
	                }else{
	                    HtmArr.push('<a onclick="changeStatus('+item.productSKN+',2)" href="javascript:;" class="btn btn-danger btn-xs edit-btn">关闭价格</a>');
	                }
	                return HtmArr.join('');
	            }
	        }, {
	            display: '返币操作',
	            render: function (item) {
	                var HtmArr = [];
	                if(item.vipReturnCoinStatus == 0){
	                    HtmArr.push('<a onclick="changeReturnCoinStatus('+item.productSKN+',1)" href="javascript:;" class="btn btn-info btn-xs edit-btn">开启返币</a>');
	                }else{
	                    HtmArr.push('<a onclick="changeReturnCoinStatus('+item.productSKN+',0)" href="javascript:;" class="btn btn-danger btn-xs edit-btn">关闭返币</a>');
	                }
	                return HtmArr.join('');
	            }
	        }]
	});
	g.init('/vip/queryProductVipList');
	/**
	 * 批量修改商品VIP状态
	 * @param status
	 */
	function batchChangeStatus(status) {
	    var chk_value =[];
	    $('input[name="choose"]:checked').each(function(){
	        chk_value.push($(this).val());
	    });
	    if(chk_value.length==0) {
	        alert("你还没有选择任何SKN!");
	        return;
	    }
	    var params= {
	        sknList: chk_value.toString(),
	        changeStatus: status
	    };
	    common.dialog.confirm("警告",
	        "确认批量修改商品VIP状态?",
	        function () {
	            common.util.__ajax({
	                url: '/vip/batchChangeStatus',
	                data: params
	            }, function(res) {
	                g.reload();
	                $("[name='all']").removeAttr("checked");
	            });
	        });
	}

	/**
	 * 批量修改商品VIP返币状态
	 * @param status
	 */
	function batchChangeReturnCoinStatus(status) {
	    console.log(status);
	    var chk_value =[];
	    $('input[name="choose"]:checked').each(function(){
	        chk_value.push($(this).val());
	    });
	    if(chk_value.length==0) {
	        alert("你还没有选择任何SKN!");
	        return;
	    }
	    var params= {
	        sknList: chk_value.toString(),
	        vipReturnCoinStatus: status
	    };
	    common.dialog.confirm("警告",
	        "确认批量修改商品VIP返币状态?",
	        function () {
	            common.util.__ajax({
	                url: '/vip/batchChangeReturnCoinStatus',
	                data: params
	            }, function(res) {
	                g.reload();
	                $("[name='all']").removeAttr("checked");
	            });
	        });
	}

	/**
	 * 搜索商品VIP
	 */
	$("#searchFilter").click(function() {
	    g.reload(1);
	    $("[name='all']").removeAttr("checked");
	});

	/**
	 * 单个修改商品VIP状态
	 * @param productSkn
	 * @param status
	 */
	function changeStatus(productSkn,status) {
	    var param = {
	        productSkn: productSkn,
	        productVipStatus: status
	    };
	    common.dialog.confirm("警告",
	        "确认修改商品VIP状态?",
	        function () {
	            common.util.__ajax({
	                url: '/vip/changeStatus',
	                data: param
	            }, function(res) {
	                g.reload();
	                $("[name='all']").removeAttr("checked");
	            });
	        });
	};

	/**
	 * 单个修改商品VIP返币状态
	 * @param productSkn
	 * @param status
	 */
	function changeReturnCoinStatus(productSkn,status) {
	    console.log(status);
	    var param = {
	        productSkn: productSkn,
	        vipReturnCoinStatus: status
	    };
	    console.log(param);
	    common.dialog.confirm("警告",
	        "确认修改商品VIP返币状态?",
	        function () {
	            common.util.__ajax({
	                url: '/vip/changeReturnCoinStatus',
	                data: param
	            }, function(res) {
	                g.reload();
	                $("[name='all']").removeAttr("checked");
	            });
	        });
	};

	/*************导出****************/
	$("#batchExportReturnCoin").click(function(){
	    var productSkn = common.util.__input('productSkn');
	    var shopId = common.util.__input('shopId');
	    var brandId = common.util.__input('brandId');
	    var vipDiscountType = common.util.__input('vipDiscountType');
	    var vipReturnCoinStatus = common.util.__input('vipReturnCoinStatus');

	    var getResult=function(){
	        return {
	            productSkn: productSkn,
	            brandId: brandId,
	            shopId: shopId,
	            vipDiscountType: vipDiscountType,
	            vipReturnCoinStatus: vipReturnCoinStatus
	        }
	    }
	    window.open("/ajax/down?queryConf=" + JSON.stringify(getResult()) + "&type=batchExportReturnCoin");
	});

	/**
	 * 全选、反选
	 * @constructor
	 */
	function DoCheck()
	{
	    var ch=document.getElementsByName("choose");
	    if(document.getElementsByName("all")[0].checked==true)
	    {
	        for(var i=0;i<ch.length;i++)
	        {
	            ch[i].checked=true;
	        }
	    }else{
	        for(var i=0;i<ch.length;i++)
	        {
	            ch[i].checked=false;
	        }
	    }
	}
	window.DoCheck = DoCheck;
	window.changeStatus = changeStatus;
	/**
	 * 切换TAB
	 * @param tab
	 */
	function changeTab(tab) {
	    if(tab == 1){
	        $("#shopVipTab").show();
	        $("#productVipTab").hide();
	    }else if(tab == 2){
	        $("#shopVipTab").hide();
	        $("#productVipTab").show();
	    }
	}
	window.changeTab = changeTab;
	window.batchChangeStatus = batchChangeStatus;
	window.changeReturnCoinStatus = changeReturnCoinStatus;
	window.batchChangeReturnCoinStatus = batchChangeReturnCoinStatus;


/***/ }
]);