index.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <template>
  2. <view class="box">
  3. <view class="flex1 overh boxtop">
  4. <tablist :tablist="tablist" :tabval="tabval" @getCheck="getCheck"></tablist>
  5. </view>
  6. <view class="stepbox" >
  7. <box-list :datainfo="list" type="notice" :wtdt="wtdt" @getDetail="getDetail"></box-list>
  8. </view>
  9. <loading></loading>
  10. </view>
  11. </template>
  12. <script>
  13. import {checkPermi,checkRole} from "@/utils/permission"; // 权限判断函数
  14. import {getDictionaryFn} from "@/api/mine/register.js";
  15. import {getNoticeList} from "@/api/common.js"
  16. import tablist from '@/components/tabs/index.vue'
  17. import boxList from "@/news/components/box/list.vue"
  18. export default {
  19. components:{tablist,boxList},
  20. data(){
  21. return{
  22. list:[],
  23. pageSize: 10,
  24. pageNum: 1,
  25. reachflag: true,
  26. tabval:'',
  27. tablist:[],
  28. wtdt:'',
  29. tzList:[],
  30. }
  31. },
  32. onShow() {
  33. },
  34. onLoad: function() {
  35. this.init();
  36. },
  37. // 上拉触底加载更多触发事件
  38. onReachBottom() {
  39. if (this.reachflag) {
  40. this.pageNum++
  41. this.getDataFn()
  42. }
  43. },
  44. methods:{
  45. checkPermi,checkRole,
  46. init(){
  47. //通知类型
  48. getDictionaryFn('sys_notice_type').then(res => {
  49. if (res.code == 200) {
  50. this.tablist = res.data.map(v => {
  51. this.tabval=res.data[0].dictValue
  52. return {
  53. dictLabel: v.dictLabel,
  54. dictValue: v.dictValue
  55. }
  56. })
  57. this.getDataFn()
  58. }
  59. })
  60. },
  61. getCheck(val){
  62. this.tabval=val;
  63. this.getrefreshData()
  64. },
  65. getrefreshData(){
  66. this.pageNum=1;
  67. this.list=[];
  68. this.reachflag=true;
  69. this.getDataFn()
  70. },
  71. getDetail(ite){
  72. var id=ite.noticeId;
  73. if(ite.noticeType==3){
  74. this.$tab.navigateTo(`/news/pages/notice/detail?id=${id}&type=`+ite.noticeType)
  75. }else{
  76. this.$tab.navigateTo(`/news/pages/notice/tzdetail?id=${id}&type=`+ite.noticeType)
  77. }
  78. },
  79. getDataFn(){
  80. var params={
  81. pageSize:this.pageSize,
  82. pageNum: this.pageNum,
  83. }
  84. params.noticeType=this.tabval
  85. getNoticeList(params).then(res=>{
  86. if(res.code==200){
  87. if (res.rows.length < this.pageSize) {
  88. this.reachflag = false
  89. this.wtdt = '到底了~';
  90. } else {
  91. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  92. if (num < res.total) {
  93. this.reachflag = true
  94. this.wtdt = ''
  95. } else {
  96. this.reachflag = false
  97. this.wtdt = '到底了~';
  98. }
  99. }
  100. if (this.pageNum == 1) {
  101. this.list = res.rows;
  102. } else {
  103. this.list = this.list.concat(res.rows)
  104. }
  105. }else{
  106. this.$toast(res.msg)
  107. }
  108. })
  109. },
  110. }
  111. }
  112. </script>
  113. <style lang="scss" scoped>
  114. .boxtop{padding: 18rpx 0 0;background-color: #ffffff;
  115. position: fixed;left: 0;top: 0;right: 0;z-index: 2;
  116. }
  117. .box{padding-top: 100rpx;}
  118. .stepbox{padding: 18rpx 24rpx 0;}
  119. </style>