article-list.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <template>
  2. <app-layout>
  3. <view style="height: 100%;background-color: #f7f7f7;position: absolute;width: 100%">
  4. <view class='article-list' v-for="item in list" :key="item.id">
  5. <app-form-id @click="toDetail(item.id)">
  6. <view class='article-item main-between'>
  7. <text class="t-omit" style="width: 90%">{{item.title}}</text>
  8. <image class='enter' src='/static/image/icon/arrow-right.png'></image>
  9. </view>
  10. </app-form-id>
  11. </view>
  12. </view>
  13. </app-layout>
  14. </template>
  15. <script>
  16. import { mapState } from "vuex";
  17. export default {
  18. data() {
  19. return {
  20. page: 2,
  21. list: []
  22. }
  23. },
  24. computed: {
  25. ...mapState({
  26. theme: state => state.mallConfig.theme,
  27. title: state => state.mallConfig.bar_title
  28. })
  29. },
  30. methods: {
  31. getList() {
  32. let that = this;
  33. that.$showLoading({
  34. text: '加载中...'
  35. });
  36. this.$request({
  37. url: that.$api.article.list,
  38. method: 'get',
  39. }).then(response=>{
  40. that.$hideLoading();
  41. if(response.code == 0) {
  42. this.list = response.data.list;
  43. }
  44. }).catch(e => {
  45. that.$hideLoading();
  46. });
  47. },
  48. getMore() {
  49. let that = this;
  50. uni.showLoading({
  51. title: '加载中...'
  52. });
  53. that.$request({
  54. url: that.$api.article.list,
  55. data: {
  56. page: that.page
  57. },
  58. }).then(response=>{
  59. uni.hideLoading();
  60. if(response.code == 0) {
  61. if(response.data.list.length > 0) {
  62. that.list.concat(response.data.list);
  63. that.page++;
  64. }
  65. }
  66. }).catch(e => {
  67. uni.hideLoading();
  68. });
  69. },
  70. toDetail(id) {
  71. uni.navigateTo({
  72. url: '/pages/article/article-detail/article-detail?id=' + id
  73. });
  74. }
  75. },
  76. onLoad() {
  77. this.getList();
  78. },
  79. onReachBottom() {
  80. this.getMore();
  81. },
  82. onShareAppMessage: function() {
  83. let that = this;
  84. for(let i in that.title) {
  85. if(that.title[i].name == '文章中心') {
  86. return that.$shareAppMessage({
  87. title: that.title[i].new_name,
  88. path: "/pages/article/article-list/article-list",
  89. });
  90. }
  91. }
  92. },
  93. }
  94. </script>
  95. <style scoped lang="scss">
  96. .article-item {
  97. height: #{100rpx};
  98. line-height: #{100rpx};
  99. background-color: #fff;
  100. border-bottom: #{1rpx} solid #e2e2e2;
  101. padding: 0 #{30rpx};
  102. }
  103. .enter {
  104. margin-top: #{39rpx};
  105. width: #{12rpx};
  106. height: #{22rpx};
  107. }
  108. </style>