indexSearchReasultCtrl.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  1. angular.module('push')
  2. .controller('indexSearchReasultCtrl', function ($scope, $state, $timeout, $http, UtilService, ActivityService, $sce, ModelService, $ionicModal,
  3. UserService, $ionicActionSheet, ConfigService, ConnSearchService) {
  4. $scope.search = {key: ""};
  5. $scope.searchtype = 2;//0全部 1节点 2资源 3资源库 4记录 5文件夹 6活动 7用户
  6. var hiskey = "";
  7. $scope.showSearchWrapFloor=false;
  8. $scope.defaultLan = UserService.defaultLan;
  9. if ($scope.defaultLan == 'Chinese') {
  10. $scope.searchtypeTxt='资源';
  11. } else {
  12. $scope.searchtypeTxt='Resource';
  13. }
  14. // 数组 index:0 1 2 3 4 依次对应以上(资源开始)
  15. var index = 0;
  16. $scope.loadind = 0;//是否继续加载的索引
  17. $scope.alllist = [{curpage: 1, list: [], hasmore: false, hiskey: ""}, {
  18. curpage: 1,
  19. list: [],
  20. hasmore: false,
  21. hiskey: ""
  22. },
  23. {curpage: 1, list: [], hasmore: false, hiskey: ""}, {curpage: 1, list: [], hasmore: false, hiskey: ""},
  24. {curpage: 1, list: [], hasmore: false, hiskey: ""},
  25. {curpage: 1, list: [], hasmore: false, hiskey: ""}, {curpage: 1, list: [], hasmore: false, hiskey: ""},
  26. {curpage: 1, list: [], hasmore: false, hiskey: ""}];
  27. // 综合搜索各种类型信息
  28. $scope.searchAllInfo = function () {
  29. if (!UtilService.isDefined($scope.search.key)) {
  30. return;
  31. }
  32. if (index == 3) {
  33. searchCloudFolder();
  34. return;
  35. }
  36. $scope.alllist[index].hiskey = angular.copy($scope.search.key);
  37. $scope.showLoadingToast();
  38. $scope.alllist[index].curpage = 1;
  39. ActivityService.searchAllInfo($scope.search.key, $scope.searchtype, $scope.alllist[index].curpage).then(function (response) {
  40. if (angular.isDefined(response.data)) {
  41. $scope.alllist[index].list = response.data.result;
  42. } else {
  43. $scope.alllist[index].list = [];
  44. }
  45. if (angular.isDefined(response.data.page) && angular.isDefined(response.data.page.totalPage)) {
  46. if ($scope.alllist[index].curpage >= response.data.page.totalPage) {
  47. $scope.alllist[index].hasmore = false;
  48. } else {
  49. $scope.alllist[index].curpage++;
  50. $scope.alllist[index].hasmore = true;
  51. }
  52. } else {
  53. $scope.alllist[index].hasmore = false;
  54. }
  55. $scope.hideLoadingToast();
  56. }, function () {
  57. $scope.hideLoadingToast();
  58. })
  59. };
  60. // 加载更多
  61. $scope.loadMore = function () {
  62. $scope.showLoadingToast();
  63. $scope.alllist[index].hasmore = false;
  64. ActivityService.searchAllInfo($scope.search.key, $scope.searchtype, $scope.alllist[index].curpage).then(function (response) {
  65. if (response.data.result.length > 0) {
  66. $scope.alllist[index].list = $scope.alllist[index].list.concat(response.data.result);
  67. }
  68. $timeout(function () {
  69. if (angular.isDefined(response.data.page.totalPage)) {
  70. if ($scope.alllist[index].curpage >= response.data.page.totalPage) {
  71. $scope.alllist[index].hasmore = false;
  72. } else {
  73. $scope.alllist[index].curpage++;
  74. $scope.alllist[index].hasmore = true;
  75. }
  76. }
  77. }, 1500);
  78. $scope.hideLoadingToast();
  79. }, function () {
  80. $scope.hideLoadingToast();
  81. }).finally(function () {
  82. $scope.$broadcast('scroll.infiniteScrollComplete');
  83. });
  84. };
  85. $scope.selectSearchTag=function () {
  86. $scope.showSearchWrapFloor=!$scope.showSearchWrapFloor;
  87. };
  88. // 切换页签
  89. $scope.changeAct = function (type) {
  90. $scope.showSearchWrapFloor=false;
  91. $scope.searchtype = type;
  92. index = type - 2;
  93. $scope.loadind = type - 2;
  94. if (($scope.search.key.length > 0 && $scope.alllist[index].list.length <= 0) || hiskey != $scope.alllist[index].hiskey) {
  95. if (index == 3) {
  96. searchCloudFolder();
  97. } else {
  98. $scope.searchAllInfo();
  99. }
  100. }
  101. if ($scope.defaultLan == 'Chinese') {
  102. switch (type) {
  103. case 2:
  104. $scope.searchtypeTxt = '资源';
  105. break;
  106. /*case 3:
  107. $scope.searchtypeTxt='资源库';
  108. break;
  109. case 6:
  110. $scope.searchtypeTxt='活动';
  111. break;
  112. case 5:
  113. $scope.searchtypeTxt='文件夹';
  114. break;*/
  115. case 4:
  116. $scope.searchtypeTxt = '记录';
  117. break;
  118. case 7:
  119. $scope.searchtypeTxt = '用户';
  120. break;
  121. }
  122. } else {
  123. switch (type) {
  124. case 2:
  125. $scope.searchtypeTxt = 'Resource';
  126. break;
  127. case 4:
  128. $scope.searchtypeTxt = 'Record';
  129. break;
  130. case 7:
  131. $scope.searchtypeTxt = 'User';
  132. break;
  133. }
  134. }
  135. };
  136. var searchCloudFolder = function () {
  137. $scope.alllist[index].hiskey = angular.copy($scope.search.key);
  138. $scope.showLoadingToast();
  139. ConnSearchService.searchCloudFolder($scope.search.key, 0).then(function (response) {
  140. $scope.alllist[index].list = response.list;
  141. $scope.alllist[index].hasmore = false;
  142. $scope.hideLoadingToast();
  143. }, function () {
  144. $scope.hideLoadingToast();
  145. });
  146. };
  147. $scope.goActivityDetail = function (actid) {
  148. $scope.go("activityIntroduction", {activityid: actid});
  149. };
  150. //进入分类详情,记录列表
  151. $scope.queryFolder = function (folder) {
  152. ModelService.setCheckdeFolder(folder);
  153. if (UtilService.isDefined(folder.localid)) {
  154. //本地文件夹记录列表
  155. $scope.go('conninfolist', {folder: angular.toJson(folder)});
  156. } else {
  157. //云文件夹记录列表
  158. $scope.go('cloudFolderDetail', {folder: angular.toJson(folder)});
  159. }
  160. };
  161. //进入记录详情
  162. $scope.goDockingdetails = function (rec) {
  163. $scope.islogin = ConfigService.islogin;
  164. if(!$scope.islogin){
  165. if (localStorage.wxFlag == "true") {
  166. if (localStorage.isUserFocusXW == 0) {
  167. var title = localStorage.appidStr;
  168. $ionicPopup.alert({
  169. title: '提示',
  170. template: '请先关注微信公众号"' + title + '"!'
  171. });
  172. return;
  173. } else {
  174. if (localStorage.isUserBindWx == 0) {
  175. var wxFlag = JSON.parse(localStorage.params);
  176. if (wxFlag.weChatModel) {
  177. $scope.go('bindPhone', {
  178. params: localStorage.params,
  179. comfrom: 'maincontroller',
  180. url: window.location.href.split('#/')[1]
  181. });
  182. } else {
  183. $scope.go('login');
  184. return;
  185. }
  186. } else {
  187. $scope.go('login');
  188. return;
  189. }
  190. }
  191. } else {
  192. $scope.go('login');
  193. return;
  194. }
  195. }else{
  196. $scope.go('resourceCommonInfoDetailsPage', {resid: rec.id, isAllVisitor: 1,node:UserService.node});
  197. }
  198. };
  199. //进入资源库详情
  200. $scope.goResorceLibaryDetail = function (reclib) {
  201. reclib.id = reclib.unique;
  202. reclib.name = reclib.title;
  203. $scope.islogin = ConfigService.islogin;
  204. if(!$scope.islogin){
  205. if (localStorage.wxFlag == "true") {
  206. if (localStorage.isUserFocusXW == 0) {
  207. var title = localStorage.appidStr;
  208. $ionicPopup.alert({
  209. title: '提示',
  210. template: '请先关注微信公众号"' + title + '"!'
  211. });
  212. return;
  213. } else {
  214. if (localStorage.isUserBindWx == 0) {
  215. var wxFlag = JSON.parse(localStorage.params);
  216. if (wxFlag.weChatModel) {
  217. $scope.go('bindPhone', {
  218. params: localStorage.params,
  219. comfrom: 'maincontroller',
  220. url: window.location.href.split('#/')[1]
  221. });
  222. } else {
  223. $scope.go('login');
  224. return;
  225. }
  226. } else {
  227. $scope.go('login');
  228. return;
  229. }
  230. }
  231. } else {
  232. $scope.go('login');
  233. return;
  234. }
  235. }else{
  236. $scope.go('resourceLibraryPrivate', {reclib: angular.toJson(reclib)});
  237. }
  238. };
  239. //进入资源详情
  240. $scope.goResourceDetail = function (resource) {
  241. $scope.islogin = ConfigService.islogin;
  242. if(!$scope.islogin){
  243. if (localStorage.wxFlag == "true") {
  244. if (localStorage.isUserFocusXW == 0) {
  245. var title = localStorage.appidStr;
  246. $ionicPopup.alert({
  247. title: '提示',
  248. template: '请先关注微信公众号"' + title + '"!'
  249. });
  250. return;
  251. } else {
  252. if (localStorage.isUserBindWx == 0) {
  253. var wxFlag = JSON.parse(localStorage.params);
  254. if (wxFlag.weChatModel) {
  255. $scope.go('bindPhone', {
  256. params: localStorage.params,
  257. comfrom: 'maincontroller',
  258. url: window.location.href.split('#/')[1]
  259. });
  260. } else {
  261. $scope.go('login');
  262. return;
  263. }
  264. } else {
  265. $scope.go('login');
  266. return;
  267. }
  268. }
  269. } else {
  270. $scope.go('login');
  271. return;
  272. }
  273. }else{
  274. if (resource.groupid == "0") {
  275. $scope.go('resourceDetails', {
  276. recourceid: resource.unique,
  277. recourcetype: resource.type,
  278. recourcecomefrom: resource.source
  279. });
  280. } else {
  281. $scope.go('resourceCommonDetailsPage', {
  282. recourceid: resource.unique,
  283. recourcetype: resource.type,
  284. recourcecomefrom: resource.source,
  285. creator: resource.clickthrough,
  286. title:resource.title
  287. });
  288. }
  289. }
  290. };
  291. // 搜索关键字标红
  292. $scope.badge = function (title) {
  293. var re = eval("/" + $scope.search.key + "/g");
  294. title = title.replace(re, '<span style="color:red">' + $scope.search.key + '</span>');
  295. return $sce.trustAsHtml(title)
  296. };
  297. $scope.gobackback = function () {
  298. if($scope.app){
  299. cordova.plugins.Keyboard.close();
  300. }
  301. $timeout(function () {
  302. $scope.goback();
  303. }, 350);
  304. $scope.closeKeyboard();
  305. };
  306. //清空搜索内容
  307. $scope.clearSearch = function () {
  308. $scope.search.key = "";
  309. };
  310. $scope.showFunc = function () {
  311. $scope.showbaidu = true;
  312. };
  313. //监测key变化,即时匹配词库
  314. $scope.fixKey = function () {
  315. if (angular.isDefined($scope.search.key) && $scope.search.key.length > 0) {
  316. $scope.searchKey($scope.search.key);
  317. }
  318. };
  319. $scope.data = [];
  320. //百度词库
  321. $scope.searchKey = function (searchName) {
  322. var search_history = angular.element(document.getElementById("his_search"));
  323. if (search_history.val().length != 0) {
  324. var baidu = angular.element(document.getElementById("baidu_search"));
  325. baidu.css("display", "block");
  326. }
  327. $http({
  328. method: 'JSONP',
  329. url: 'https://sp0.baidu.com/5a1Fazu8AA54nxGko9WTAnF6hhy/su?wd=' + searchName + '&cb=JSON_CALLBACK'
  330. }).success(function (data) {
  331. $scope.data = data.s;
  332. });
  333. };
  334. $scope.searchInfoByKey = function (d) {
  335. $scope.search.key = d;
  336. searchAllInfo();
  337. };
  338. /*---------------------------------------------------------------------------*/
  339. var authstatus = 0;// 0 未认证 1 认证
  340. ActivityService.getUserAuth().then(function (response) {
  341. authstatus = response.result;
  342. }, function () {
  343. });
  344. // 活动页面快捷入口路由跳转
  345. $scope.goNextPage = function (index, act) {
  346. switch (index) {
  347. case 1:
  348. // 通知
  349. $scope.go("activityNotice", {activityid: act.id, title: act.title});
  350. break;
  351. case 2:
  352. // 通知管理
  353. $scope.go("activityNoticeManger", {
  354. activityid: act.id,
  355. title: act.title,
  356. status: act.status,
  357. days: act.activityLeaveDays
  358. });
  359. break;
  360. case 3:
  361. // 报名
  362. if (authstatus == 1 || authstatus == 2) {
  363. $scope.go("activitySignUpConfirm", {activityid: act.id});
  364. } else {
  365. UtilService.showMess("您还未认证!");
  366. $timeout(function () {
  367. $scope.go('personIdentify');
  368. }, 1000);
  369. }
  370. break;
  371. case 4:
  372. // 高校报名管理
  373. $scope.go("activitySchoolSignUpManger", {
  374. activityid: act.id,
  375. title: act.title,
  376. visittime: act.visitclosingdate
  377. });
  378. break;
  379. case 5:
  380. // 企业报名管理
  381. $scope.go("activityCompanySignUpManger", {
  382. activityid: act.id,
  383. title: act.title,
  384. visittime: act.visitclosingdate
  385. });
  386. break;
  387. case 6:
  388. // 参与企业
  389. if (authstatus == 1 || authstatus == 2) {
  390. $scope.go("activityCompanyList", {activityid: act.id});
  391. } else {
  392. UtilService.showMess("您还未认证!");
  393. $timeout(function () {
  394. $scope.go('personIdentify');
  395. }, 1000);
  396. }
  397. break;
  398. case 7:
  399. // 活动统计
  400. $scope.go("activityStatistics", {activityid: act.id});
  401. break;
  402. case 8:
  403. // 活动安排管理
  404. $scope.go("activityArrangeManger", {activityid: act.id});
  405. break;
  406. case 9:
  407. // 签到
  408. checkIntime(act.id);
  409. break;
  410. case 10:
  411. // 反馈(1、非企业用户:1.1 未填写过进入填写页面,1.2 已填写过进入列表 2、企业用户:填写本企业的走访反馈列表)
  412. if (UserService.role[0] <= 8 && UserService.role[0] != 1) {
  413. ActivityService.checkFollowupInfo(act.id).then(function (response) {
  414. if (response.result == 0) {
  415. $scope.go("activityFeedBack", {activityid: act.id, title: act.title});
  416. } else {
  417. $scope.go("activityFeedBackList", {activityid: act.id, title: act.title});
  418. }
  419. }, function () {
  420. });
  421. } else {
  422. $scope.go("activityCompanyViewFeedList", {activityid: act.id});
  423. }
  424. break;
  425. case 11:
  426. // 活动安排
  427. if (UserService.role[0] <= 8 && UserService.role[0] != 1) {
  428. $scope.go("activityArrange", {activityid: act.id});
  429. } else {
  430. $scope.go("activityCompanyArrange", {activityid: act.id});
  431. }
  432. break;
  433. case 12:
  434. // 反馈管理
  435. $scope.go("activityBackManger", {activityid: act.id});
  436. break;
  437. case 13:
  438. // 签到管理
  439. $scope.go("activitySignManger", {activityid: act.id});
  440. break;
  441. case 14:
  442. // 备案
  443. $scope.go("activityRecord");
  444. break;
  445. case 15:
  446. // 备案管理
  447. $scope.go("activityReacordManger");
  448. break;
  449. case 16:
  450. // 选择企业
  451. $scope.go("activityChooseCompany", {activityid: act.id});
  452. break;
  453. case 17:
  454. // 报名信息
  455. $scope.go("activitySignUpInfo", {activityid: act.id});
  456. break;
  457. case 18:
  458. // 选择专家
  459. $scope.go("activityChooseTeacher", {activityid: act.id});
  460. break;
  461. default:
  462. break;
  463. }
  464. };
  465. // 活动是否弹出签到弹窗(否临时人员:弹窗,已报名:直接签到)
  466. var activityid = 0;
  467. var checkIntime = function (actid) {
  468. activityid = actid;
  469. $scope.showLoadingToast();
  470. ActivityService.checkIntime(activityid).then(function (response) {
  471. if (response.result == 1) {
  472. $scope.userinfo = response.userinfo;
  473. $scope.categoryModal.show();
  474. $scope.hideLoadingToast();
  475. } else {
  476. checkIn();
  477. }
  478. }, function () {
  479. $scope.hideLoadingToast();
  480. })
  481. };
  482. // 签到
  483. var checkIn = function () {
  484. ActivityService.getCheckInStatus(activityid).then(function (response) {
  485. // 0未签到,1已签到
  486. if (response.result == 0) {
  487. ActivityService.checkIn(activityid, ConfigService.location.lat, ConfigService.location.lng).then(function (response) {
  488. if (response.result == 1) {
  489. UtilService.showMess("签到成功");
  490. } else {
  491. UtilService.showMess("网络不给力,请重试");
  492. }
  493. $scope.hideLoadingToast();
  494. }, function () {
  495. $scope.hideLoadingToast();
  496. UtilService.showMess("网络不给力,请重试");
  497. });
  498. } else {
  499. UtilService.showMess("您已成功签到");
  500. $scope.hideLoadingToast();
  501. }
  502. }, function () {
  503. UtilService.showMess("网络不给力,请重试");
  504. $scope.hideLoadingToast();
  505. });
  506. };
  507. // 临时人员签到
  508. $scope.tempCheckin = function () {
  509. if (!UtilService.isDefined($scope.userinfo.name)) {
  510. UtilService.showMess("姓名不能为空");
  511. return;
  512. }
  513. if (!UtilService.isDefined($scope.userinfo.university)) {
  514. UtilService.showMess("所属院校不能为空");
  515. return;
  516. }
  517. $scope.showLoadingToast();
  518. ActivityService.tempCheckIn(activityid, ConfigService.location.lat, ConfigService.location.lng, $scope.userinfo).then(function (response) {
  519. if (response.result == 1) {
  520. UtilService.showMess("签到成功");
  521. $timeout(function () {
  522. $scope.categoryModal.hide();
  523. }, 300);
  524. } else {
  525. UtilService.showMess("网络不给力,请重试");
  526. }
  527. $scope.hideLoadingToast();
  528. }, function () {
  529. UtilService.showMess("网络不给力,请重试");
  530. $scope.hideLoadingToast();
  531. });
  532. };
  533. //关闭报名入口
  534. $scope.closeCategoryModal = function () {
  535. $scope.categoryModal.hide();
  536. };
  537. $ionicModal.fromTemplateUrl("templates/modal.html", {
  538. scope: $scope,
  539. animation: 'slide-in-up'
  540. }).then(function (modal) {
  541. $scope.categoryModal = modal;
  542. });
  543. //获取研究领域标签
  544. var buttons = [];
  545. var getLabelList = function () {
  546. ActivityService.getCategory().then(function (response) {
  547. angular.forEach(response, function (value, index) {
  548. var temphtml = {
  549. text: '<a class="action-sheet-push">' + value.name + '</a>',
  550. category: value.name,
  551. id: value.id
  552. };
  553. buttons.push(temphtml);
  554. });
  555. }, function () {
  556. })
  557. };
  558. getLabelList();
  559. //选择研究领域
  560. $scope.showDockingStatus = function () {
  561. $ionicActionSheet.show({
  562. buttons: buttons,
  563. cancelText: '取消',
  564. buttonClicked: function (index) {
  565. $scope.userinfo.categoryid = buttons[index].id;
  566. $scope.userinfo.category = buttons[index].category;
  567. return true;
  568. }
  569. });
  570. };
  571. // 进入个人主页
  572. $scope.goPublisher = function (userid) {
  573. $scope.islogin = ConfigService.islogin;
  574. if(!$scope.islogin){
  575. if (localStorage.wxFlag == "true") {
  576. if (localStorage.isUserFocusXW == 0) {
  577. var title = localStorage.appidStr;
  578. $ionicPopup.alert({
  579. title: '提示',
  580. template: '请先关注微信公众号"' + title + '"!'
  581. });
  582. return;
  583. } else {
  584. if (localStorage.isUserBindWx == 0) {
  585. var wxFlag = JSON.parse(localStorage.params);
  586. if (wxFlag.weChatModel) {
  587. $scope.go('bindPhone', {
  588. params: localStorage.params,
  589. comfrom: 'maincontroller',
  590. url: window.location.href.split('#/')[1]
  591. });
  592. } else {
  593. $scope.go('login');
  594. return;
  595. }
  596. } else {
  597. $scope.go('login');
  598. return;
  599. }
  600. }
  601. } else {
  602. $scope.go('login');
  603. return;
  604. }
  605. }else{
  606. $scope.go('publisher', {Id: userid});
  607. }
  608. };
  609. });