25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

305 lines
7.1 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.updateInit()
  122. this._freshing = true;
  123. setTimeout(() => {
  124. this.triggered = false;
  125. this._freshing = false;
  126. }, 3000)
  127. },
  128. onRestore() {
  129. this.triggered = 'restore'; // 需要重置
  130. console.log("onRestore");
  131. },
  132. lower(e) {
  133. this.pageNum++
  134. this.updateInit()
  135. },
  136. initPage() {
  137. this.updateAnnList = []
  138. this.pageNum = 1
  139. this.updateInit()
  140. },
  141. // 全部标记已读
  142. allRead() {
  143. this.$u.get('/zkMessage/updateState', { accountId: uni.getStorageSync('weapp_session_userInfo_data').accountId, projectId: uni.getStorageSync('buildingID').id, }).then(res => {
  144. uni.showToast({
  145. title: '全部已读成功!',
  146. duration: 2000
  147. });
  148. this.initPage()
  149. }).catch(e => {
  150. console.log(e)
  151. })
  152. },
  153. updateInit() {
  154. uni.request({
  155. url: config.service.updateList,
  156. method: "GET",
  157. data: {
  158. messageType: this.list[this.current].id,
  159. projectId: uni.getStorageSync('buildingID').id,
  160. id: uni.getStorageSync('weapp_session_userInfo_data').accountId,
  161. num: this.pageNum,
  162. size: this.pageSize
  163. },
  164. header: {
  165. 'content-type': 'application/json',
  166. 'Access-Token': uni.getStorageSync('weapp_session_login_data').token
  167. },
  168. success: (res) => {
  169. // this.updateAnnList = res.data.data.list.results
  170. if (res.data.data == null) {
  171. console.log(11)
  172. uni.showToast({
  173. title: '已经到底了!',
  174. duration: 2000
  175. });
  176. } else {
  177. this.count = res.data.data.sum
  178. if (this.pageNum != 1) {
  179. this.updateAnnList = [...this.updateAnnList, ...res.data.data.list.results];
  180. } else {
  181. this.updateAnnList = res.data.data.list.results
  182. }
  183. }
  184. }
  185. })
  186. },
  187. goDetail(data) {
  188. this.$store.commit('setMessageObj', data)
  189. uni.navigateTo({
  190. url: "./messageDetail"
  191. })
  192. },
  193. // 跳转日报
  194. goReception(data, index) {
  195. this.$store.commit('setMessageObj', data)
  196. if (data.messageType == 2) {
  197. uni.navigateTo({
  198. url: `/pages/mine/reportExcel/weekReport?id=${data.id}`
  199. })
  200. } else {
  201. uni.navigateTo({
  202. url: `/pages/mine/reportExcel/dayReport?id=${data.id}`
  203. })
  204. }
  205. },
  206. change(index) {
  207. this.current = index;
  208. this.initPage()
  209. }
  210. }
  211. }
  212. </script>
  213. <style lang="scss">
  214. .message_list {
  215. width: 100vw;
  216. height: calc(100vh - var(--window-top));
  217. background: #F8F8F8;
  218. display: flex;
  219. flex-direction: column;
  220. .m-nav {
  221. flex-shrink: 0;
  222. padding: 0 30rpx;
  223. width: 100%;
  224. height: 68rpx;
  225. display: flex;
  226. align-items: center;
  227. .m-n-lside {
  228. flex-grow: 1;
  229. display: flex;
  230. align-items: center;
  231. image {
  232. margin-right: 16rpx;
  233. width: 36rpx;
  234. height: 36rpx;
  235. }
  236. }
  237. .m-n-rside {
  238. flex-shrink: 0;
  239. padding: 6rpx 14rpx;
  240. border: 1rpx solid #E0E0E0;
  241. font-size: 24rpx;
  242. }
  243. }
  244. .m-tabs {
  245. flex-shrink: 0;
  246. }
  247. .scroll-Y {
  248. padding: 20rpx 0 0 0;
  249. flex-grow: 1;
  250. overflow-y: scroll;
  251. .upgradeItem {
  252. margin: 0 0 20rpx 0;
  253. padding: 24rpx 30rpx 28rpx;
  254. height: 156rpx;
  255. display: flex;
  256. background: #fff;
  257. .right {
  258. .title {
  259. font-size: 32rpx;
  260. font-weight: bold;
  261. display: flex;
  262. .notRead {
  263. width: 14rpx;
  264. height: 14rpx;
  265. background: #FF0000;
  266. border-radius: 100%;
  267. }
  268. }
  269. .time {
  270. margin: 18rpx 0 0 0;
  271. color: #6f6f6f;
  272. font-size: 24rpx;
  273. }
  274. }
  275. }
  276. }
  277. }
  278. </style>