index.vue 2.3 KB

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