articlecategory.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. const app = getApp();
  4. Page({
  5. data: {
  6. ImageUrl:app.globalData.uploadImageUrl,
  7. },
  8. onLoad: function (options) {
  9. let that = this;
  10. that.setData({
  11. Containnerheight: main.getWindowHeight(),
  12. });
  13. wx.setNavigationBarTitle({
  14. title: options.title,
  15. });
  16. that.init(options);
  17. main.checkGenerating();
  18. },
  19. init:function(options){
  20. let that = this;
  21. let list=wx.getStorageSync('ChoicenessList');
  22. let arr=[];
  23. let levelArr=[];
  24. for(let i=0;i<list.length;i++){
  25. if ((options.level && options.level.indexOf(list[i].LevelStr)>=0)
  26. || (options.articlestyle && options.articlestyle==list[i].ArticleStyle)){
  27. list[i].Words=list[i].Words.split(",").join(" ");
  28. list[i].IsShow=1;
  29. arr.push(list[i]);
  30. let b=false;
  31. //debugger;
  32. for(let j=0;j<levelArr.length;j++){
  33. if (levelArr[j].Name==list[i].LevelStr){
  34. b=true;
  35. break;
  36. }
  37. }
  38. if (!b){
  39. let obj={};
  40. obj.Name=list[i].LevelStr;
  41. obj.CSS="";
  42. levelArr.push(obj);
  43. }
  44. }
  45. }
  46. levelArr=common.sort(levelArr,"ASC","Name","String");
  47. levelArr.unshift({Name:"LATEST",CSS:"Selected",CSS2:"btn0"});
  48. //debugger;
  49. that.setData({
  50. List:arr,
  51. Level:levelArr,
  52. });
  53. },
  54. filter:function(e){
  55. let that = this;
  56. let level=e.currentTarget.dataset.name;
  57. let list=that.data.List;
  58. for(let i=0;i<list.length;i++){
  59. list[i].IsShow=0;
  60. if (level==list[i].LevelStr || level=="LATEST"){
  61. list[i].IsShow=1;
  62. }
  63. }
  64. let list2=that.data.Level;
  65. for(let i=0;i<list2.length;i++){
  66. list2[i].CSS="";
  67. if (level==list2[i].Name){
  68. list2[i].CSS="Selected";
  69. }
  70. }
  71. that.setData({
  72. List:list,
  73. Level:list2,
  74. });
  75. },
  76. goto: function (e) {
  77. let that=this;
  78. var url=e.currentTarget.dataset.url;
  79. wx.navigateTo({
  80. url: url,
  81. });
  82. },
  83. onShareAppMessage: function () {
  84. return {
  85. title: app.globalData.ShareTitle,
  86. path: app.globalData.SharePath + '?goto=articlefine&UserID=' + app.globalData.userInfo.UserID,
  87. }
  88. },
  89. })