knowledge.vue 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <template>
  2. <!-- 知识库列表 -->
  3. <view class="container">
  4. <view class="rnwdList">
  5. <view class="list" @tap="goDetails(item)" v-for="(item, index1) in dataSource" :key="index1">
  6. <span class="lb">{{ item.popular == '1' ? '热门' : '非热门' }}</span>
  7. <span class="listTitle" v-if="item.imgUrlList != null">{{ item.titleName }}</span>
  8. <view class="onePic" v-if="item.imgUrlList != null && item.imgUrlList.split(',').length == 1">
  9. <image :src="loadImgSrcLocalhost(itemurl)" v-for="(itemurl, index1) in item.imgUrlList.split(',')" :key="index1">
  10. </image>
  11. </view>
  12. <view class="twoPic" v-if="item.imgUrlList != null && item.imgUrlList.split(',').length == 2">
  13. <image :src="loadImgSrcLocalhost(itemurl)" v-for="(itemurl, index1) in item.imgUrlList.split(',')" :key="index1">
  14. </image>
  15. </view>
  16. <view class="threePic" v-if="item.imgUrlList != null && item.imgUrlList.split(',').length == 3">
  17. <image :src="loadImgSrcLocalhost(itemurl)" v-for="(itemurl, index1) in item.imgUrlList.split(',')" :key="index1">
  18. </image>
  19. </view>
  20. <view class="jlSj">
  21. <span style="color: #07c160;font-size: 24rpx;">
  22. {{ item.createTime }}
  23. <!-- <em class="iconfont icon-jifen"></em> -->
  24. </span>
  25. <view class="ck">
  26. <span>
  27. <em class="iconfont icon-shoucang"></em>
  28. {{ item.watchNum }}
  29. </span>
  30. </view>
  31. </view>
  32. </view>
  33. <uni-fab ref="fab" :horizontal="right" :vertical="bottom" @fabClick="fabClick()" />
  34. </view>
  35. </view>
  36. </template>
  37. <script>
  38. import {
  39. list,
  40. knowledgePay
  41. } from '@/api/knowledge/knowledge.js';
  42. export default {
  43. data() {
  44. return {
  45. dataSource: [],
  46. // 数据总量
  47. total: 0,
  48. queryParams: {
  49. // 当前页
  50. pageNum: 1,
  51. // 每页数据量
  52. pageSize: 10,
  53. },
  54. loading: false,
  55. //是否显示弹出层
  56. open: false,
  57. //悬浮按钮右对齐
  58. right: 'right',
  59. //悬浮按钮下对齐
  60. bottom: 'bottom',
  61. }
  62. },
  63. /**
  64. * 生命周期函数--监听页面加载
  65. */
  66. onLoad(options) {
  67. this.getList()
  68. },
  69. onReachBottom() {
  70. let pageNum = this.queryParams.pageNum
  71. let pageSize = this.queryParams.pageSize
  72. let total = this.total
  73. if (pageNum * pageSize >= total) {
  74. uni.showToast({
  75. title: '暂无更多数据'
  76. })
  77. return
  78. } else {
  79. this.queryParams.pageNum += 1;
  80. this.getList()
  81. }
  82. },
  83. methods: {
  84. goDetails(item) {
  85. this.isKnowledgePay(item)
  86. },
  87. isKnowledgePay(item) {
  88. let params = {
  89. //减少积分人id
  90. userId: getApp().globalData.userId,
  91. //增加积分人id
  92. createId: item.createId,
  93. integral: item.integral,
  94. id: item.id,
  95. relevance: "1",
  96. }
  97. knowledgePay(params).then(res => {
  98. if (res.code == 200) {
  99. uni.navigateTo({
  100. url: '/pages/highServer/knowledgeDetails/knowledgeDetails?id=' + item.id,
  101. });
  102. } else {
  103. uni.showToast({
  104. title: res.msg
  105. })
  106. }
  107. })
  108. },
  109. // 分页触发
  110. change(e) {
  111. this.getList(e.current);
  112. },
  113. // 获取数据
  114. getList() {
  115. let params = {
  116. pageSize: this.queryParams.pageSize,
  117. pageNum: this.queryParams.pageNum
  118. }
  119. list(params).then(res => {
  120. if (res.code == 200) {
  121. this.dataSource = [...this.dataSource, ...res.rows]
  122. this.total = res.total
  123. }
  124. })
  125. },
  126. //悬浮按钮点击事件
  127. fabClick() {
  128. uni.navigateTo({
  129. url: '../knowledge/knowledgeForm'
  130. });
  131. },
  132. }
  133. }
  134. </script>
  135. <style>
  136. @import './knowledge.css';
  137. </style>