myarticles.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. import common from '../../utils/util';
  2. import main from '../../utils/main';
  3. import animation from '../../utils/animation';
  4. const app = getApp();
  5. Page({
  6. data: {
  7. IsShowRemind:false,
  8. IsNew:0,
  9. },
  10. onLoad: function (options) {
  11. let that = this;
  12. that.setData({
  13. Containnerheight: main.getWindowHeight(),
  14. });
  15. main.checkGenerating();
  16. that.getData(app.globalData.userInfo.UserID);
  17. },
  18. onShow:function(e){
  19. let that=this;
  20. if (that.data.IsNew){
  21. setTimeout(function(){
  22. that.getData(app.globalData.userInfo.UserID);
  23. },1000);
  24. }
  25. },
  26. getData:function(userID){
  27. wx.showLoading({
  28. title: '请稍候',
  29. });
  30. let that=this;
  31. let url='GetYJBDCArticleList?UserID=' + userID;
  32. //debugger;
  33. if (that.data.IsNew==1)
  34. url+="&IsNew=1";
  35. console.log(url);
  36. main.getData(url, function (data) {
  37. wx.hideLoading();
  38. if (data) {
  39. for(let i=0;i<data.length;i++){
  40. let item=data[i];
  41. item.WordsStr=item.Words.split(",").join(" ");
  42. }
  43. that.setData({
  44. List:data,
  45. });
  46. }
  47. });
  48. },
  49. goto: function (e) {
  50. let that=this;
  51. if (e.currentTarget.dataset.readcount===0){
  52. that.setData({
  53. IsNew:1,
  54. });
  55. }
  56. else{
  57. that.setData({
  58. IsNew:0,
  59. });
  60. }
  61. var url=e.currentTarget.dataset.url;
  62. wx.navigateTo({
  63. url: url,
  64. });
  65. },
  66. setClipboard:function(e){
  67. let words=e.currentTarget.dataset.words;
  68. app.globalData.SelectedWords=words.split(",");
  69. wx.redirectTo({
  70. url: 'wordsinput',
  71. })
  72. },
  73. deleteArticle:function(e){
  74. animation.toggleRemindWithAnimation(this);
  75. this.setData({
  76. ID:e.currentTarget.dataset.id
  77. });
  78. },
  79. showRemind:function(e){
  80. let that=this;
  81. const confirm=e.currentTarget.dataset.confirm;
  82. animation.toggleRemindWithAnimation(this);
  83. if (confirm=="1") {
  84. main.getData('DeleteYJBDCArticleList?UserID=' + app.globalData.userInfo.UserID+"&ID="+that.data.ID, function (data) {
  85. wx.showToast({
  86. title: '删除完成',
  87. });
  88. that.setData({
  89. IsNew:1,
  90. });
  91. that.getData(app.globalData.userInfo.UserID);
  92. });
  93. }
  94. },
  95. setGotoID:function(e){
  96. let that=this;
  97. if (app.globalData.userInfo.UserID<4){
  98. wx.showModal({
  99. title: '输入用户ID,获得生成的文章',
  100. content: '',
  101. editable:true,
  102. complete: (res) => {
  103. if (res.confirm) {
  104. if (res.content)
  105. that.getData(res.content);
  106. }
  107. }
  108. })
  109. }
  110. },
  111. onShareAppMessage: function () {
  112. return {
  113. title: app.globalData.ShareTitle,
  114. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  115. imageUrl: app.globalData.ShareImage,
  116. }
  117. },
  118. })