list.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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">
  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 {getDictionaryFn} from "@/api/mine/register.js"
  32. import {getNoticeList} from "@/api/mine/news.js"
  33. import popUp from "@/work/components/popup/popup.vue"
  34. import newsList from "@/work/components/news/list.vue"
  35. export default{
  36. components:{newsList,popUp},
  37. data(){
  38. return{
  39. ccicoimg:require("@/work/static/images/fbico.png"),
  40. backimg:require("@/work/static/images/back.png"),
  41. backgroundColor:"#1D64E2",
  42. tabval:'',
  43. type:1,
  44. tabList:[],
  45. nvaHeight:44,
  46. datainfo:{
  47. talb:'',
  48. },
  49. ptype:'',//弹窗类型
  50. list:[],
  51. pageSize: 10,
  52. pageNum: 1,
  53. reachflag: true,
  54. wtdt:'',
  55. }
  56. },
  57. onLoad(e) {
  58. this.init()
  59. },
  60. mounted() {
  61. this.getHeightFn()
  62. },
  63. methods:{
  64. init(){
  65. getDictionaryFn('sys_notice_type').then(res=>{
  66. if(res.code==200&&res.data.length){
  67. this.tabList = res.data.map(v => {
  68. return {
  69. label: v.dictLabel,
  70. value: v.dictValue
  71. }
  72. })
  73. if(res.data){
  74. this.tabval=res.data[0].dictValue;
  75. this.getDataFn()
  76. }
  77. }
  78. })
  79. },
  80. getHeightFn(){
  81. var s=uni.getSystemInfoSync().statusBarHeight;
  82. let query = uni.createSelectorQuery().in(this);
  83. //需要给黄色区域设置一个id标识,在这里是demo
  84. query.select('.navbox').boundingClientRect(data => {
  85. this.nvaHeight =s? data.height:Number(data.height)-20//赋值,待会要用
  86. }).exec();
  87. },
  88. getClose(){
  89. this.ptype=""
  90. },
  91. getFaFn(type){
  92. this.ptype="";
  93. if(type=='new'){
  94. uni.removeStorageSync('zcList')
  95. }
  96. this.$tab.navigateTo('/work/pages/news/add?type='+type)
  97. },
  98. getTabFn(idx){
  99. this.tabval=idx;
  100. this.list=[];
  101. this.pageNum=1;
  102. this.reachflag=true;
  103. this.getDataFn()
  104. },
  105. getBack(){
  106. uni.navigateBack({
  107. delta:1
  108. })
  109. },
  110. getAddNewsFn(){
  111. // this.ptype='zcfb'
  112. // return
  113. if(uni.getStorageSync('zcList')){
  114. var newObj=JSON.parse(JSON.stringify(uni.getStorageSync('zcList')))
  115. this.ptype='zcfb'
  116. }else{
  117. this.$tab.navigateTo('/work/pages/news/add')
  118. }
  119. },
  120. getTuiFn(ite){
  121. this.ptype=ite.type
  122. },
  123. getDetail(id){
  124. this.$tab.navigateTo('/work/pages/news/add?id='+id)
  125. },
  126. getDataFn(){
  127. var params={
  128. pageSize:this.pageSize,
  129. pageNum: this.pageNum,
  130. noticeType:this.tabval
  131. }
  132. getNoticeList(params).then(res=>{
  133. if(res.code==200){
  134. if (res.rows.length < this.pageSize) {
  135. this.reachflag = false
  136. this.wtdt = '到底了~';
  137. } else {
  138. var num = parseInt(res.rows.length) + parseInt(this.pageSize) * parseInt(this.pageNum - 1)
  139. if (num < res.total) {
  140. this.reachflag = true
  141. this.wtdt = '上拉加载更多'
  142. } else {
  143. this.reachflag = false
  144. this.wtdt = '到底了~';
  145. }
  146. }
  147. if (this.pageNum == 1) {
  148. this.list = res.rows;
  149. } else {
  150. this.list = this.list.concat(res.rows)
  151. }
  152. }else{
  153. this.$toast(res.msg)
  154. }
  155. })
  156. },
  157. }
  158. }
  159. </script>
  160. <style scoped lang="scss">
  161. page{background-color: #FFFFFF;}
  162. .navbox{position: fixed;left: 0;right: 0;top: 0;z-index: 4;background-color: $com-cd3;padding-bottom: 40rpx;
  163. .topl{width: 60rpx;height: 60rpx;display: flex;align-items: center;justify-content: center;
  164. image{width: 40rpx;height: 30rpx;}
  165. }
  166. .topr{display: flex;align-items: center;
  167. image{width: 26rpx;height: 26rpx;margin-right: 12rpx;}
  168. view{font-weight: 500;font-size: 26rpx;color: #FFFFFF;}
  169. }
  170. .tablists{
  171. overflow: auto;flex-wrap: nowrap;min-height:84rpx;
  172. 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;
  173. &:last-child{margin-right: 0;}
  174. &.act{font-size: 30rpx;
  175. &::after{content: '';width: 62rpx;height: 10rpx;background: #FFFFFF;border-radius: 4rpx;left: 50%;margin-left: -31rpx;bottom: 0rpx;position: absolute;}
  176. }
  177. }
  178. }
  179. }
  180. .mbox{}
  181. </style>