123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369 |
- angular.module('push')
- .controller('connInfoListCtrl', function ($scope, UserService, $timeout, $stateParams, DockingService, $ionicPopup, UtilService, ModelService, $ionicListDelegate, SqliteStorageService, HandleService, $ionicActionSheet) {
- if($scope.app){
- $scope.setStatusBar(0);
- }
- var cloudfolder = angular.fromJson($stateParams.folder);
- $scope.name = cloudfolder.name;
- $scope.user = UserService.user.user;
- var checkedresource = {};//单个分享时选中的资源
- var checkedindex = -1;//多个分享时第一个选择的索引
- $scope.checkedresourcelist = [];//多个分享时选中的资源
- $scope.userid = UserService.id;
- $scope.isload = false;
- var pageindex = 0;
- //--本地记录列表提取第一张图为列表显示图
- var extractConninfoPicture = function (conninfolist, picturelist, flg) {
- HandleService.extractConninfoPicture(conninfolist, picturelist).then(function (response) {
- if (flg) {
- $scope.recordList = response;
- } else {
- $scope.recordList = $scope.recordList.concat(response);
- }
- //判读是否有下一页
- $scope.isload = response.length >= 10;
- if ($scope.isload) {
- if (flg) {
- pageindex = 10;
- } else {
- pageindex += 10;
- }
- }
- // console.log($scope.recordList);
- }, function () {
- })
- };
- //取本地记录
- $scope.initConninfoList = function () {
- var q_sql = "select c1.*,foldercounts,infocounts from " +
- "(select * from conninfofolder where localparentid = '" + cloudfolder.localid + "') c1 " +
- "LEFT JOIN " +
- "(" +
- "select localparentid,count(1) foldercounts from " +
- "conninfofolder where localparentid in " +
- "(select localid from conninfofolder where localparentid = '" + cloudfolder.localid + "') " +
- "GROUP BY localparentid " +
- ") c2 " +
- "ON c1.localid = c2.localparentid " +
- "LEFT JOIN " +
- "(" +
- "select localclaid, count(1) infocounts " +
- "from conninfo where localclaid in " +
- "(select localid from conninfofolder where localparentid = '" + cloudfolder.localid + "') " +
- "GROUP BY localclaid " +
- ") c3" +
- " ON c1.localid = c3.localclaid";
- // var sql1 = "select * from conninfofolder where localparentid = order by updatetime desc";
- SqliteStorageService.queryData(q_sql).then(function (response) {
- // console.log(response);
- $scope.smallfolderlist = response;
- angular.forEach($scope.smallfolderlist, function (value, index) {
- $scope.smallfolderlist[index].counts = Number(value.foldercounts) + Number(value.infocounts);
- });
- }, function () {
- });
- var sql = "select * from conninfo where localclaid = '" + cloudfolder.localid + "' and synchrotype != 4 order by conntime desc";// limit 10 offset 0
- SqliteStorageService.queryData(sql).then(function (response) {
- // console.log(response);
- if (response.length > 0) {
- //拼接记录localid
- var infoidlist = "";
- angular.forEach(response, function (value) {
- var tempstr = "'" + value.localid + "'";
- infoidlist = infoidlist + tempstr + ",";
- });
- infoidlist = infoidlist.substring(0, infoidlist.length - 1);
- //--查询图片信息
- var q_pic_sql = "select * from conninfopicture where localinfoid in (" + infoidlist + ")";
- SqliteStorageService.queryData(q_pic_sql).then(function (res) {
- // console.log(res);
- if (res.length > 0) {
- extractConninfoPicture(response, res, true);
- } else {
- $scope.recordList = response;
- //判读是否有下一页
- $scope.isload = response.length >= 10;
- if ($scope.isload) {
- pageindex = 10;
- }
- }
- }, function () {
- $scope.recordList = response;
- //判读是否有下一页
- $scope.isload = response.length >= 10;
- if ($scope.isload) {
- pageindex = 10;
- }
- });
- } else {
- $scope.isload = false;
- $scope.recordList = [];
- }
- }, function () {
- $scope.recordList = [];
- }).finally(function () {
- $scope.$broadcast('scroll.refreshComplete');
- });
- };
- $scope.initConninfoList();
- //加载更多记录
- $scope.loadMore = function () {
- $scope.isload = false;
- var sql = "select * from conninfo where localclaid = " + cloudfolder.localid + " and creator = " + UserService.id + " order by conntime desc limit 10 offset " + pageindex;
- SqliteStorageService.queryData(sql).then(function (response) {
- // console.log(response);
- if (response.length > 0) {
- //拼接记录localid
- var infoidlist = "";
- angular.forEach(response, function (value) {
- var tempstr = "'" + value.localid + "'";
- infoidlist = infoidlist + tempstr + ",";
- });
- infoidlist = infoidlist.substring(0, infoidlist.length - 1);
- //--查询图片信息
- var q_pic_sql = "select * from conninfopicture where localinfoid in (" + infoidlist + ")";
- SqliteStorageService.queryData(q_pic_sql).then(function (res) {
- // console.log(res);
- if (res.length > 0) {
- extractConninfoPicture(response, res, false);
- } else {
- $scope.recordList = $scope.recordList.concat(response);
- //判读是否有下一页
- $scope.isload = response.length >= 10;
- if ($scope.isload) {
- pageindex += 10;
- }
- }
- }, function () {
- $scope.recordList = $scope.recordList.concat(response);
- //判读是否有下一页
- $scope.isload = response.length >= 10;
- if ($scope.isload) {
- pageindex += 10;
- }
- });
- } else {
- $scope.isload = false;
- }
- }, function () {
- }).finally(function () {
- $scope.$broadcast('scroll.infiniteScrollComplete');
- });
- };
- $scope.showMoreAction = true;
- $scope.showAction = function () {
- $scope.showMoreAction = !$scope.showMoreAction;
- };
- //新建记录
- $scope.createConninfo = function () {
- ModelService.setCreateType(1);
- $scope.go('cloudAddConnInfo');
- };
- //创建子文件夹
- $scope.createFolder = function () {
- $scope.go("authorityCreate", {localparentid: cloudfolder.localid, level: cloudfolder.level, templettype:1});
- };
- //进入分类详情,记录列表
- $scope.queryFolder = function (folder) {
- $scope.go('conninfolist', {folder: angular.toJson(folder)});
- };
- //点击进入对接详情
- $scope.goDockingdetails = function (rec) {
- $scope.go("Dockingdetails", {infoid: rec.localid, creator: rec.creator});
- };
- //进入设置文件夹页面
- $scope.goAutoritySet = function (reclib) {
- $timeout(function () {
- $ionicListDelegate.closeOptionButtons();
- }, 10);
- $scope.go("authorityLocalSet", {authoritydata: angular.toJson(reclib), type: 0, goflg: 1});
- if (UtilService.isDefined(reclib.localid)) {
- } else {
- $scope.go("authoritySet", {
- reclibid: reclib.id,
- authorityid: reclib.authorityid,
- authoritycomefrom: reclib.authoritycomefrom,
- name: reclib.name,
- content: reclib.content,
- sort: reclib.sort,
- type: 0
- });
- }
- };
- //修改云文件夹
- $scope.editCloudFolder = function () {
- $ionicActionSheet.show({
- buttons: [{text: '<a class="action-sheet-push">设置</a>'}],
- cancelText: '取消',
- buttonClicked: function (index) {
- if (index == 0) {
- $scope.go("authorityLocalSet", {authoritydata: angular.toJson(cloudfolder), type: 0, goflg: 1});
- }
- return true;
- }
- });
- };
- $scope.shareflg = false;
- $scope.openShare = function (tempobj, ind) {
- $scope.go('chooseShareFolder', {
- chereslist: angular.toJson([tempobj.localid]),
- folderid: cloudfolder.localid,
- isCloud: cloudfolder.isCloud
- });
- /*$scope.shareflg = true;
- $(".resource_wrap").css("left", "0%");
- $(".pay_list_c2").css("left", "-35px");
- $("#collect-bottom").css("display", "none");
- checkedresource = tempobj;
- checkedindex = ind;*/
- };
- $scope.closeShare = function () {
- $timeout(function () {
- $ionicListDelegate.closeOptionButtons();
- }, 10);
- $scope.shareflg = false;
- };
- //分享选择操作表
- var selectflg = false;//列表选择打开标志
- $scope.openCollectShare = function () {
- selectflg = true;
- $scope.recordList[checkedindex].value = true;
- var tempres = {
- infoid: checkedresource.id,
- infocomefrom: checkedresource.creatorcomefrom,
- infoType: 81,
- claid: cloudfolder.id
- };
- $scope.checkedresourcelist.push(tempres);
- $(".item-options").addClass("invisible");
- $(".resource_wrap").css("left", "10%");
- $(".pay_list_c2").css("left", "4%");
- $(".item-content").css("transform", "translate3d(0px, 0px, 0px)");
- $("#collect-bottom").css("display", "block");
- $scope.closeShare();
- };
- //取消分享
- $scope.cancelShare = function () {
- angular.forEach($scope.recordList, function (value, ind) {
- $scope.recordList[ind].value = false;
- });
- $scope.checkedresourcelist = [];
- $(".resource_wrap").css("left", "0%");
- $(".pay_list_c2").css("left", "-35px");
- $("#collect-bottom").css("display", "none");
- selectflg = false;
- };
- var selectResource = function (rec, ind) {
- var tempres = {
- infoid: rec.id,
- infocomefrom: rec.creatorcomefrom,
- infoType: 81,
- claid: cloudfolder.id
- };
- var chind = -1;
- angular.forEach($scope.checkedresourcelist, function (value, index) {
- if (value.infoid == rec.id) {
- chind = index;
- }
- });
- if (chind == -1) {
- $scope.recordList[ind].value = true;
- $scope.checkedresourcelist.unshift(tempres);
- } else {
- $scope.recordList[ind].value = false;
- $scope.checkedresourcelist.splice(chind, 1);
- }
- // console.log($scope.checkedresourcelist);
- };
- $scope.shareResourceToPrilib = function () {
- $scope.go('chooseShareFolder', {
- chereslist: angular.toJson($scope.checkedresourcelist),
- folderid: cloudfolder.id
- });
- };
- //跳转工具搜索
- $scope.goToolsSearch = function () {
- $timeout(function () {
- $scope.go("connsearch", {localfolderid: cloudfolder.localid});
- }, 300);
- };
- //0:QQ,1:QQ空间,2:微信,3:微信朋友圈,4:新浪微博
- $scope.shareMessage = function (type) {
- $scope.shareflg = false;
- $scope.showLoadingToast();
- var imagurl = "http://test.ubitech.cn/000000000/themes/avatar_save/1490753632823.jpg";
- if (checkedresource.image.length > 0) {
- imagurl = $scope.imgUrl + checkedresource.image;
- }
- var message = {
- title: checkedresource.title,
- description: checkedresource.content.substring(0, 19),
- url: checkedresource.share_url,
- imageurl: imagurl
- };
- switch (type) {
- case 0:
- case 1:
- ShareService.shareToQQ(type, message).then(function () {
- UtilService.showMess("QQ分享成功");
- $scope.hideLoadingToast();
- }, function (error) {
- UtilService.showMess(error);
- $scope.hideLoadingToast();
- });
- break;
- case 2:
- case 3:
- ShareService.shareToWechat(0, message).then(function () {
- UtilService.showMess("微信分享成功");
- $scope.hideLoadingToast();
- }, function (error) {
- UtilService.showMess(error);
- $scope.hideLoadingToast();
- });
- break;
- default:
- break;
- }
- $timeout(function () {
- $scope.hideLoadingToast();
- }, 10000);
- };
- $scope.refreshDate = function () {
- $scope.initConninfoList();
- $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);
- };
- //页面加载完成,设置当前文件夹为选中文件夹
- $scope.$on('$ionicView.afterEnter', function () {
- ModelService.setCheckdeFolder(cloudfolder);
- });
- });
|