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

messageList.vue 8.7 KiB

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