chatMailListFansCtrl.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. angular.module('push')
  2. .controller('chatMailListFansCtrl', function ($scope, $timeout, $rootScope, $ionicLoading, $http, $ionicScrollDelegate, ScienceCircleService) {
  3. if($scope.app){
  4. $scope.setStatusBar(0);
  5. }
  6. $scope.showMiddle = false; //是否在屏幕中央显示选中的字母索引
  7. // 获取通讯录列表
  8. var getFans = function () {
  9. $scope.showLoadingToast();
  10. ScienceCircleService.getContacts(1).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. getFans();
  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.goPublisher = function (userId) {
  46. $scope.go('publisher', {Id: userId});
  47. };
  48. });
  49. /* .directive('rjPositionMiddle', ['$window', function ($window) {
  50. return {
  51. replace: false,
  52. link: function (scope, iElm, iAttrs, controller) {
  53. var height = $window.innerHeight - 44 - 49 - iElm[0].offsetHeight;
  54. if (height >= 0) {
  55. iElm[0].style.top = (height / 2 + 44) + 'px';
  56. } else {
  57. iElm[0].style.top = 44 + 'px';
  58. }
  59. }
  60. }
  61. }]);*/