app.controller('sysChargeConfigCtrl', ['$scope', '$http', '$timeout', 'toaster', 'uiGridConstants', 'FileUploader', 'i18nService', function ($scope, $http, $timeout, toaster, uiGridConstants, FileUploader, i18nService) { i18nService.setCurrentLang("zh-cn");//中文环境,如表格分页 /********默认充值优惠设置**********/ $scope.config = { chargeList: [], }; $http.get("/manager/getChargeList").then(function (data) { var response = data.data $scope.config.chargeList = response.data; $timeout(function () { //由于出现滚动条,导致横向空间减少,导致表格控件多出横向滚动条,需要resize $(window).trigger("resize"); }) }); $scope.deleteCharge = function (index) { var chargeList = $scope.config.chargeList; if (chargeList[index]) { chargeList.splice(index, 1); } }; //充值套餐 $scope.addCharge = function () { var chargeList = $scope.config.chargeList; if (!$.isArray(chargeList)) { chargeList = $scope.config.chargeList = []; } var length = chargeList.length; var data = {}; if (length == 0) { data = { payAmount: 1, coins: 1 }; } else { data = { payAmount: chargeList[length - 1]["payAmount"] * 2, coins: chargeList[length - 1]["coins"] * 2 }; } chargeList.push(data); }; //保存充值优惠 $scope.saveChargeData = function () { $http({ method: 'POST', url: "/manager/saveChargeData", data: $scope.config.chargeList }).then(function (response) { toaster.pop("success", "提示", "保存成功!"); }, function (response) { toaster.pop("error", "提示", "保存失败!"); }); }; }]);