list.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. that.getrefreshData()
  65. })
  66. },
  67. mounted() {
  68. this.getHeightFn()
  69. },
  70. methods:{
  71. checkPermi, checkRole,
  72. getrefreshData(){
  73. this.pageNum=1;
  74. this.list=[];
  75. this.reachflag=true;
  76. this.getDataFn()
  77. },
  78. init(){
  79. getDictionaryFn('sys_notice_type').then(res=>{
  80. if(res.code==200&&res.data.length){
  81. this.tabList = res.data.map(v => {
  82. return {
  83. label: v.dictLabel,
  84. value: v.dictValue
  85. }
  86. })
  87. if(res.data){
  88. this.tabval=res.data[0].dictValue;
  89. this.getDataFn()
  90. }
  91. }
  92. })
  93. },
  94. getHeightFn(){
  95. var s=uni.getSystemInfoSync().statusBarHeight;
  96. let query = uni.createSelectorQuery().in(this);
  97. //需要给黄色区域设置一个id标识,在这里是demo
  98. query.select('.navbox').boundingClientRect(data => {
  99. this.nvaHeight =s? data.height:Number(data.height)-20//赋值,待会要用
  100. }).exec();
  101. },
  102. getClose(){
  103. this.ptype=""
  104. },
  105. getFaFn(type){
  106. this.ptype="";
  107. if(type=='new'){
  108. uni.removeStorageSync('zcList')
  109. }
  110. this.$tab.navigateTo('/work/pages/news/add?type='+type)
  111. },
  112. getTabFn(idx){
  113. this.tabval=idx;
  114. this.list=[];
  115. this.pageNum=1;
  116. this.reachflag=true;
  117. this.getDataFn()
  118. },
  119. getBack(){
  120. uni.navigateBack({
  121. delta:1
  122. })
  123. },
  124. getAddNewsFn(){
  125. if(checkPermi(['zxNotice:notice:add'])){
  126. if(uni.getStorageSync('zcList')){
  127. var newObj=JSON.parse(JSON.stringify(uni.getStorageSync('zcList')))
  128. this.ptype='zcfb'
  129. }else{
  130. this.$tab.navigateTo('/work/pages/news/add')
  131. }
  132. }
  133. // this.ptype='zcfb'
  134. // return
  135. },
  136. getTuiFn(ite){
  137. this.ptype=ite.type
  138. },
  139. getDetail(id){
  140. this.$tab.navigateTo('/work/pages/news/detail?id='+id)
  141. },
  142. getDataFn(){
  143. var params={
  144. pageSize:this.pageSize,
  145. pageNum: this.pageNum,
  146. noticeType:this.tabval
  147. }
  148. getNoticeList(params).then(res=>{
  149. if(res.code==200){
  150. if (res.rows.length < this.pageSize) {
  151. this.reachflag = false
  152. this.wtdt = '到底了~';
  153. } else {
  154. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  155. if (num < res.total) {
  156. this.reachflag = true
  157. this.wtdt = '上拉加载更多'
  158. } else {
  159. this.reachflag = false
  160. this.wtdt = '到底了~';
  161. }
  162. }
  163. if (this.pageNum == 1) {
  164. this.list = res.rows;
  165. } else {
  166. this.list = this.list.concat(res.rows)
  167. }
  168. }else{
  169. this.$toast(res.msg)
  170. }
  171. })
  172. },
  173. }
  174. }
  175. </script>
  176. <style scoped lang="scss">
  177. page{background-color: #FFFFFF;}
  178. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4;background-color: $com-cd3;padding-bottom: 40rpx;
  179. .topl{width: 60rpx;height: 60rpx;display: flex;align-items: center;justify-content: center;
  180. image{width: 40rpx;height: 30rpx;}
  181. }
  182. .topr{display: flex;align-items: center;
  183. image{width: 26rpx;height: 26rpx;margin-right: 12rpx;}
  184. view{font-weight: 500;font-size: 26rpx;color: #FFFFFF;}
  185. }
  186. .tablists{
  187. overflow: auto;flex-wrap: nowrap;min-height:84rpx;
  188. 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;
  189. &:last-child{margin-right: 0;}
  190. &.act{font-size: 30rpx;
  191. &::after{content: '';width: 62rpx;height: 10rpx;background: #FFFFFF;border-radius: 4rpx;left: 50%;margin-left: -31rpx;bottom: 0rpx;position: absolute;}
  192. }
  193. }
  194. }
  195. }
  196. .mbox{}
  197. </style>