list.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. <template>
  2. <view :style="'padding-top:'+nvaHeight+'px;'">
  3. <view class="navbox">
  4. <uni-nav-bar color="#ffffff" rightWidth="150rpx" title="消息通知" @clickLeft="getBack" @clickRight="getAddNewsFn" :background-color="backgroundColor" :border="false" statusBar='true' fixed="true">
  5. <block slot="left">
  6. <view class="topl">
  7. <image :src="backimg" ></image>
  8. </view>
  9. </block>
  10. <block slot="right">
  11. <view class="topr" v-if="checkPermi(['zxNotice:notice:add'])">
  12. <image :src="ccicoimg"></image>
  13. <view>发布消息</view>
  14. </view>
  15. </block>
  16. </uni-nav-bar>
  17. <view class="tablists flexc">
  18. <view v-for="(ite,idx) in tabList" @click="getTabFn(ite.value)" :class="{act:tabval==ite.value}" :key="idx">{{ite.label}}</view>
  19. </view>
  20. </view>
  21. <!-- 列表 -->
  22. <view class="mbox">
  23. <news-list :datalist="list" :wtdt="wtdt" :type='type' @getDetail="getDetail" @getTuiFn="getTuiFn"></news-list>
  24. </view>
  25. <!-- <view class="fwbtns">提交提案</view> -->
  26. <!-- 弹窗 -->
  27. <pop-up :type='ptype' @getClose="getClose" @getFaFn="getFaFn"></pop-up>
  28. </view>
  29. </template>
  30. <script>
  31. import { checkPermi, checkRole } from "@/utils/permission"; // 权限判断函数
  32. import {getDictionaryFn} from "@/api/mine/register.js"
  33. import {getNoticeList} from "@/api/mine/news.js"
  34. import popUp from "@/work/components/popup/popup.vue"
  35. import newsList from "@/work/components/news/list.vue"
  36. export default{
  37. components:{newsList,popUp},
  38. data(){
  39. return{
  40. ccicoimg:require("@/work/static/images/fbico.png"),
  41. backimg:require("@/work/static/images/back.png"),
  42. backgroundColor:"#1D64E2",
  43. tabval:'',
  44. type:1,
  45. tabList:[],
  46. nvaHeight:44,
  47. datainfo:{
  48. talb:'',
  49. },
  50. ptype:'',//弹窗类型
  51. list:[],
  52. pageSize: 10,
  53. pageNum: 1,
  54. reachflag: true,
  55. wtdt:'',
  56. }
  57. },
  58. onUnload(){
  59. uni.$off('refreshxxlist')
  60. },
  61. onLoad(e) {
  62. this.init()
  63. uni.$on('refreshxxlist', (e) => {
  64. this.getrefreshData()
  65. })
  66. },
  67. // 上拉触底加载更多触发事件
  68. onReachBottom() {
  69. if (this.reachflag) {
  70. this.pageNum++
  71. this.getDataFn()
  72. }
  73. },
  74. mounted() {
  75. this.getHeightFn()
  76. },
  77. methods:{
  78. checkPermi, checkRole,
  79. getrefreshData(){
  80. this.pageNum=1;
  81. this.list=[];
  82. this.reachflag=true;
  83. this.getDataFn()
  84. },
  85. init(){
  86. getDictionaryFn('sys_notice_type').then(res=>{
  87. if(res.code==200&&res.data.length){
  88. this.tabList = res.data.map(v => {
  89. return {
  90. label: v.dictLabel,
  91. value: v.dictValue
  92. }
  93. })
  94. if(res.data){
  95. this.tabval=res.data[0].dictValue;
  96. this.getDataFn()
  97. }
  98. }
  99. })
  100. },
  101. getHeightFn(){
  102. var s=uni.getSystemInfoSync().statusBarHeight;
  103. let query = uni.createSelectorQuery().in(this);
  104. //需要给黄色区域设置一个id标识,在这里是demo
  105. query.select('.navbox').boundingClientRect(data => {
  106. this.nvaHeight =s? data.height:Number(data.height)-20//赋值,待会要用
  107. }).exec();
  108. },
  109. getClose(){
  110. this.ptype=""
  111. },
  112. getFaFn(type){
  113. this.ptype="";
  114. if(type=='new'){
  115. uni.removeStorageSync('zcList')
  116. }
  117. this.$tab.navigateTo('/work/pages/news/add?type='+type)
  118. },
  119. getTabFn(idx){
  120. this.tabval=idx;
  121. this.list=[];
  122. this.pageNum=1;
  123. this.reachflag=true;
  124. this.getDataFn()
  125. },
  126. getBack(){
  127. uni.navigateBack({
  128. delta:1
  129. })
  130. },
  131. getAddNewsFn(){
  132. if(checkPermi(['zxNotice:notice:add'])){
  133. if(uni.getStorageSync('zcList')){
  134. var newObj=JSON.parse(JSON.stringify(uni.getStorageSync('zcList')))
  135. this.ptype='zcfb'
  136. }else{
  137. this.$tab.navigateTo('/work/pages/news/add')
  138. }
  139. }
  140. // this.ptype='zcfb'
  141. // return
  142. },
  143. getTuiFn(ite){
  144. this.ptype=ite.type
  145. },
  146. getDetail(id){
  147. this.$tab.navigateTo('/work/pages/news/detail?id='+id)
  148. },
  149. getDataFn(){
  150. var params={
  151. pageSize:this.pageSize,
  152. pageNum: this.pageNum,
  153. noticeType:this.tabval
  154. }
  155. getNoticeList(params).then(res=>{
  156. if(res.code==200){
  157. if (res.rows.length < this.pageSize) {
  158. this.reachflag = false
  159. this.wtdt = '到底了~';
  160. } else {
  161. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  162. if (num < res.total) {
  163. this.reachflag = true
  164. this.wtdt = '上拉加载更多'
  165. } else {
  166. this.reachflag = false
  167. this.wtdt = '到底了~';
  168. }
  169. }
  170. if (this.pageNum == 1) {
  171. this.list = res.rows;
  172. } else {
  173. this.list = this.list.concat(res.rows)
  174. }
  175. }else{
  176. this.$toast(res.msg)
  177. }
  178. })
  179. },
  180. }
  181. }
  182. </script>
  183. <style scoped lang="scss">
  184. page{background-color: #FFFFFF;}
  185. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4;background-color: $com-cd3;padding-bottom: 40rpx;
  186. .topl{width: 60rpx;height: 60rpx;display: flex;align-items: center;justify-content: center;
  187. image{width: 40rpx;height: 30rpx;}
  188. }
  189. .topr{display: flex;align-items: center;
  190. image{width: 26rpx;height: 26rpx;margin-right: 12rpx;}
  191. view{font-weight: 500;font-size: 26rpx;color: #FFFFFF;}
  192. }
  193. .tablists{
  194. overflow: auto;flex-wrap: nowrap;min-height:84rpx;
  195. view{font-weight: bold;font-size: 26rpx;color: #FFFFFF;position: relative;flex: 0 0 auto;padding: 22rpx 24rpx;margin-right: 6rpx;box-sizing: border-box;
  196. &:last-child{margin-right: 0;}
  197. &.act{font-size: 30rpx;
  198. &::after{content: '';width: 62rpx;height: 10rpx;background: #FFFFFF;border-radius: 4rpx;left: 50%;margin-left: -31rpx;bottom: 0rpx;position: absolute;}
  199. }
  200. }
  201. }
  202. }
  203. .mbox{}
  204. </style>