send.vue 8.9 KB

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