index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480
  1. <template>
  2. <view class="visit" v-if="workList.length>0">
  3. <view class="notify-list" v-for="(item,i) in workList" :key="i">
  4. <!-- <view class="card-bg">
  5. <db-list :list="worksList" :path="'/pages/message/content?id='"></db-list>
  6. </view> -->
  7. <view class="list-item" @click="clickItem(item)">
  8. <view class="notify-wrapper">
  9. <view class="title in1line">{{item.title}}</view>
  10. <view class="clear">
  11. <view class="time">{{item.createTime|time}}</view>
  12. <uni-tag class="tag" type="error" :text="item.taskName | notifyTypeFilter" size="small" />
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. </view>
  18. <view v-else class="noMes">
  19. 没有待办工作
  20. </view>
  21. </template>
  22. <script>
  23. import {
  24. worksList
  25. } from '@/api/userInfo';
  26. import rfLoadMore from '@/components/oa-load-more/oa-load-more';
  27. import moment from '@/common/moment';
  28. import $mAssetsPath from '@/config/assets.config';
  29. import oaEmpty from '@/components/oa-empty';
  30. import dbList from '@/components/leo-list/db-list.vue'
  31. export default {
  32. components: {
  33. rfLoadMore,
  34. oaEmpty,
  35. dbList
  36. },
  37. data() {
  38. return {
  39. workList: [],
  40. page: 1,
  41. // cate_id: '',
  42. loadingType: 'more',
  43. loading: true,
  44. hasLogin: false,
  45. moneySymbol: this.moneySymbol,
  46. // 控制滑动效果
  47. theIndex: null,
  48. oldIndex: null
  49. };
  50. },
  51. filters: {
  52. time(val) {
  53. // 拿到当前时间戳和发布时的时间戳,然后得出时间戳差
  54. var curTime = new Date();
  55. var postTime = new Date(val);
  56. var timeDiff = curTime.getTime() - postTime.getTime();
  57. // 单位换算
  58. var min = 60 * 1000;
  59. var hour = min * 60;
  60. var day = hour * 24;
  61. var week = day * 7;
  62. // 计算发布时间距离当前时间的周、天、时、分
  63. var exceedWeek = Math.floor(timeDiff / week);
  64. var exceedDay = Math.floor(timeDiff / day);
  65. var exceedHour = Math.floor(timeDiff / hour);
  66. var exceedMin = Math.floor(timeDiff / min);
  67. // 最后判断时间差到底是属于哪个区间,然后return
  68. if (exceedWeek > 0) {
  69. if (curTime.getFullYear() == postTime.getFullYear()) {
  70. return moment(val).format('MM-DD');
  71. } else {
  72. return moment(val).format('YYYY-MM-DD');
  73. }
  74. } else {
  75. if (exceedDay < 7 && exceedDay > 0) {
  76. return exceedDay + '天前';
  77. } else {
  78. if (exceedHour < 24 && exceedHour > 0) {
  79. return exceedHour + '小时前';
  80. } else {
  81. if(exceedMin<1){
  82. exceedMin=0
  83. }
  84. return exceedMin + '分钟前';
  85. }
  86. }
  87. }
  88. },
  89. notifyTypeFilter(val) {
  90. return val;
  91. }
  92. },
  93. async onShow(options) {
  94. await this.initData();
  95. },
  96. // 下拉刷新
  97. onPullDownRefresh() {
  98. this.page = 1;
  99. this.workList = [];
  100. this.loading = true;
  101. this.getworksList('refresh');
  102. },
  103. // 加载更多
  104. onReachBottom() {
  105. if (this.loadingType === 'nomore') return;
  106. this.page = parseInt(this.page) + 1;
  107. this.getworksList('getmore');
  108. },
  109. methods: {
  110. // 数据初始化
  111. initData() {
  112. this.hasLogin = this.$mStore.getters.hasLogin;
  113. this.page = 1;
  114. this.workList.length = 0;
  115. this.getworksList();
  116. uni.setNavigationBarColor({
  117. frontColor: '#ffffff',
  118. backgroundColor: this.themeColor.color,
  119. animation: {
  120. duration: 400,
  121. timingFunc: 'easeIn'
  122. }
  123. })
  124. },
  125. // 获取资料列表
  126. getworksList(type) {
  127. var that = this;
  128. console.log(66666);
  129. if (!this.hasLogin) {
  130. this.loading = false;
  131. uni.reLaunch({
  132. url: '../public/login'
  133. })
  134. return;
  135. }
  136. var url = this.$mConfig.baseUrl + '/fw/queryDocumentAndNotice';
  137. var token = this.$preToken + ' ' + this.$store.state.accessToken;
  138. this.$http.request({
  139. url: url,
  140. timeout:60*1000*100,
  141. header: {
  142. 'content-type': 'application/json',
  143. 'Authorization': token
  144. },
  145. data: {
  146. pageNum: this.page,
  147. pageSize: 20,
  148. orderByColumn: "ID",
  149. isAsc: "desc",
  150. }
  151. }).then(r => {
  152. this.loading = false;
  153. if (type === 'refresh') {
  154. that.workList = [];
  155. uni.stopPullDownRefresh();
  156. }
  157. if (r.total > that.workList.length + r.rows.length) {
  158. that.loadingType = 'more';
  159. } else {
  160. that.loadingType = 'nomore';
  161. }
  162. that.workList = [...that.workList, ...r.rows];
  163. if (r.total > 0) {
  164. uni.setTabBarBadge({
  165. index: 1,
  166. text: r.total.toString()
  167. })
  168. }else{
  169. uni.removeTabBarBadge({
  170. index:1
  171. })
  172. }
  173. })
  174. },
  175. navToLogin(route) {
  176. this.$mRouter.push({
  177. route
  178. });
  179. },
  180. navTo(route) {
  181. this.$mRouter.push({
  182. route
  183. });
  184. },
  185. clickItem(item) {
  186. if (item.taskName === '文件通知')
  187. this.navTo('/pages/gongwen/content?businessKey=' + item.businessKey + '&qianshou=false')
  188. else
  189. this.navTo('/pages/gongwen/meetingNotice?businessKey=' + item.businessKey + '&qianshou=false')
  190. /* this.navTo('/pages/notify/content?id=' + item.id + '&qianshou=0') */
  191. }
  192. }
  193. };
  194. </script>
  195. <style lang="scss">
  196. page {
  197. background-color: $page-color-base;
  198. }
  199. .noMes {
  200. color: gray;
  201. text-align: center;
  202. margin: 9px;
  203. }
  204. .visit {
  205. .uni-media-list-logo {
  206. width: 180rpx;
  207. height: 140rpx;
  208. }
  209. .uni-media-list-body {
  210. height: auto;
  211. justify-content: space-around;
  212. }
  213. .uni-media-list-text-top {
  214. height: 74rpx;
  215. font-size: 28rpx;
  216. overflow: hidden;
  217. }
  218. .uni-media-list-text-bottom {
  219. display: flex;
  220. flex-direction: row;
  221. justify-content: space-between;
  222. }
  223. .add-round {
  224. position: fixed;
  225. z-index: 999;
  226. right: 30rpx;
  227. bottom: 30rpx;
  228. border-radius: 50%;
  229. width: 120rpx;
  230. height: 120rpx;
  231. color: #fff;
  232. text-align: center;
  233. line-height: 120rpx;
  234. font-weight: 100;
  235. font-size: 80rpx;
  236. }
  237. .notify-list {
  238. border-radius: 5px;
  239. background: $page-color-base;
  240. /* #ifdef APP-PLUS */
  241. //padding-top: var(--status-bar-height);
  242. /* #endif */
  243. /* #ifndef APP-PLUS */
  244. padding-top: 1rpx;
  245. /* #endif */
  246. padding-bottom: 1rpx;
  247. .card-bg {
  248. margin: 0 24rpx;
  249. padding: 0 32rpx 0 0;
  250. background: #ffffff;
  251. border-radius: 20rpx;
  252. box-shadow: 0px 4rpx 20rpx 0rpx rgba(235, 241, 244, 0.35);
  253. }
  254. .read {
  255. text-align: right;
  256. margin-right: $spacing-base;
  257. margin-top: $spacing-base;
  258. margin-bottom: $spacing-sm;
  259. text {
  260. margin-left: $spacing-base;
  261. }
  262. }
  263. .list-item {
  264. margin: 0 24rpx;
  265. //padding: 0 0 30rpx 0;
  266. border-bottom: 1px solid #E5E5E5;
  267. }
  268. .row {
  269. width: calc(94%);
  270. height: calc(22vw + 40upx);
  271. margin: 0 auto $spacing-base;
  272. border-radius: 15upx;
  273. box-shadow: 0upx 5upx 20upx rgba(0, 0, 0, 0.1);
  274. display: flex;
  275. align-items: center;
  276. position: relative;
  277. overflow: hidden;
  278. z-index: 4;
  279. border: 0;
  280. .menu {
  281. .iconfont {
  282. color: #fff;
  283. font-size: 60upx;
  284. }
  285. position: absolute;
  286. width: 29%;
  287. height: 100%;
  288. right: 0;
  289. display: flex;
  290. justify-content: center;
  291. align-items: center;
  292. color: #fff;
  293. z-index: 2;
  294. }
  295. .carrier {
  296. @keyframes showMenu {
  297. 0% {
  298. transform: translateX(0);
  299. }
  300. 100% {
  301. transform: translateX(-30%);
  302. }
  303. }
  304. @keyframes closeMenu {
  305. 0% {
  306. transform: translateX(-30%);
  307. }
  308. 100% {
  309. transform: translateX(0);
  310. }
  311. }
  312. &.open {
  313. animation: showMenu 0.25s linear both;
  314. }
  315. &.close {
  316. animation: closeMenu 0.15s linear both;
  317. }
  318. background-color: #fff;
  319. position: absolute;
  320. width: 100%;
  321. padding: 0 0;
  322. height: 100%;
  323. z-index: 3;
  324. display: flex;
  325. align-items: center;
  326. }
  327. }
  328. // $spacing-base
  329. .notify-wrapper {
  330. background-color: $color-white;
  331. width: 100%;
  332. padding: $spacing-base $spacing-lg $spacing-base $spacing-lg;
  333. margin: 0 0;
  334. border-radius: 15upx;
  335. position: relative;
  336. .title {
  337. //width: 80%;
  338. font-size: $font-lg;
  339. color: $font-color-dark;
  340. font-weight: 500;
  341. margin: 0 0 $spacing-sm;
  342. line-height:1.5;
  343. }
  344. .content {
  345. font-size: $font-sm;
  346. color: $font-color-base;
  347. height: 75upx;
  348. line-height: 36upx;
  349. }
  350. .time {
  351. //position: absolute;
  352. //right: 10upx;
  353. font-size: $font-sm;
  354. color: $font-color-light;
  355. //top:65upx;
  356. width:40%;
  357. float: left;
  358. }
  359. .tag {
  360. //position: absolute;
  361. //top: 20upx;
  362. //right: 10upx;
  363. border: none;
  364. font-size: $font-sm;
  365. opacity: 0.8;
  366. float: right;
  367. }
  368. .clear{clear: both;overflow: hidden;}
  369. .type {
  370. position: absolute;
  371. top: 26upx;
  372. left: -10upx;
  373. border: none;
  374. font-size: $font-sm;
  375. opacity: 0.8;
  376. }
  377. .un-read {
  378. display: inline-block;
  379. width: 12upx;
  380. height: 12upx;
  381. border-radius: 50%;
  382. position: absolute;
  383. top: 32upx;
  384. right: 30upx;
  385. }
  386. }
  387. }
  388. .notify-empty {
  389. position: fixed;
  390. left: 0;
  391. top: 0;
  392. width: 100%;
  393. height: 100vh;
  394. padding-bottom: 100upx;
  395. display: flex;
  396. justify-content: center;
  397. flex-direction: column;
  398. align-items: center;
  399. background: #fff;
  400. .iconfont {
  401. font-size: $font-lg + 100upx;
  402. }
  403. .empty-tips {
  404. display: flex;
  405. font-size: $font-sm + 2upx;
  406. color: $font-color-disabled;
  407. .navigator {
  408. margin-left: 16upx;
  409. }
  410. }
  411. }
  412. .works-empty {
  413. position: fixed;
  414. left: 0;
  415. top: 0;
  416. width: 100%;
  417. height: 100vh;
  418. padding-bottom: 100upx;
  419. display: flex;
  420. justify-content: center;
  421. flex-direction: column;
  422. align-items: center;
  423. background: #fff;
  424. .iconfont {
  425. font-size: $font-lg + 100upx;
  426. }
  427. .empty-tips {
  428. display: flex;
  429. font-size: $font-sm + 2upx;
  430. color: $font-color-disabled;
  431. .navigator {
  432. margin-left: 16upx;
  433. }
  434. }
  435. }
  436. }
  437. </style>