resourceLocalDetailsCtrl.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. angular.module('push')
  2. .controller('resourceLocalDetailsCtrl', function ($scope, SqliteStorageService, $stateParams, UtilService,
  3. CommentService, $sce, $timeout, UserService, $ionicActionSheet, $ionicSlideBoxDelegate) {
  4. if($scope.app){
  5. $scope.setStatusBar(0);
  6. }
  7. //1:需求,2:成果,6:企业,8:人才
  8. var recourceid = $stateParams.recourceid;
  9. var recourcetype = $scope.type = $stateParams.recourcetype;
  10. var recourcecomefrom = $stateParams.recourcecomefrom;
  11. var categorylabel = $stateParams.categorylabel;
  12. $scope.user = UserService.user.user;
  13. $scope.userid = UserService.id;
  14. $scope.comment = {content: ""};
  15. //获取相关资源
  16. $scope.getRelativeResource = function () {
  17. CommentService.getRelativeResource(0, $scope.resource.title, categorylabel, "", recourceid, "").then(function (response) {
  18. $scope.relativelist = response.resourcelibrary;
  19. $scope.relativerecord = response.connectioninfoEntity;
  20. }, function () {
  21. })
  22. };
  23. var sharelink = "";
  24. //获取资源详情
  25. var getPublicResourceList = function () {
  26. var sql = "select * from resource where localid = " + recourceid;
  27. SqliteStorageService.queryData(sql).then(function (response) {
  28. $scope.resource = response[0];
  29. $scope.getRelativeResource();
  30. $scope.contenthtml = $sce.trustAsHtml($scope.resource.content);
  31. }, function (err) {
  32. });
  33. };
  34. getPublicResourceList();
  35. //进入相关资源详情
  36. $scope.goRelativeResource = function (relative) {
  37. if (relative.type == 81) {
  38. $scope.go('cloudDockingdetail', {infoid: relative.id, creator: relative.creator});
  39. } else {
  40. if (relative.groupid == "0") {
  41. $scope.go('resourceDetails', {
  42. recourceid: relative.unique,
  43. recourcetype: relative.type,
  44. recourcecomefrom: relative.source,
  45. categorylabel: categorylabel
  46. });
  47. } else {
  48. $scope.go('resourcePrivateDetails', {
  49. recourceid: relative.unique,
  50. recourcetype: relative.type,
  51. recourcecomefrom: relative.source,
  52. creator: relative.clickthrough
  53. });
  54. }
  55. }
  56. };
  57. //进入相关资源列表
  58. $scope.goResourceMatch = function (relative) {
  59. $scope.go('resourceMatch', {type: relative.type, title: $scope.resource.title, categorylabel: categorylabel});
  60. };
  61. //点击图片放大
  62. $scope.bigImage = false; //初始默认大图是隐藏的
  63. $scope.hideBigImage = function () {
  64. $timeout(function () {
  65. if($scope.app){
  66. $scope.setStatusBar(0);
  67. }
  68. $scope.bigImage = false;
  69. }, 400);
  70. };
  71. $scope.shouBigImage = function (piclist, index) { //传递一个参数(图片的URl)
  72. if($scope.app){
  73. $scope.setStatusBar(1);
  74. }
  75. $scope.commentpiclist = piclist;
  76. $scope.bigImage = true; //显示大图
  77. $(function () {
  78. $('div.pinch-zoom').each(function () {
  79. new RTP.PinchZoom($(this), {});
  80. });
  81. });
  82. $ionicSlideBoxDelegate.update();//重绘,让图片显示出来
  83. //图片总数量
  84. setTimeout(function () {
  85. $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, 0);
  86. //获取图片
  87. var imgObj = document.getElementsByClassName('bigimage');
  88. var n;
  89. for (n = 0; n < imgObj.length; n++) {
  90. // 获取图片的原始高度和宽度
  91. var oldWid = imgObj[n].naturalWidth;
  92. var oldHei = imgObj[n].naturalHeight;
  93. var screen = document.body.offsetWidth;
  94. var screenH = window.innerHeight;
  95. var cc = screen / (oldWid / oldHei);
  96. imgObj[n].style.height = cc + 'px';
  97. if (cc < screenH) {
  98. imgObj[n].style.marginTop = (screenH - cc) / 2 + 'px';
  99. } else {
  100. imgObj[n].style.marginTop = 0 + 'px';
  101. }
  102. }
  103. }, 0);
  104. };
  105. //查看原图
  106. $scope.viewOldImg = function (index) {
  107. var url = UtilService.isDefined($scope.commentpiclist[index].source_name) ? $scope.commentpiclist[index].source_name : $scope.commentpiclist[index].photo_name;
  108. $(".bigimage").eq(index).attr("src", $scope.imgUrl + url);
  109. $timeout(function () {
  110. $scope.commentpiclist[index].loadsource = true;
  111. }, 20);
  112. };
  113. //拨打电话
  114. $scope.openTel = function (tel) {
  115. window.open("tel:" + tel);
  116. };
  117. });