农燊高科官方网站
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 

166 líneas
6.6 KiB

  1. /**
  2. * Created by Administrator on 2021/4/5.
  3. */
  4. define(['jquery', "template", "Tools", "interactApi", "paging"], function ($, template, Tools ) {
  5. //数据存储
  6. var module = {
  7. data: {
  8. //互动交流列表
  9. interactInformationList:'',
  10. //搜索结果列表
  11. searchInformationList:'',
  12. //页码
  13. pageNum: 1,
  14. //页码集合
  15. pageList: [],
  16. //每页数量
  17. pageSize: 5,
  18. //总页数
  19. pageCount:0,
  20. questionsUrl:'',
  21. answerUrl:''
  22. },
  23. };
  24. var tools = new Tools();
  25. module.init = function (page) {
  26. //底部友情链接
  27. tools.doGet(friendsLinks, {}, module.bottomFriendsLinks, true);
  28. if(getQueryVariable('keyWord')){
  29. $('#searchTitle').val(getQueryVariable('keyWord'));
  30. goSearch()
  31. }
  32. //网站配置信息(网站名称 底部联系方式 公安备案号 网站备案号)
  33. tools.getWebConfig();
  34. setTimeout(function(){
  35. //主题图片切换
  36. module.switchTheme();
  37. //互动交流
  38. tools.doGet(interactList, {deptId:100,pageNum:module.data.pageNum,pageSize:module.data.pageSize,reply:'notnull'}, module.interactInformation,true);
  39. },500)
  40. };
  41. //主题图片切换
  42. module.switchTheme = function(){
  43. if(themeColor == 'red'){
  44. module.data.questionsUrl='../../static/images/questions_red.png';
  45. module.data.answerUrl='../../static/images/answer_red.png';
  46. }else if(themeColor == 'green'){
  47. module.data.questionsUrl='../../static/images/questions.png';
  48. module.data.answerUrl='../../static/images/answer.png';
  49. }
  50. }
  51. //获取地址栏参数
  52. function getQueryVariable(variable){
  53. var query = window.location.search.substring(1);
  54. var vars = query.split("&");
  55. for (var i=0;i<vars.length;i++) {
  56. var pair = vars[i].split("=");
  57. if(pair[0] == variable){return decodeURI(pair[1]);}
  58. }
  59. return(false);
  60. }
  61. //新闻资讯数据
  62. module.interactInformation = function (data) {
  63. if (data.code == 200) {
  64. //console.log(data)
  65. var content = data.rows;
  66. var pageCount = (data.total/module.data.pageSize).toFixed(0);
  67. if (pageCount < 1){
  68. pageCount = 1;
  69. }
  70. //console.log(module.data.interactInformationList)
  71. if(module.data.interactInformationList == ''){
  72. //console.log('aaa')
  73. // 初始化 分页器
  74. var page_s1=createPage('.page_s1');
  75. // 设置分页
  76. setPage(page_s1,{
  77. pageTotal: data.total, // 数据总条数
  78. pageSize: module.data.pageSize, // 每页显示条数
  79. pageCurrent: module.data.pageNum, // 当前页
  80. maxBtnNum: 5, // 最多按钮个数 (最少5个)
  81. })
  82. $('#page_s1').html('共'+pageCount+'页')
  83. }
  84. module.data.pageCount = pageCount;
  85. module.data.interactInformationList = content;
  86. var interactInformationData = template('interactInformationData', module.data);
  87. $("#interactInformationContent").html(interactInformationData);
  88. }
  89. }
  90. //底部友情链接
  91. module.bottomFriendsLinks = function (data) {
  92. if (data.code == 200) {
  93. var content = data.data;
  94. //console.log(content)
  95. module.data.friendsLinksList = content;
  96. var friendsLinksData = template('friendsLinksData', module.data);
  97. $("#friendsLinksContent").html(friendsLinksData);
  98. }
  99. }
  100. //新闻资讯数据
  101. module.searchInteractInformation = function (data) {
  102. if (data.code == 200) {
  103. var content = data.rows;
  104. var pageCount = (data.total/module.data.pageSize).toFixed(0);
  105. if (pageCount < 1){
  106. pageCount = 1;
  107. }
  108. if((module.data.searchInformationList == '' || module.data.searchType == 'YES')&& module.data.turnPage != 'YES'){
  109. // 初始化 分页器
  110. var page_s1=createPage('.page_s2');
  111. // 设置分页
  112. setPage(page_s1,{
  113. pageTotal: data.total, // 数据总条数
  114. pageSize: module.data.pageSize, // 每页显示条数
  115. pageCurrent: module.data.pageNum, // 当前页
  116. maxBtnNum: 5, // 最多按钮个数 (最少5个)
  117. })
  118. $('#page_s2').html('共'+pageCount+'页')
  119. }
  120. module.data.pageCount = pageCount;
  121. module.data.searchInformationList = content;
  122. var searchInformationData = template('searchInformationData', module.data);
  123. $("#searchInformationContent").html(searchInformationData);
  124. }
  125. }
  126. goSearch = function () {
  127. $('.page_s2').html('');
  128. var searchTitle = $('#searchTitle').val();
  129. var searchContent = $('#searchContent').val();
  130. module.data.searchTitle = searchTitle ;
  131. module.data.searchContent = searchContent ;
  132. module.data.searchType = 'YES';
  133. module.data.turnPage = 'NO';
  134. module.data.pageNum = 1 ;
  135. document.getElementById('interact').style.display = 'none';
  136. document.getElementById('search').style.display = 'block';
  137. tools.doGet(interactSearch, {deptId:100,title:searchTitle,content:searchContent,pageNum:1,pageSize:module.data.pageSize,reply:'notnull'}, module.searchInteractInformation,true)
  138. }
  139. turnThePage = function (pageNum) {
  140. module.data.pageNum = pageNum ;
  141. if (module.data.searchType == 'YES'){
  142. module.data.turnPage = 'YES';
  143. tools.doGet(interactSearch, {deptId:100,title:module.data.searchTitle,content:module.data.searchContent,pageNum:pageNum,pageSize:module.data.pageSize,reply:'notnull'}, module.searchInteractInformation,true)
  144. }else{
  145. tools.doGet(interactList, {deptId:100,pageNum:pageNum,pageSize:module.data.pageSize,reply:'notnull'}, module.interactInformation,true);
  146. }
  147. }
  148. goUserInteract = function () {
  149. if(tools.getCookie('Admin-Token')){
  150. tools.skip('../user/user.html?type=goInteract')
  151. }else{
  152. tools.initDialog('登陆提示', '登陆后可参与竞价,是否登录?', function () {
  153. tools.skip('../login/login.html')
  154. }, '登录', function () { }, "取消")
  155. }
  156. }
  157. return module;
  158. });