notice.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <template>
  2. <view class="container">
  3. <view v-if="noticeList.length == 0" class="no-data">——暂无数据——</view>
  4. <view class="listBox" v-else v-for="item,index in noticeList" :key="index" @click="notice(item)">
  5. <view class="listTpl">
  6. <view class="name">{{item.title}}</view>
  7. <view class="time">{{item.add_time}}</view>
  8. </view>
  9. </view>
  10. </view>
  11. </template>
  12. <script>
  13. import { getArtList} from '@/api/notice.js';
  14. export default {
  15. data() {
  16. return {
  17. noticeList:[]
  18. };
  19. },
  20. onLoad() {
  21. this.loadData()
  22. },
  23. methods: {
  24. //获取公告列表数据
  25. async loadData() {
  26. let obj = this;
  27. getArtList('1').then(function(e) {
  28. obj.noticeList = e.data
  29. console.log(obj.noticeList,'obj.noticeList');
  30. })
  31. },
  32. //公告详情
  33. notice(item){
  34. let id = item.id;
  35. uni.navigateTo({
  36. url: `/pages/index/noticeDetails?id=${id}`
  37. });
  38. }
  39. }
  40. };
  41. </script>
  42. <style lang="scss">
  43. .container{
  44. width: 100%;
  45. color: #FFFFFF;
  46. background-color: #051137;
  47. }
  48. .listBox{
  49. background-color: #1F2A4A;
  50. .listTpl{
  51. border-bottom: 1rpx solid #919295;
  52. padding: 25rpx 25rpx;
  53. .name{
  54. font-size: 28rpx;
  55. color: #FFFFFF;
  56. }
  57. .time{
  58. font-size: 22rpx;
  59. color: #999999;
  60. padding-top: 15rpx;
  61. }
  62. }
  63. }
  64. .no-data{
  65. color:#A2A5B8;
  66. font-size: 26rpx;
  67. padding: 25rpx 0rpx;
  68. width: 100%;
  69. text-align: center;
  70. background-color: #051137;
  71. }
  72. </style>