authorityAddMemberCtrl.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. angular.module('push')
  2. .controller('authorityAddMemberCtrl', function ($scope, $stateParams, UserService, UtilService, CommentService, AuthorityService,
  3. AuthorityModelService, AuthorityModel, ShareService, $timeout, ConfigService) {
  4. //切换关注、权限
  5. $scope.act = true;
  6. $scope.changeTab = function () {
  7. $scope.act = !$scope.act;
  8. };
  9. var authorityid = $stateParams.authid;
  10. var authoritycomefrom = $stateParams.authcomefrom;
  11. var useridlist = [];
  12. $scope.qrcodeurl = ConfigService.server + "getCloudAutQRCode.action?url=" + AuthorityModel.invite_url;
  13. var initData = function () {
  14. //获取关注用户列表
  15. CommentService.getMyAttentionList(0, authorityid, authoritycomefrom).then(function (response) {
  16. // console.log(response);
  17. $scope.userList = response.userList;
  18. }, function () {
  19. });
  20. //获取权限列表
  21. AuthorityService.getAuthorityList(authorityid, authoritycomefrom).then(function (response) {
  22. // console.log(response);
  23. $scope.AuthorityList = response.cloautlist;
  24. }, function () {
  25. UtilService.showMess("网络不给力,请稍后重试");
  26. });
  27. };
  28. initData();
  29. var addUser = function () {
  30. var useridstr = useridlist.join(',');
  31. AuthorityService.editAuthority(2, authorityid, authoritycomefrom, "", useridstr).then(function (response) {
  32. // console.log(response);
  33. AuthorityModel.editmemberflg = true;
  34. }, function () {
  35. UtilService.showMess("网络不给力,请稍后重试");
  36. });
  37. };
  38. //关注用户添加
  39. $scope.addMember = function (user, index) {
  40. useridlist = [];
  41. $scope.userList[index].isExisits = 1;
  42. useridlist.push(user.userId);
  43. addUser();
  44. };
  45. //批量导入权限
  46. $scope.addAuthority = function (authority, index) {
  47. useridlist = [];
  48. $scope.AuthorityList[index].isadd = 1;
  49. angular.forEach($scope.AuthorityList[index].userList, function (data, ind) {
  50. $scope.AuthorityList[index].userList[ind].isExisits = 1;
  51. useridlist.push($scope.AuthorityList[index].userList[ind].userId);
  52. });
  53. addUser();
  54. };
  55. //单个导入权限下用户
  56. $scope.addAuthorityMember = function (authority, user, index) {
  57. useridlist = [];
  58. var i = $scope.AuthorityList.indexOf(authority);
  59. $scope.AuthorityList[i].userList[index].isExisits = 1;
  60. useridlist.push($scope.AuthorityList[i].userList[index].userId);
  61. addUser();
  62. };
  63. //是否现在权限下用户
  64. $scope.showMember = function (index) {
  65. $scope.AuthorityList[index].showlist = !$scope.AuthorityList[index].showlist;
  66. };
  67. $scope.goUserSearch = function () {
  68. $scope.go('userSearch', {searchtype: 1, isset: 1, authorityid: authorityid, authoritycomefrom: authoritycomefrom});
  69. };
  70. $scope.goGroupCreate = function () {
  71. AuthorityModelService.isfirst = 0;
  72. $scope.go('groupCreate');
  73. };
  74. $scope.openShare = function () {
  75. $scope.showshare = true;
  76. };
  77. $scope.cancelShare = function () {
  78. $scope.showshare = false;
  79. };
  80. //隐藏二维码
  81. $scope.hiddenTwoCode = function () {
  82. $(".fixedTwo").css("display", "none");
  83. };
  84. //0:QQ,1:QQ空间,2:微信,3:微信朋友圈,4:新浪微博,5:邀请二维码
  85. $scope.shareMessage = function (type) {
  86. $scope.showshare = false;
  87. $scope.showLoadingToast();
  88. var title = '"' + UserService.user.user.userName + '"邀请你加入' + AuthorityModel.getReclibName();
  89. var message = {
  90. title: title,
  91. description: "使用对接宝、随时随地体验高效便捷",
  92. url: AuthorityModel.invite_url,
  93. imageurl: "http://pic.ubittc.com/group3/M00/04/31/wKjILFkIQKWACad2AABJ-vCWu_4719.jpg"
  94. };
  95. switch (type) {
  96. case 0:
  97. case 1:
  98. ShareService.shareToQQ(type, message).then(function () {
  99. UtilService.showMess("QQ分享成功");
  100. $scope.hideLoadingToast();
  101. }, function (error) {
  102. UtilService.showMess(error);
  103. $scope.hideLoadingToast();
  104. });
  105. break;
  106. case 2:
  107. case 3:
  108. ShareService.shareToWechat(0, message).then(function () {
  109. UtilService.showMess("微信分享成功");
  110. $scope.hideLoadingToast();
  111. }, function (error) {
  112. UtilService.showMess(error);
  113. $scope.hideLoadingToast();
  114. });
  115. break;
  116. case 4:
  117. ShareService.shareToWeibo(message).then(function () {
  118. UtilService.showMess("新浪微博分享成功");
  119. $scope.hideLoadingToast();
  120. }, function (error) {
  121. UtilService.showMess(error);
  122. $scope.hideLoadingToast();
  123. });
  124. break;
  125. case 5:
  126. $(".fixedTwo").css("display", "block");
  127. $scope.hideLoadingToast();
  128. break;
  129. default:
  130. break;
  131. }
  132. $timeout(function () {
  133. $scope.hideLoadingToast();
  134. }, 10000);
  135. };
  136. });