send.vue 8.5 KB

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