list.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <template>
  2. <view>
  3. <block v-if="datainfo.length>0">
  4. <!-- 新闻 -->
  5. <block v-if="type=='article'">
  6. <view class="newlist" v-for="(ite,idx) in datainfo" :key="idx" @click="getDetail(ite.newsId)">
  7. <view class="over tit">{{ite.newsTitle}}</view>
  8. <view class="txt overtwo mb10" v-if="ite.newsContent"><rich-text :nodes="filterImages(ite.newsContent)"></rich-text></view>
  9. <view class="nfoot flexc">
  10. <image :src="look"></image>
  11. <text>{{ite.viewsNum}}</text>
  12. <view class="flex1"></view>
  13. <text>{{ite.releaseTime||KaTime(ite.createTime)}}</text>
  14. </view>
  15. </view>
  16. </block>
  17. <!-- 视频 -->
  18. <block v-if="type=='avideo'">
  19. <view class="newlist" v-for="(ite,idx) in datainfo" :key="idx">
  20. <video v-if="ite.newUrl[0]" id="myVideo" :src="baseUrl+ite.newUrl[0]" controls></video>
  21. <view class="tit">{{ite.newsTitle}}</view>
  22. <view class="nfoot flexc">
  23. <image :src="look"></image>
  24. <text>{{ite.viewsNum}}</text>
  25. <view class="flex1"></view>
  26. <text>{{ite.releaseTime||KaTime(ite.createTime)}}</text>
  27. </view>
  28. </view>
  29. </block>
  30. <view class="shax" v-if="wtdt">{{wtdt}}</view>
  31. </block>
  32. <!-- 无数据 -->
  33. <view class="nodata" v-else>
  34. <image :src="noiconpimg"></image>
  35. <view>暂无数据</view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  41. import config from '@/config'
  42. export default{
  43. props:{
  44. datainfo: {
  45. type: Array,
  46. default () {
  47. return []
  48. }
  49. },
  50. wtdt:{
  51. type:String,
  52. default () {
  53. return ''
  54. }
  55. },
  56. type:{
  57. type:String,
  58. default () {
  59. return 0
  60. }
  61. },
  62. },
  63. data(){
  64. return{
  65. noiconpimg:require("@/static/images/nodata.png"),
  66. look:require("@/static/images/home/look.png"),
  67. baseUrl:config.baseUrl,
  68. }
  69. },
  70. mounted() {
  71. },
  72. methods:{
  73. checkPermi, checkRole,
  74. getDetail(e){
  75. this.$emit('getDetail',e)
  76. },
  77. // 过滤掉图片
  78. filterImages(html) {
  79. if (!html) return '';
  80. return html.replace(/<img[^>]*>/gi, '');
  81. },
  82. KaTime(val){
  83. if(val){
  84. return val.substring(0,10)
  85. }
  86. }
  87. }
  88. }
  89. </script>
  90. <style lang="scss" scoped>
  91. // 新闻
  92. .newlist{width: 100%;background: #FFFFFF;border-radius: 20rpx;margin-bottom: 20rpx;padding: 20rpx 26rpx;
  93. .tit{font-weight: bold;font-size: 30rpx;color: #161A1E;margin-bottom: 16rpx;}
  94. .txt{font-weight: 500;font-size: 24rpx;color: #666666;}
  95. .nfoot{
  96. image{width: 24rpx;height: 16rpx;margin-right: 10rpx;}
  97. text{font-weight: 500;font-size:24rpx;color: #949695;}
  98. }
  99. video{width: 100%;height: 342rpx;margin-bottom: 16rpx;}
  100. }
  101. // 无数据
  102. .nodata{display: flex;flex-direction: column;align-items: center;padding-top: 48rpx;
  103. image{width: 336rpx;height: 284rpx;margin-bottom: 26rpx;}
  104. view{font-size: 24rpx;color: #666666;font-weight: 500;}
  105. }
  106. </style>