DockingdetailsCtrl.js 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. angular.module('push')
  2. .controller('DockingdetailsCtrl', function ($scope, UtilService, $stateParams, $sce, $timeout, CommentService,
  3. UserService, SqliteStorageService, HandleService, $ionicSlideBoxDelegate, $ionicActionSheet) {
  4. if($scope.app){
  5. $scope.setStatusBar(0);
  6. }
  7. $scope.user = UserService.user.user;
  8. $scope.userid = UserService.id;
  9. $scope.creator = $stateParams.creator;
  10. var localinfoid = $stateParams.infoid;//是localinfoid
  11. //处理对接信息列表
  12. var handleConninfoDetailData = function () {
  13. HandleService.handleConninfoDetailData(cardlist, personlist, themelist, productlist, iur1list, iur2list, yearprojectlist).then(function (response) {
  14. // console.log(response);
  15. $scope.cardlist = response;
  16. angular.forEach($scope.cardlist, function (value, index) {
  17. if (angular.isDefined(value.personlist) && value.personlist.length > 0) {
  18. var contactsrt = [];
  19. angular.forEach(value.personlist, function (val, ind) {
  20. contactsrt.push(val.contact);
  21. });
  22. $scope.cardlist[index].contactsrt = contactsrt.join("、");
  23. }
  24. $scope.cardlist[index].type = parseInt(value.type);
  25. });
  26. }, function () {
  27. });
  28. //关闭监听
  29. overwatch();
  30. };
  31. //获取相关资源
  32. $scope.getRelativeResource = function () {
  33. CommentService.getRelativeResource(0, $scope.conninfo.title, "", "", "", 0).then(function (response) {
  34. // console.log(response);
  35. $scope.relativelist = response.resourcelibrary;
  36. $scope.relativerecord = response.connectioninfoEntity;
  37. }, function () {
  38. })
  39. };
  40. $scope.isover = 0;//0:本地对接信息开始查询 4:查询结束
  41. var personlist = [];
  42. var themelist = [];
  43. var cardlist = [];
  44. var productlist = [];
  45. var iur1list = [];
  46. var iur2list = [];
  47. var yearprojectlist = [];
  48. var uptemprecord = {};
  49. //获取对接信息列表
  50. var getConninfoList = function () {
  51. var sql = "select * from conninfo where localid = " + localinfoid;
  52. SqliteStorageService.queryData(sql).then(function (response) {
  53. // console.log(response);
  54. $scope.conninfo = response[0];
  55. uptemprecord = angular.copy(response[0]);
  56. $scope.content = $sce.trustAsHtml(response[0].content);
  57. $scope.getRelativeResource();
  58. //--查询图片信息
  59. var q_pic_sql = "select * from conninfopicture where localinfoid = " + localinfoid;
  60. SqliteStorageService.queryData(q_pic_sql).then(function (res) {
  61. // console.log(res);
  62. $scope.picturelist = res;
  63. }, function () {
  64. });
  65. //--查询名片信息
  66. var q_com_sql = "select * from conninfounit where localinfoid = " + localinfoid;
  67. SqliteStorageService.queryData(q_com_sql).then(function (res) {
  68. // console.log(res);
  69. cardlist = res;
  70. if (cardlist.length > 0) {
  71. //组装名片localid list
  72. var cardlocalidstr = "";
  73. angular.forEach(cardlist, function (data) {
  74. var tempstr = "'" + data.localid + "'";
  75. cardlocalidstr = cardlocalidstr + tempstr + ",";
  76. });
  77. cardlocalidstr = cardlocalidstr.substring(0, cardlocalidstr.length - 1);
  78. //--查询人员信息
  79. var q_per_sql = "select * from conninfoperson where localuid in (" + cardlocalidstr + ")";
  80. SqliteStorageService.queryData(q_per_sql).then(function (resp) {
  81. // console.log(resp);
  82. personlist = resp;
  83. $scope.isover++;
  84. }, function () {
  85. $scope.isover++;
  86. });
  87. //--查询主题信息
  88. var q_the_sql = "select * from conninfotheme where localuid in (" + cardlocalidstr + ")";
  89. SqliteStorageService.queryData(q_the_sql).then(function (resp) {
  90. // console.log(resp);
  91. themelist = resp;
  92. $scope.isover++;
  93. }, function () {
  94. $scope.isover++;
  95. });
  96. //--查询产品信息
  97. var q_pro_sql = "select * from conninfoproduct where localuid in (" + cardlocalidstr + ")";
  98. SqliteStorageService.queryData(q_pro_sql).then(function (resp) {
  99. // console.log(resp);
  100. productlist = resp;
  101. $scope.isover++;
  102. }, function () {
  103. $scope.isover++;
  104. });
  105. //--查询产学研经历信息
  106. var q_iur1_sql = "select * from conninfoiur where localuid in (" + cardlocalidstr + ")";
  107. SqliteStorageService.queryData(q_iur1_sql).then(function (resp) {
  108. // console.log(resp);
  109. iur1list = resp;
  110. $scope.isover++;
  111. }, function () {
  112. $scope.isover++;
  113. });
  114. //--查询重大科研项目信息
  115. var q_iur2_sql = "select * from conninforesearch where localuid in (" + cardlocalidstr + ")";
  116. SqliteStorageService.queryData(q_iur2_sql).then(function (resp) {
  117. // console.log(resp);
  118. iur2list = resp;
  119. $scope.isover++;
  120. }, function () {
  121. $scope.isover++;
  122. });
  123. //--查询历年申报项目信息
  124. var q_project_sql = "select * from yearproject where localuid in (" + cardlocalidstr + ")";
  125. SqliteStorageService.queryData(q_project_sql).then(function (resp) {
  126. // console.log(resp);
  127. yearprojectlist = resp;
  128. $scope.isover++;
  129. }, function () {
  130. $scope.isover++;
  131. });
  132. }
  133. }, function () {
  134. });
  135. }, function (err) {
  136. // console.log(err);
  137. });
  138. };
  139. getConninfoList();
  140. //监听查询是否结束
  141. var overwatch = $scope.$watch("isover", function (newValue, oldValue, scope) {
  142. if (newValue == 6) {
  143. handleConninfoDetailData();
  144. }
  145. });
  146. //进入相关资源详情
  147. $scope.goRelativeResource = function (relative) {
  148. if (relative.type == 81) {
  149. $scope.go('cloudDockingdetail', {
  150. infoid: relative.id,
  151. infocomefrom: relative.creatorcomefrom,
  152. creator: relative.creator
  153. });
  154. } else {
  155. if (relative.groupid == "0") {
  156. $scope.go('resourceDetails', {
  157. recourceid: relative.unique,
  158. recourcetype: relative.type,
  159. recourcecomefrom: relative.source,
  160. categorylabel: ""
  161. });
  162. } else {
  163. $scope.go('resourcePrivateDetails', {
  164. recourceid: relative.unique,
  165. recourcetype: relative.type,
  166. recourcecomefrom: relative.source,
  167. creator: relative.clickthrough
  168. });
  169. }
  170. }
  171. };
  172. //进入相关资源列表
  173. $scope.goResourceMatch = function (relative) {
  174. $scope.go('resourceMatch', {
  175. type: relative.type,
  176. title: $scope.conninfo.title,
  177. categorylabel: "",
  178. recordid: 0
  179. });
  180. };
  181. //显示更多名片部分
  182. $scope.showMoreCard = function (index) {
  183. $(".parentWrapCard").eq(index).toggle();
  184. $(".showCardWrap").eq(index).toggle();
  185. $(".changeArrowButton").eq(index).toggleClass("upArrow");
  186. };
  187. //打开操作表
  188. $scope.openActionSheet = function () {
  189. $ionicActionSheet.show({
  190. buttons: [{text: '编辑'}],
  191. cancelText: '取消',
  192. buttonClicked: function (index) {
  193. if (index == 0) {
  194. $scope.go("editconninfo", {infoid: localinfoid});
  195. }
  196. return true;
  197. }
  198. });
  199. };
  200. //点击图片放大
  201. $scope.bigImage = false; //初始默认大图是隐藏的
  202. $scope.hideBigImage = function () {
  203. $timeout(function () {
  204. $scope.bigImage = false;
  205. }, 400);
  206. };
  207. $scope.shouBigImage = function (index) { //传递一个参数(图片的URl)
  208. $scope.bigImage = true; //显示大图
  209. // console.log(index);
  210. $(function () {
  211. $('div.pinch-zoom').each(function () {
  212. new RTP.PinchZoom($(this), {});
  213. });
  214. });
  215. $ionicSlideBoxDelegate.update();//重绘,让图片显示出来
  216. //图片总数量
  217. setTimeout(function () {
  218. // console.log(parseInt($ionicSlideBoxDelegate.slidesCount()));
  219. // console.log(parseInt($ionicSlideBoxDelegate.currentIndex()));
  220. $ionicSlideBoxDelegate.$getByHandle('slide_detail').slide(index, -5);
  221. // var nowIndex=parseInt($ionicSlideBoxDelegate.currentIndex());
  222. var totalIndex = parseInt($ionicSlideBoxDelegate.slidesCount());
  223. // console.log(index);
  224. $scope.nowIndex = index + 1;
  225. $scope.totalIndex = totalIndex;
  226. //获取图片
  227. var imgObj = document.getElementsByClassName('bigimage');
  228. var n;
  229. for (n = 0; n < imgObj.length; n++) {
  230. // 获取图片的原始高度和宽度
  231. var oldWid = imgObj[n].naturalWidth;
  232. var oldHei = imgObj[n].naturalHeight;
  233. var screen = document.body.offsetWidth;
  234. var screenH = window.innerHeight;
  235. // console.log(oldWid/oldHei);
  236. // console.log(screen );
  237. var cc = screen / (oldWid / oldHei);
  238. imgObj[n].style.height = cc + 'px';
  239. if (cc < screenH) {
  240. imgObj[n].style.marginTop = (screenH - cc) / 2 + 'px';
  241. // console.log("e:" + imgObj[n].style.marginTop);
  242. } else {
  243. imgObj[n].style.marginTop = 0 + 'px';
  244. // console.log((cc - screenH) + 'px')
  245. }
  246. }
  247. }, 0);
  248. };
  249. //查看原图
  250. $scope.viewOldImg = function (index) {
  251. // console.log($scope.picturelist[index]);
  252. // console.log("查看原图" + index);
  253. var url = UtilService.isDefined($scope.picturelist[index].source_name) ? $scope.picturelist[index].source_name : $scope.picturelist[index].photo_name;
  254. $(".bigimage").eq(index).attr("src", $scope.imgUrl + url);
  255. $timeout(function () {
  256. $scope.picturelist[index].loadsource = true;
  257. }, 20);
  258. };
  259. //拨打电话
  260. $scope.openTel = function (tel) {
  261. window.open("tel:" + tel);
  262. };
  263. });