|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166 |
- /**
- * Created by Administrator on 2021/4/5.
- */
- define(['jquery', "template", "Tools", "interactApi", "paging"], function ($, template, Tools ) {
- //数据存储
- var module = {
- data: {
- //互动交流列表
- interactInformationList:'',
- //搜索结果列表
- searchInformationList:'',
- //页码
- pageNum: 1,
- //页码集合
- pageList: [],
- //每页数量
- pageSize: 5,
- //总页数
- pageCount:0,
- questionsUrl:'',
- answerUrl:''
- },
- };
- var tools = new Tools();
-
- module.init = function (page) {
- //底部友情链接
- tools.doGet(friendsLinks, {}, module.bottomFriendsLinks, true);
- if(getQueryVariable('keyWord')){
- $('#searchTitle').val(getQueryVariable('keyWord'));
- goSearch()
- }
-
-
- //网站配置信息(网站名称 底部联系方式 公安备案号 网站备案号)
- tools.getWebConfig();
- setTimeout(function(){
- //主题图片切换
- module.switchTheme();
- //互动交流
- tools.doGet(interactList, {deptId:100,pageNum:module.data.pageNum,pageSize:module.data.pageSize,reply:'notnull'}, module.interactInformation,true);
-
- },500)
- };
- //主题图片切换
- module.switchTheme = function(){
- if(themeColor == 'red'){
- module.data.questionsUrl='../../static/images/questions_red.png';
- module.data.answerUrl='../../static/images/answer_red.png';
- }else if(themeColor == 'green'){
- module.data.questionsUrl='../../static/images/questions.png';
- module.data.answerUrl='../../static/images/answer.png';
- }
- }
- //获取地址栏参数
- function getQueryVariable(variable){
- var query = window.location.search.substring(1);
- var vars = query.split("&");
- for (var i=0;i<vars.length;i++) {
- var pair = vars[i].split("=");
- if(pair[0] == variable){return decodeURI(pair[1]);}
- }
- return(false);
- }
- //新闻资讯数据
- module.interactInformation = function (data) {
- if (data.code == 200) {
- //console.log(data)
- var content = data.rows;
- var pageCount = (data.total/module.data.pageSize).toFixed(0);
- if (pageCount < 1){
- pageCount = 1;
- }
- //console.log(module.data.interactInformationList)
- if(module.data.interactInformationList == ''){
- //console.log('aaa')
- // 初始化 分页器
- var page_s1=createPage('.page_s1');
- // 设置分页
- setPage(page_s1,{
- pageTotal: data.total, // 数据总条数
- pageSize: module.data.pageSize, // 每页显示条数
- pageCurrent: module.data.pageNum, // 当前页
- maxBtnNum: 5, // 最多按钮个数 (最少5个)
- })
- $('#page_s1').html('共'+pageCount+'页')
- }
- module.data.pageCount = pageCount;
- module.data.interactInformationList = content;
- var interactInformationData = template('interactInformationData', module.data);
- $("#interactInformationContent").html(interactInformationData);
- }
- }
- //底部友情链接
- module.bottomFriendsLinks = function (data) {
- if (data.code == 200) {
- var content = data.data;
- //console.log(content)
- module.data.friendsLinksList = content;
- var friendsLinksData = template('friendsLinksData', module.data);
- $("#friendsLinksContent").html(friendsLinksData);
- }
- }
- //新闻资讯数据
- module.searchInteractInformation = function (data) {
- if (data.code == 200) {
- var content = data.rows;
- var pageCount = (data.total/module.data.pageSize).toFixed(0);
- if (pageCount < 1){
- pageCount = 1;
- }
- if((module.data.searchInformationList == '' || module.data.searchType == 'YES')&& module.data.turnPage != 'YES'){
- // 初始化 分页器
- var page_s1=createPage('.page_s2');
- // 设置分页
- setPage(page_s1,{
- pageTotal: data.total, // 数据总条数
- pageSize: module.data.pageSize, // 每页显示条数
- pageCurrent: module.data.pageNum, // 当前页
- maxBtnNum: 5, // 最多按钮个数 (最少5个)
- })
- $('#page_s2').html('共'+pageCount+'页')
- }
- module.data.pageCount = pageCount;
- module.data.searchInformationList = content;
- var searchInformationData = template('searchInformationData', module.data);
- $("#searchInformationContent").html(searchInformationData);
- }
- }
-
- goSearch = function () {
- $('.page_s2').html('');
- var searchTitle = $('#searchTitle').val();
- var searchContent = $('#searchContent').val();
- module.data.searchTitle = searchTitle ;
- module.data.searchContent = searchContent ;
- module.data.searchType = 'YES';
- module.data.turnPage = 'NO';
- module.data.pageNum = 1 ;
-
- document.getElementById('interact').style.display = 'none';
- document.getElementById('search').style.display = 'block';
- tools.doGet(interactSearch, {deptId:100,title:searchTitle,content:searchContent,pageNum:1,pageSize:module.data.pageSize,reply:'notnull'}, module.searchInteractInformation,true)
- }
-
- turnThePage = function (pageNum) {
- module.data.pageNum = pageNum ;
- if (module.data.searchType == 'YES'){
- module.data.turnPage = 'YES';
- tools.doGet(interactSearch, {deptId:100,title:module.data.searchTitle,content:module.data.searchContent,pageNum:pageNum,pageSize:module.data.pageSize,reply:'notnull'}, module.searchInteractInformation,true)
- }else{
- tools.doGet(interactList, {deptId:100,pageNum:pageNum,pageSize:module.data.pageSize,reply:'notnull'}, module.interactInformation,true);
- }
- }
-
- goUserInteract = function () {
- if(tools.getCookie('Admin-Token')){
- tools.skip('../user/user.html?type=goInteract')
- }else{
- tools.initDialog('登陆提示', '登陆后可参与竞价,是否登录?', function () {
- tools.skip('../login/login.html')
- }, '登录', function () { }, "取消")
- }
- }
- return module;
- });
|