knowledge.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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">{{ 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 class="jf">
  27. <em class="iconfont icon-jifen"></em>
  28. {{ item.integral || 0 }}
  29. </span>
  30. <span>
  31. <em class="iconfont icon-shoucang"></em>
  32. {{ item.watchNum }}
  33. </span>
  34. </view>
  35. </view>
  36. </view>
  37. <uni-fab ref="fab" :horizontal="right" :vertical="bottom" @fabClick="fabClick()" />
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import {
  43. list,
  44. knowledgePay,
  45. getDetails
  46. } from '@/api/knowledge/knowledge.js';
  47. export default {
  48. data() {
  49. return {
  50. dataSource: [],
  51. // 数据总量
  52. total: 0,
  53. queryParams: {
  54. // 当前页
  55. pageNum: 1,
  56. // 每页数据量
  57. pageSize: 10,
  58. },
  59. loading: false,
  60. //是否显示弹出层
  61. open: false,
  62. //悬浮按钮右对齐
  63. right: 'right',
  64. //悬浮按钮下对齐
  65. bottom: 'bottom',
  66. }
  67. },
  68. /**
  69. * 生命周期函数--监听页面加载
  70. */
  71. onLoad(options) {
  72. this.getList()
  73. },
  74. onReachBottom() {
  75. let pageNum = this.queryParams.pageNum
  76. let pageSize = this.queryParams.pageSize
  77. let total = this.total
  78. if (pageNum * pageSize >= total) {
  79. uni.showToast({
  80. title: '暂无更多数据'
  81. })
  82. return
  83. } else {
  84. this.queryParams.pageNum += 1;
  85. this.getList()
  86. }
  87. },
  88. methods: {
  89. goDetails(item) {
  90. this.isKnowledgePay(item)
  91. },
  92. isKnowledgePay(item) {
  93. let params = {
  94. //减少积分人id
  95. userId: getApp().globalData.userId,
  96. //增加积分人id
  97. createId: item.createId,
  98. integral: item.integral,
  99. id: item.id,
  100. relevance: "1",
  101. }
  102. knowledgePay(params).then(res => {
  103. if (res.code == 200) {
  104. getDetails(item.id).then(res => {
  105. let data = res.data
  106. if(data.imgUrlList!=null){
  107. data.urls = data.imgUrlList.split(',')
  108. }
  109. uni.navigateTo({
  110. url: `/pages/common/articleDetail/articleDetail?data=${this.encodify(data)}`
  111. });
  112. })
  113. } else {
  114. uni.showToast({
  115. title: res.msg
  116. })
  117. }
  118. })
  119. },
  120. // 分页触发
  121. change(e) {
  122. this.getList(e.current);
  123. },
  124. // 获取数据
  125. getList() {
  126. let params = {
  127. pageSize: this.queryParams.pageSize,
  128. pageNum: this.queryParams.pageNum
  129. }
  130. list(params).then(res => {
  131. if (res.code == 200) {
  132. this.dataSource = [...this.dataSource, ...res.rows]
  133. this.total = res.total
  134. }
  135. })
  136. },
  137. //悬浮按钮点击事件
  138. fabClick() {
  139. uni.navigateTo({
  140. url: '../knowledge/knowledgeForm'
  141. });
  142. },
  143. }
  144. }
  145. </script>
  146. <style>
  147. @import './knowledge.css';
  148. </style>