AI销管
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

367 řádky
8.6 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. <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. }
  175. uni.request({
  176. url: config.service.updateList,
  177. method: "GET",
  178. data: obj,
  179. header: {
  180. 'content-type': 'application/json',
  181. 'Authorization': 'Bearer ' + uni.getStorageSync('weapp_session_login_data').token
  182. },
  183. success: (res) => {
  184. if (res.data.data) {
  185. if (this.pageNum != 1) {
  186. this.updateAnnList = [...this.updateAnnList, ...res.data.data.list.results];
  187. } else {
  188. this.updateAnnList = res.data.data.list.records || []
  189. }
  190. }
  191. },
  192. fail: e => {
  193. console.log(e)
  194. }
  195. })
  196. },
  197. goDetail(data) {
  198. this.$store.commit('setMessageObj', data)
  199. uni.navigateTo({
  200. url: "./messageDetail"
  201. })
  202. },
  203. // 获取未读消息数量
  204. getMessageNotRed() {
  205. uni.request({
  206. url: config.service.notReadNum,
  207. method: "GET",
  208. data: {
  209. id: uni.getStorageSync('weapp_session_userInfo_data').accountId,
  210. projectId: uni.getStorageSync('buildingID').id,
  211. },
  212. header: {
  213. 'content-type': 'application/json',
  214. 'Authorization': 'Bearer ' + uni.getStorageSync('weapp_session_login_data').token
  215. },
  216. success: (res) => {
  217. this.count = res.data.data || 0
  218. }
  219. })
  220. },
  221. // 跳转日报
  222. goReception(data, index) {
  223. this.$store.commit('setMessageObj', data)
  224. data.readFlag = 1
  225. if (data.messageType == 2) {
  226. uni.navigateTo({
  227. url: `/pages/reportExcel/weekReport?id=${data.id}`
  228. })
  229. } else {
  230. uni.navigateTo({
  231. url: `/pages/reportExcel/dayReport?id=${data.id}`
  232. })
  233. }
  234. },
  235. fomatDate(date) {
  236. if (!date) return '--'
  237. let arr = date.split(' ')
  238. let str = arr[0]
  239. let result = str.split('-')
  240. return `${result[1]}月${result[2]}日`
  241. },
  242. // 转换时间
  243. getTimeLine(date, type = 1) {
  244. let resu = '--'
  245. if (!date) return resu
  246. let time = new Date(date.replace(/-/g, '/'))
  247. time.setDate(time.getDate() - 7)
  248. let arr = date.split(' ')
  249. let str = arr[0]
  250. let result = str.split('-')
  251. let m = (time.getMonth() + 1) < 10 ? `0${time.getMonth() + 1}` : (time.getMonth() + 1)
  252. let d = time.getDate() < 10 ? `0${time.getDate()}` : time.getDate()
  253. if (type == 1) {
  254. resu = `${m}.${d}-${result[1]}.${result[2]}`
  255. } else {
  256. resu = `${m}月${d}日~${result[1]}月${result[2]}日`
  257. }
  258. return resu
  259. },
  260. change(index) {
  261. this.current = index;
  262. this.initPage()
  263. }
  264. }
  265. }
  266. </script>
  267. <style lang="scss">
  268. .message_list {
  269. width: 100vw;
  270. height: calc(100vh - var(--window-top));
  271. background: #F8F8F8;
  272. display: flex;
  273. flex-direction: column;
  274. .m-nav {
  275. flex-shrink: 0;
  276. padding: 0 30rpx;
  277. width: 100%;
  278. height: 68rpx;
  279. display: flex;
  280. align-items: center;
  281. .m-n-lside {
  282. flex-grow: 1;
  283. display: flex;
  284. align-items: center;
  285. image {
  286. margin-right: 16rpx;
  287. width: 36rpx;
  288. height: 36rpx;
  289. }
  290. }
  291. .m-n-rside {
  292. flex-shrink: 0;
  293. padding: 6rpx 14rpx;
  294. border: 1rpx solid #E0E0E0;
  295. font-size: 24rpx;
  296. }
  297. }
  298. .m-tabs {
  299. flex-shrink: 0;
  300. }
  301. .scroll-Y {
  302. padding: 20rpx 0 0 0;
  303. flex-grow: 1;
  304. overflow-y: scroll;
  305. .upgradeItem {
  306. margin: 0 0 20rpx 0;
  307. padding: 24rpx 30rpx 28rpx;
  308. height: 156rpx;
  309. display: flex;
  310. background: #fff;
  311. .right {
  312. .title {
  313. font-size: 32rpx;
  314. font-weight: bold;
  315. display: flex;
  316. .notRead {
  317. width: 14rpx;
  318. height: 14rpx;
  319. background: #FF0000;
  320. border-radius: 100%;
  321. }
  322. }
  323. .time {
  324. margin: 18rpx 0 0 0;
  325. color: #6f6f6f;
  326. font-size: 24rpx;
  327. }
  328. }
  329. }
  330. }
  331. }
  332. </style>