connInfoList.js 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. angular.module('push')
  2. .controller('connInfoListCtrl', function ($scope, UserService, $timeout, $stateParams, DockingService, $ionicPopup, UtilService, ModelService, $ionicListDelegate, SqliteStorageService, HandleService, $ionicActionSheet) {
  3. if($scope.app){
  4. $scope.setStatusBar(0);
  5. }
  6. var cloudfolder = angular.fromJson($stateParams.folder);
  7. $scope.name = cloudfolder.name;
  8. $scope.user = UserService.user.user;
  9. var checkedresource = {};//单个分享时选中的资源
  10. var checkedindex = -1;//多个分享时第一个选择的索引
  11. $scope.checkedresourcelist = [];//多个分享时选中的资源
  12. $scope.userid = UserService.id;
  13. $scope.isload = false;
  14. var pageindex = 0;
  15. //--本地记录列表提取第一张图为列表显示图
  16. var extractConninfoPicture = function (conninfolist, picturelist, flg) {
  17. HandleService.extractConninfoPicture(conninfolist, picturelist).then(function (response) {
  18. if (flg) {
  19. $scope.recordList = response;
  20. } else {
  21. $scope.recordList = $scope.recordList.concat(response);
  22. }
  23. //判读是否有下一页
  24. $scope.isload = response.length >= 10;
  25. if ($scope.isload) {
  26. if (flg) {
  27. pageindex = 10;
  28. } else {
  29. pageindex += 10;
  30. }
  31. }
  32. // console.log($scope.recordList);
  33. }, function () {
  34. })
  35. };
  36. //取本地记录
  37. $scope.initConninfoList = function () {
  38. var q_sql = "select c1.*,foldercounts,infocounts from " +
  39. "(select * from conninfofolder where localparentid = '" + cloudfolder.localid + "') c1 " +
  40. "LEFT JOIN " +
  41. "(" +
  42. "select localparentid,count(1) foldercounts from " +
  43. "conninfofolder where localparentid in " +
  44. "(select localid from conninfofolder where localparentid = '" + cloudfolder.localid + "') " +
  45. "GROUP BY localparentid " +
  46. ") c2 " +
  47. "ON c1.localid = c2.localparentid " +
  48. "LEFT JOIN " +
  49. "(" +
  50. "select localclaid, count(1) infocounts " +
  51. "from conninfo where localclaid in " +
  52. "(select localid from conninfofolder where localparentid = '" + cloudfolder.localid + "') " +
  53. "GROUP BY localclaid " +
  54. ") c3" +
  55. " ON c1.localid = c3.localclaid";
  56. // var sql1 = "select * from conninfofolder where localparentid = order by updatetime desc";
  57. SqliteStorageService.queryData(q_sql).then(function (response) {
  58. // console.log(response);
  59. $scope.smallfolderlist = response;
  60. angular.forEach($scope.smallfolderlist, function (value, index) {
  61. $scope.smallfolderlist[index].counts = Number(value.foldercounts) + Number(value.infocounts);
  62. });
  63. }, function () {
  64. });
  65. var sql = "select * from conninfo where localclaid = '" + cloudfolder.localid + "' and synchrotype != 4 order by conntime desc";// limit 10 offset 0
  66. SqliteStorageService.queryData(sql).then(function (response) {
  67. // console.log(response);
  68. if (response.length > 0) {
  69. //拼接记录localid
  70. var infoidlist = "";
  71. angular.forEach(response, function (value) {
  72. var tempstr = "'" + value.localid + "'";
  73. infoidlist = infoidlist + tempstr + ",";
  74. });
  75. infoidlist = infoidlist.substring(0, infoidlist.length - 1);
  76. //--查询图片信息
  77. var q_pic_sql = "select * from conninfopicture where localinfoid in (" + infoidlist + ")";
  78. SqliteStorageService.queryData(q_pic_sql).then(function (res) {
  79. // console.log(res);
  80. if (res.length > 0) {
  81. extractConninfoPicture(response, res, true);
  82. } else {
  83. $scope.recordList = response;
  84. //判读是否有下一页
  85. $scope.isload = response.length >= 10;
  86. if ($scope.isload) {
  87. pageindex = 10;
  88. }
  89. }
  90. }, function () {
  91. $scope.recordList = response;
  92. //判读是否有下一页
  93. $scope.isload = response.length >= 10;
  94. if ($scope.isload) {
  95. pageindex = 10;
  96. }
  97. });
  98. } else {
  99. $scope.isload = false;
  100. $scope.recordList = [];
  101. }
  102. }, function () {
  103. $scope.recordList = [];
  104. }).finally(function () {
  105. $scope.$broadcast('scroll.refreshComplete');
  106. });
  107. };
  108. $scope.initConninfoList();
  109. //加载更多记录
  110. $scope.loadMore = function () {
  111. $scope.isload = false;
  112. var sql = "select * from conninfo where localclaid = " + cloudfolder.localid + " and creator = " + UserService.id + " order by conntime desc limit 10 offset " + pageindex;
  113. SqliteStorageService.queryData(sql).then(function (response) {
  114. // console.log(response);
  115. if (response.length > 0) {
  116. //拼接记录localid
  117. var infoidlist = "";
  118. angular.forEach(response, function (value) {
  119. var tempstr = "'" + value.localid + "'";
  120. infoidlist = infoidlist + tempstr + ",";
  121. });
  122. infoidlist = infoidlist.substring(0, infoidlist.length - 1);
  123. //--查询图片信息
  124. var q_pic_sql = "select * from conninfopicture where localinfoid in (" + infoidlist + ")";
  125. SqliteStorageService.queryData(q_pic_sql).then(function (res) {
  126. // console.log(res);
  127. if (res.length > 0) {
  128. extractConninfoPicture(response, res, false);
  129. } else {
  130. $scope.recordList = $scope.recordList.concat(response);
  131. //判读是否有下一页
  132. $scope.isload = response.length >= 10;
  133. if ($scope.isload) {
  134. pageindex += 10;
  135. }
  136. }
  137. }, function () {
  138. $scope.recordList = $scope.recordList.concat(response);
  139. //判读是否有下一页
  140. $scope.isload = response.length >= 10;
  141. if ($scope.isload) {
  142. pageindex += 10;
  143. }
  144. });
  145. } else {
  146. $scope.isload = false;
  147. }
  148. }, function () {
  149. }).finally(function () {
  150. $scope.$broadcast('scroll.infiniteScrollComplete');
  151. });
  152. };
  153. $scope.showMoreAction = true;
  154. $scope.showAction = function () {
  155. $scope.showMoreAction = !$scope.showMoreAction;
  156. };
  157. //新建记录
  158. $scope.createConninfo = function () {
  159. ModelService.setCreateType(1);
  160. $scope.go('cloudAddConnInfo');
  161. };
  162. //创建子文件夹
  163. $scope.createFolder = function () {
  164. $scope.go("authorityCreate", {localparentid: cloudfolder.localid, level: cloudfolder.level, templettype:1});
  165. };
  166. //进入分类详情,记录列表
  167. $scope.queryFolder = function (folder) {
  168. $scope.go('conninfolist', {folder: angular.toJson(folder)});
  169. };
  170. //点击进入对接详情
  171. $scope.goDockingdetails = function (rec) {
  172. $scope.go("Dockingdetails", {infoid: rec.localid, creator: rec.creator});
  173. };
  174. //进入设置文件夹页面
  175. $scope.goAutoritySet = function (reclib) {
  176. $timeout(function () {
  177. $ionicListDelegate.closeOptionButtons();
  178. }, 10);
  179. $scope.go("authorityLocalSet", {authoritydata: angular.toJson(reclib), type: 0, goflg: 1});
  180. if (UtilService.isDefined(reclib.localid)) {
  181. } else {
  182. $scope.go("authoritySet", {
  183. reclibid: reclib.id,
  184. authorityid: reclib.authorityid,
  185. authoritycomefrom: reclib.authoritycomefrom,
  186. name: reclib.name,
  187. content: reclib.content,
  188. sort: reclib.sort,
  189. type: 0
  190. });
  191. }
  192. };
  193. //修改云文件夹
  194. $scope.editCloudFolder = function () {
  195. $ionicActionSheet.show({
  196. buttons: [{text: '<a class="action-sheet-push">设置</a>'}],
  197. cancelText: '取消',
  198. buttonClicked: function (index) {
  199. if (index == 0) {
  200. $scope.go("authorityLocalSet", {authoritydata: angular.toJson(cloudfolder), type: 0, goflg: 1});
  201. }
  202. return true;
  203. }
  204. });
  205. };
  206. $scope.shareflg = false;
  207. $scope.openShare = function (tempobj, ind) {
  208. $scope.go('chooseShareFolder', {
  209. chereslist: angular.toJson([tempobj.localid]),
  210. folderid: cloudfolder.localid,
  211. isCloud: cloudfolder.isCloud
  212. });
  213. /*$scope.shareflg = true;
  214. $(".resource_wrap").css("left", "0%");
  215. $(".pay_list_c2").css("left", "-35px");
  216. $("#collect-bottom").css("display", "none");
  217. checkedresource = tempobj;
  218. checkedindex = ind;*/
  219. };
  220. $scope.closeShare = function () {
  221. $timeout(function () {
  222. $ionicListDelegate.closeOptionButtons();
  223. }, 10);
  224. $scope.shareflg = false;
  225. };
  226. //分享选择操作表
  227. var selectflg = false;//列表选择打开标志
  228. $scope.openCollectShare = function () {
  229. selectflg = true;
  230. $scope.recordList[checkedindex].value = true;
  231. var tempres = {
  232. infoid: checkedresource.id,
  233. infocomefrom: checkedresource.creatorcomefrom,
  234. infoType: 81,
  235. claid: cloudfolder.id
  236. };
  237. $scope.checkedresourcelist.push(tempres);
  238. $(".item-options").addClass("invisible");
  239. $(".resource_wrap").css("left", "10%");
  240. $(".pay_list_c2").css("left", "4%");
  241. $(".item-content").css("transform", "translate3d(0px, 0px, 0px)");
  242. $("#collect-bottom").css("display", "block");
  243. $scope.closeShare();
  244. };
  245. //取消分享
  246. $scope.cancelShare = function () {
  247. angular.forEach($scope.recordList, function (value, ind) {
  248. $scope.recordList[ind].value = false;
  249. });
  250. $scope.checkedresourcelist = [];
  251. $(".resource_wrap").css("left", "0%");
  252. $(".pay_list_c2").css("left", "-35px");
  253. $("#collect-bottom").css("display", "none");
  254. selectflg = false;
  255. };
  256. var selectResource = function (rec, ind) {
  257. var tempres = {
  258. infoid: rec.id,
  259. infocomefrom: rec.creatorcomefrom,
  260. infoType: 81,
  261. claid: cloudfolder.id
  262. };
  263. var chind = -1;
  264. angular.forEach($scope.checkedresourcelist, function (value, index) {
  265. if (value.infoid == rec.id) {
  266. chind = index;
  267. }
  268. });
  269. if (chind == -1) {
  270. $scope.recordList[ind].value = true;
  271. $scope.checkedresourcelist.unshift(tempres);
  272. } else {
  273. $scope.recordList[ind].value = false;
  274. $scope.checkedresourcelist.splice(chind, 1);
  275. }
  276. // console.log($scope.checkedresourcelist);
  277. };
  278. $scope.shareResourceToPrilib = function () {
  279. $scope.go('chooseShareFolder', {
  280. chereslist: angular.toJson($scope.checkedresourcelist),
  281. folderid: cloudfolder.id
  282. });
  283. };
  284. //跳转工具搜索
  285. $scope.goToolsSearch = function () {
  286. $timeout(function () {
  287. $scope.go("connsearch", {localfolderid: cloudfolder.localid});
  288. }, 300);
  289. };
  290. //0:QQ,1:QQ空间,2:微信,3:微信朋友圈,4:新浪微博
  291. $scope.shareMessage = function (type) {
  292. $scope.shareflg = false;
  293. $scope.showLoadingToast();
  294. var imagurl = "http://test.ubitech.cn/000000000/themes/avatar_save/1490753632823.jpg";
  295. if (checkedresource.image.length > 0) {
  296. imagurl = $scope.imgUrl + checkedresource.image;
  297. }
  298. var message = {
  299. title: checkedresource.title,
  300. description: checkedresource.content.substring(0, 19),
  301. url: checkedresource.share_url,
  302. imageurl: imagurl
  303. };
  304. switch (type) {
  305. case 0:
  306. case 1:
  307. ShareService.shareToQQ(type, message).then(function () {
  308. UtilService.showMess("QQ分享成功");
  309. $scope.hideLoadingToast();
  310. }, function (error) {
  311. UtilService.showMess(error);
  312. $scope.hideLoadingToast();
  313. });
  314. break;
  315. case 2:
  316. case 3:
  317. ShareService.shareToWechat(0, message).then(function () {
  318. UtilService.showMess("微信分享成功");
  319. $scope.hideLoadingToast();
  320. }, function (error) {
  321. UtilService.showMess(error);
  322. $scope.hideLoadingToast();
  323. });
  324. break;
  325. default:
  326. break;
  327. }
  328. $timeout(function () {
  329. $scope.hideLoadingToast();
  330. }, 10000);
  331. };
  332. $scope.refreshDate = function () {
  333. $scope.initConninfoList();
  334. $scope.$broadcast('scroll.refreshComplete');
  335. var trHtml = "<div class='refresh_tip_div'>更新了" + $scope.recordList.length + "条内容</div>";
  336. $timeout(function () {
  337. $(".resourcelistDiv").prepend(trHtml);
  338. $(".refresh_tip_div").animate({width: 100 + "%"}, 150);
  339. }, 800);
  340. $timeout(function () {
  341. $(".refresh_tip_div").slideUp();
  342. }, 1200);
  343. };
  344. //页面加载完成,设置当前文件夹为选中文件夹
  345. $scope.$on('$ionicView.afterEnter', function () {
  346. ModelService.setCheckdeFolder(cloudfolder);
  347. });
  348. });