angular.module('push') .controller('DockingdetailsCtrl', function ($scope, UtilService, $stateParams, $sce, $timeout, CommentService, UserService, SqliteStorageService, HandleService, $ionicSlideBoxDelegate, $ionicActionSheet) { if($scope.app){ $scope.setStatusBar(0); } $scope.user = UserService.user.user; $scope.userid = UserService.id; $scope.creator = $stateParams.creator; var localinfoid = $stateParams.infoid;//是localinfoid //处理对接信息列表 var handleConninfoDetailData = function () { HandleService.handleConninfoDetailData(cardlist, personlist, themelist, productlist, iur1list, iur2list, yearprojectlist).then(function (response) { // console.log(response); $scope.cardlist = response; angular.forEach($scope.cardlist, function (value, index) { if (angular.isDefined(value.personlist) && value.personlist.length > 0) { var contactsrt = []; angular.forEach(value.personlist, function (val, ind) { contactsrt.push(val.contact); }); $scope.cardlist[index].contactsrt = contactsrt.join("、"); } $scope.cardlist[index].type = parseInt(value.type); }); }, function () { }); //关闭监听 overwatch(); }; //获取相关资源 $scope.getRelativeResource = function () { CommentService.getRelativeResource(0, $scope.conninfo.title, "", "", "", 0).then(function (response) { // console.log(response); $scope.relativelist = response.resourcelibrary; $scope.relativerecord = response.connectioninfoEntity; }, function () { }) }; $scope.isover = 0;//0:本地对接信息开始查询 4:查询结束 var personlist = []; var themelist = []; var cardlist = []; var productlist = []; var iur1list = []; var iur2list = []; var yearprojectlist = []; var uptemprecord = {}; //获取对接信息列表 var getConninfoList = function () { var sql = "select * from conninfo where localid = " + localinfoid; SqliteStorageService.queryData(sql).then(function (response) { // console.log(response); $scope.conninfo = response[0]; uptemprecord = angular.copy(response[0]); $scope.content = $sce.trustAsHtml(response[0].content); $scope.getRelativeResource(); //--查询图片信息 var q_pic_sql = "select * from conninfopicture where localinfoid = " + localinfoid; SqliteStorageService.queryData(q_pic_sql).then(function (res) { // console.log(res); $scope.picturelist = res; }, function () { }); //--查询名片信息 var q_com_sql = "select * from conninfounit where localinfoid = " + localinfoid; SqliteStorageService.queryData(q_com_sql).then(function (res) { // console.log(res); cardlist = res; if (cardlist.length > 0) { //组装名片localid list var cardlocalidstr = ""; angular.forEach(cardlist, function (data) { var tempstr = "'" + data.localid + "'"; cardlocalidstr = cardlocalidstr + tempstr + ","; }); cardlocalidstr = cardlocalidstr.substring(0, cardlocalidstr.length - 1); //--查询人员信息 var q_per_sql = "select * from conninfoperson where localuid in (" + cardlocalidstr + ")"; SqliteStorageService.queryData(q_per_sql).then(function (resp) { // console.log(resp); personlist = resp; $scope.isover++; }, function () { $scope.isover++; }); //--查询主题信息 var q_the_sql = "select * from conninfotheme where localuid in (" + cardlocalidstr + ")"; SqliteStorageService.queryData(q_the_sql).then(function (resp) { // console.log(resp); themelist = resp; $scope.isover++; }, function () { $scope.isover++; }); //--查询产品信息 var q_pro_sql = "select * from conninfoproduct where localuid in (" + cardlocalidstr + ")"; SqliteStorageService.queryData(q_pro_sql).then(function (resp) { // console.log(resp); productlist = resp; $scope.isover++; }, function () { $scope.isover++; }); //--查询产学研经历信息 var q_iur1_sql = "select * from conninfoiur where localuid in (" + cardlocalidstr + ")"; SqliteStorageService.queryData(q_iur1_sql).then(function (resp) { // console.log(resp); iur1list = resp; $scope.isover++; }, function () { $scope.isover++; }); //--查询重大科研项目信息 var q_iur2_sql = "select * from conninforesearch where localuid in (" + cardlocalidstr + ")"; SqliteStorageService.queryData(q_iur2_sql).then(function (resp) { // console.log(resp); iur2list = resp; $scope.isover++; }, function () { $scope.isover++; }); //--查询历年申报项目信息 var q_project_sql = "select * from yearproject where localuid in (" + cardlocalidstr + ")"; SqliteStorageService.queryData(q_project_sql).then(function (resp) { // console.log(resp); yearprojectlist = resp; $scope.isover++; }, function () { $scope.isover++; }); } }, function () { }); }, function (err) { // console.log(err); }); }; getConninfoList(); //监听查询是否结束 var overwatch = $scope.$watch("isover", function (newValue, oldValue, scope) { if (newValue == 6) { handleConninfoDetailData(); } }); //进入相关资源详情 $scope.goRelativeResource = function (relative) { if (relative.type == 81) { $scope.go('cloudDockingdetail', { infoid: relative.id, infocomefrom: relative.creatorcomefrom, creator: relative.creator }); } else { if (relative.groupid == "0") { $scope.go('resourceDetails', { recourceid: relative.unique, recourcetype: relative.type, recourcecomefrom: relative.source, 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.conninfo.title, categorylabel: "", recordid: 0 }); }; //显示更多名片部分 $scope.showMoreCard = function (index) { $(".parentWrapCard").eq(index).toggle(); $(".showCardWrap").eq(index).toggle(); $(".changeArrowButton").eq(index).toggleClass("upArrow"); }; //打开操作表 $scope.openActionSheet = function () { $ionicActionSheet.show({ buttons: [{text: '编辑'}], cancelText: '取消', buttonClicked: function (index) { if (index == 0) { $scope.go("editconninfo", {infoid: localinfoid}); } return true; } }); }; //点击图片放大 $scope.bigImage = false; //初始默认大图是隐藏的 $scope.hideBigImage = function () { $timeout(function () { $scope.bigImage = false; }, 400); }; $scope.shouBigImage = function (index) { //传递一个参数(图片的URl) $scope.bigImage = true; //显示大图 // console.log(index); $(function () { $('div.pinch-zoom').each(function () { new RTP.PinchZoom($(this), {}); }); }); $ionicSlideBoxDelegate.update();//重绘,让图片显示出来 //图片总数量 setTimeout(function () { // console.log(parseInt($ionicSlideBoxDelegate.slidesCount())); // console.log(parseInt($ionicSlideBoxDelegate.currentIndex())); $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, -5); // var nowIndex=parseInt($ionicSlideBoxDelegate.currentIndex()); var totalIndex = parseInt($ionicSlideBoxDelegate.slidesCount()); // console.log(index); $scope.nowIndex = index + 1; $scope.totalIndex = totalIndex; //获取图片 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; // console.log(oldWid/oldHei); // console.log(screen ); var cc = screen / (oldWid / oldHei); imgObj[n].style.height = cc + 'px'; if (cc < screenH) { imgObj[n].style.marginTop = (screenH - cc) / 2 + 'px'; // console.log("e:" + imgObj[n].style.marginTop); } else { imgObj[n].style.marginTop = 0 + 'px'; // console.log((cc - screenH) + 'px') } } }, 0); }; //查看原图 $scope.viewOldImg = function (index) { // console.log($scope.picturelist[index]); // console.log("查看原图" + index); var url = UtilService.isDefined($scope.picturelist[index].source_name) ? $scope.picturelist[index].source_name : $scope.picturelist[index].photo_name; $(".bigimage").eq(index).attr("src", $scope.imgUrl + url); $timeout(function () { $scope.picturelist[index].loadsource = true; }, 20); }; //拨打电话 $scope.openTel = function (tel) { window.open("tel:" + tel); }; });