chatMailListCtrl.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. angular.module('push')
  2. .controller('chatMailListCtrl', function ($scope, $timeout, $rootScope, $ionicLoading, $http, $ionicScrollDelegate, ScienceCircleService) {
  3. if($scope.app){
  4. $scope.setStatusBar(0);
  5. }
  6. $scope.showMiddle = false; //是否在屏幕中央显示选中的字母索引
  7. // 获取通讯录列表
  8. var getContacts = function () {
  9. $scope.showLoadingToast();
  10. ScienceCircleService.getContacts(0).then(function (response) {
  11. console.log(response);
  12. $scope.mailDatas = response;
  13. //联系人首字母字母数组
  14. $scope.letters = [];
  15. angular.forEach($scope.mailDatas, function (value, index) {
  16. $scope.letters.push(value.userUpper);
  17. });
  18. $scope.heightAccount=20*($scope.letters.length)+"px";
  19. $scope.hideLoadingToast();
  20. }, function () {
  21. $scope.hideLoadingToast();
  22. });
  23. };
  24. getContacts();
  25. // 触摸字母定位至对应联系人
  26. $scope.mTouch = function (event) {
  27. var c = $(this).attr("c");
  28. $scope.hint = c;
  29. $scope.showMiddle = true;
  30. $timeout(function () {
  31. $scope.showMiddle = false;
  32. }, 300);
  33. var scroll = document.getElementById($scope.hint).offsetTop - $ionicScrollDelegate.getScrollPosition().top;
  34. $ionicScrollDelegate.scrollBy(0, scroll, true);
  35. var ele = document.getElementsByTagName("ion-content");
  36. ele[0].style.overflow = "auto"; //解决滑动右边的导航字母后,左边不能再滚动的bug,可以试着注释这两句来测试这个问题
  37. };
  38. // 手指从屏幕上离开 隐藏中间显示的字母
  39. $scope.mRelease = function () {
  40. $timeout(function () {
  41. $scope.showMiddle = false;
  42. }, 300);
  43. };
  44. // 通讯录搜索
  45. $scope.goSearchChatMail = function () {
  46. $scope.go('chatSearchModel');
  47. };
  48. // 添加好友
  49. $scope.addChatFriends = function () {
  50. $scope.go('addChatFriends');
  51. };
  52. // 进入陌生人页面
  53. $scope.goStrangerList = function () {
  54. $scope.go("strangerList");
  55. };
  56. // 查看个人主页
  57. $scope.goPublisher = function (userId) {
  58. $scope.go('publisher', {Id: userId});
  59. };
  60. // 我的粉丝
  61. $scope.goMyFans = function () {
  62. $scope.go('chatMailListFans');
  63. };
  64. });
  65. /* .directive('rjPositionMiddle', ['$window', function ($window) {
  66. return {
  67. replace: false,
  68. link: function (scope, iElm, iAttrs, controller) {
  69. var height = $window.innerHeight - 44 - 49 - iElm[0].offsetHeight;
  70. if (height >= 0) {
  71. iElm[0].style.top = (height / 2 + 44) + 'px';
  72. } else {
  73. iElm[0].style.top = 44 + 'px';
  74. }
  75. }
  76. }
  77. }]);*/