matters.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <template>
  2. <!-- pages/me.wxml -->
  3. <view class="container">
  4. <uni-search-bar :focus="true" v-model="searchValue" @input="search"
  5. style="width: 100%;"
  6. @cancel="cancel">
  7. </uni-search-bar>
  8. <!-- <view style="width: 100%;display: flex;">
  9. <uni-search-bar :focus="true" v-model="searchValue" @input="search"
  10. style="width: 70%;"
  11. @cancel="cancel">
  12. </uni-search-bar>
  13. <uni-data-select
  14. style="width: 30%;margin: auto;"
  15. v-model="value"
  16. placeholder="请选择排序"
  17. :localdata="range"
  18. @change="getList(value)"
  19. ></uni-data-select>
  20. </view> -->
  21. <view class="rnwdList">
  22. <view class="list" @tap="goDetails(item)" v-for="(item, index1) in qbwd" :key="index1">
  23. <span class="listTitle">{{ item.title }}</span>
  24. <view class="onePic">
  25. <image :src="loadImgSrcLocalhost(item.picture)">
  26. </image>
  27. </view>
  28. </view>
  29. </view>
  30. <!-- 新增资讯按钮 -->
  31. <!-- <button class="addInfomarionBtn" @click="addInfomation()"></button> -->
  32. </view>
  33. </template>
  34. <script>
  35. import { getMattersList } from '@/api/me/matters/matters.js'
  36. // pages/me.js
  37. export default {
  38. data() {
  39. return {
  40. qbwd:[],
  41. listParams:{
  42. pageNum: 1,
  43. pageSize: 7,
  44. title: '',
  45. isTop:0,
  46. type: 11,
  47. flag:''
  48. },
  49. topList:[],
  50. total:0,
  51. searchValue:'',
  52. favoriteList:[],
  53. value: 1,
  54. range: [
  55. { value: 'watch', text: "热度" },
  56. { value: 'like', text: "点赞" },
  57. { value: '', text: "最新" },
  58. ],
  59. };
  60. },
  61. created(){
  62. this.getList()
  63. },
  64. // 下拉刷新
  65. onPullDownRefresh() {
  66. setTimeout(() => {
  67. this.listParams.pageNum = 1;
  68. this.qbwd = [];
  69. let result = this.getList(this.listParams.flag,'刷新')
  70. },500)
  71. },
  72. onReachBottom(){
  73. let pageNum = this.listParams.pageNum
  74. let pageSize = this.listParams.pageSize
  75. let total = this.total
  76. if(pageNum * pageSize >= total){
  77. uni.showToast({
  78. title:'暂无更多数据'
  79. })
  80. return
  81. } else {
  82. this.listParams.pageNum += 1;
  83. this.getList(null,'dropDown')
  84. }
  85. },
  86. methods:{
  87. currentFavoriteCount(e){
  88. if(this.favoriteList.includes(e.id)){
  89. return e.likeNum + 1
  90. } else {
  91. return e.likeNum
  92. }
  93. },
  94. addFavorite(e){
  95. if(this.favoriteList.includes(e.id)) return
  96. likeServer({
  97. id:e.id,
  98. type:11
  99. }).then(e => {
  100. })
  101. this.favoriteList.push(e.id)
  102. return
  103. if(this.favoriteList.includes(e.id)){
  104. // 取消点赞
  105. likeServer({
  106. id:e.id,
  107. type:12
  108. })
  109. let deleteIdx = this.favoriteList.findIndex((v => v == e.id))
  110. this.favoriteList.splice(deleteIdx,1)
  111. } else {
  112. likeServer({
  113. id:e.id,
  114. type:12
  115. })
  116. this.favoriteList.push(e.id)
  117. }
  118. },
  119. cancel(){
  120. this.listParams.title = ''
  121. },
  122. fabClick(){
  123. uni.navigateTo({
  124. url: `/pages/handleAffairs/mattersAdd/mattersAdd`
  125. })
  126. },
  127. search(){
  128. this.listParams.title = this.searchValue
  129. this.getList()
  130. },
  131. getList(val = null,toastVal = '加载'){
  132. this.listParams.flag = val || ''
  133. this.qbwd = this.topList
  134. getMattersList(this.listParams).then(res => {
  135. this.qbwd = [...this.qbwd,...res.rows]
  136. this.total = res.total
  137. uni.showToast({
  138. title:`${toastVal}成功`
  139. })
  140. })
  141. },
  142. goDetails(e) {
  143. let id = e.id || ''
  144. let type = 11
  145. uni.navigateTo({
  146. url: `../mattersDetail/mattersDetail?id=${id}`
  147. });
  148. },
  149. // 新增资讯
  150. addInfomation(){
  151. uni.navigateTo({
  152. url: `../informationAdd/informationAdd`
  153. });
  154. }
  155. },
  156. /**
  157. * 生命周期函数--监听页面加载
  158. */
  159. onLoad(options) {},
  160. /**
  161. * 生命周期函数--监听页面初次渲染完成
  162. */
  163. onReady() {},
  164. /**
  165. * 生命周期函数--监听页面显示
  166. */
  167. onShow() {},
  168. /**
  169. * 生命周期函数--监听页面隐藏
  170. */
  171. onHide() {},
  172. /**
  173. * 生命周期函数--监听页面卸载
  174. */
  175. onUnload() {},
  176. /**
  177. * 用户点击右上角分享
  178. */
  179. onShareAppMessage() {},
  180. };
  181. </script>
  182. <style lang="scss">
  183. @import './matters.css';
  184. .container{
  185. height: 100%;
  186. }
  187. .container{
  188. height: 100%;
  189. content: '\e633';
  190. }
  191. .favorite{
  192. .icon-shoucang:before{
  193. color: red;
  194. }
  195. }
  196. .not-favorite{
  197. }
  198. </style>