// 登录 var login = new Vue({ el: '#login', data: { islogin: false }, mounted: function () { console.log("登录") }, methods: { // 点击手机登录 phone: function () { console.log("点击手机登录") document.getElementById('popup').style.display = 'block' document.getElementById('popup-video').style.display = 'block' document.body.setAttribute('style', 'overflow:hidden'); popup.isactive = 'phonelogin'; //popup.logintext = '登录' }, //点击立即注册 register: function () { console.log("点击注册") document.getElementById('popup').style.display = 'block' document.getElementById('popup-video').style.display = 'block' document.body.setAttribute('style', 'overflow:hidden'); popup.isactive = 'register' }, // 点击签到 check: function () { console.log("点击签到") }, //登陆2 loginSubto:function(){ var user = document.getElementById('user2').value; var password = document.getElementById('password2').value; if (user == '') { waringtxt('用户名或手机号不能为空!'); return false; } if (password == '') { waringtxt('密码不能为空!'); return false; } var params = new URLSearchParams(); params.append('user', user); params.append('password', password); // 请求帖子列表信息 axios.post('/index.php/User/login.html', params) .then(function (response) { console.log("帖子列表", response.data, response.data.length); if (response.data.state == 1) { waringtxt(response.data.msg); history.go(0); } else { waringtxt(response.data.msg); } }) .catch(function (error) { console.log(error); }); }, } }) // 登录成功 var loginok = new Vue({ el: '#loginok', mounted: function () { if(document.getElementById('signflag')){ axios.get('/index.php/Api/getsignstate') .then(function (response) { // console.log(response.data); if(response.data.today){ var s = response.data.today; document.getElementById('signflag').value = s; if(s == 1){ document.getElementById('signbn').style.background = "url(/public/new/images/icon-check-on.png)"; } } }); } }, methods: { //退出登录 logout:function(){ // 请求帖子列表信息 axios.get('/index.php/User/logout.html') .then(function (response) { console.log("帖子列表", response.data, response.data.length); waringtxt("退出成功!"); location.href = '/'; }) .catch(function (error) { console.log(error); }); }, //签到 signok:function(){ var uid = document.getElementById('loginuid').value var signflag = document.getElementById('signflag').value; if(signflag == "1"){ waringtxt("今天已经签到,请明天再来签到!"); return false; } if(uid != '' && uid != null && uid != undefined){ axios.get('/index.php/Api/sign',{ params:{ uid:uid } }) .then(function (response) { console.log(response.data); waringtxt("已签到,获得"+response.data.data.jifen+"积分!"); document.getElementById('signbn').style.background = "url(/public/new/images/icon-check-on.png)"; }); } } } }) function select_fun(){ // 每日精选 var select = new Vue({ el: '#select', data: { select_list: '' }, mounted: function () { // 请求每日精选 axios.get('/index.php/Api/tuijian') .then(function (response) { console.log("每日精选", response.data); select.select_list = response.data // 每日精选swiper var mySwiper mySwiper = new Swiper('.select-box', { autoplay: { delay: 5000 }, init: false, slidesPerView: 3, spaceBetween: 15, initialSlide: 0, loop: true, navigation: { nextEl: '.switch-next', prevEl: '.switch-prev', }, observer: true,//修改swiper自己或子元素时,自动初始化swiper observeParents: true,//修改swiper的父元素时,自动初始化swiper }); setTimeout(function () { mySwiper.init();//因动态加载数据,延迟初始化,以保证显示效果正常 }, 200) }) .catch(function (error) { console.log(error); }); } }) } function todayactive_fun(){ //今日活跃 var todayactive = new Vue({ el: '#todayactive', data: { userlist: '' }, mounted: function () { // 请求今日活跃 axios.get('/index.php/Api/activeUsers') .then(function (response) { console.log("今日活跃", response.data); todayactive.userlist = response.data // 今日活跃swiper new Swiper('.user-box', { autoplay: { delay: 5000, }, reverseDirection: true, height: 64, slidesPerView: 1, slidesPerColumn: 3, navigation: { nextEl: '.switch-next-active', prevEl: '.switch-prev-active', }, observer: true,//修改swiper自己或子元素时,自动初始化swiper observeParents: true,//修改swiper的父元素时,自动初始化swiper }); }) .catch(function (error) { console.log(error); }); } }) } function tiezilist_fun(){ // 帖子列表 var type var nowpage var fid var tiezilist = new Vue({ el: '#tiezilist', data: { tiezilist: '', nowpage: 0, type: 2, fid: '', active: 0 }, mounted: function () { type = this.type nowpage = this.nowpage fid = this.fid this.request_list(type, nowpage, fid) }, methods: { request_list: function (type, nowpage, fid) { // 请求帖子列表信息 axios.get('/index.php/Api/forumlist', { params: { type: type, nowpage: nowpage, fid: fid || '' } }) .then(function (response) { console.log("帖子列表", response.data, response.data.length); tiezilist.tiezilist = response.data tiezilist.nowpage = nowpage }) .catch(function (error) { console.log(error); }); }, // 点击推荐 tuijian: function () { tiezilist.tiezilist = '' nowpage = 0 type = 2 fid = '' console.log("推荐", nowpage, type, fid) // 请求帖子列表信息 axios.get('/index.php/Api/forumlist', { params: { type: type, nowpage: nowpage, } }) .then(function (response) { console.log("帖子列表", response.data, response.data.length); tiezilist.tiezilist = response.data tiezilist.nowpage = nowpage tiezilist.active = 0 }) .catch(function (error) { console.log(error); }); }, // 点击最新 zuixin: function () { tiezilist.tiezilist = '' nowpage = 0 type = 1 fid = '' console.log("最新", nowpage, type, fid) // 请求帖子列表信息 axios.get('/index.php/Api/forumlist', { params: { type: type, nowpage: nowpage, } }) .then(function (response) { console.log("帖子列表", response.data, response.data.length); tiezilist.tiezilist = response.data tiezilist.nowpage = nowpage tiezilist.active = 1 }) .catch(function (error) { console.log(error); }); }, // 点击问答 wenda: function () { tiezilist.tiezilist = '' nowpage = 0 type = 1 fid = 36 console.log("问答", nowpage, type, fid) // 请求帖子列表信息 axios.get('/index.php/Api/forumlist', { params: { type: type, nowpage: nowpage, fid: fid } }) .then(function (response) { console.log("帖子列表", response.data, response.data.length); tiezilist.tiezilist = response.data tiezilist.nowpage = nowpage tiezilist.active = 2 }) .catch(function (error) { console.log(error); }); }, // 上一页 prevpage: function () { console.log("上一页", nowpage) if (nowpage > 0) { // tiezilist.tiezilist='' nowpage = nowpage - 1 } // 请求帖子列表信息 axios.get('/index.php/Api/forumlist', { params: { type: type, nowpage: nowpage, fid: fid || '' } }) .then(function (response) { console.log("帖子列表", response.data, response.data.length); tiezilist.tiezilist = response.data tiezilist.nowpage = nowpage tiezilist.scrolltotiezitop() }) .catch(function (error) { console.log(error); }); }, // 下一页 nextpage: function () { console.log("下一页", nowpage) nowpage = nowpage + 1 tiezilist.tiezilist = '' // 请求帖子列表信息 axios.get('/index.php/Api/forumlist', { params: { type: type, nowpage: nowpage, fid: fid || '' } }) .then(function (response) { console.log("帖子列表", response.data, response.data.length); tiezilist.tiezilist = response.data tiezilist.nowpage = nowpage tiezilist.scrolltotiezitop() }) .catch(function (error) { console.log(error); }); }, // 向上滑动到帖子列表位置 scrolltotiezitop: function () { let osTop = document.documentElement.scrollTop || document.body.scrollTop // let ispeed = Math.floor(-osTop / 8) document.documentElement.scrollTop = document.body.scrollTop = 450 this.isTop = true }, //发帖 threadsend:function(){ var uid= document.getElementById('loginuid').value if(uid == ''){ document.getElementById('popup').style.display = 'block' document.getElementById('popup-video').style.display = 'block' document.body.setAttribute('style', 'overflow:hidden'); }else{ location.href="/index.php/NewIndex/threadsend"; } }, } }) } // 板块帖子列表 function forumlist_fun(){ var forumlist = new Vue({ el: '#forumlist', data: { forumlist: '', nowpage: 0, type: 2, fid: '', active: 0, showloading:false, pagecount:10, nomore:false, }, mounted: function () { type = this.type nowpage = this.nowpage fid = document.getElementById('fid')?document.getElementById('fid').value:'' this.request_list(fid, nowpage) }, methods: { request_list: function (fid, nowpage) { // 请求帖子列表信息 axios.get('/index.php/Api/forumlist', { params: { fid:fid, nowpage: nowpage } }) .then(function (response) { console.log("帖子列表", response.data, response.data.length); if (forumlist.forumlist != '') { forumlist.forumlist = forumlist.forumlist.concat(response.data); forumlist.showloading = false } else { forumlist.forumlist = response.data } if (response.data.length < forumlist.pagecount) { forumlist.nomore = true } else { forumlist.nomore = false } }) .catch(function (error) { console.log(error); }); }, loadmore:function(){ forumlist.showloading = true nowpage = nowpage + 1 this.request_list(fid, nowpage) }, threadsend:function(){ var uid=document.getElementById('loginuid').value; if(uid == ''){ document.getElementById('popup').style.display = 'block' document.getElementById('popup-video').style.display = 'block' document.body.setAttribute('style', 'overflow:hidden'); }else{ location.href="/index.php/NewIndex/threadsend?fid="+fid; } } } }) }