strangerListCtrl.js 2.3 KB

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