You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

168 lines
3.4 KiB

3 years ago
  1. <template>
  2. <view class="app">
  3. <mescroll-body
  4. ref="mescrollRef"
  5. @init="mescrollInit"
  6. :top="0"
  7. @down="downCallback"
  8. :up="upOption"
  9. @up="loadList"
  10. >
  11. <view class="notice-item" v-for="(item, index) in list" :key="index">
  12. <text class="time">{{ item.add_time | friendDate }}</text>
  13. <view class="content">
  14. <text class="title">{{ item.name }}</text>
  15. <view v-if="item.image" class="img-wrapper">
  16. <image class="pic" :src="item.image" mode="aspectFill"></image>
  17. </view>
  18. <view class="introduce-wrap" :class="{'has-pic': item.image}">
  19. <text class="introduce">{{ item.content }}</text>
  20. </view>
  21. <view class="bot b-t" @click="navToDetai(item)">
  22. <text>查看详情</text>
  23. <text class="mix-icon icon-you"></text>
  24. </view>
  25. </view>
  26. </view>
  27. </mescroll-body>
  28. <mix-loading v-if="isLoading" :type="2"></mix-loading>
  29. </view>
  30. </template>
  31. <script>
  32. import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
  33. export default {
  34. mixins: [MescrollMixin],
  35. data() {
  36. return {
  37. list: [],
  38. upOption:{
  39. auto: false, // 是否自动加载
  40. page: {
  41. num: 0, // 当前页码,默认0,回调之前会加1,即callback(page)会从1开始
  42. size: 10 // 每页数据的数量
  43. },
  44. noMoreSize: 6
  45. },
  46. }
  47. },
  48. methods: {
  49. //加载列表
  50. async loadList(e){
  51. const res = await this.$request('notice', 'getList', {
  52. offset: (e.num - 1) * e.size,
  53. limit: e.size,
  54. });
  55. const curList = res.data;
  56. if(e.num === 1){
  57. this.list = [];
  58. }
  59. this.list = this.list.concat(curList); //追加新数据
  60. this.mescroll.endSuccess(curList.length); //结束加载状态
  61. this.log(curList)
  62. },
  63. navToDetai(item){
  64. this.navTo('/pages/public/article?param=' + JSON.stringify({
  65. module: 'notice',
  66. operation: 'getDetail',
  67. data: {
  68. id: item._id
  69. }
  70. }))
  71. },
  72. mescrollInit(mescroll){
  73. this.isLoading = true;
  74. this.mescroll = mescroll;
  75. this.mescroll.resetUpScroll(false)
  76. }
  77. }
  78. }
  79. </script>
  80. <style>
  81. page{
  82. background-color: #f7f7f7;
  83. }
  84. </style>
  85. <style lang='scss'>
  86. .app {
  87. padding-bottom: 30rpx;
  88. }
  89. .notice-item {
  90. display: flex;
  91. flex-direction: column;
  92. align-items: center;
  93. }
  94. .time {
  95. display: flex;
  96. align-items: center;
  97. justify-content: center;
  98. height: 80rpx;
  99. padding-top: 10rpx;
  100. font-size: 26rpx;
  101. color: #7d7d7d;
  102. }
  103. .content {
  104. width: 710rpx;
  105. padding: 0 24rpx;
  106. background-color: #fff;
  107. border-radius: 12rpx;
  108. }
  109. .title {
  110. display: flex;
  111. align-items: center;
  112. height: 90rpx;
  113. font-size: 32rpx;
  114. color: #303133;
  115. font-weight: 700;
  116. }
  117. .img-wrapper {
  118. width: 100%;
  119. height: 280rpx;
  120. margin-bottom: 16rpx;
  121. position: relative;
  122. }
  123. .pic {
  124. display: block;
  125. width: 100%;
  126. height: 100%;
  127. border-radius: 6rpx;
  128. }
  129. .introduce-wrap{
  130. padding-bottom: 20rpx;
  131. .introduce {
  132. font-size: 28rpx;
  133. color: #606266;
  134. line-height: 40rpx;
  135. display: -webkit-box;
  136. -webkit-box-orient: vertical;
  137. -webkit-line-clamp: 3;
  138. overflow: hidden;
  139. }
  140. &.has-pic .introduce{
  141. -webkit-line-clamp: 2;
  142. }
  143. }
  144. .bot {
  145. display: flex;
  146. align-items: center;
  147. justify-content: space-between;
  148. height: 80rpx;
  149. font-size: 24rpx;
  150. color: #707070;
  151. position: relative;
  152. }
  153. .icon-you {
  154. font-size: 24rpx;
  155. }
  156. </style>