widgetCtrl.js 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. app.controller('widgetCtrl', ['$scope', '$http', '$timeout', '$q', 'toaster', 'FileUploader', function ($scope, $http, $timeout, $q, toaster, FileUploader) {
  2. //文件提交控件
  3. var uploader = $scope.uploader = new FileUploader({
  4. url: '/common/upload?category=wechatValidate&type=wechatValidate',
  5. queueLimit: 1, //文件个数
  6. removeAfterUpload: true //上传后删除文件
  7. });
  8. //注册上传事件
  9. uploader.onCompleteItem = function (fileItem, response, status, headers) {
  10. if (response.payload) {
  11. //适配数据
  12. response.data = response.payload;
  13. }
  14. if (response.result) {
  15. toaster.pop("success", "提示", "上传成功!请点击检查");
  16. $scope.fileLink = location.protocol + "//" + location.host + "/" + response.data;
  17. } else {
  18. toaster.pop("error", "失败", response.description);
  19. }
  20. clearUploader();
  21. };
  22. uploader.onErrorItem = function (fileItem, response, status, headers) {
  23. toaster.pop("error", "提示", "上传失败,请重试");
  24. clearUploader();
  25. };
  26. /*恢复上传框初始状态*/
  27. function clearUploader() {
  28. $("#fileUpload").val("");
  29. uploader.clearQueue();
  30. uploader.cancelAll();
  31. }
  32. /************预充值***********************/
  33. var defaultValue = {
  34. agent: {id: "", nickname: "-选择代理商-"},
  35. };
  36. //下拉框数据
  37. $scope.condition = {
  38. agent: [defaultValue.agent],
  39. };
  40. //查询条件
  41. $scope.query = {
  42. agent: defaultValue.agent,
  43. cardNoStart: "",
  44. cardNoEnd: "",
  45. money: 120,
  46. };
  47. $scope.ngEvent = {
  48. prepChargeCard: function () {
  49. if (!$scope.query.agent || !$scope.query.agent.id) {
  50. toaster.pop("info", "提示", "请选择代理商!");
  51. return;
  52. }
  53. var data = {
  54. agentId: $scope.query.agent.id,
  55. cardNoStart: $scope.query.cardNoStart,
  56. cardNoEnd: $scope.query.cardNoEnd,
  57. money: $scope.query.money,
  58. };
  59. $http({
  60. method: 'POST',
  61. url: "/manager/initCardsBalance",
  62. data: data
  63. }).then(function (response) {
  64. toaster.pop("success", "提示", "预充值成功!");
  65. }, function (response) {
  66. toaster.pop("error", "提示", "保存失败!");
  67. });
  68. }
  69. };
  70. //不传分页参数则获取全部代理商
  71. $http.get('/agent/getAgentsDetailList', {}).then(function (data) {
  72. data = data.data
  73. $scope.condition.agent = data.data.dataList;
  74. $scope.condition.agent.unshift(defaultValue.agent);//可以选空
  75. });
  76. }]);