book.vue 2.9 KB

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