//index.js //获取应用实例 const app = getApp() var host = app.globalData.host; Page({ data: { zimu_list: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'], scroll: '', //滚动到指定 id值的子元素 touchmove: 0,//给字母导航添加背景色 1 添加 0不添加 nav_height: '',//字母导航单个元素高度 nav_top:'', hiddenn: true,//hint_box 提示框 展示隐藏 nav_text: '',//hint_box 提示框里面的文本 lb:[], act:0, journals:[], organizers:[], subjects:[], show:1, uid:'', page_org:1, page_sub:1, total_org:0, total_sub:0 }, onShow: function () { if (this.data.uid){ this.setData({ organizers: [], subjects: [], page_org: 1, page_sub: 1, total_org: 0, total_sub: 0 }) this.getData(); }else{ this.setData({ openid: app.globalData.openid }) wx.getStorage({ key: 'uid', success: res => { if (res.data) { this.setData({ show: 0, uid: res.data }) } this.getData(); }, }) } }, onGotUserInfo: function () { wx.getUserProfile({ desc: '用于完善会员资料', success: res=> { //获取基本信息 var data = { nickName: res.userInfo.nickName, avatarUrl: res.userInfo.avatarUrl } wx.showLoading({ title: '正在登陆', }) wx.setStorage({ key: 'userInfo', data: data, }) wx.request({ url: host + '/api/auth', method: 'POST', data: { nickname: data.nickName, avatar: data.avatarUrl, openid: app.globalData.openid, }, success: res => { wx.hideLoading() wx.setStorage({ key: 'uid', data: res.data.data.uid, }) this.setData({ show: 0 }) }, fail:error=>{ wx.hideLoading() wx.showLoading({ title: '登陆失败', }) } }) } }) }, //主办单位下一页 next_org:function(){ if(this.data.organizers.length < this.data.total_org){ const page = this.data.page_org+1 this.setData({ page_org: page }) this.getorg() } }, //领域期刊下一页 next_sub:function(){ if(this.data.subjects.length < this.data.total_sub){ const page = this.data.page_sub+1 this.setData({ page_sub: page }) this.getsub() } }, //获取所有数据 getData:function(flag){ wx.showNavigationBarLoading() var that=this; if(!flag){ wx.request({ url: host+'/api/index/banners', method:'GET', success:function(res){ that.setData({ lb: res.data.data.banners }) }, fail: function () { wx.hideNavigationBarLoading() wx.showToast({ title: '服务器开小差啦!', icon: 'none' }) } }) // 全刊 wx.request({ url: host + '/api/index/journals', method: 'GET', success: function (res) { wx.hideNavigationBarLoading() that.setData({ journals: res.data.data.journals }) } }) } this.getorg() this.getsub() }, //主办单位 getorg:function(){ console.log(this.data.page_org) const organizers=this.data.organizers; wx.request({ url: host + '/api/index/organizers', method: 'GET', data: { uid: this.data.uid, page: this.data.page_org }, success: res=>{ wx.hideNavigationBarLoading() if(res.data.code == 0){ const list=res.data.data.list; for(let i=0;i{ wx.hideNavigationBarLoading() if(res.data.code == 0){ const list=res.data.data.list; for(let i=0;i