angular.module('push') .controller('strangerListCtrl', function ($scope, $timeout, $rootScope, $ionicLoading, $http, $ionicScrollDelegate, ScienceCircleService) { /* $scope.setStatusBar(0);*/ $scope.showMiddle = false; //是否在屏幕中央显示选中的字母索引 // 获取陌生人列表 var getContacts = function () { $scope.showLoadingToast(); ScienceCircleService.getContacts(2).then(function (response) { // console.log(response); $scope.mailDatas = response; //联系人首字母字母数组 $scope.letters = []; angular.forEach($scope.mailDatas, function (value, index) { $scope.letters.push(value.userUpper); }); $scope.hideLoadingToast(); }, function () { $scope.hideLoadingToast(); }); }; getContacts(); // 触摸字母定位至对应联系人 $scope.mTouch = function (event) { var c = $(this).attr("c"); $scope.hint = c; $scope.showMiddle = true; $timeout(function () { $scope.showMiddle = false; }, 300); var scroll = document.getElementById($scope.hint).offsetTop - $ionicScrollDelegate.getScrollPosition().top; $ionicScrollDelegate.scrollBy(0, scroll, true); var ele = document.getElementsByTagName("ion-content"); ele[0].style.overflow = "auto"; //解决滑动右边的导航字母后,左边不能再滚动的bug,可以试着注释这两句来测试这个问题 }; // 手指从屏幕上离开 隐藏中间显示的字母 $scope.mRelease = function () { $timeout(function () { $scope.showMiddle = false; }, 300); }; // 通讯录搜索 $scope.goSearchChatMail = function () { $scope.go('chatSearchModel'); }; // 查看个人主页 $scope.goPublisher = function (userId) { $scope.go('publisher', {Id: userId}); }; }) .directive('rjPositionMiddle', ['$window', function ($window) { return { replace: false, link: function (scope, iElm, iAttrs, controller) { var height = $window.innerHeight - 44 - 49 - iElm[0].offsetHeight; if (height >= 0) { iElm[0].style.top = (height / 2 + 44) + 'px'; } else { iElm[0].style.top = 44 + 'px'; } } } }]);