angular.module('push') .controller('resourceLocalDetailsCtrl', function ($scope, SqliteStorageService, $stateParams, UtilService, CommentService, $sce, $timeout, UserService, $ionicActionSheet, $ionicSlideBoxDelegate) { if($scope.app){ $scope.setStatusBar(0); } //1:需求,2:成果,6:企业,8:人才 var recourceid = $stateParams.recourceid; var recourcetype = $scope.type = $stateParams.recourcetype; var recourcecomefrom = $stateParams.recourcecomefrom; var categorylabel = $stateParams.categorylabel; $scope.user = UserService.user.user; $scope.userid = UserService.id; $scope.comment = {content: ""}; //获取相关资源 $scope.getRelativeResource = function () { CommentService.getRelativeResource(0, $scope.resource.title, categorylabel, "", recourceid, "").then(function (response) { $scope.relativelist = response.resourcelibrary; $scope.relativerecord = response.connectioninfoEntity; }, function () { }) }; var sharelink = ""; //获取资源详情 var getPublicResourceList = function () { var sql = "select * from resource where localid = " + recourceid; SqliteStorageService.queryData(sql).then(function (response) { $scope.resource = response[0]; $scope.getRelativeResource(); $scope.contenthtml = $sce.trustAsHtml($scope.resource.content); }, function (err) { }); }; getPublicResourceList(); //进入相关资源详情 $scope.goRelativeResource = function (relative) { if (relative.type == 81) { $scope.go('cloudDockingdetail', {infoid: relative.id, creator: relative.creator}); } else { if (relative.groupid == "0") { $scope.go('resourceDetails', { recourceid: relative.unique, recourcetype: relative.type, recourcecomefrom: relative.source, categorylabel: categorylabel }); } else { $scope.go('resourcePrivateDetails', { recourceid: relative.unique, recourcetype: relative.type, recourcecomefrom: relative.source, creator: relative.clickthrough }); } } }; //进入相关资源列表 $scope.goResourceMatch = function (relative) { $scope.go('resourceMatch', {type: relative.type, title: $scope.resource.title, categorylabel: categorylabel}); }; //点击图片放大 $scope.bigImage = false; //初始默认大图是隐藏的 $scope.hideBigImage = function () { $timeout(function () { if($scope.app){ $scope.setStatusBar(0); } $scope.bigImage = false; }, 400); }; $scope.shouBigImage = function (piclist, index) { //传递一个参数(图片的URl) if($scope.app){ $scope.setStatusBar(1); } $scope.commentpiclist = piclist; $scope.bigImage = true; //显示大图 $(function () { $('div.pinch-zoom').each(function () { new RTP.PinchZoom($(this), {}); }); }); $ionicSlideBoxDelegate.update();//重绘,让图片显示出来 //图片总数量 setTimeout(function () { $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, 0); //获取图片 var imgObj = document.getElementsByClassName('bigimage'); var n; for (n = 0; n < imgObj.length; n++) { // 获取图片的原始高度和宽度 var oldWid = imgObj[n].naturalWidth; var oldHei = imgObj[n].naturalHeight; var screen = document.body.offsetWidth; var screenH = window.innerHeight; var cc = screen / (oldWid / oldHei); imgObj[n].style.height = cc + 'px'; if (cc < screenH) { imgObj[n].style.marginTop = (screenH - cc) / 2 + 'px'; } else { imgObj[n].style.marginTop = 0 + 'px'; } } }, 0); }; //查看原图 $scope.viewOldImg = function (index) { var url = UtilService.isDefined($scope.commentpiclist[index].source_name) ? $scope.commentpiclist[index].source_name : $scope.commentpiclist[index].photo_name; $(".bigimage").eq(index).attr("src", $scope.imgUrl + url); $timeout(function () { $scope.commentpiclist[index].loadsource = true; }, 20); }; //拨打电话 $scope.openTel = function (tel) { window.open("tel:" + tel); }; });