list.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <view class="container">
  3. <view v-if="list.length > 0" class="list-box flex_item" v-for="(ls,index) in list" :key='index' @click="nav(index)">
  4. <image :src="baseURL + ls.coverimage"></image>
  5. <view class="list-item">
  6. <view class="title ellipsis">{{ls.title}}</view>
  7. <view class="time">{{ls.time}}</view>
  8. </view>
  9. </view>
  10. <!-- <view class="empty-box" v-show="list.length === 0"><u-empty></u-empty></view> -->
  11. </view>
  12. </template>
  13. <script>
  14. import { article } from '@/api/index.js';
  15. import { mapState, mapMutations } from 'vuex';
  16. import { getTime } from '@/utils/rocessor.js';
  17. export default {
  18. data() {
  19. return {
  20. list:''
  21. };
  22. },
  23. onLoad(option){
  24. uni.setNavigationBarTitle({
  25. title:this.$t('foo.tglb')
  26. })
  27. this.loadData();
  28. },
  29. onShow() {
  30. },
  31. computed: {
  32. ...mapState(['baseURL']),
  33. ...mapState('user', ['userInfo', 'orderInfo', 'hasLogin'])
  34. },
  35. methods: {
  36. // 请求载入数据
  37. async loadData() {
  38. let obj = this;
  39. article({
  40. page:1,
  41. limit:10000,
  42. category_id: 14
  43. }).then(({ data }) => {
  44. console.log(data)
  45. data.list.forEach(e =>{
  46. console.log(e)
  47. e.time = getTime(e.updatetime)
  48. })
  49. obj.list = data.list;
  50. });
  51. },
  52. nav(index){
  53. uni.navigateTo({
  54. url: '/pages/index/article?id=' + this.list[index].id
  55. })
  56. },
  57. }
  58. };
  59. </script>
  60. <style lang="scss">
  61. page {
  62. min-height: 100%;
  63. .container {
  64. width: 100%;
  65. padding: 25rpx 27rpx;
  66. }
  67. }
  68. .empty-box{
  69. margin-top: 100rpx;
  70. width: 100%;
  71. height: 500rpx;
  72. }
  73. .list-box{
  74. border-bottom: 1rpx solid #E3E3E3;
  75. margin-bottom: 25rpx;
  76. padding-bottom: 25rpx;
  77. image{
  78. width: 200rpx;
  79. height: 160rpx;
  80. border-radius: 15rpx;
  81. }
  82. .list-item{
  83. padding-left: 16rpx;
  84. width: 80%;
  85. .title{
  86. height: 80rpx;
  87. color: #FFFFFF;
  88. font-size: 30rpx;
  89. font-weight: 500;
  90. }
  91. .time{
  92. padding-top: 40rpx;
  93. color: #999999;
  94. font-size: 24rpx;
  95. }
  96. }
  97. }
  98. </style>