sysCharge.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. app.controller('sysChargeConfigCtrl', ['$scope', '$http', '$timeout', 'toaster', 'uiGridConstants', 'FileUploader', 'i18nService', function ($scope, $http, $timeout, toaster, uiGridConstants, FileUploader, i18nService) {
  2. i18nService.setCurrentLang("zh-cn");//中文环境,如表格分页
  3. /********默认充值优惠设置**********/
  4. $scope.config = {
  5. chargeList: [],
  6. };
  7. $http.get("/manager/getChargeList").then(function (data) {
  8. var response = data.data
  9. $scope.config.chargeList = response.data;
  10. $timeout(function () {
  11. //由于出现滚动条,导致横向空间减少,导致表格控件多出横向滚动条,需要resize
  12. $(window).trigger("resize");
  13. })
  14. });
  15. $scope.deleteCharge = function (index) {
  16. var chargeList = $scope.config.chargeList;
  17. if (chargeList[index]) {
  18. chargeList.splice(index, 1);
  19. }
  20. };
  21. //充值套餐
  22. $scope.addCharge = function () {
  23. var chargeList = $scope.config.chargeList;
  24. if (!$.isArray(chargeList)) {
  25. chargeList = $scope.config.chargeList = [];
  26. }
  27. var length = chargeList.length;
  28. var data = {};
  29. if (length == 0) {
  30. data = {
  31. payAmount: 1,
  32. coins: 1
  33. };
  34. } else {
  35. data = {
  36. payAmount: chargeList[length - 1]["payAmount"] * 2,
  37. coins: chargeList[length - 1]["coins"] * 2
  38. };
  39. }
  40. chargeList.push(data);
  41. };
  42. //保存充值优惠
  43. $scope.saveChargeData = function () {
  44. $http({
  45. method: 'POST',
  46. url: "/manager/saveChargeData",
  47. data: $scope.config.chargeList
  48. }).then(function (response) {
  49. toaster.pop("success", "提示", "保存成功!");
  50. }, function (response) {
  51. toaster.pop("error", "提示", "保存失败!");
  52. });
  53. };
  54. }]);