123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- angular.module('push')
- .controller('resourceListCtrl', function ($scope, UserService, $timeout, $stateParams, DockingService, $ionicPopup, UtilService, ModelService, $ionicListDelegate, SqliteStorageService, HandleService, $ionicActionSheet) {
- if($scope.app){
- $scope.setStatusBar(0);
- }
- var libtype = $stateParams.libtype;
- var reclibid = $stateParams.reclibid;
- $scope.privateName = $stateParams.privateName;
- $scope.name = $stateParams.name;
- var modlibid = $stateParams.modlibid;
- var isCloud = $stateParams.isCloud;
- $scope.user = UserService.user.user;
- $scope.userid = UserService.id;
- $scope.isload = false;
- var pageindex = 0;
- //取本地记录
- $scope.initResourceList = function () {
- var sql = "select * from resource where localclaid = '" + reclibid + "' and type = " + libtype + " order by timestamp desc limit 10 offset 0";
- SqliteStorageService.queryData(sql).then(function (response) {
- $scope.resourceList = response;
- //判读是否有下一页
- $scope.isload = response.length >= 10;
- if ($scope.isload) {
- pageindex = 10;
- }
- }, function () {
- $scope.resourceList = [];
- }).finally(function () {
- $scope.$broadcast('scroll.refreshComplete');
- });
- };
- $scope.initResourceList();
- //加载更多记录
- $scope.loadMore = function () {
- $scope.isload = false;
- var sql = "select * from resource where localclaid = '" + reclibid + "' and type = " + libtype + " order by timestamp desc limit 10 offset " + pageindex;
- SqliteStorageService.queryData(sql).then(function (response) {
- $scope.resourceList = $scope.resourceList.concat(response);
- //判读是否有下一页
- $scope.isload = response.length >= 10;
- if ($scope.isload) {
- pageindex += 10;
- }
- }, function () {
- }).finally(function () {
- $scope.$broadcast('scroll.infiniteScrollComplete');
- });
- };
- //点击进入对接详情
- $scope.goResourceDetail = function (rec) {
- $scope.go('resourceLocalDetails', {
- recourceid: rec.localid,
- recourcetype: rec.type,
- recourcecomefrom: rec.source,
- creator: rec.creator
- });
- };
- $scope.shareflg = false;
- $scope.openShare = function (tempobj, ind) {
- $scope.go('chooseShareResource', {
- chereslist: angular.toJson([tempobj.localid]),
- folderid: reclibid,
- isCloud: isCloud,
- recourcetype: tempobj.type,
- recourcecomefrom: tempobj.source
- });
- };
- //跳转工具搜索
- $scope.goToolsSearch = function () {
- //1:需求,2:成果,6:企业,8:人才
- var tabindex = 3;
- if (libtype == 1) {
- tabindex = 4;
- } else if (libtype == 2) {
- tabindex = 3;
- } else if (libtype == 6) {
- tabindex = 5;
- } else if (libtype == 8) {
- tabindex = 6;
- }
- $timeout(function () {
- $scope.go('resourceSearch', {resourcetype: 1001, reclibid: reclibid, tabindex: tabindex});
- }, 350);
- };
- $scope.refreshDate = function () {
- $scope.initResourceList();
- $scope.$broadcast('scroll.refreshComplete');
- var trHtml = "<div class='refresh_tip_div'>更新了" + $scope.recordList.length + "条内容</div>";
- $timeout(function () {
- $(".resourcelistDiv").prepend(trHtml);
- $(".refresh_tip_div").animate({width: 100 + "%"}, 150);
- }, 800);
- $timeout(function () {
- $(".refresh_tip_div").slideUp();
- }, 1200);
- }
- });
|