mysend.vue 9.1 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.fwtitle}}</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. if (type === 'refresh') uni.stopPullDownRefresh();
  130. uni.reLaunch({
  131. url: '../public/login'
  132. })
  133. return;
  134. }
  135. var url = this.$mConfig.baseUrl + '/fw/applyFor';
  136. var token = this.$preToken + ' ' + this.$store.state.accessToken;
  137. this.$http.request({
  138. url: url,
  139. header: {
  140. 'content-type': 'application/json',
  141. 'Authorization': token
  142. },
  143. data: {
  144. pageNum: this.page,
  145. pageSize: this.pageSize,
  146. orderByColumn: "createTime",
  147. isAsc: "desc",
  148. title:ser
  149. }
  150. }).then(r => {
  151. this.loading = false;
  152. if (type === 'refresh') {
  153. uni.stopPullDownRefresh();
  154. this.worksList = [...this.worksList, ...r.rows];
  155. } else if (type === 'search') {
  156. this.worksList = r.rows;
  157. } else {
  158. this.worksList = [...this.worksList, ...r.rows];
  159. }
  160. if (r.total > that.worksList.length) {
  161. that.loadingType = 'more';
  162. } else {
  163. that.loadingType = 'nomore';
  164. }
  165. })
  166. .catch(() => {
  167. this.loading = false;
  168. if (type === 'refresh') {
  169. uni.stopPullDownRefresh();
  170. }
  171. });
  172. },
  173. navToLogin(route) {
  174. this.$mRouter.push({
  175. route
  176. });
  177. },
  178. navTo(item) {
  179. var route=''
  180. if (item.taskName === '文件通知')
  181. route = '/pages/gongwen/content?businessKey='+item.businessKey+'&qianshou=true&ismine=true&isme=true'
  182. else
  183. route = '/pages/gongwen/meetingNotice?businessKey='+item.businessKey+'&qianshou=true&ismine=true&isme=true'
  184. this.$mRouter.push({
  185. route
  186. });
  187. },
  188. search(e){
  189. this.searchTitle = e;
  190. this.getworksList('search',e);
  191. },
  192. cancel(){
  193. this.searchTitle = null;
  194. this.getworksList('search');
  195. }
  196. }
  197. };
  198. </script>
  199. <style lang="scss">
  200. page {
  201. background-color: $page-color-base;
  202. }
  203. .noMes {
  204. color: gray;
  205. text-align: center;
  206. margin: 9px;
  207. }
  208. .visit {
  209. .uni-media-list-logo {
  210. width: 180rpx;
  211. height: 140rpx;
  212. }
  213. .uni-media-list-body {
  214. height: auto;
  215. justify-content: space-around;
  216. }
  217. .uni-media-list-text-top {
  218. height: 74rpx;
  219. font-size: 28rpx;
  220. overflow: hidden;
  221. }
  222. .uni-media-list-text-bottom {
  223. display: flex;
  224. flex-direction: row;
  225. justify-content: space-between;
  226. }
  227. .add-round {
  228. position: fixed;
  229. z-index: 999;
  230. right: 30rpx;
  231. bottom: 30rpx;
  232. border-radius: 50%;
  233. width: 120rpx;
  234. height: 120rpx;
  235. color: #fff;
  236. text-align: center;
  237. line-height: 120rpx;
  238. font-weight: 100;
  239. font-size: 80rpx;
  240. }
  241. .notify-list {
  242. margin-top: 20upx;
  243. .read {
  244. text-align: right;
  245. margin-right: $spacing-base;
  246. margin-top: $spacing-base;
  247. margin-bottom: $spacing-sm;
  248. text {
  249. margin-left: $spacing-base;
  250. }
  251. }
  252. .row {
  253. width: calc(94%);
  254. height:22vw;
  255. margin: 0 auto $spacing-base;
  256. border-radius: 15upx;
  257. box-shadow: 0upx 5upx 20upx rgba(0, 0, 0, 0.1);
  258. display: flex;
  259. align-items: center;
  260. position: relative;
  261. overflow: hidden;
  262. z-index: 4;
  263. border: 0;
  264. .menu {
  265. .iconfont {
  266. color: #fff;
  267. font-size: 60upx;
  268. }
  269. position: absolute;
  270. width: 29%;
  271. height: 100%;
  272. right: 0;
  273. display: flex;
  274. justify-content: center;
  275. align-items: center;
  276. color: #fff;
  277. z-index: 2;
  278. }
  279. .carrier {
  280. @keyframes showMenu {
  281. 0% {
  282. transform: translateX(0);
  283. }
  284. 100% {
  285. transform: translateX(-30%);
  286. }
  287. }
  288. @keyframes closeMenu {
  289. 0% {
  290. transform: translateX(-30%);
  291. }
  292. 100% {
  293. transform: translateX(0);
  294. }
  295. }
  296. &.open {
  297. animation: showMenu 0.25s linear both;
  298. }
  299. &.close {
  300. animation: closeMenu 0.15s linear both;
  301. }
  302. background-color: #fff;
  303. position: absolute;
  304. width: 100%;
  305. padding: 0 0;
  306. height: 100%;
  307. z-index: 3;
  308. display: flex;
  309. align-items: center;
  310. }
  311. }
  312. .notify-wrapper {
  313. background-color: $color-white;
  314. width: 100%;
  315. padding: 0 $spacing-lg;
  316. //margin: $spacing-base 0 0;
  317. border-radius: 15upx;
  318. position: relative;
  319. .title {
  320. width:80%;
  321. font-size: $font-lg;
  322. color: $font-color-dark;
  323. font-weight: 500;
  324. margin: 0 0 $spacing-sm;
  325. }
  326. .content {
  327. font-size: $font-sm;
  328. color: $font-color-base;
  329. height: 75upx;
  330. line-height: 36upx;
  331. }
  332. .time {
  333. float:right;
  334. font-size: $font-base;
  335. color: $font-color-light;
  336. }
  337. .tag {
  338. position: absolute;
  339. top: 26upx;
  340. right: 10upx;
  341. border: none;
  342. font-size: $font-sm;
  343. opacity: 0.8;
  344. }
  345. .type {
  346. position: absolute;
  347. top: 26upx;
  348. left: -10upx;
  349. border: none;
  350. font-size: $font-sm;
  351. opacity: 0.8;
  352. }
  353. .un-read {
  354. display: inline-block;
  355. width: 12upx;
  356. height: 12upx;
  357. border-radius: 50%;
  358. position: absolute;
  359. top: 32upx;
  360. right: 30upx;
  361. }
  362. }
  363. }
  364. .notify-empty {
  365. position: fixed;
  366. left: 0;
  367. top: 0;
  368. width: 100%;
  369. height: 100vh;
  370. padding-bottom: 100upx;
  371. display: flex;
  372. justify-content: center;
  373. flex-direction: column;
  374. align-items: center;
  375. background: #fff;
  376. .iconfont {
  377. font-size: $font-lg + 100upx;
  378. }
  379. .empty-tips {
  380. display: flex;
  381. font-size: $font-sm + 2upx;
  382. color: $font-color-disabled;
  383. .navigator {
  384. margin-left: 16upx;
  385. }
  386. }
  387. }
  388. .works-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. }
  413. </style>