yblist.vue 9.0 KB

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