history.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view class="art-wrap">
  3. <view class="tabs">
  4. <view class="tab" v-for="(tab,index) in tabs" :key="index" @click="changeTab(tab)" :class="(tab.artCatId===artCatId)&&(tabs.length>1)?'active':''">{{tab.artCatTitle}}</view>
  5. </view>
  6. <view class="tab-container">
  7. <view class="item" v-for="(item,idx) in artList" :key="idx">
  8. <view class="content card" @click="showDetail(item)">
  9. <view class="top">
  10. <view class="lf">
  11. <view class="tag">{{item.artCatTitle}}</view>
  12. <view class="author" v-if="item.editorName">{{item.editorName}}</view>
  13. </view>
  14. <view class="rt"><span>{{MessageTimeFormat(item.issuedAt)}}</span></view>
  15. </view>
  16. <view class="info">
  17. <view class="title" v-if="item.artTitle">{{item.artTitle}}</view>
  18. <view class="footer">
  19. <view class="author">{{item.artAuthor?item.artAuthor:'未知'}}</view>
  20. <view class="time">{{item.issuedAt}}</view>
  21. </view>
  22. </view>
  23. </view>
  24. </view>
  25. </view>
  26. </view>
  27. </template>
  28. <script>
  29. import {getToken} from '@/libs/auth.js';
  30. import {MessageTimeFormat} from '@/libs/index.js';
  31. import {getArtCatTop,getArtByPage} from '@/api/system/art.js'
  32. export default {
  33. data() {
  34. return {
  35. artCatId:"",
  36. tabs:[],
  37. artList:[],
  38. conditions: {
  39. page: 1,
  40. limit: 10
  41. },
  42. total:0
  43. }
  44. },
  45. onShow() {
  46. this.conditions={
  47. page: 1,
  48. limit: 10
  49. }
  50. this.artList=[]
  51. this.getArtCatTop()
  52. },
  53. methods:{
  54. MessageTimeFormat,
  55. changeTab(item){
  56. this.artCatId=item.artCatId
  57. this.conditions={
  58. page: 1,
  59. limit: 10
  60. }
  61. this.artList=[]
  62. this.getArtByPage()
  63. },
  64. getArtCatTop(){
  65. getArtCatTop().then((res)=>{
  66. this.tabs=res.data
  67. if(res.data.length>0){
  68. this.artCatId=res.data[0].artCatId
  69. this.getArtByPage()
  70. }
  71. })
  72. },
  73. getArtByPage(){
  74. let items=JSON.parse(JSON.stringify(this.artList))
  75. getArtByPage({
  76. ...this.conditions,
  77. artCatId:this.artCatId
  78. }).then((res)=>{
  79. this.artList=items.concat(res.data)
  80. this.total=res.total
  81. })
  82. },
  83. showDetail(item){
  84. let baseUrl=this.$h5
  85. uni.navigateTo({
  86. url:`/pages/webview/webview?href=${baseUrl}/art/views/detail.html&artId=${item.artId}&name=${item.artCatTitle}`
  87. })
  88. }
  89. },
  90. onReachBottom() {
  91. if(this.total>=this.conditions.page*this.conditions.limit){
  92. this.conditions.page++
  93. this.getArtByPage()
  94. }
  95. },
  96. onPullDownRefresh() {
  97. this.conditions={
  98. page: 1,
  99. limit: 10
  100. }
  101. this.artList=[]
  102. this.getArtCatTop()
  103. uni.stopPullDownRefresh()
  104. }
  105. }
  106. </script>
  107. <style lang="scss" scoped>
  108. .art-wrap{
  109. padding: 24rpx;
  110. background-color: #f2f2f2;
  111. .tabs{
  112. overflow-x: auto;
  113. overflow-y: hidden;
  114. display: flex;
  115. background-color: #fff;
  116. border-radius: 16rpx;
  117. .tab{
  118. height: 88rpx;
  119. line-height: 88rpx;
  120. display: inline-block;
  121. padding: 0 32rpx;
  122. flex: 1 0 auto;
  123. font-size: 28rpx;
  124. color: #35364F;
  125. position: relative;
  126. text-align: center;
  127. &::after{
  128. display: block;
  129. width: 50%;
  130. border-bottom: 2px solid transparent;
  131. position: absolute;
  132. bottom: 0;
  133. left: 50%;
  134. transform: translateX(-50%);
  135. content: "";
  136. }
  137. &.active{
  138. font-size: 34rpx;
  139. font-weight: 700;
  140. &::after{
  141. border-bottom: 2px solid #15CD85;
  142. }
  143. }
  144. }
  145. }
  146. .tab-container{
  147. background-color: #f2f2f2;
  148. .item{
  149. margin-top: 20rpx;
  150. .card{
  151. background: #FFFFFF;
  152. border-radius: 10rpx;
  153. padding: 24rpx;
  154. .top{
  155. display: flex;
  156. justify-content: space-between;
  157. align-items: center;
  158. padding-bottom: 20rpx;
  159. .lf{
  160. flex: 1;
  161. display: flex;
  162. align-items: center;
  163. .tag{
  164. font-size: 20rpx;
  165. display: inline-block;
  166. padding:4rpx 6rpx;
  167. border: 1px solid #15CD85;
  168. line-height: 1;
  169. color: #15CD85;
  170. border-radius: 4rpx;
  171. }
  172. .author{
  173. display: inline-block;
  174. padding-left: 5px;
  175. line-height: 1;
  176. color: #666;
  177. }
  178. }
  179. }
  180. .info{
  181. font-size: 24rpx;
  182. font-weight: 500;
  183. color: #B0B0B0;
  184. line-height:1;
  185. padding-top: 0.22rem;
  186. .title{
  187. font-size:32rpx;
  188. font-family: PingFang SC;
  189. font-weight: bold;
  190. color: #000000;
  191. line-height:48rpx;
  192. text-overflow: ellipsis;
  193. overflow: hidden;
  194. -webkit-line-clamp: 2;
  195. display: -webkit-box;
  196. -webkit-box-orient: vertical;
  197. }
  198. .footer{
  199. display: flex;
  200. justify-content: space-between;
  201. align-items: center;
  202. padding-top: 10rpx;
  203. }
  204. }
  205. }
  206. }
  207. }
  208. }
  209. </style>