book.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <template>
  2. <view class="main">
  3. <view class="indexswiper" style="margin-top: 10rpx;">
  4. <swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" style="height: 250rpx;">
  5. <swiper-item v-for="(item,index) in configInfo" :key="index">
  6. <view class="swiper-item">
  7. <image :src="item.image" mode="widthFix"></image>
  8. </view>
  9. </swiper-item>
  10. </swiper>
  11. </view>
  12. <view class="tltleStyle">
  13. 推荐文章
  14. </view>
  15. <u-card :show-head="false" :show-foot="false" margin="0" :border="false">
  16. <view class="" slot="body" v-for="(item,index) in list" :key="index" @click="bookinfo(item.id,item.title)">
  17. <view class="u-border-bottom padding-bottom-sm">
  18. <view class="u-body-item u-flex u-col-between u-p-t-0 justify-between">
  19. <view class="u-body-item-title u-line-2">{{item.title}}</view>
  20. <u-image :src="imghost+item.banner_url" width="120" height="120" style="margin-left: 12rpx;"></u-image>
  21. </view>
  22. <u-tag :text="item.type==1?'健康科普':item.type==2?'疫苗科普':'常见问题'" size="mini" shape="circle" mode="dark" type="info" />
  23. </view>
  24. </view>
  25. </u-card>
  26. <view class="margin-tb padding-tb-xs">
  27. <u-loadmore :status="nomore" :icon-type="flower" />
  28. </view>
  29. <u-no-network></u-no-network>
  30. </view>
  31. </template>
  32. <script>
  33. var user = require('../../common/user.js');
  34. export default {
  35. onLoad(options) {
  36. this.imghost = this.$imgHost
  37. this.pageindex = 1
  38. this.list = []
  39. this.getbook()
  40. },
  41. onShow() {
  42. this.ismaxbook = true
  43. this.getconfigLsit()
  44. },
  45. mounted() {
  46. },
  47. data() {
  48. return {
  49. list: [],
  50. configInfo: {},
  51. pageindex: 1,
  52. imghost: "",
  53. ismaxbook: true
  54. }
  55. },
  56. onReachBottom() {
  57. this.getbook()
  58. },
  59. methods: {
  60. getbook: async function() {
  61. if (this.ismaxbook) {
  62. let res = await this.$request.post("/api/v1/article/articleList", {
  63. page: this.pageindex
  64. }, false)
  65. let status = user.islogin(res)
  66. if (status) {
  67. if (this.pageindex > res.data.last_page) {
  68. uni.showToast({
  69. title: "没有更多了",
  70. icon: "none"
  71. })
  72. this.ismaxbook = false
  73. return false
  74. } else {
  75. this.list = this.list.concat(res.data.data)
  76. this.pageindex++
  77. }
  78. }
  79. }
  80. },
  81. bookinfo(id, title) {
  82. uni.navigateTo({
  83. url: "../common_tools/collection/collection_details?id=" + id + "&title=" + title
  84. })
  85. },
  86. getconfigLsit: async function() {
  87. let res = await this.$request.post("/api/v1/common/icons", {
  88. type: 2
  89. }, false)
  90. if (res.status == 200) {
  91. this.configInfo = res.data
  92. }
  93. }
  94. }
  95. };
  96. </script>
  97. <style scoped lang="scss">
  98. .main {
  99. padding-top: 10rpx;
  100. padding-left: 20rpx;
  101. padding-right: 20rpx;
  102. }
  103. .tltleStyle {
  104. padding: 30rpx 30rpx 15rpx 15rpx;
  105. font-weight: bold;
  106. font-size: 40rpx;
  107. background-color: #fff;
  108. }
  109. .u-card-wrap {
  110. background-color: $u-bg-color;
  111. padding: 1px;
  112. }
  113. .u-body-item {
  114. font-size: 32rpx;
  115. color: #333;
  116. padding: 20rpx 10rpx;
  117. }
  118. .u-body-item image {
  119. width: 120rpx;
  120. flex: 0 0 120rpx;
  121. height: 120rpx;
  122. border-radius: 8rpx;
  123. margin-left: 12rpx;
  124. }
  125. </style>