article.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <template>
  2. <view>
  3. <scroll-view scroll-x class="bg-white nav text-center solid-bottom echo-fixed-top">
  4. <view class="cu-item" :class="item.id==cateid?'text-blue cur':''" v-for="(item, index) in allcate" :key="item.id" @tap="tabSelect" :data-id="item.id">
  5. {{item.title}}
  6. </view>
  7. </scroll-view>
  8. <view class="echo-fixed-top-empty"></view>
  9. <block v-for="(item,index) in plist" :key="index">
  10. <view class="cu-card article no-card solid-bottom">
  11. <view class="cu-item shadow" @tap="goDetail(item.atype, item.id, item.tilurl)">
  12. <view class="title"><view class="text-cut">{{item.title}}</view></view>
  13. <view class="content">
  14. <image :src="item.tilpic" mode="aspectFill"></image>
  15. <view class="desc">
  16. <view class="text-content">{{item.summary}}</view>
  17. <view class="flex justify-between">
  18. <view class="text-sm text-gray">{{item.createtime_text}}</view>
  19. <view class="text-sm text-gray text-right" v-if="item.atype==1">
  20. <text class="cuIcon-attentionfill margin-lr-xs"></text> {{item.volume}}
  21. <text class="cuIcon-appreciatefill margin-lr-xs"></text> {{item.article_thumb_count}}
  22. <text class="cuIcon-messagefill margin-lr-xs"></text> {{item.article_comment_count}}
  23. </view>
  24. <view class="text-sm text-gray text-right" v-else>
  25. <text class="cuIcon-attentionfill margin-lr-xs"></text> {{item.volume}}
  26. <text class="cuIcon-discoverfill margin-lr-xs"></text> 链接
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </block>
  34. <uni-load-more :status="pstatus"></uni-load-more>
  35. </view>
  36. </template>
  37. <script>
  38. import uniLoadMore from "@/components/uni-load-more/uni-load-more.vue";
  39. var _this;
  40. export default {
  41. components: {
  42. uniLoadMore
  43. },
  44. data() {
  45. return {
  46. cateid: 0,
  47. allcate: [],
  48. pstatus: 'more',
  49. ppage: 1,
  50. psize: 20,
  51. plist: []
  52. };
  53. },
  54. onLoad: function(option){
  55. _this = this;
  56. _this.cateid = option.cateid || 0;
  57. _this.$req.ajax({
  58. path: "article/allcate"
  59. }).then((data) => {
  60. _this.allcate = data.allcate;
  61. _this.getMore();
  62. }).catch((err) => {
  63. uni.showModal({
  64. title: '信息提示',
  65. content: err,
  66. showCancel: false
  67. });
  68. });
  69. },
  70. onShareAppMessage: function(res) {
  71. return {
  72. title: "文章资讯",
  73. path: "/pages/article/article?cateid="+_this.cateid
  74. }
  75. },
  76. onPullDownRefresh: function() {
  77. _this.ppage = 1;
  78. _this.pstatus = 'more';
  79. _this.plist = [];
  80. _this.getMore();
  81. },
  82. onReachBottom: function() {
  83. if (_this.pstatus !== 'more') {
  84. return;
  85. }
  86. _this.getMore();
  87. },
  88. methods: {
  89. tabSelect: function(e) {
  90. _this.cateid = e.currentTarget.dataset.id;
  91. _this.pageRefresh();
  92. },
  93. pageRefresh: function() {
  94. _this.pstatus = 'more';
  95. _this.ppage = 1;
  96. _this.plist = [];
  97. _this.getMore();
  98. },
  99. getMore: function() {
  100. _this.$req.ajax({
  101. path: "article/listarticle",
  102. data: {
  103. ppage: _this.ppage,
  104. psize: _this.psize,
  105. cateid: _this.cateid
  106. }
  107. }).then((data) => {
  108. _this.pstatus = data.pstatus;
  109. _this.plist = _this.plist.concat(data.plist);
  110. _this.ppage += 1;
  111. uni.stopPullDownRefresh();
  112. }).catch((err) => {
  113. uni.showModal({
  114. title: '信息提示',
  115. content: err,
  116. showCancel: false
  117. });
  118. });
  119. },
  120. goDetail: function(atype, articleid, tilurl) {
  121. if (atype==1){
  122. uni.navigateTo({
  123. url: '/pages/article/detail?articleid=' + articleid
  124. });
  125. }else{
  126. _this.$req.ajax({
  127. path: "article/getarticle",
  128. data: {
  129. articleid: articleid
  130. }
  131. }).then((data) => {
  132. if (atype==2) {
  133. uni.navigateTo({
  134. url: tilurl
  135. });
  136. } else{
  137. // #ifdef H5
  138. location.href = tilurl;
  139. // #endif
  140. // #ifndef H5
  141. uni.navigateTo({
  142. url: '/pages/tool/webview?pagesrc=' + encodeURIComponent(tilurl)
  143. });
  144. // #endif
  145. }
  146. }).catch((err) => {
  147. uni.showModal({
  148. title: '信息提示',
  149. content: err,
  150. showCancel: false
  151. });
  152. });
  153. }
  154. }
  155. }
  156. }
  157. </script>
  158. <style>
  159. </style>