article-list.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view class="article-wrapper">
  3. <view class="search-sort">
  4. <view class="sort">
  5. <view class="drop-btn" @click="dropFlag = !dropFlag">
  6. <text class="text" v-text="showDropText"></text>
  7. <text class="iconfont" :class="dropFlag ? 'icon-xiangshang' : 'icon-xiangxia'"></text>
  8. </view>
  9. <view class="drop-select" v-show="dropFlag">
  10. <template v-for="(item, index) in dropItems">
  11. <view
  12. class="drop-select-item"
  13. :class="{ active: index === dropCurrent }"
  14. :key="index"
  15. v-text="item.name"
  16. @click="onDropItemClick(index, item)"
  17. ></view>
  18. </template>
  19. </view>
  20. </view>
  21. </view>
  22. <view class="article-list">
  23. <view class="article-item" v-for="item in list" :key="item.articleId" @click="onToDetail(item)">
  24. <view class="cover"><image :src="item.image"></image></view>
  25. <view class="content">
  26. <view class="title" v-text="item.title"></view>
  27. <view class="description" v-text="item.intro"></view>
  28. <view class="tag">
  29. <text class="iconfont icon-biaoqian1"></text>
  30. <text v-text="item.labelText"></text>
  31. </view>
  32. <view class="info">
  33. <view class="item author">
  34. <text class="iconfont icon-bianji2"></text>
  35. <text v-text="item.publisher"></text>
  36. </view>
  37. <view class="item view">
  38. <text class="iconfont icon-liulan"></text>
  39. <text v-text="item.pv"></text>
  40. </view>
  41. <view class="item date">
  42. <text class="iconfont icon-shijian2"></text>
  43. <text>{{ item.publishDate | dateFormat }}</text>
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="mask" v-show="dropFlag" @click="dropFlag = false"></view>
  50. </view>
  51. </template>
  52. <script>
  53. import { debounce } from '@/common/config/common'
  54. const myDebounce = fn => debounce(fn, 200, false)
  55. export default {
  56. props: {
  57. list: {
  58. type: Array,
  59. default: () => []
  60. }
  61. },
  62. data() {
  63. return {
  64. dropItems: [{ name: '综合排序', status: 1 }, { name: '时间排序', status: 2 }],
  65. dropFlag: false,
  66. dropCurrent: 0
  67. }
  68. },
  69. computed: {
  70. showDropText() {
  71. return this.dropItems[this.dropCurrent].name
  72. }
  73. },
  74. created() {
  75. console.log('article-list')
  76. },
  77. methods: {
  78. onDropItemClick(index, dropItems) {
  79. this.dropCurrent = index
  80. this.dropFlag = false
  81. this.$emit('change', dropItems)
  82. },
  83. onToDetail: myDebounce(function(item) {
  84. let URL_CONFIG = ''
  85. if (process.env.NODE_ENV === 'development') {
  86. URL_CONFIG = 'http://zzjtest.gz.aeert.com'
  87. } else {
  88. URL_CONFIG = 'https://www.caimei365.com/'
  89. }
  90. const link = `${URL_CONFIG}/info/detail-${item.articleId}-1.html`
  91. this.$api.navigateTo(`/pages/h5/activity/activity?link=${link}&title=${item.title}`)
  92. })
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. /* scss中可以用mixin来扩展 */
  98. @mixin ellipsis($line: 1) {
  99. overflow: hidden;
  100. text-overflow: ellipsis;
  101. display: -webkit-box;
  102. -webkit-line-clamp: $line;
  103. -webkit-box-orient: vertical;
  104. }
  105. .article-wrapper {
  106. .mask {
  107. position: fixed;
  108. width: 100%;
  109. height: 100%;
  110. min-height: 100vh;
  111. background: transparent;
  112. z-index: 9;
  113. left: 0;
  114. top: 0;
  115. }
  116. .search-sort {
  117. padding: 0 32rpx;
  118. height: 90rpx;
  119. .sort {
  120. position: relative;
  121. z-index: 10;
  122. .drop-btn {
  123. display: flex;
  124. align-items: center;
  125. .text {
  126. font-size: 28rpx;
  127. color: #333;
  128. font-weight: 500;
  129. line-height: 90rpx;
  130. }
  131. .iconfont {
  132. font-size: 14rpx;
  133. color: #333;
  134. margin-left: 20rpx;
  135. line-height: 90rpx;
  136. }
  137. }
  138. .drop-select {
  139. position: absolute;
  140. background: #fff;
  141. width: 340rpx;
  142. left: 0;
  143. top: 90rpx;
  144. box-shadow: 0px 6rpx 16rpx 1rpx rgba(0, 0, 0, 0.1);
  145. .drop-select-item {
  146. position: relative;
  147. line-height: 90rpx;
  148. height: 90rpx;
  149. padding-left: 88rpx;
  150. font-size: 28rpx;
  151. color: #22272e;
  152. &:first-child {
  153. border-bottom: 1rpx solid #e1e1e1;
  154. }
  155. &.active {
  156. color: #F3B574;
  157. &::before {
  158. background: #F3B574;
  159. border-color: #F3B574;
  160. }
  161. }
  162. &::before,
  163. &::after {
  164. content: '';
  165. display: block;
  166. position: absolute;
  167. border-radius: 50%;
  168. background: #fff;
  169. box-sizing: border-box;
  170. }
  171. &::before {
  172. width: 32rpx;
  173. height: 32rpx;
  174. left: 40rpx;
  175. top: 29rpx;
  176. border: 1rpx solid #999999;
  177. }
  178. &::after {
  179. width: 14rpx;
  180. height: 14rpx;
  181. left: 49rpx;
  182. top: 38rpx;
  183. }
  184. }
  185. }
  186. }
  187. }
  188. .article-item {
  189. display: flex;
  190. padding: 32rpx;
  191. border-top: 1rpx solid #e1e1e1;
  192. .cover {
  193. width: 220rpx;
  194. height: 220rpx;
  195. flex-shrink: 0;
  196. image {
  197. display: block;
  198. width: 100%;
  199. height: 100%;
  200. }
  201. }
  202. .content {
  203. flex: 1;
  204. margin-left: 24rpx;
  205. .title {
  206. @include ellipsis(2);
  207. font-size: 28rpx;
  208. color: #22272e;
  209. line-height: 36rpx;
  210. height: 72rpx;
  211. }
  212. .description {
  213. @include ellipsis(1);
  214. font-size: 22rpx;
  215. color: #666;
  216. height: 28rpx;
  217. margin-top: 8rpx;
  218. }
  219. .tag {
  220. font-size: 24rpx;
  221. color: #999999;
  222. height: 28rpx;
  223. margin-top: 34rpx;
  224. @include ellipsis(1);
  225. .iconfont {
  226. font-size: 24rpx;
  227. margin-right: 8rpx;
  228. }
  229. }
  230. .info {
  231. display: flex;
  232. height: 28rpx;
  233. margin-top: 16rpx;
  234. .item {
  235. color: #999999;
  236. font-size: 22rpx;
  237. margin-right: 32rpx;
  238. &.date {
  239. margin-right: 0;
  240. }
  241. .iconfont {
  242. font-size: 24rpx;
  243. margin-right: 8rpx;
  244. }
  245. }
  246. }
  247. }
  248. }
  249. }
  250. </style>