list.js 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. ImageUrl:app.globalData.serverUrl,
  7. },
  8. onLoad: function (options) {
  9. let that = this;
  10. that.setData({
  11. Title:options.Title,
  12. Containnerheight: main.getWindowHeight(),
  13. });
  14. wx.setNavigationBarTitle({
  15. title: options.Title,
  16. });
  17. main.getData('GetReaderBooksChapter?UserID=' + app.globalData.userInfo.UserID+"&Title="+options.Title, function (data) {
  18. if (data) {
  19. let arr=[];
  20. for(let i=0;i<data.length;i++){
  21. let obj={};
  22. obj.CSS="";
  23. obj.Chapter=data[i];
  24. arr.push(obj);
  25. }
  26. that.setData({
  27. List:arr,
  28. });
  29. that.enterSchedule();
  30. }
  31. });
  32. },
  33. enterSchedule:function(){
  34. let that=this;
  35. let schedule=wx.getStorageSync('Schedule_'+this.data.Title);
  36. if (schedule){
  37. let list=this.data.List;
  38. for(let i=0;i<list.length;i++){
  39. if (list[i].Chapter==schedule.Chapter){
  40. list[i].CSS="highlight";
  41. break;
  42. }
  43. }
  44. that.setData({
  45. List:list,
  46. });
  47. let url="article?Title="+that.data.Title+"&Chapter="+schedule.Chapter;
  48. that.goto({currentTarget:{dataset:{url:url}}});
  49. }
  50. },
  51. goto: function (e) {
  52. let that=this;
  53. var url=e.currentTarget.dataset.url;
  54. wx.navigateTo({
  55. url: url,
  56. });
  57. },
  58. onShareAppMessage: function () {
  59. return {
  60. title: app.globalData.ShareTitle,
  61. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  62. imageUrl: app.globalData.ShareImage,
  63. }
  64. },
  65. })