list-item.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <div v-if="itemData" class="item-container" @click="handleToPage(itemData.info_id)">
  3. <div class="item-title">{{itemData.title}}</div>
  4. <div class="item-pic-wrap" v-if="itemData.img_list.length > 1 ">
  5. <div class="item-pic-item" v-for="(url, idx) in itemData.img_list" :key="idx">
  6. <div class="pic-item" v-if="idx < 3">
  7. <img mode="widthFix" :src="!!url ? url : defImage " alt="" >
  8. </div>
  9. </div>
  10. </div>
  11. <div class="item-media">
  12. <span class="media-name">{{itemData.media_info.media_name}}</span>
  13. <span class="media-tip" @click="todrawEvent"></span>
  14. </div>
  15. </div>
  16. </template>
  17. <script>
  18. export default {
  19. props: ['itemData'],
  20. data () {
  21. return {
  22. defImage: '/static/images/grey.gif'
  23. }
  24. },
  25. methods: {
  26. todrawEvent () {
  27. wx.navigateTo({
  28. url: '/pages/banner/main'
  29. })
  30. },
  31. handleToPage (infoId) {
  32. let goldCoins = wx.getStorageSync('userInfo').gold_coins
  33. if (goldCoins < 10) {
  34. wx.showToast({
  35. title: `很遗憾, 阅读至少需要10金币`,
  36. icon: 'none',
  37. duration: 2000
  38. })
  39. } else {
  40. wx.navigateTo({
  41. url: `/pages/detail/main?info_id=${infoId}`
  42. })
  43. }
  44. }
  45. }
  46. }
  47. </script>
  48. <style lang="scss" scoped>
  49. .item-container {
  50. &:last-child {
  51. margin-bottom: 60px;
  52. }
  53. border-bottom: 1px solid #ebebeb;
  54. padding: 10px 0;
  55. margin: 0 15px;
  56. display: flex;
  57. flex-direction: column;
  58. align-items: flex-start;
  59. justify-content: space-around;
  60. .item-title {
  61. font-size: 18px;
  62. color: #222;
  63. }
  64. .item-pic-wrap {
  65. width: 100%;
  66. display: flex;
  67. flex-wrap: wrap;
  68. align-items: center;
  69. justify-content: space-between;
  70. .item-pic-item {
  71. display: inline-block;
  72. width: 32%;
  73. .pic-item {
  74. margin-top: 10px;
  75. max-height: 80px;
  76. overflow: hidden;
  77. img {
  78. border: none;
  79. width: 100%;
  80. height: 100%
  81. }
  82. }
  83. }
  84. }
  85. .item-media {
  86. width: 100%;
  87. display: flex;
  88. align-items: center;
  89. justify-content: space-between;
  90. font-size: 14px;
  91. margin-bottom: -5px;
  92. .media-name {
  93. color: #9b9b9b;
  94. visibility: hidden;
  95. }
  96. .media-tip {
  97. color: #fccf85;
  98. }
  99. }
  100. }
  101. </style>