myhd.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template>
  2. <view class="news">
  3. <!-- tab栏 -->
  4. <view class="cartop">
  5. <view class="tabtop flexc">
  6. <view class="tabt" :class="tabval==ite.val?'act':''" v-for="(ite,idx) in tablist" :key="idx" @click="getTabFn(ite.val)">{{ite.tit}}</view>
  7. </view>
  8. </view>
  9. <box-list :datainfo="list" :wtdt="wtdt" :tabval="tabval" type="wdhd" @getDetail='getDetail'></box-list>
  10. <loading></loading>
  11. </view>
  12. </template>
  13. <script>
  14. import config from '@/config'
  15. const baseUrl = config.baseUrl
  16. import boxList from "@/mine/components/box/list.vue"
  17. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  18. import {mycommentStars,mycommentLikes,mycommentIndex} from "@/api/work/news.js"
  19. export default{
  20. components:{boxList},
  21. data(){
  22. return{
  23. hrimg:require('@/static/logo.png'),
  24. list:[],
  25. pageSize: 10,
  26. pageNum: 1,
  27. reachflag: true,
  28. wtdt:'',
  29. tabval:'mypl',
  30. userId:this.$store.state.user.userId,
  31. tablist:[{tit:"评论",val:'mypl'},{tit:"点赞",val:'mydz'},{tit:"收藏",val:'mysc'},]
  32. }
  33. },
  34. onUnload() {
  35. uni.$off('partyNewsList')
  36. },
  37. onLoad: function() {
  38. uni.$on('partyNewsList',(res)=>{
  39. this.getrefreshData()
  40. })
  41. this.getDataFn()
  42. },
  43. onPageScroll(e) {
  44. var scrollTop = Number(e.scrollTop);
  45. // var listTop=Number(this.listTop)-Number(this.nvaHeight)
  46. if(scrollTop>2){
  47. this.scroflag=true
  48. }else{
  49. this.scroflag=false
  50. }
  51. },
  52. // 上拉触底加载更多触发事件
  53. onReachBottom() {
  54. if (this.reachflag) {
  55. this.pageNum++
  56. this.getDataFn()
  57. }
  58. },
  59. methods:{
  60. checkPermi, checkRole,
  61. // getNextFn(){
  62. // this.$tab.navigateTo("/work/pages/business/add")
  63. // },
  64. getDetail(data){
  65. var info=JSON.parse(JSON.stringify(data))
  66. var type=this.tabval;
  67. var targetType=info.targetType;//1:社区 2:党建
  68. if(type=='mypl'){
  69. var id=info.commentId;
  70. this.$tab.navigateTo("/news/pages/news/detail?id="+id)
  71. }else{
  72. var id=info.targetId;
  73. if(targetType==1){
  74. this.$tab.navigateTo("/news/pages/news/detail?id="+id)
  75. }else if(targetType==2){
  76. this.$tab.navigateTo("/news/pages/news/djdetail?id="+id)
  77. }
  78. }
  79. },
  80. getDelFn(id){
  81. var that=this;
  82. // reservDel(data).then(res=>{
  83. // if(res.code==200){
  84. // this.$toast("删除成功");
  85. // setTimeout(function(){
  86. // that.getrefreshData()
  87. // },1500)
  88. // }
  89. // })
  90. },
  91. getTabFn(val){
  92. this.tabval=val;
  93. this.getrefreshData()
  94. },
  95. getrefreshData(){
  96. this.pageNum=1;
  97. this.list=[];
  98. this.reachflag=true;
  99. this.getDataFn()
  100. },
  101. getSh(data){
  102. var that=this;
  103. var params=JSON.parse(JSON.stringify(data))
  104. commentContentPut(params).then(res=>{
  105. if(res.code==200){
  106. this.$toast('审核成功')
  107. setTimeout(function() {
  108. that.getrefreshData()
  109. }, 1500);
  110. }
  111. })
  112. },
  113. getDataFn(){
  114. var params={
  115. pageSize:this.pageSize,
  116. pageNum: this.pageNum,
  117. userId:this.userId
  118. }
  119. var tabval=this.tabval
  120. if(tabval=='mypl'){
  121. mycommentIndex(params).then(res=>{
  122. if(res.code==200){
  123. if (res.rows.length < this.pageSize) {
  124. this.reachflag = false
  125. this.wtdt = '到底了~';
  126. } else {
  127. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  128. if (num < res.total) {
  129. this.reachflag = true
  130. this.wtdt = ''
  131. } else {
  132. this.reachflag = false
  133. this.wtdt = '到底了~';
  134. }
  135. }
  136. var newArr=JSON.parse(JSON.stringify(res.rows))
  137. newArr.forEach(ite=>{
  138. ite.right=0;
  139. })
  140. if (this.pageNum == 1) {
  141. this.list = newArr;
  142. } else {
  143. this.list = this.list.concat(newArr)
  144. }
  145. }else{
  146. this.$toast(res.msg)
  147. }
  148. })
  149. }else if(tabval=='mydz'){
  150. mycommentLikes(params).then(res=>{
  151. if(res.code==200){
  152. if (res.rows.length < this.pageSize) {
  153. this.reachflag = false
  154. this.wtdt = '到底了~';
  155. } else {
  156. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  157. if (num < res.total) {
  158. this.reachflag = true
  159. this.wtdt = ''
  160. } else {
  161. this.reachflag = false
  162. this.wtdt = '到底了~';
  163. }
  164. }
  165. var newArr=JSON.parse(JSON.stringify(res.rows))
  166. newArr.forEach(ite=>{
  167. ite.right=0;
  168. })
  169. if (this.pageNum == 1) {
  170. this.list = newArr;
  171. } else {
  172. this.list = this.list.concat(newArr)
  173. }
  174. }else{
  175. this.$toast(res.msg)
  176. }
  177. })
  178. }else{
  179. mycommentStars(params).then(res=>{
  180. if(res.code==200){
  181. if (res.rows.length < this.pageSize) {
  182. this.reachflag = false
  183. this.wtdt = '到底了~';
  184. } else {
  185. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  186. if (num < res.total) {
  187. this.reachflag = true
  188. this.wtdt = ''
  189. } else {
  190. this.reachflag = false
  191. this.wtdt = '到底了~';
  192. }
  193. }
  194. var newArr=JSON.parse(JSON.stringify(res.rows))
  195. newArr.forEach(ite=>{
  196. ite.right=0;
  197. })
  198. if (this.pageNum == 1) {
  199. this.list = newArr;
  200. } else {
  201. this.list = this.list.concat(newArr)
  202. }
  203. }else{
  204. this.$toast(res.msg)
  205. }
  206. })
  207. }
  208. console.log(this.list)
  209. },
  210. }
  211. }
  212. </script>
  213. <style>
  214. page{background: #F3F3F0;}
  215. </style>
  216. <style lang="scss" scoped>
  217. .news{padding:124rpx 18rpx 12rpx;}
  218. .cartop{position: fixed;left: 0;right: 0;top: 0;background-color: #ffffff;z-index: 2;
  219. .toptit{display: flex;justify-content: center;font-weight: 500;font-size: 26rpx;color: #8592AA;height: 70rpx;align-items: center;
  220. background: #E4EDFF;
  221. text{font-size: 32rpx;color: #0156FE;padding: 0 10rpx;}
  222. image{width: 28rpx;height: 26rpx;flex: 0 0 auto;margin-right: 12rpx;}
  223. }
  224. .tabtop{padding-bottom: 40rpx;padding-top: 14rpx;
  225. .tabt{font-weight: 500;font-size: 32rpx;color: #666666;position: relative;line-height: 56rpx;padding: 0 40rpx;
  226. &.act{font-weight: bold;font-size: 32rpx;color: #272727;
  227. &::after{content: '';width: 40rpx;height: 10rpx;background: #0156FE;border-radius: 6rpx;position: absolute;left: 50%;margin-left: -20rpx;bottom: -10rpx;}
  228. }
  229. }
  230. }
  231. }
  232. </style>