|
- /**
- * Created by Administrator on 2021/4/5.
- */
- define(['jquery', "template", "Tools", "policyApi", "paging"], function ($, template, Tools ) {
- //数据存储
- var module = {
- data: {
- //政策法规
- policyInformationList:'',
- //交易规则
- ruleInformationList:'',
- //资料下载
- downloadInformationList:'',
- //页码
- pageNum: 1,
- //页码集合
- pageList: [],
- //每页数量
- pageSize: 50,
- //总页数
- pageCount:0
- },
- };
- var tools = new Tools();
-
- module.init = function (page) {
-
- var type = getQueryVariable('type');
- if(type != undefined && type != ''){
- console.log('搜索进入')
- tabList(type);
- //政策法规
- tools.doGet(newList, {number:3,deptId:100,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.policyInformation,true);
-
- //交易规则
- tools.doGet(newList, {number:4,deptId:100,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.ruleInformation,true);
-
- //资料下载
- tools.doGet(newList, {number:5,deptId:100,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.downloadInformation,true);
- }else{
- console.log('正常进入')
- //政策法规
- tools.doGet(newList, {number:3,deptId:100,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.policyInformation,true);
-
- //交易规则
- tools.doGet(newList, {number:4,deptId:100,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.ruleInformation,true);
-
- //资料下载
- tools.doGet(newList, {number:5,deptId:100,pageNum:module.data.pageNum,pageSize:module.data.pageSize}, module.downloadInformation,true);
- }
-
- };
-
- //获取地址栏参数
- 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 pair[1];}
- }
- return(false);
- }
-
- //政策法规数据
- module.policyInformation = 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.policyInformationList == ''){
- // 初始化 分页器
- var page_s1=createPage('.page_s1');
- // 设置分页
- setPage(page_s1,{
- pageTotal: data.total, // 数据总条数
- pageSize: module.data.pageSize, // 每页显示条数
- pageCurrent: 1, // 当前页
- maxBtnNum: 5, // 最多按钮个数 (最少5个)
- })
- $('#page_s1').html('共'+pageCount+'页')
- }
- module.data.pageCount = pageCount;
- module.data.policyInformationList = content;
- var policyInformationData = template('policyInformationData', module.data);
- $("#policyInformationContent").html(policyInformationData);
- }
- }
-
- //交易规则数据
- module.ruleInformation = 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.ruleInformationList == ''){
- // 初始化 分页器
- var page_s1=createPage('.page_s2');
- // 设置分页
- setPage(page_s1,{
- pageTotal: data.total, // 数据总条数
- pageSize: module.data.pageSize, // 每页显示条数
- pageCurrent: 1, // 当前页
- maxBtnNum: 5, // 最多按钮个数 (最少5个)
- })
- $('#page_s2').html('共'+pageCount+'页')
- }
- module.data.pageCount = pageCount;
- module.data.ruleInformationList = content;
- var ruleInformationData = template('ruleInformationData', module.data);
- $("#ruleInformationContent").html(ruleInformationData);
- }
- }
-
- //交易规则数据
- module.downloadInformation = 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.downloadInformationList == ''){
- // 初始化 分页器
- var page_s1=createPage('.page_s3');
- // 设置分页
- setPage(page_s1,{
- pageTotal: data.total, // 数据总条数
- pageSize: module.data.pageSize, // 每页显示条数
- pageCurrent: 1, // 当前页
- maxBtnNum: 5, // 最多按钮个数 (最少5个)
- })
- $('#page_s3').html('共'+pageCount+'页')
- }
- module.data.pageCount = pageCount;
- module.data.downloadInformationList = content;
- var downloadInformationData = template('downloadInformationData', module.data);
- $("#downloadInformationContent").html(downloadInformationData);
- }
- }
-
- tabList = function(type){
- console.log(type)
- document.getElementById('policyInformationContent').style.display = 'none';
- document.getElementById('ruleInformationContent').style.display = 'none';
- document.getElementById('downloadInformationContent').style.display = 'none';
- document.getElementById(type+'InformationContent').style.display = 'block';
-
- document.getElementById('policy').className = '';
- document.getElementById('rule').className = '';
- document.getElementById('download').className = '';
- document.getElementById(type).className = 'active';
-
- document.getElementById('policyNum').style.display = 'none';
- document.getElementById('ruleNum').style.display = 'none';
- document.getElementById('downloadNum').style.display = 'none';
- document.getElementById(type+'Num').style.display = 'block';
-
- module.data.clickType = type;
- module.data.pageNum = 1 ;
- }
-
- turnThePage = function (pageNum) {
- module.data.pageNum = pageNum ;
- if(module.data.clickType == 'policy'){
- tools.doGet(newList, {number:3,deptId:100,pageNum:pageNum,pageSize:module.data.pageSize}, module.policyInformation,true);
- }
- if(module.data.clickType == 'rule'){
- tools.doGet(newList, {number:4,deptId:100,pageNum:pageNum,pageSize:module.data.pageSize}, module.ruleInformation,true);
- }
- if(module.data.clickType == 'download'){
- tools.doGet(newList, {number:5,deptId:100,pageNum:pageNum,pageSize:module.data.pageSize}, module.downloadInformation,true);
- }
- }
- return module;
- });
|