sh.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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 "@/my/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. list:[],
  18. pageSize: 10,
  19. pageNum: 1,
  20. reachflag: true,
  21. wtdt:'',
  22. }
  23. },
  24. onLoad: function() {
  25. this.getDataFn()
  26. },
  27. onPageScroll(e) {
  28. var scrollTop = Number(e.scrollTop);
  29. // var listTop=Number(this.listTop)-Number(this.nvaHeight)
  30. if(scrollTop>2){
  31. this.scroflag=true
  32. }else{
  33. this.scroflag=false
  34. }
  35. },
  36. // 上拉触底加载更多触发事件
  37. onReachBottom() {
  38. if (this.reachflag) {
  39. this.pageNum++
  40. this.getDataFn()
  41. }
  42. },
  43. methods:{
  44. checkPermi, checkRole,
  45. // getNextFn(){
  46. // this.$tab.navigateTo("/work/pages/business/add")
  47. // },
  48. getDelFn(id){
  49. var that=this;
  50. reservDel(data).then(res=>{
  51. if(res.code==200){
  52. this.$toast("删除成功");
  53. setTimeout(function(){
  54. that.getrefreshData()
  55. },1500)
  56. }
  57. })
  58. },
  59. getrefreshData(){
  60. this.pageNum=1;
  61. this.list=[];
  62. this.reachflag=true;
  63. this.getDataFn()
  64. },
  65. getSh(data){
  66. var that=this;
  67. var params=JSON.parse(JSON.stringify(data))
  68. commentContentPut(params).then(res=>{
  69. if(res.code==200){
  70. this.$toast('审核成功')
  71. setTimeout(function() {
  72. that.getrefreshData()
  73. }, 1500);
  74. }
  75. })
  76. },
  77. getDataFn(){
  78. var params={
  79. pageSize:this.pageSize,
  80. pageNum: this.pageNum,
  81. "status":'1'
  82. }
  83. commentSh(params).then(res=>{
  84. if(res.code==200){
  85. if (res.rows.length < this.pageSize) {
  86. this.reachflag = false
  87. this.wtdt = '到底了~';
  88. } else {
  89. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  90. if (num < res.total) {
  91. this.reachflag = true
  92. this.wtdt = ''
  93. } else {
  94. this.reachflag = false
  95. this.wtdt = '到底了~';
  96. }
  97. }
  98. var newArr=JSON.parse(JSON.stringify(res.rows))
  99. newArr.forEach(ite=>{
  100. ite.right=0;
  101. })
  102. if (this.pageNum == 1) {
  103. this.list = newArr;
  104. } else {
  105. this.list = this.list.concat(newArr)
  106. }
  107. }else{
  108. this.$toast(res.msg)
  109. }
  110. })
  111. },
  112. }
  113. }
  114. </script>
  115. <style>
  116. page{background: #F3F3F0;}
  117. </style>
  118. <style lang="scss" scoped>
  119. .news{padding:20rpx 18rpx;}
  120. </style>