myarticles.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. app.globalData.UnReadCount=0;
  46. for(let i=0;i<data.length;i++){
  47. let item=data[i];
  48. item.WordsStr=item.Words.split(",").join(" ");
  49. that.data.List.push(item);
  50. if (item.ReadCount==0){
  51. app.globalData.UnReadCount++;
  52. }
  53. }
  54. let isShowMore=true;
  55. if (that.data.List[0].RowsCount==that.data.List.length)
  56. isShowMore=false;
  57. that.setData({
  58. List:that.data.List,
  59. IsShowMore:isShowMore,
  60. });
  61. }
  62. });
  63. },
  64. getMore:function(e){
  65. this.getData(this.data.UserID,this.data.List[this.data.List.length-1].ID);
  66. },
  67. goto: function (e) {
  68. let that=this;
  69. if (e.currentTarget.dataset.readcount===0){
  70. that.setData({
  71. IsNew:1,
  72. });
  73. }
  74. else{
  75. that.setData({
  76. IsNew:0,
  77. });
  78. }
  79. var url=e.currentTarget.dataset.url;
  80. wx.navigateTo({
  81. url: url,
  82. });
  83. },
  84. setClipboard:function(e){
  85. let words=e.currentTarget.dataset.words;
  86. app.globalData.SelectedWords=words.split(",");
  87. wx.redirectTo({
  88. url: 'wordsinput',
  89. })
  90. },
  91. deleteArticle:function(e){
  92. let that=this;
  93. that.setData({
  94. ID:e.currentTarget.dataset.id,
  95. });
  96. animation.toggleRemindWithAnimation(this, {
  97. hideColor: 'rgba(0,0,0,0)',
  98. showColor: 'rgba(277,277,277,0.5)',
  99. panelAnimationKey: 'panelAnimation', // 控制内容面板的动画
  100. animationKey: 'parentAnimation' // 控制父容器的动画(如果需要)
  101. });
  102. },
  103. showRemind:function(e){
  104. let that=this;
  105. const confirm=e.currentTarget.dataset.confirm;
  106. animation.toggleRemindWithAnimation(this, {
  107. hideColor: 'rgba(0,0,0,0)',
  108. showColor: 'rgba(277,277,277,0.5)'
  109. });
  110. if (confirm=="1") {
  111. main.getData('DeleteYJBDCArticleList?UserID=' + that.data.UserID+"&ID="+that.data.ID, function (data) {
  112. wx.showToast({
  113. title: '删除完成',
  114. });
  115. that.setData({
  116. IsNew:1,
  117. });
  118. for(let i=0;i<that.data.List.length;i++){
  119. if (that.data.List[i].ID==that.data.ID){
  120. that.data.List.splice(i,1);
  121. break;
  122. }
  123. }
  124. that.setData({
  125. List:that.data.List,
  126. });
  127. });
  128. }
  129. },
  130. setGotoID:function(e){
  131. let that=this;
  132. if (app.globalData.userInfo.UserID<4 || app.globalData.userInfo.UserID==11){
  133. wx.showModal({
  134. title: '输入用户ID,获得生成的文章',
  135. content: '',
  136. editable:true,
  137. complete: (res) => {
  138. if (res.confirm) {
  139. if (res.content){
  140. that.setData({
  141. UserID:res.content,
  142. });
  143. that.getData(res.content);
  144. }
  145. }
  146. else{
  147. that.setData({
  148. IsShowID:!that.data.IsShowID,
  149. });
  150. }
  151. }
  152. })
  153. }
  154. },
  155. onShareAppMessage: function () {
  156. return {
  157. title: app.globalData.ShareTitle,
  158. path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
  159. imageUrl: app.globalData.ShareImage,
  160. }
  161. },
  162. })