index.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <view class="news">
  3. <box-list :datainfo="list" :wtdt="wtdt" type="myhd" @getDetail='getDetail'></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 {getCommentInteraction} 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. getDataFn(){
  67. var params={
  68. pageSize:this.pageSize,
  69. pageNum: this.pageNum,
  70. }
  71. getCommentInteraction(params).then(res=>{
  72. if(res.code==200){
  73. var data=res.data.list;
  74. if (data.length < this.pageSize) {
  75. this.reachflag = false
  76. this.wtdt = '到底了~';
  77. } else {
  78. var num = parseInt(data.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  79. if (num < res.total) {
  80. this.reachflag = true
  81. this.wtdt = ''
  82. } else {
  83. this.reachflag = false
  84. this.wtdt = '到底了~';
  85. }
  86. }
  87. if (this.pageNum == 1) {
  88. this.list = data;
  89. } else {
  90. this.list = this.list.concat(data)
  91. }
  92. }else{
  93. this.$toast(res.msg)
  94. }
  95. })
  96. },
  97. }
  98. }
  99. </script>
  100. <style>
  101. page{background: #F3F3F0;}
  102. </style>
  103. <style lang="scss" scoped>
  104. .news{padding:20rpx 18rpx;}
  105. </style>