myarticles.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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. IsShowID:false,
  10. IsShowMore:true,
  11. },
  12. onLoad: function (options) {
  13. let that = this;
  14. that.setData({
  15. Containnerheight: main.getWindowHeight(),
  16. UserID:app.globalData.userInfo.UserID,
  17. });
  18. main.checkGenerating();
  19. that.getData(that.data.UserID);
  20. },
  21. onShow:function(e){
  22. let that=this;
  23. if (that.data.IsNew){
  24. setTimeout(function(){
  25. that.getData(that.data.UserID);
  26. },1000);
  27. }
  28. },
  29. getData:function(userID,pageID){
  30. wx.showLoading({
  31. title: '请稍候',
  32. });
  33. let that=this;
  34. let url='GetYJBDCArticleList?UserID=' + userID;
  35. if (pageID)
  36. url+="&PageID="+pageID;
  37. if (that.data.IsNew==1)
  38. url+="&IsNew=1";
  39. console.log(url);
  40. main.getData(url, function (data) {
  41. wx.hideLoading();
  42. if (data) {
  43. if (!pageID)
  44. that.data.List=[];
  45. for(let i=0;i<data.length;i++){
  46. let item=data[i];
  47. item.WordsStr=item.Words.split(",").join(" ");
  48. that.data.List.push(item);
  49. }
  50. let isShowMore=true;
  51. if (that.data.List[0].RowsCount==that.data.List.length)
  52. isShowMore=false;
  53. that.setData({
  54. List:that.data.List,
  55. IsShowMore:isShowMore,
  56. });
  57. }
  58. });
  59. },
  60. getMore:function(e){
  61. this.getData(this.data.UserID,this.data.List[this.data.List.length-1].ID);
  62. },
  63. goto: function (e) {
  64. let that=this;
  65. if (e.currentTarget.dataset.readcount===0){
  66. that.setData({
  67. IsNew:1,
  68. });
  69. }
  70. else{
  71. that.setData({
  72. IsNew:0,
  73. });
  74. }
  75. var url=e.currentTarget.dataset.url;
  76. wx.navigateTo({
  77. url: url,
  78. });
  79. },
  80. setClipboard:function(e){
  81. let words=e.currentTarget.dataset.words;
  82. app.globalData.SelectedWords=words.split(",");
  83. wx.redirectTo({
  84. url: 'wordsinput',
  85. })
  86. },
  87. deleteArticle:function(e){
  88. animation.toggleRemindWithAnimation(this);
  89. this.setData({
  90. ID:e.currentTarget.dataset.id
  91. });
  92. },
  93. showRemind:function(e){
  94. let that=this;
  95. const confirm=e.currentTarget.dataset.confirm;
  96. animation.toggleRemindWithAnimation(this);
  97. if (confirm=="1") {
  98. main.getData('DeleteYJBDCArticleList?UserID=' + that.data.UserID+"&ID="+that.data.ID, function (data) {
  99. wx.showToast({
  100. title: '删除完成',
  101. });
  102. that.setData({
  103. IsNew:1,
  104. });
  105. for(let i=0;i<that.data.List.length;i++){
  106. if (that.data.List[i].ID==that.data.ID){
  107. that.data.List.splice(i,1);
  108. break;
  109. }
  110. }
  111. that.setData({
  112. List:that.data.List,
  113. });
  114. });
  115. }
  116. },
  117. setGotoID:function(e){
  118. let that=this;
  119. if (app.globalData.userInfo.UserID<4 || app.globalData.userInfo.UserID==11){
  120. wx.showModal({
  121. title: '输入用户ID,获得生成的文章',
  122. content: '',
  123. editable:true,
  124. complete: (res) => {
  125. if (res.confirm) {
  126. if (res.content){
  127. that.setData({
  128. UserID:res.content,
  129. });
  130. that.getData(res.content);
  131. }
  132. }
  133. else{
  134. that.setData({
  135. IsShowID:!that.data.IsShowID,
  136. });
  137. }
  138. }
  139. })
  140. }
  141. },
  142. onShareAppMessage: function () {
  143. return {
  144. title: app.globalData.ShareTitle,
  145. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  146. imageUrl: app.globalData.ShareImage,
  147. }
  148. },
  149. })