systemConfigCtrl.js 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. app.controller('systemConfigCtrl', ['$scope', '$http', '$timeout', 'toaster', 'FileUploader', function ($scope, $http, $timeout, toaster, FileUploader) {
  2. $scope.configForm = {};
  3. $http.get('/manager/getManagerConfigs', {
  4. params: {}
  5. }).then(function (data) {
  6. data = data.data
  7. if (data.result == 1) {
  8. var payload = data.payload;
  9. $scope.configForm = payload.configs;
  10. }
  11. }).catch(function (data) {
  12. toaster.pop("error", "提示", "获取数据失败");
  13. });
  14. $scope.saveConfig = function () {
  15. $http.post('/manager/setManagerConfigs', {
  16. params: $scope.configForm
  17. }).then(function (data) {
  18. if (data.data.result == 1) {
  19. toaster.pop("success", "保存成功");
  20. }
  21. }).catch(function (data) {
  22. toaster.pop("error", "提示", "保存失败");
  23. });
  24. };
  25. /********默认充值优惠设置**********/
  26. $scope.config = {
  27. chargeList: [],
  28. };
  29. $http.get("/manager/getChargeList").then(function (response) {
  30. $scope.config.chargeList = response.data.payload;
  31. $timeout(function () {
  32. //由于出现滚动条,导致横向空间减少,导致表格控件多出横向滚动条,需要resize
  33. $(window).trigger("resize");
  34. })
  35. });
  36. $scope.deleteCharge = function (index) {
  37. var chargeList = $scope.config.chargeList;
  38. if (chargeList[index]) {
  39. chargeList.splice(index, 1);
  40. }
  41. };
  42. //充值套餐
  43. $scope.addCharge = function () {
  44. var chargeList = $scope.config.chargeList;
  45. if (!$.isArray(chargeList)) {
  46. chargeList = $scope.config.chargeList = [];
  47. }
  48. var length = chargeList.length;
  49. var data = {};
  50. if (length == 0) {
  51. data = {
  52. payAmount: 1,
  53. coins: 1
  54. };
  55. } else {
  56. data = {
  57. payAmount: chargeList[length - 1]["payAmount"] * 2,
  58. coins: chargeList[length - 1]["coins"] * 2
  59. };
  60. }
  61. chargeList.push(data);
  62. };
  63. //保存充值优惠
  64. $scope.saveChargeData = function () {
  65. $http({
  66. method: 'POST',
  67. url: "/manager/saveChargeData",
  68. data: $scope.config.chargeList
  69. }).then(function (response) {
  70. if (response.data.result === 1) {
  71. toaster.pop("success", "提示", "保存成功!")
  72. }
  73. }, function (response) {
  74. toaster.pop("error", "提示", "保存失败!");
  75. });
  76. };
  77. }]);