Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.
 
 
 

306 Zeilen
7.0 KiB

  1. <template>
  2. <view class="message_list">
  3. <!-- 公告 -->
  4. <view class="m-nav">
  5. <view class="m-n-lside">
  6. <image src="@/static/images/notice.png" mode=""></image>
  7. 全部{{ count }}条消息
  8. </view>
  9. <view class="m-n-rside" @click="allRead">
  10. 全部已读
  11. </view>
  12. </view>
  13. <!-- 选项卡 -->
  14. <view class="m-tabs">
  15. <u-tabs :list="list" :current="current" :is-scroll="false" @change="change"></u-tabs>
  16. </view>
  17. <template v-if="current == 0">
  18. <scroll-view :scroll-top="scrollTop" refresher-enabled="true" :refresher-triggered="triggered"
  19. @refresherpulling="onPulling" @refresherrefresh="onRefresh" @refresherrestore="onRestore"
  20. :scroll-y="true" class="scroll-Y" @scrolltolower="lower">
  21. <template v-if="updateAnnList.length!=0">
  22. <block v-for="(item,index) in updateAnnList" :key="index">
  23. <view class="upgradeItem" @click="goReception(item, index)">
  24. <view class="right">
  25. <view class="title">
  26. {{item.title}}
  27. <template v-if="item.readFlag==0">
  28. <view class="notRead"></view>
  29. </template>
  30. </view>
  31. <view class="time">{{item.createTime}}</view>
  32. </view>
  33. </view>
  34. </block>
  35. </template>
  36. <template v-else>
  37. <view style="padding: 100rpx 0;">
  38. <u-empty text="暂无数据" mode="list"></u-empty>
  39. </view>
  40. </template>
  41. </scroll-view>
  42. </template>
  43. <!-- 升级公告 -->
  44. <template v-if="current == 1">
  45. <scroll-view :scroll-top="scrollTop" refresher-enabled="true" :refresher-triggered="triggered"
  46. @refresherpulling="onPulling" @refresherrefresh="onRefresh" @refresherrestore="onRestore"
  47. :scroll-y="true" class="scroll-Y" @scrolltolower="lower">
  48. <template v-if="updateAnnList.length!=0">
  49. <block v-for="(item,index) in updateAnnList" :key="index">
  50. <view class="upgradeItem" @click="goDetail(item)">
  51. <view class="right">
  52. <view class="title">
  53. {{item.title}}
  54. <template v-if="item.readFlag==0">
  55. <view class="notRead"></view>
  56. </template>
  57. </view>
  58. <view class="time">{{item.createTime}}</view>
  59. </view>
  60. </view>
  61. </block>
  62. </template>
  63. <template v-else>
  64. <view style="padding: 100rpx 0;">
  65. <u-empty text="暂无数据" mode="list"></u-empty>
  66. </view>
  67. </template>
  68. </scroll-view>
  69. </template>
  70. </view>
  71. </template>
  72. <script>
  73. var util = require("../../utils/util.js");
  74. var config = require("../../config");
  75. export default {
  76. data() {
  77. return {
  78. triggered: true,
  79. scrollTop: 0,
  80. old: {
  81. scrollTop: 0
  82. },
  83. updateAnnList: [],
  84. sysItemList: [],
  85. list: [{
  86. name: '接待报告',
  87. id: 1, // 1日报 2周报 3其他(非3为接待报告,3是系统消息)
  88. }, {
  89. name: '升级公告',
  90. id: 3, // 1日报 2周报 3其他(非3为接待报告,3是系统消息)
  91. }],
  92. count: 0, // 全部条数
  93. current: 0,
  94. pageNum: 1,
  95. pageSize: 10,
  96. };
  97. },
  98. onShow() {
  99. this.updateAnnList = []
  100. this.pageNum = 1
  101. this.updateInit()
  102. },
  103. onLoad() {
  104. this._freshing = false;
  105. setTimeout(() => {
  106. this.triggered = true;
  107. }, 1000)
  108. },
  109. onPullDownRefresh() {
  110. this.initPage()
  111. setTimeout(function() {
  112. uni.stopPullDownRefresh();
  113. }, 1000);
  114. },
  115. methods: {
  116. onPulling(e) {
  117. console.log("onpulling", e);
  118. },
  119. onRefresh() {
  120. if (this._freshing) return;
  121. this.updateAnnList = []
  122. this.pageNum = 1
  123. this.updateInit()
  124. this._freshing = true;
  125. setTimeout(() => {
  126. this.triggered = false;
  127. this._freshing = false;
  128. }, 3000)
  129. },
  130. onRestore() {
  131. this.triggered = 'restore'; // 需要重置
  132. console.log("onRestore");
  133. },
  134. lower(e) {
  135. this.pageNum++
  136. this.updateInit()
  137. },
  138. initPage() {
  139. this.updateAnnList = []
  140. this.pageNum = 1
  141. this.updateInit()
  142. },
  143. // 全部标记已读
  144. allRead() {
  145. this.$u.get('/zkMessage/updateState', {
  146. accountId: uni.getStorageSync('weapp_session_userInfo_data').accountId,
  147. projectId: uni.getStorageSync('buildingID').id,
  148. }).then(res => {
  149. uni.showToast({
  150. title: '全部已读成功!',
  151. duration: 2000
  152. });
  153. this.initPage()
  154. }).catch(e => {
  155. console.log(e)
  156. })
  157. },
  158. updateInit() {
  159. uni.request({
  160. url: config.service.updateList,
  161. method: "GET",
  162. data: {
  163. messageType: this.list[this.current].id,
  164. projectId: uni.getStorageSync('buildingID').id,
  165. id: uni.getStorageSync('weapp_session_userInfo_data').accountId,
  166. num: this.pageNum,
  167. size: this.pageSize
  168. },
  169. header: {
  170. 'content-type': 'application/json',
  171. 'Access-Token': uni.getStorageSync('weapp_session_login_data').token
  172. },
  173. success: (res) => {
  174. if (res.data.data) {
  175. this.count = res.data.data.sum
  176. if (this.pageNum != 1) {
  177. this.updateAnnList = [...this.updateAnnList, ...res.data.data.list.results];
  178. } else {
  179. this.updateAnnList = res.data.data.list.results
  180. }
  181. }
  182. },
  183. fail: e => {
  184. console.log(e)
  185. }
  186. })
  187. },
  188. goDetail(data) {
  189. this.$store.commit('setMessageObj', data)
  190. uni.navigateTo({
  191. url: "./messageDetail"
  192. })
  193. },
  194. // 跳转日报
  195. goReception(data, index) {
  196. this.$store.commit('setMessageObj', data)
  197. data.readFlag = 1
  198. if (data.messageType == 2) {
  199. uni.navigateTo({
  200. url: `/pages/mine/reportExcel/weekReport?id=${data.id}`
  201. })
  202. } else {
  203. uni.navigateTo({
  204. url: `/pages/mine/reportExcel/dayReport?id=${data.id}`
  205. })
  206. }
  207. },
  208. change(index) {
  209. this.current = index;
  210. this.initPage()
  211. }
  212. }
  213. }
  214. </script>
  215. <style lang="scss">
  216. .message_list {
  217. width: 100vw;
  218. height: calc(100vh - var(--window-top));
  219. background: #F8F8F8;
  220. display: flex;
  221. flex-direction: column;
  222. .m-nav {
  223. flex-shrink: 0;
  224. padding: 0 30rpx;
  225. width: 100%;
  226. height: 68rpx;
  227. display: flex;
  228. align-items: center;
  229. .m-n-lside {
  230. flex-grow: 1;
  231. display: flex;
  232. align-items: center;
  233. image {
  234. margin-right: 16rpx;
  235. width: 36rpx;
  236. height: 36rpx;
  237. }
  238. }
  239. .m-n-rside {
  240. flex-shrink: 0;
  241. padding: 6rpx 14rpx;
  242. border: 1rpx solid #E0E0E0;
  243. font-size: 24rpx;
  244. }
  245. }
  246. .m-tabs {
  247. flex-shrink: 0;
  248. }
  249. .scroll-Y {
  250. padding: 20rpx 0 0 0;
  251. flex-grow: 1;
  252. overflow-y: scroll;
  253. .upgradeItem {
  254. margin: 0 0 20rpx 0;
  255. padding: 24rpx 30rpx 28rpx;
  256. height: 156rpx;
  257. display: flex;
  258. background: #fff;
  259. .right {
  260. .title {
  261. font-size: 32rpx;
  262. font-weight: bold;
  263. display: flex;
  264. .notRead {
  265. width: 14rpx;
  266. height: 14rpx;
  267. background: #FF0000;
  268. border-radius: 100%;
  269. }
  270. }
  271. .time {
  272. margin: 18rpx 0 0 0;
  273. color: #6f6f6f;
  274. font-size: 24rpx;
  275. }
  276. }
  277. }
  278. }
  279. }
  280. </style>