12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485 |
- app.controller('systemConfigCtrl', ['$scope', '$http', '$timeout', 'toaster', 'FileUploader', function ($scope, $http, $timeout, toaster, FileUploader) {
- $scope.configForm = {};
- $http.get('/manager/getManagerConfigs', {
- params: {}
- }).then(function (data) {
- data = data.data
- if (data.result == 1) {
- var payload = data.payload;
- $scope.configForm = payload.configs;
- }
- }).catch(function (data) {
- toaster.pop("error", "提示", "获取数据失败");
- });
- $scope.saveConfig = function () {
- $http.post('/manager/setManagerConfigs', {
- params: $scope.configForm
- }).then(function (data) {
- if (data.data.result == 1) {
- toaster.pop("success", "保存成功");
- }
- }).catch(function (data) {
- toaster.pop("error", "提示", "保存失败");
- });
- };
- /********默认充值优惠设置**********/
- $scope.config = {
- chargeList: [],
- };
- $http.get("/manager/getChargeList").then(function (response) {
- $scope.config.chargeList = response.data.payload;
- $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) {
- if (response.data.result === 1) {
- toaster.pop("success", "提示", "保存成功!")
- }
- }, function (response) {
- toaster.pop("error", "提示", "保存失败!");
- });
- };
- }]);
|