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