history.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  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.conditions={
  92. page: 1,
  93. limit: 10
  94. }
  95. this.getArtCatTop()
  96. uni.stopPullDownRefresh()
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. .art-wrap{
  102. padding: 24rpx;
  103. background-color: #f2f2f2;
  104. .tabs{
  105. overflow-x: auto;
  106. overflow-y: hidden;
  107. display: flex;
  108. background-color: #fff;
  109. border-radius: 16rpx;
  110. .tab{
  111. height: 88rpx;
  112. line-height: 88rpx;
  113. display: inline-block;
  114. padding: 0 32rpx;
  115. flex: 1 0 auto;
  116. font-size: 28rpx;
  117. color: #35364F;
  118. position: relative;
  119. text-align: center;
  120. &::after{
  121. display: block;
  122. width: 50%;
  123. border-bottom: 2px solid transparent;
  124. position: absolute;
  125. bottom: 0;
  126. left: 50%;
  127. transform: translateX(-50%);
  128. content: "";
  129. }
  130. &.active{
  131. font-size: 34rpx;
  132. font-weight: 700;
  133. &::after{
  134. border-bottom: 2px solid #15CD85;
  135. }
  136. }
  137. }
  138. }
  139. .tab-container{
  140. background-color: #f2f2f2;
  141. .item{
  142. margin-top: 20rpx;
  143. .card{
  144. background: #FFFFFF;
  145. border-radius: 10rpx;
  146. padding: 24rpx;
  147. .top{
  148. display: flex;
  149. justify-content: space-between;
  150. align-items: center;
  151. padding-bottom: 20rpx;
  152. .lf{
  153. flex: 1;
  154. display: flex;
  155. align-items: center;
  156. .tag{
  157. font-size: 20rpx;
  158. display: inline-block;
  159. padding:4rpx 6rpx;
  160. border: 1px solid #15CD85;
  161. line-height: 1;
  162. color: #15CD85;
  163. border-radius: 4rpx;
  164. }
  165. .author{
  166. display: inline-block;
  167. padding-left: 5px;
  168. line-height: 1;
  169. color: #666;
  170. }
  171. }
  172. }
  173. .info{
  174. font-size: 24rpx;
  175. font-weight: 500;
  176. color: #B0B0B0;
  177. line-height:1;
  178. padding-top: 0.22rem;
  179. .title{
  180. font-size:32rpx;
  181. font-family: PingFang SC;
  182. font-weight: bold;
  183. color: #000000;
  184. line-height:48rpx;
  185. text-overflow: ellipsis;
  186. overflow: hidden;
  187. -webkit-line-clamp: 2;
  188. display: -webkit-box;
  189. -webkit-box-orient: vertical;
  190. }
  191. .footer{
  192. display: flex;
  193. justify-content: space-between;
  194. align-items: center;
  195. padding-top: 10rpx;
  196. }
  197. }
  198. }
  199. }
  200. }
  201. }
  202. </style>