history.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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?'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.getArtCatTop()
  47. },
  48. methods:{
  49. MessageTimeFormat,
  50. changeTab(item){
  51. this.artCatId=item.artCatId
  52. this.conditions={
  53. page: 1,
  54. limit: 10
  55. }
  56. this.getArtByPage()
  57. },
  58. getArtCatTop(){
  59. getArtCatTop().then((res)=>{
  60. this.tabs=res.data
  61. if(res.data.length>0){
  62. this.artCatId=res.data[0].artCatId
  63. this.getArtByPage()
  64. }
  65. })
  66. },
  67. getArtByPage(){
  68. let items=JSON.parse(JSON.stringify(this.artList))
  69. getArtByPage({
  70. ...this.conditions,
  71. artCatId:this.artCatId
  72. }).then((res)=>{
  73. this.artList=items.concat(res.data)
  74. this.total=res.total
  75. })
  76. },
  77. showDetail(){
  78. let baseUrl="http://h5.xazhyc.com"
  79. uni.navigateTo({
  80. url:`/pages/webview/webview?href=${baseUrl}/art/views/detail.html&artId=473700&name=通讯录`
  81. })
  82. }
  83. },
  84. onReachBottom() {
  85. if(this.total>=this.conditions.page*this.conditions.limit){
  86. this.conditions.page++
  87. this.getArtByPage()
  88. }
  89. },
  90. onPullDownRefresh() {
  91. this.getArtCatTop()
  92. uni.stopPullDownRefresh()
  93. }
  94. }
  95. </script>
  96. <style lang="scss" scoped>
  97. .art-wrap{
  98. padding: 24rpx;
  99. background-color: #f2f2f2;
  100. .tabs{
  101. overflow-x: auto;
  102. overflow-y: hidden;
  103. display: flex;
  104. background-color: #fff;
  105. border-radius: 16rpx;
  106. .tab{
  107. height: 88rpx;
  108. line-height: 88rpx;
  109. display: inline-block;
  110. padding: 0 32rpx;
  111. flex: 1 0 auto;
  112. font-size: 28rpx;
  113. color: #35364F;
  114. position: relative;
  115. &::after{
  116. display: block;
  117. width: 50%;
  118. border-bottom: 2px solid transparent;
  119. position: absolute;
  120. bottom: 0;
  121. left: 50%;
  122. transform: translateX(-50%);
  123. content: "";
  124. }
  125. &.active{
  126. font-size: 34rpx;
  127. font-weight: 700;
  128. &::after{
  129. border-bottom: 2px solid #15CD85;
  130. }
  131. }
  132. }
  133. }
  134. .tab-container{
  135. background-color: #f2f2f2;
  136. .item{
  137. margin-top: 20rpx;
  138. .card{
  139. background: #FFFFFF;
  140. border-radius: 10rpx;
  141. padding: 24rpx;
  142. .top{
  143. display: flex;
  144. justify-content: space-between;
  145. align-items: center;
  146. padding-bottom: 20rpx;
  147. .lf{
  148. flex: 1;
  149. display: flex;
  150. align-items: center;
  151. .tag{
  152. font-size: 20rpx;
  153. display: inline-block;
  154. padding:4rpx 6rpx;
  155. border: 1px solid #15CD85;
  156. line-height: 1;
  157. color: #15CD85;
  158. border-radius: 4rpx;
  159. }
  160. .author{
  161. display: inline-block;
  162. padding-left: 5px;
  163. line-height: 1;
  164. color: #666;
  165. }
  166. }
  167. }
  168. .info{
  169. font-size: 24rpx;
  170. font-weight: 500;
  171. color: #B0B0B0;
  172. line-height:1;
  173. padding-top: 0.22rem;
  174. .title{
  175. font-size:32rpx;
  176. font-family: PingFang SC;
  177. font-weight: bold;
  178. color: #000000;
  179. line-height:48rpx;
  180. text-overflow: ellipsis;
  181. overflow: hidden;
  182. -webkit-line-clamp: 2;
  183. display: -webkit-box;
  184. -webkit-box-orient: vertical;
  185. }
  186. .footer{
  187. display: flex;
  188. justify-content: space-between;
  189. align-items: center;
  190. padding-top: 10rpx;
  191. }
  192. }
  193. }
  194. }
  195. }
  196. }
  197. </style>