IndexArticle.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. <template>
  2. <view class="div index-article">
  3. <flex-line class="article-wrapper" :show-border="true">
  4. <view class="div wrapper">
  5. <text class="em title"><text class="span" style="color:#000">最新</text>资讯</text>
  6. <view class="ul scroll-content" :style="top" >
  7. <view class="li" v-for="(item, index) in items" :key="index" @click="goArticleDetail(item)">
  8. {{item.article_title}}
  9. </view>
  10. </view>
  11. </view>
  12. <view slot="right" class="div more common-btn" @click="goHomeArticlelist('1')">点击查看</view>
  13. </flex-line>
  14. </view>
  15. </template>
  16. <script>
  17. import { urlencode } from '@/util/common'
  18. import flexLine from '../../flexLine'
  19. export default {
  20. name: 'IndexArticle',
  21. data () {
  22. return {
  23. activeIndex: 0
  24. }
  25. },
  26. components:{
  27. flexLine
  28. },
  29. props: ['items'],
  30. computed: {
  31. top () {
  32. return 'top:'+ (-this.activeIndex * 2) + 'rem'
  33. }
  34. },
  35. beforeDestroy: function () {
  36. clearInterval(this.time_interval)
  37. },
  38. mounted () {
  39. let _this = this
  40. this.time_interval = setInterval(function () {
  41. if (_this.activeIndex < (_this.items.length-1)) {
  42. _this.activeIndex += 1
  43. } else {
  44. _this.activeIndex = 0
  45. }
  46. }, 2000)
  47. },
  48. methods: {
  49. goHomeArticlelist (acId) {
  50. uni.navigateTo({ url: '/pages/home/article/Articlelist'+'?'+urlencode( { ac_id: acId } )})
  51. },
  52. goArticleDetail (item) {
  53. uni.navigateTo({ url: '/pages/home/article/Articledetail'+'?'+urlencode( { 'article_id': item.article_id } )})
  54. }
  55. }
  56. }
  57. </script>
  58. <style scoped lang="scss">
  59. .index-article{
  60. background:#fff;
  61. padding-bottom:$modelSpace;
  62. .article-wrapper{
  63. .wrapper{
  64. height: 2rem;
  65. line-height:2rem;
  66. overflow: hidden;
  67. display:flex;
  68. align-items: center;
  69. margin-left:$pageSpace;
  70. }
  71. }
  72. }
  73. .title{text-align:center;font-size:$mainFontSize;font-weight:700;color:$primaryColor;padding:0 0.5rem;}
  74. .more{background: $primaryGradualColor;color: #fff;box-shadow: 0px 2px 4px #ffd5d7;margin-right:$pageSpace;}
  75. .scroll-content{
  76. align-self:flex-start;
  77. flex:1;
  78. position: relative;
  79. transition: top 0.5s;
  80. .li{
  81. line-height: 2rem;
  82. text-align: left;
  83. font-size:$fontSize;
  84. color:$descTextColor;
  85. font-weight: normal;
  86. }
  87. }
  88. </style>