版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
第STYLEREF"标题1"\n1章STYLEREF"标题1"绪论第STYLEREF"标题1"\n1章STYLEREF"标题1"绪论2附录1.书城代码://pages/bookCity/bookCity.jsconstapi=require('../../utils/api.js')Page({data:{STATIC_HOST:'',winHeight:"",//窗口高度currentTab:0,//预设当前项的值majorList:{},rankCategory:{},openMaleOther:false,//控制列表伸缩openFemaleOther:false,flag:false},//滚动切换标签样式switchTab:function(e){this.setData({currentTab:e.detail.current});},//点击标题切换当前页时改变样式swichNav:function(e){varcur=e.target.dataset.current;if(this.data.currentTaB==cur){returnfalse;}else{this.setData({currentTab:cur})}},//展开当前其他排行榜toggleList:function(e){letid=e.target.dataset.id;if(id==='0'){this.setData({openMaleOther:!this.data.openMaleOther});}elseif(id==='1'){this.setData({openFemaleOther:!this.data.openFemaleOther});}},//获取一级分类及数目getCats:function(){api.rankInfo({url:"classUrl",id:"statistics"}).then(res=>{this.setData({majorList:res.data});});},//获取二级分类getMinor:function(){api.rankInfo({url:"classUrl"}).then(res=>{wx.hideLoading();wx.setStorage({key:'minor',data:res.data,})});},//获取排行getRankCategory:function(){api.rankInfo({url:"rankingUrl",id:"gender"}).then(res=>{wx.hideLoading();for(letkeyinres.data){//对于有别人家的排行榜的特殊处理将追书替换为轻读for(leti=0;i<res.data[key].length;i++){res.data[key][i].title=res.data[key][i].title.replace('追书','轻读');if(res.data[key][i].collapse){res.data[key].splice(i,0,{title:'别人家的排行榜',key:'isOther',collapse:true,cover:'../../img/otherIcon.png'});break;}}}this.setData({rankCategory:res.data});});},onLoad:function(){letthat=this;letnowTime=newDate().getTime();letcountTimes=newDate((api.formatTime("2020-05-22")+"23:00:00").replace(/-/g,'/')).getTime();if(nowTime<countTimes){this.setData({flag:true});wx.setNavigationBarTitle({title:'排行榜'})}if(this.data.flag){//正在热映api.rankInfo({url:'hotUrl',params:{start:0,count:10,city:''}}).then(datas=>{letdata=datas.data;lettype={title:data.title.split("-")[0],list:data.subjects,method:data.method}this.setData({'types[0]':type});}).catch(api.showError);//新片榜api.rankInfo({url:'newUrl',params:{start:0,count:10,}}).then(datas=>{letdata=datas.data;lettype={title:"新片榜",list:data.subjects,method:data.method}this.setData({'types[1]':type});}).catch(api.showError);}wx.showLoading({title:'加载中',mask:true})this.getCats();this.getMinor();this.getRankCategory();//高度自适应wx.getSystemInfo({success:(res)=>{varclientHeight=res.windowHeight,clientWidth=res.windowWidth,rpxR=750/clientWidth;varcalc=clientHeight*rpxR-80;this.setData({winHeight:calc});}});},//电影详情onDetail(e){wx.navigateTo({url:'/pages/detail/detail?id='+e.currentTarget.dataset.id})}})2.书架代码://index.js//获取应用实例constapi=require('../../utils/api.js');constapp=getApp().globalData;Page({data:{STATIC_HOST:'',userInfo:{},bookShelfData:[],hasUpdate:[],isEdit:false,flag:false},edit:function(){this.setData({isEdit:!this.data.isEdit});},delete:function(e){leti=e.target.dataset.id;this.data.bookShelfData.splice(i,1);wx.getStorage({key:'bookShelfData',success:function(res){res.data.splice(i,1);wx.setStorage({key:'bookShelfData',data:res.data,})},})this.setData({bookShelfData:this.data.bookShelfData});},getlasterChapter:function(){for(leti=0;i<this.data.bookShelfData.length;i++){api.rankInfo({url:"detailUrl",id:this.data.bookShelfData[i].bookInfo.id}).then(res=>{wx.hideLoading();//如果有更新就将最近更新的时间刷新进去,初次与加入书架时比较if(Date.parse(this.data.bookShelfData[i].bookInfo.laterChapter)+60*60*24<=Date.parse(res.data.updated)){this.data.bookShelfData[i].bookInfo.laterChapter=res.data.updated;wx.setStorage({key:'bookShelfData',data:this.data.bookShelfData,})this.data.hasUpdate[i]=1;this.setData({hasUpdate:this.data.hasUpdate});}});}wx.hideLoading();},getShelfInfo:function(){wx.getStorage({//获取书架信息key:'bookShelfData',success:res=>{this.setData({STATIC_HOST:api.STATIC_HOST,bookShelfData:res.data});for(leti=0;i<res.data.length;i++){this.data.hasUpdate.push(0);//用数组表示是否有更新,1有0无this.setData({hasUpdate:this.data.hasUpdate});}this.getlasterChapter();},fail:function(){wx.hideLoading();wx.setStorage({key:'bookShelfData',data:[],})}})},onLoad:function(){letthat=this;letnowTime=newDate().getTime();letcountTimes=newDate((api.formatTime("2020-05-22")+"23:00:00").replace(/-/g,'/')).getTime();if(nowTime<countTimes){this.setData({flag:true});wx.setNavigationBarTitle({title:'首页'})}if(this.data.flag){//正在热映api.rankInfo({url:'comingSoonUrl',params:{start:0,count:10,city:''}}).then(datas=>{letdata=datas.data;lettype={title:data.title.split("-")[0],list:data.subjects,method:data.method}this.setData({'types[0]':type});}).catch(api.showError);//top250api.rankInfo({url:'topUrl',params:{start:0,count:10,}}).then(datas=>{letdata=datas.data;lettype={title:"电影Top250",list:data.subjects,method:data.method}this.setData({'types[1]':type});}).catch(api.showError);}},onShow:function(){wx.showLoading({title:'加载中',mask:true});this.setData({hasUpdate:[]});if(1616635124000>Date.now()){app.configFlag=false}else{app.configFlag=true}this.setData({configFlag:app.configFlag});this.getShelfInfo();},//电影详情onDetail(e){wx.navigateTo({url:'/pages/detail/detail?id='+e.currentTarget.dataset.id})}})3.排名代码://pages/rank/rank.jsconstapi=require('../../utils/api.js');Page({/***页面的初始数据*/data:{STATIC_HOST:'',winHeight:"",//窗口高度currentTab:0,//预设当前项的值weekRank:[],monthRank:[],totalRank:[]},//滚动切换标签样式switchTab:function(e){this.setData({currentTab:e.detail.current});},//点击标题切换当前页时改变样式swichNav:function(e){varcur=e.target.dataset.current;if(this.data.currentTaB==cur){returnfalse;}else{this.setData({currentTab:cur})}},getRankList:function(ids){for(leti=0;i<ids.length;i++){if(i==0&&ids[i]!=='undefined'){//url:api.rank.rankInfo(ids[i]),api.rankInfo({url:"rankingUrl",id:ids[i]}).then(res=>{wx.setNavigationBarTitle({title:res.data.ranking.title,});this.setData({weekRank:res.data.ranking.books});wx.hideLoading();});}if(i==1&&ids[i]!=='undefined'){api.rankInfo({url:"rankingUrl",id:ids[i]}).then(res=>{this.setData({monthRank:res.data.ranking.books});});}if(i==2&&ids[i]!=='undefined'){api.rankInfo({url:"rankingUrl",id:ids[i]}).then(res=>{this.setData({totalRank:res.data.ranking.books});});}}},/***生命周期函数--监听页面加载*/onLoad:function(options){this.setData({STATIC_HOST:api.STATIC_HOST});wx.showLoading({title:'加载中',mask:true})letids=options.id.split('|');this.getRankList(ids);//高度自适应wx.getSystemInfo({success:(res)=>{varclientHeight=res.windowHeight,clientWidth=res.windowWidth,rpxR=750/clientWidth;varcalc=clientHeight*rpxR;this.setData({winHeight:calc});}});},/***生命周期函数--监听页面初次渲染完成*/onReady:function(){},/***生命周期函数--监听页面显示*/onShow:function(){},/***生命周期函数--监听页面隐藏*/onHide:function(){},/***生命周期函数--监听页面卸载*/onUnload:function(){},/***页面相关事件处理函数--监听用户下拉动作*/onPullDownRefresh:function(){},/***页面上拉触底事件的处理函数*/onReachBottom:function(){},/***用户点击右上角分享*/onShareAppMessage:function(){}})4.阅读器代码://pages/reader/reader.jsconstapi=require('../../utils/api.js')constWxParse=require('../wxParse/wxParse.js');Page({/***页面的初始数据*/data:{showPage:false,//请求到数据显示界面clientWidth:"",clientHeight:"",winHeight:"",//窗口高度book_id:'',scrollTop:0,bookSources:[],bookChapters:{},indexPage:0,//当前章节indexChapterContent:{},//当前阅读的内容readerCss:{titleSize:20,contentSize:16,color:'#333',//夜间#424952lineHeight:60,backgroundColor:'#fff'//#C7EDCC护眼色#080C10黑夜},showMenu:false,showChapter:false,isDark:false,isHuyan:false},toggleDark:function(){this.setData({isDark:!this.data.isDark});if(this.data.isDark){wx.setNavigationBarColor({frontColor:'#ffffff',backgroundColor:'#080C10'});this.data.readerCss.color='#696969';this.data.readerCss.backgroundColor='#080C10';this.setData({isHuyan:false,readerCss:this.data.readerCss});}else{wx.setNavigationBarColor({frontColor:'#ffffff',backgroundColor:'#cb1c36'});this.data.readerCss.color='#333';this.data.readerCss.backgroundColor='#fff';this.setData({isHuyan:false,readerCss:this.data.readerCss});}},toggleHuyan:function(){this.setData({isHuyan:!this.data.isHuyan});if(this.data.isHuyan){wx.setNavigationBarColor({frontColor:'#ffffff',backgroundColor:'#000000'});this.data.readerCss.color='#333';this.data.readerCss.backgroundColor='#C7EDCC';this.setData({isDark:false,readerCss:this.data.readerCss});}else{wx.setNavigationBarColor({frontColor:'#ffffff',backgroundColor:'#cb1c36'});this.data.readerCss.color='#333';this.data.readerCss.backgroundColor='#fff';this.setData({isDark:false,readerCss:this.data.readerCss});}},incSize:function(){if(this.data.readerCss.titleSize===30){return}this.data.readerCss.titleSize=this.data.readerCss.titleSize+5;this.data.readerCss.lineHeight=this.data.readerCss.lineHeight+10;this.data.readerCss.contentSize=this.data.readerCss.contentSize+5;this.setData({readerCss:this.data.readerCss});},decSize:function(){if(this.data.readerCss.titleSize===20){return}this.data.readerCss.titleSize=this.data.readerCss.titleSize-5;this.data.readerCss.contentSize=this.data.readerCss.contentSize-5;this.data.readerCss.lineHeight=this.data.readerCss.lineHeight-10;this.setData({readerCss:this.data.readerCss});},getBookSources:function(book_id){api.rankInfo({url:"atocUrl",params:{book:book_id,view:"summary"}}).then(res=>{this.setData({bookSources:res.data});this.getBookChapters(this.data.bookSources[0]._id);});},getBookSourcess:function(book_id){api.rankInfo({url:"pingccUrl",params:{xsurl1:book_id}}).then(res=>{this.setData({bookChapters:res.data});this.getChapterContents(res.data.list[0].url)});},getChapterContents:function(cid){wx.showLoading({title:'加载中',mask:true})api.rankInfo({url:"pingccUrl",params:{xsurl2:cid}}).then(res=>{wx.hideLoading();//存储当前读到哪一章wx.getStorage({key:'bookShelfData',success:res=>{letdata=res.data;for(leti=0;i<data.length;i++){if(this.data.book_id===data[i].bookInfo.url){data[i].readNum=this.data.indexPage+1;data[i].laterScrollTop=this.data.scrollTopwx.setStorage({key:'bookShelfData',data:data,})}}},});this.setData({showPage:true,showChapter:false,//关闭目录indexChapterContent:(res&&res.data)?res.data:{content:["请稍后重试"]}});//使用Wxparse格式化小说内容对收费的显示文字后期换接口处理//WxParse.wxParse('article','html',this.data.indexChapterContent.content?this.data.indexChapterContent.content:'小轻还没有给主人搬到此书,去看看别的吧',this);//等到渲染页面后调节scrollTopthis.setData({scrollTop:this.data.scrollTop})});},getBookChapters:function(source_id){api.rankInfo({url:"mixAtocUrl",id:source_id,params:{view:"chapters"}}).then(res=>{//console.log(res.data)this.setData({bookChapters:res.data});this.getChapterContent(this.data.bookChapters.chapters[this.data.indexPage].link);});},getChapterContent:function(link){wx.showLoading({title:'加载中',mask:true})api.rankInfo({url:"chapterUrl",id:encodeURIComponent(link)}).then(res=>{wx.hideLoading();//if(res.data.chapter.cpContent){//letbodyArray=res.data.chapter.cpContent.split(/\n/).map((item)=>{//给每个段落加开头空格,方案改为修改wxParse.wxss//returnitem//});//res.data.chapter.cpContent=bodyArray.join('<br>');//}//letbodyArray=res.data.chapter.body.split(/\n/).map((item)=>{//returnitem//});//res.data.chapter.body=bodyArray.join('<br>');this.setData({showPage:true,showChapter:false,//关闭目录indexChapterContent:res.data});//存储当前读到哪一章wx.getStorage({key:'bookShelfData',success:res=>{letdata=res.data;for(leti=0;i<data.length;i++){if(this.data.book_id===data[i].bookInfo.id){data[i].readNum=this.data.indexPage+1;data[i].laterScrollTop=this.data.scrollTopwx.setStorage({key:'bookShelfData',data:data,})}}},});//使用Wxparse格式化小说内容对收费的显示文字后期换接口处理//WxParse.wxParse('article','html',this.data.indexChapterContent.chapter.cpContent?'小轻还没有给主人搬到此书,去看看别的吧':this.data.indexChapterContent.chapter.body,this);//等到渲染页面后调节scrollTopthis.setData({scrollTop:this.data.scrollTop})});},goPrev:function(){if(this.data.indexPage===0){wx.showToast({title:'已到第一章',icon:'loading',mask:true});}wx.showLoading({title:'加载中',mask:true})this.setData({indexPage:this.data.index1,scrollTop:0});if(this.data.bookChapters.chapters&&this.data.bookChapters.chapters[this.data.indexPage]&&!this.data.flag){this.getChapterContent(this.data.bookChapters.chapters[this.data.indexPage].link);}else{this.getChapterContents(this.data.bookChapters.list[this.data.indexPage].url);}},goNext:function(){if((this.data.bookChapters.chapters&&(this.data.indexPage===this.data.bookChapters.chapters.length-1))||(this.data.bookChapters.list&&(this.data.indexPage===this.data.bookChapters.list.length-1))){//当前在最后一章wx.showToast({title:'已到最新章节',icon:'loading',mask:true});return;}wx.showLoading({title:'加载中',mask:true})this.setData({indexPage:this.data.indexPage+1,scrollTop:0});if(this.data.bookChapters.chapters&&this.data.bookChapters.chapters[this.data.indexPage]&&!this.data.flag){this.getChapterContent(this.data.bookChapters.chapters[this.data.indexPage].link);}else{this.getChapterContents(this.data.bookChapters.list[this.data.indexPage].url);}},//点击中央打开菜单openMenu:function(event){letxMid=this.data.clientWidth/2;letyMid=this.data.clientHeight/2;letx=event.detail.x;lety=event.detail.y;if((x>xMid-100&&x<xMid+100)&&(y<yMid+100&&y>yMid-100)){this.setData({showMenu:!this.data.showMenu});}},getScrollTop:function(event){//设置读取到文章的具体什么位置//this.setData({//scrollTop:event.detail.scrollTop//});//存储读到章节的什么位置wx.getStorage({key:'bookShelfData',success:res=>{letdata=res.data;for(leti=0;i<data.length;i++){if(this.data.book_id===data[i].bookInfo.id){data[i].laterScrollTop=event.detail.scrollTop;wx.setStorage({key:'bookShelfData',data:data,})}}},});},showChapter:function(){this.setData({showChapter:!this.data.showChapter});},pickChapter:function(event){this.setData({indexPage:event.target.dataset.indexpage,scrollTop:0});if(!this.data.flag){this.getChapterContent(event.target.dataset.link);}else{this.getChapterContents(event.target.dataset.cid);}},/***生命周期函数--监听页面加载*/onLoad:function(options){this.setData({book_id:options.book_id,flag:options.flag});letbookShelfData=wx.getStorageSync('bookShelfData');//利用缓存实现阅读记录和书架if(bookShelfData.length!==0){for(leti=0;i<bookShelfData.length;i++){if(options.flag){if(bookShelfData[i].bookInfo.url===options.book_id){this.setData({//上次读到哪indexPage:bookShelfData[i].readNum-1,scrollTop:bookShelfData[i].laterScrollTop});break;}}else{if(bookShelfData[i].bookInfo.id===options.book_id){this.setData({//上次读到哪indexPage:bookShelfData[i].readNum-1,scrollTop:bookShelfData[i].laterScrollTop});break;}}}}wx.setNavigationBarTitle({//设置标题title:options.book_title,});wx.getSystemInfo({success:(res)=>{varclientHeight=res.windowHeight,clientWidth=res.windowWidth,rpxR=750/clientWidth;varcalc=clientHeight*rpxR;this.setData({clientHeight:clientHeight,clientWidth:clientWidth,winHeight:calc});}});wx.getStorage({key:'isAlerted',success:(res)=>{letdata=res.data;if(!data){wx.showModal({title:'提示',content:'点击呼出菜单',success:(res)=>{if(res.confirm){wx.setStorage({key:'isAlerted',value:true});}}});}}});setTimeout(()=>{wx.hideLoading();if(options.flag){this.getBookSourcess(options.book_id);}else{this.getBookSources(options.book_id);}},2000);}});5.搜索代码://pages/search/search.jsconstapi=require('../../utils/api.js')Page({/***页面的初始数据*/data:{winHeight:"",//窗口高度STATIC_HOST:'',scrollTop:0,hotWords:[],showHotWords:[],//随机显示六个热词hotWordBackgoundColor:['#FFC0CB','#7B68EE','#FF69B4','#66CDAA','#FA8072','#228B22'],showSearchContent:false,searchValue:'',searchRes:{},historyWords:[]},getHotWords:function(){api.rankInfo({url:"searchUrl"}).then(res=>{this.setData({hotWords:res.data.searchHotWords});this.randomHotWord();});},randomHotWord:function
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 无纸化考试题库试题带答案
- 技能基础介绍课件
- 体验式旅游的智慧景区运营策略与实践
- 2026年花艺师高级资格考试理论知识模拟试卷及答案(共十三套)
- 2026湖南益阳市第一中医医院招聘备案制人员14人考试参考题库及答案解析
- 2026年职工食堂工作总结范文2篇
- 宜宾市三中屏山县岷江实验中学校体育临聘教师招聘(1人)笔试备考试题及答案解析
- 2026南昌市东湖区墩子塘街道办事处招聘基层就业专岗1人笔试备考题库与答案解析
- 2026年南平科特派教育服务有限公司面向残疾人自主招聘1人笔试模拟试题及答案解析
- 2026浙江金华市消防救援支队招录消防车驾驶员18人考试参考题库及答案解析
- 小区门口保安合同协议书7篇
- 抖音直播运营中心薪酬绩效考核实施管理方案
- 2026年学生入团考试题库及参考答案
- 2027届河南省部分城市联考高三上学期11月阶段检测历史试题(含答案)
- 2026年宁夏水务投资集团有限公司招聘笔试参考题库附带答案详解析版
- 2026秋北师大版选择性必修第一册Unit 1-3 句子语法填空练习(备考期中)
- 智能体电脑行业王伟东白皮书
- 秦皇岛市建设现代有轨电车项目调研报告
- 2026秋新教材苏教版五年级上册数学第七单元 用字母表示数量关系(一) 教案(共7课时)
- 《中药炮制技术》教案-13模块十三 其他炮制技术
- 2026年辅警笔试的题库及答案
评论
0/150
提交评论