recive.vue 8.8 KB

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