|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- /**
- * Created by Administrator on 2021/4/5.
- */
- define(['jquery', "template", "Tools", "demandApi", "paging", 'swiper'], function ($, template, Tools ) {
- //数据存储
- var module = {
- data: {
- //焦点图数据
- focusListTop: [],
- //公告列表
- demandInformationList:'',
- //鉴证列表
- supplyInformationList:'',
- //页码
- pageNum: 1,
- //页码集合
- pageList: [],
- //每页数量
- pageSize: 50,
- //总页数
- pageCount:0,
- //选中卡ID
- clickType:'supply',
- //供求类型 1:供应 2:求购 (不传值获取两种类型混合数据)
- demandType:1
- },
- };
- var tools = new Tools();
-
- module.init = function (page) {
- //获取焦点图信息
- tools.doGet(websitePicture, {picType:1,status:0,orderByColumn:'picSort',isAsc:'desc'}, module.focusNewsTop , true);
- //底部友情链接
- tools.doGet(friendsLinks, {}, module.bottomFriendsLinks, true);
- //个人供应
- tools.doGet(
- demandList,
- {
- deptId:100,
- pageNum:module.data.pageNum,
- pageSize:module.data.pageSize,
- supplyDemandType:1
- },
- module.supplyInformation,true
- );
-
- //个人需求
- tools.doGet(
- demandList,
- {
- deptId:100,
- pageNum:module.data.pageNum,
- pageSize:module.data.pageSize,
- supplyDemandType:2
- },
- module.demandInformation,true
- );
-
- //网站配置信息(网站名称 底部联系方式 公安备案号 网站备案号)
- tools.getWebConfig();
- };
-
- //焦点图数据
- module.focusNewsTop = function (data) {
- if (data.code == 200) {
-
- let focusArray = [];
-
- if(data.data.length<1){
- focusArray.push({
- picUrl:'../../../static/images/banner1.png'
- },{
- picUrl:'../../../static/images/banner2.png'
- },{
- picUrl:'../../../static/images/banner3.png'
- })
- }else{
- data.data.forEach(res=>{
- focusArray.push({
- picUrl:'/api'+res.picUrl
- })
- })
- }
-
- module.data.focusListTop = focusArray;
- var bannerFocusDataTop = template('bannerFocusDataTop', module.data);
- $("#bannerFocusTopContent").html(bannerFocusDataTop);
-
- new Swiper('#bannerFocusWrapTop', {
- paginationClickable: true,
- autoplay : 4000,
- loop:true
- })
-
- }
- }
-
- //底部友情链接
- 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.supplyInformation = 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;
- }
- if(module.data.supplyInformationList == ''){
- // 初始化 分页器
- 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.supplyInformationList = content;
- var supplyInformationData = template('supplyInformationData', module.data);
- $("#supply").html(supplyInformationData);
- }
- }
-
- //个人需求数据
- module.demandInformation = 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.demandInformationList == ''){
- // 初始化 分页器
- 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.demandInformationList = content;
- var demandInformationData = template('demandInformationData', module.data);
- $("#demand").html(demandInformationData);
- }
- }
-
- tabCheck = function (type) {
- document.getElementById('supply').style.display = 'none';
- document.getElementById('demand').style.display = 'none';
- document.getElementById(type).style.display = 'inline-table';
- document.getElementById('supplyBtn').className = '';
- document.getElementById('demandBtn').className = '';
- document.getElementById(type+'Btn').className = 'active';
- module.data.clickType = type ;
- }
-
- turnThePage = function (pageNum) {
- module.data.pageNum = pageNum ;
- if(module.data.clickType == 'supply'){
- //个人供应
- tools.doGet(
- demandList,
- {
- deptId:100,
- pageNum:module.data.pageNum,
- pageSize:module.data.pageSize,
- supplyDemandType:1
- },
- module.supplyInformation,true
- );
- }
- if(module.data.clickType == 'demand'){
- //个人需求
- tools.doGet(
- demandList,
- {
- deptId:100,
- pageNum:module.data.pageNum,
- pageSize:module.data.pageSize,
- supplyDemandType:2
- },
- module.demandInformation,true
- );
- }
- }
- goUserDemand = function () {
- if(tools.getCookie('Admin-Token')){
- tools.skip('../user/user.html?type=goDemand')
- }else{
- tools.initDialog('登录提示', '登录后可参与发布,是否登录?', function () {
- tools.skip('../login/login.html')
- }, '登录', function () { }, "取消")
- }
- }
- return module;
- });
|