ActivityLogistyCtrl.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. angular.module('push')
  2. .controller('ActivityLogistyCtrl', function ($scope, $stateParams, DockingService, UserService,$timeout,$ionicSlideBoxDelegate) {
  3. var folupid = $stateParams.folupid;
  4. $scope.role = $stateParams.role;// 当前用户的权限:0用户 3超级管理员
  5. var orgname = $stateParams.orgname;
  6. $scope.docking_content = $stateParams.docking_content;
  7. $scope.user = UserService.user.user;
  8. $scope.addressstr = "";
  9. // 获取企业对应的活动跟进表明细
  10. var getActivitiesFollowupInfo = function () {
  11. $scope.showLoadingToast();
  12. DockingService.getActivitiesFollowupInfo(folupid, $scope.role, orgname, $scope.docking_content).then(function (response) {
  13. if ($scope.role == 0) {
  14. $scope.activityInfo = response.activityList[0];
  15. var tempimglist = [];
  16. angular.forEach($scope.activityInfo.taglist, function (value, index) {
  17. if (angular.isDefined(value.picList)) {
  18. if (tempimglist.length > 0) {
  19. tempimglist = tempimglist.concat(value.picList);
  20. } else {
  21. tempimglist = value.picList;
  22. }
  23. }
  24. });
  25. $scope.activityInfo.imagelist = tempimglist;
  26. }
  27. if ($scope.role == 3) {
  28. $scope.activitylist = response.activityList;
  29. $scope.companyinfo = response.activityList[0];
  30. $scope.orglogo = response.activityList[$scope.activitylist.length - 1].orglogo;
  31. angular.forEach($scope.activitylist, function (val, ind) {
  32. var tempimglist = [];
  33. angular.forEach(val.taglist, function (value, index) {
  34. if (angular.isDefined(value.picList)) {
  35. if (tempimglist.length > 0) {
  36. tempimglist = tempimglist.concat(value.picList);
  37. } else {
  38. tempimglist = value.picList;
  39. }
  40. }
  41. });
  42. $scope.activitylist[ind].imagelist = tempimglist;
  43. })
  44. }
  45. if(angular.isDefined($scope.activityInfo.orgplaceaddress)) {
  46. repslash($scope.activityInfo.orgplaceaddress);
  47. }
  48. $scope.hideLoadingToast();
  49. }, function () {
  50. UtilService.showMess("网络不给力,请重试");
  51. $scope.hideLoadingToast();
  52. });
  53. };
  54. getActivitiesFollowupInfo();
  55. var repslash = function (str) {
  56. $scope.addressstr = str.replace("/","");
  57. if($scope.addressstr.indexOf("/") != -1){
  58. repslash($scope.addressstr);
  59. }else {
  60. return $scope.addressstr;
  61. }
  62. };
  63. //点击图片放大
  64. $scope.bigImage = false; //初始默认大图是隐藏的
  65. $scope.hideBigImage = function () {
  66. if($scope.app){
  67. $scope.setStatusBar(0);
  68. }
  69. $timeout(function () {
  70. $scope.bigImage = false;
  71. }, 400);
  72. };
  73. $scope.shouBigImage = function (index) { //传递一个参数(图片的URl)
  74. if($scope.app){
  75. $scope.setStatusBar(1);
  76. }
  77. $(function () {
  78. $('div.pinch-zoom').each(function () {
  79. new RTP.PinchZoom($(this), {});
  80. });
  81. });
  82. $scope.bigImage = true;//显示大图
  83. $ionicSlideBoxDelegate.update();//重绘,让图片显示出来
  84. //图片总数量
  85. setTimeout(function () {
  86. $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, -10);
  87. //获取图片
  88. var imgObj = document.getElementsByClassName('bigimage');
  89. var n;
  90. for (n = 0; n < imgObj.length; n++) {
  91. // 获取图片的原始高度和宽度
  92. var oldWid = imgObj[n].naturalWidth;
  93. var oldHei = imgObj[n].naturalHeight;
  94. var screen = document.body.offsetWidth;
  95. var screenH = window.innerHeight;
  96. // console.log(oldWid / oldHei);
  97. // console.log(screen);
  98. var cc = screen / (oldWid / oldHei);
  99. imgObj[n].style.height = cc + 'px';
  100. if (cc < screenH) {
  101. imgObj[n].style.marginTop = (screenH - cc) / 2 + 'px';
  102. // console.log("e:"+imgObj[n].style.marginTop);
  103. } else {
  104. imgObj[n].style.marginTop = 0 + 'px';
  105. // console.log((cc-screenH) +'px')
  106. }
  107. }
  108. }, 10);
  109. };
  110. //删除图片
  111. $scope.deletePhoto = function (index) {
  112. $scope.activityInfo.imagelist.splice(index, 1);
  113. };
  114. });