sh.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <template>
  2. <view class="news">
  3. <box-list :datainfo="list" :wtdt="wtdt" type="plsh" @getDetail='getDetail' @getSh="getSh"></box-list>
  4. <loading></loading>
  5. </view>
  6. </template>
  7. <script>
  8. import config from '@/config'
  9. const baseUrl = config.baseUrl
  10. import boxList from "@/mine/components/box/list.vue"
  11. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  12. import {commentSh,commentContentPut} from "@/api/work/news.js"
  13. export default{
  14. components:{boxList},
  15. data(){
  16. return{
  17. hrimg:require('@/static/logo.png'),
  18. list:[],
  19. pageSize: 10,
  20. pageNum: 1,
  21. reachflag: true,
  22. wtdt:'',
  23. }
  24. },
  25. onLoad: function() {
  26. this.getDataFn()
  27. },
  28. onPageScroll(e) {
  29. var scrollTop = Number(e.scrollTop);
  30. // var listTop=Number(this.listTop)-Number(this.nvaHeight)
  31. if(scrollTop>2){
  32. this.scroflag=true
  33. }else{
  34. this.scroflag=false
  35. }
  36. },
  37. // 上拉触底加载更多触发事件
  38. onReachBottom() {
  39. if (this.reachflag) {
  40. this.pageNum++
  41. this.getDataFn()
  42. }
  43. },
  44. methods:{
  45. checkPermi, checkRole,
  46. // getNextFn(){
  47. // this.$tab.navigateTo("/work/pages/business/add")
  48. // },
  49. getDelFn(id){
  50. var that=this;
  51. reservDel(data).then(res=>{
  52. if(res.code==200){
  53. this.$toast("删除成功");
  54. setTimeout(function(){
  55. that.getrefreshData()
  56. },1500)
  57. }
  58. })
  59. },
  60. getrefreshData(){
  61. this.pageNum=1;
  62. this.list=[];
  63. this.reachflag=true;
  64. this.getDataFn()
  65. },
  66. getSh(data){
  67. var that=this;
  68. var params=JSON.parse(JSON.stringify(data))
  69. commentContentPut(params).then(res=>{
  70. if(res.code==200){
  71. this.$toast('审核成功')
  72. setTimeout(function() {
  73. that.getrefreshData()
  74. }, 1500);
  75. }
  76. })
  77. },
  78. getDataFn(){
  79. var params={
  80. pageSize:this.pageSize,
  81. pageNum: this.pageNum,
  82. "status":'1'
  83. }
  84. commentSh(params).then(res=>{
  85. if(res.code==200){
  86. if (res.rows.length < this.pageSize) {
  87. this.reachflag = false
  88. this.wtdt = '到底了~';
  89. } else {
  90. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  91. if (num < res.total) {
  92. this.reachflag = true
  93. this.wtdt = ''
  94. } else {
  95. this.reachflag = false
  96. this.wtdt = '到底了~';
  97. }
  98. }
  99. var newArr=JSON.parse(JSON.stringify(res.rows))
  100. newArr.forEach(ite=>{
  101. ite.right=0;
  102. })
  103. if (this.pageNum == 1) {
  104. this.list = newArr;
  105. } else {
  106. this.list = this.list.concat(newArr)
  107. }
  108. }else{
  109. this.$toast(res.msg)
  110. }
  111. })
  112. },
  113. }
  114. }
  115. </script>
  116. <style>
  117. page{background: #F3F3F0;}
  118. </style>
  119. <style lang="scss" scoped>
  120. .news{padding:20rpx 18rpx;}
  121. </style>