index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662
  1. <template>
  2. <view class="container">
  3. <view>
  4. <!-- <view style="padding: 20rpx;background-color: #fff;border-bottom: 1px solid #eaeaea;">
  5. <u-search v-model="model.mainTitle" placeholder="请输入标题" :showAction="true" actionText="搜索"
  6. :animation="true" @custom="search" @clear="search">
  7. </u-search>
  8. </view> -->
  9. <!-- <view style="height: 400rpx;">
  10. <u-swiper height="400rpx" :list="lbList" keyName="imgUrl" showTitle indicator indicatorMode="line"
  11. @click="info"></u-swiper>
  12. </view> -->
  13. <view>
  14. <view style="background-color: #fff;;padding-bottom: 100rpx">
  15. <view>
  16. <view v-for="(item,index) in listWork" :key="index"
  17. style="padding: 20rpx 40rpx;border-bottom: 1px solid #eaeaea;background-color: #fff;"
  18. @click="getinfo(item)">
  19. <view>
  20. <u--text :lines="2" size="32rpx" :text="item.noticeTitle"></u--text>
  21. </view>
  22. <view
  23. style="display: flex; flex-direction:row;justify-content:space-between;margin-top: 20rpx;color:#909399;font-size: 28rpx;">
  24. <view class="">
  25. {{showtime($u.timeFormat(item.publishTime, 'yyyy-mm-dd'))}}
  26. </view>
  27. <view :style="{color:item.readStatus=='1'?'#2dc225':'red'}" class="">
  28. {{item.readStatus==1?'已读':'未读'}}
  29. </view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <!-- <view style="padding: 20rpx;" v-if="listWork.length> 0">
  35. <u-loadmore :status="status" fontSize="28rpx" />
  36. </view> -->
  37. <div v-if="listWork.length == 0">
  38. <u-empty mode="list" icon="/static/list.png" text="暂无内容" textSize="30rpx"></u-empty>
  39. </div>
  40. </view>
  41. <!-- <u-action-sheet :actions="morelist" :closeOnClickOverlay="true" :closeOnClickAction="true" cancelText="取消"
  42. title="更多" :show="show" @select="selectClick" @close="show = false"></u-action-sheet> -->
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import {
  48. showtime
  49. } from "@/utils/wjw.js"
  50. import dragSort from '@/components/dragSort/dragSort.vue'
  51. export default {
  52. data() {
  53. return {
  54. total: 0,
  55. //加载状态
  56. status: 'loadmore',
  57. listWork: [],
  58. model: {
  59. pageSize: 10,
  60. pageNum: 1,
  61. isAsc: 'Desc',
  62. orderByColumn: 'createTime'
  63. },
  64. //新闻列表
  65. list: [],
  66. //栏目列表
  67. lmlist: [],
  68. //当前tabs索引
  69. current: 0,
  70. //新闻分页列表
  71. fyList: [],
  72. //总页数列表
  73. totalList: [],
  74. //分页状态列表
  75. statusList: [],
  76. //下拉刷新列表
  77. xlList1: [],
  78. xlList2: [],
  79. //轮播图列表
  80. lbList: [],
  81. showtime: showtime,
  82. lmshow: false,
  83. //所有栏目列表
  84. allList: [],
  85. //未关注栏目
  86. wgzlm: [],
  87. //是否保存栏目
  88. save: false
  89. }
  90. },
  91. onLoad() {
  92. // this.getLmList()
  93. // this.getLbList()
  94. // // this.getAllList()
  95. // this.getwgzlm()
  96. // this.needUpdateApp()
  97. this.getWork()
  98. uni.startPullDownRefresh();
  99. },
  100. onShow() {
  101. // this.getUnreadEmail()
  102. // this.getdbNum()
  103. // setTimeout(function() {
  104. // uni.stopPullDownRefresh();
  105. // }, 800);
  106. },
  107. onPullDownRefresh() {
  108. this.getWork();
  109. console.log("refresh");
  110. setTimeout(function() {
  111. uni.stopPullDownRefresh();
  112. }, 800);
  113. },
  114. onReachBottom() {
  115. //触底事件
  116. if (this.model.pageNum * this.model.pageSize >= this.total) {
  117. uni.showToast({
  118. title: "没有更多数据了",
  119. icon: "none",
  120. duration: 1000,
  121. });
  122. setTimeout(() => {
  123. uni.hideLoading();
  124. }, 500);
  125. } else {
  126. if (this.model.pageNum <= this.model.pageNum - 1) {
  127. setTimeout(() => {
  128. uni.hideLoading();
  129. }, 500);
  130. } else {
  131. uni.showLoading({
  132. title: "加载中",
  133. });
  134. this.model.pageNum++;
  135. uni.$u.http.get("/system/notice/list", {
  136. params: this.model
  137. }).then(({
  138. rows,
  139. total
  140. }) => {
  141. this.listWork = [...this.listWork, ...rows];
  142. this.total = total;
  143. });
  144. }
  145. setTimeout(() => {
  146. uni.hideLoading();
  147. }, 500);
  148. }
  149. },
  150. methods: {
  151. //根据标题搜索内容
  152. search() {
  153. uni.showLoading({
  154. title: "搜索中...",
  155. mask: true
  156. })
  157. this.model.pageNum = 1
  158. this.listWork = []
  159. this.getWork()
  160. },
  161. getWork() {
  162. let that = this
  163. uni.$u.http.get("/system/notice/list", {
  164. params: this.model
  165. }).then(res => {
  166. // uni.hideLoading()
  167. this.listWork = res.rows;
  168. this.total = res.total;
  169. })
  170. },
  171. wancheng(e) {
  172. if (e == 'finish') {
  173. let list = []
  174. if (this.lmlist.length != 0) {
  175. this.lmlist[this.current].xlList1 = true
  176. if (this.lmlist[this.current].list == 0) {
  177. this.refresherrefresh(this.current)
  178. }
  179. this.lmlist.forEach(item => {
  180. let obj = {
  181. name: item.name,
  182. id: item.id,
  183. columnCode: item.columnCode
  184. }
  185. list.push(obj);
  186. })
  187. }
  188. uni.$u.http.post('/oa/column/saveFollowCoulumn', list).then(res => {
  189. this.save = true
  190. })
  191. }
  192. },
  193. del(e) {
  194. // uni.$u.http.delete('/system/subscribed/remove/'+e.data.id).then(res=>{
  195. this.getwgzlm()
  196. if (this.current > e.index) {
  197. this.current = this.current - 1
  198. // this.lmlist[this.current].totalList = 0
  199. // this.lmlist[this.current].totalList = 'loadmore'
  200. // this.lmlist[this.current].pageSize = 10
  201. // this.lmlist[this.current].pageNum = 1
  202. // this.lmlist[this.current].xlList1 = true
  203. // this.lmlist[this.current].xlList2= true
  204. // this.getNewsList()
  205. } else if (this.current == 0 && e.index == 0) {
  206. this.lmlist[0].xlList1 = true
  207. // this.lmlist[0].xlList2= true
  208. this.refresherrefresh(0)
  209. }
  210. // })
  211. },
  212. lmOpen() {
  213. this.lmlist[this.current].xlList1 = false
  214. this.$forceUpdate()
  215. },
  216. //点击更多
  217. more() {
  218. this.lmshow = true
  219. },
  220. //获取未读
  221. getUnreadEmail() {
  222. uni.$u.http.get('/system/notice/getCurrUserUnReadNotice').then(res => {
  223. if (res == 0) {
  224. uni.removeTabBarBadge({ //显示数字
  225. index: 1, //tabbar下标
  226. })
  227. } else {
  228. uni.setTabBarBadge({ //显示数字
  229. index: 1, //tabbar下标
  230. text: '' + res + '' //数字
  231. })
  232. }
  233. })
  234. },
  235. //获取所有栏目
  236. getAllList() {
  237. uni.$u.http.get('/oa/column/app/homePage').then(res => {
  238. this.allList = res
  239. })
  240. },
  241. //获取栏目列表
  242. getLmList() {
  243. let that = this
  244. uni.$u.http.get('/oa/column/app/wgzd').then(res => {
  245. this.lmlist = res
  246. for (let i in this.lmlist) {
  247. this.lmlist[i].list = []
  248. this.lmlist[i].totalList = 0
  249. this.lmlist[i].totalList = 'loadmore'
  250. this.lmlist[i].pageSize = 30
  251. this.lmlist[i].pageNum = 1
  252. if (i == 0) {
  253. this.lmlist[i].xlList1 = true
  254. this.lmlist[i].xlList2 = true
  255. uni.showLoading({
  256. title: "加载中...",
  257. })
  258. setTimeout(() => {
  259. this.getNewsList()
  260. }, 1000)
  261. } else {
  262. this.lmlist[i].xlList1 = false
  263. this.lmlist[i].xlList2 = true
  264. }
  265. }
  266. }).catch(error => {
  267. uni.hideLoading()
  268. })
  269. },
  270. //获取新闻列表
  271. getNewsList() {
  272. // uni.hideLoading()
  273. uni.$u.http.get("/oa/article/listByColumnId", {
  274. params: {
  275. pageSize: this.lmlist[this.current].pageSize,
  276. pageNum: this.lmlist[this.current].pageNum,
  277. columnId: this.lmlist[this.current].id,
  278. status: 1
  279. },
  280. header: {
  281. 'content-Type': 'application/x-www-form-urlencoded'
  282. }
  283. }).then(res => {
  284. uni.hideLoading()
  285. this.lmlist[this.current].list = [...this.lmlist[this.current].list, ...res.rows]
  286. this.$forceUpdate()
  287. if (res.total <= this.lmlist[this.current].pageSize) {
  288. this.lmlist[this.current].statusList = "nomore"
  289. } else {
  290. this.lmlist[this.current].statusList = "loadmore"
  291. }
  292. if (this.lmlist[this.current].pageNum == 1) {
  293. this.lmlist[this.current].totalList = Math.ceil(res.total / this.lmlist[this.current]
  294. .pageSize)
  295. }
  296. this.$forceUpdate()
  297. }).catch(error => {
  298. uni.hideLoading()
  299. })
  300. },
  301. //关注栏目
  302. guanzhu(v, i) {
  303. // console.log(v)
  304. uni.showLoading({
  305. title: "请稍等...",
  306. mask: true
  307. })
  308. uni.$u.http.post('/system/subscribed', {
  309. userId: uni.getStorageSync('userInfo').userId,
  310. columnId: v.id
  311. }).then(res => {
  312. let obj = v
  313. obj.list = []
  314. obj.totalList = 0
  315. obj.totalList = 'loadmore'
  316. obj.pageSize = 10
  317. obj.pageNum = 1
  318. obj.xlList1 = false
  319. obj.xlList2 = true
  320. this.lmlist.push(obj)
  321. if (this.lmlist.length == 1) {
  322. this.lower(0)
  323. }
  324. // this.getwgzlm()
  325. this.$forceUpdate()
  326. // this.allList[i].isFollow = '1'
  327. uni.$u.http.get("/oa/column/app/notFollow").then(res => {
  328. // console.log(res)
  329. uni.hideLoading()
  330. uni.showToast({
  331. title: "订阅成功"
  332. })
  333. this.wgzlm = res
  334. })
  335. }).catch((error) => {
  336. uni.showToast({
  337. title: "取消失败",
  338. icon: 'none'
  339. })
  340. })
  341. },
  342. //tabs点击
  343. click(e) {
  344. let qwe = this.current
  345. this.lmlist[qwe].xlList1 = false
  346. this.current = e.index
  347. this.lmlist[this.current].xlList1 = true
  348. },
  349. animationfinish(e) {
  350. let qwe = this.current
  351. this.lmlist[qwe].xlList1 = false
  352. this.current = e.detail.current;
  353. this.lmlist[this.current].xlList1 = true
  354. if (this.lmlist[this.current].list.length == 0) {
  355. uni.showLoading({
  356. title: "加载中...",
  357. })
  358. this.getNewsList()
  359. }
  360. },
  361. //触底加载
  362. lower(e) {
  363. if (this.lmlist[e].pageNum != this.lmlist[e].totalList) {
  364. this.lmlist[e].pageNum++
  365. this.getNewsList()
  366. } else {
  367. this.lmlist[e].statusList = "nomore"
  368. this.$forceUpdate()
  369. }
  370. },
  371. //下拉刷新
  372. refresherrefresh(e) {
  373. this.lmlist[e].xlList2 = true
  374. this.lmlist[e].pageNum = 1
  375. this.lmlist[e].list = []
  376. let a = new Promise((resolve, reject) => {
  377. uni.$u.http.get("/oa/article/listByColumnId", {
  378. params: {
  379. pageSize: this.lmlist[e].pageSize,
  380. pageNum: this.lmlist[e].pageNum,
  381. columnId: this.lmlist[e].id,
  382. status: 1
  383. },
  384. header: {
  385. 'content-Type': 'application/x-www-form-urlencoded'
  386. }
  387. }).then(res => {
  388. uni.hideLoading()
  389. this.lmlist[e].list = [...this.lmlist[e].list, ...res.rows]
  390. // this.$forceUpdate()
  391. if (res.total <= this.lmlist[e].pageSize) {
  392. this.lmlist[e].statusList = "nomore"
  393. } else {
  394. this.lmlist[e].statusList = "loadmore"
  395. }
  396. if (this.lmlist[e].pageNum == 1) {
  397. this.lmlist[e].totalList = Math.ceil(res.total / this.lmlist[e].pageSize)
  398. }
  399. this.$forceUpdate()
  400. resolve('1')
  401. }).catch(error => {
  402. uni.hideLoading()
  403. resolve('2')
  404. })
  405. })
  406. a.then(res => {
  407. setTimeout(() => {
  408. this.lmlist[e].xlList2 = false
  409. this.$forceUpdate()
  410. }, 500)
  411. })
  412. // setTimeout(() => {
  413. // // this.$forceUpdate()
  414. // }, 2000)
  415. },
  416. refresherrestore(e) {
  417. },
  418. //查询轮播图列表
  419. getLbList() {
  420. uni.$u.http.get('/oa/article/listHome?isCarousel=1&pageNum=1&pageSize=100').then(res => {
  421. this.lbList = res.rows
  422. for (let i in res.rows) {
  423. this.lbList[i].imgUrl = getApp().globalData.saveUrl + res.rows[i].imgUrl.split('/public/')[
  424. 1]
  425. }
  426. })
  427. },
  428. //查看轮播详细信息
  429. info(e) {
  430. if (this.lbList[e].urlLink == null) {
  431. uni.navigateTo({
  432. url: "/pages/newsContent/newsContent?id=" + this.lbList[e].id
  433. })
  434. } else {
  435. uni.navigateTo({
  436. url: "/pages/webView/webView?url=" + this.lbList[e].urlLink
  437. })
  438. }
  439. },
  440. //查看文章详情
  441. getinfo(item) {
  442. uni.navigateTo({
  443. url: "/pages/index/Info?id=" + item.noticeId
  444. })
  445. this.getWork()
  446. // if (item.urlLink != null) {
  447. // uni.navigateTo({
  448. // url: "/pages/webView/webView?url=" + item.urlLink
  449. // })
  450. // } else {
  451. // uni.navigateTo({
  452. // url: "/pages/newsContent/newsContent?id=" + item.id
  453. // })
  454. // }
  455. },
  456. //获取关注栏目
  457. getwgzlm() {
  458. uni.$u.http.get("/oa/column/app/notFollow").then(res => {
  459. // console.log(res)
  460. this.wgzlm = res
  461. })
  462. },
  463. //查询待办数量
  464. getdbNum() {
  465. uni.$u.http.get('/jflow/restful/DB_Todolist_Num?token=' + uni.getStorageSync('jtoken')).then(res => {
  466. if (res.code == 200) {
  467. if (res.list.length > 0) {
  468. let qwe = 0
  469. for (let i in res.list) {
  470. if (res.list[i].FK_Flow != '008' && res.list[i].FK_Flow != '021') {
  471. qwe = res.list[i].Total + qwe
  472. }
  473. if (i == res.list.length - 1) {
  474. uni.setTabBarBadge({ //显示数字
  475. index: 0, //tabbar下标
  476. text: '' + qwe + '' //数字
  477. })
  478. }
  479. }
  480. } else {
  481. uni.removeTabBarBadge({ //显示数字
  482. index: 0, //tabbar下标
  483. })
  484. }
  485. }
  486. })
  487. },
  488. //保存栏目顺序
  489. saveLmOrder() {
  490. if (this.save == true) {
  491. this.save = false
  492. this.lmshow = false
  493. } else {
  494. if (this.$refs.dy.cacheList.length != 0) {
  495. this.$refs.dy.toggleEdit('cancel')
  496. this.lmlist[this.current].xlList1 = true
  497. }
  498. this.lmshow = false
  499. }
  500. },
  501. //升级
  502. needUpdateApp(i) {
  503. var _this = this;
  504. plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
  505. uni.showLoading({
  506. title: "检查中...",
  507. mask: true
  508. })
  509. uni.$u.http.post('/app/version/advance/' + wgtinfo.versionCode).then(res => {
  510. if (res.code == 200) {
  511. if (res.data != undefined) {
  512. uni.hideLoading()
  513. uni.showModal({
  514. title: "提示",
  515. content: "有新版本是否进行更新",
  516. success(qwe) {
  517. if (qwe.confirm) {
  518. _this.upgradeApp(getApp().globalData.updateUrl + res
  519. .data.url)
  520. }
  521. }
  522. })
  523. } else {
  524. uni.hideLoading()
  525. // uni.showToast({
  526. // title: "当前为最新版本",
  527. // icon: "none"
  528. // })
  529. }
  530. }
  531. }).catch(res => {
  532. uni.hideLoading()
  533. })
  534. })
  535. },
  536. upgradeApp(url) {
  537. uni.showLoading({
  538. title: '更新中……'
  539. });
  540. uni.downloadFile({
  541. url: url,
  542. success: downloadResult => {
  543. if (downloadResult.statusCode === 200) {
  544. try {
  545. var filePath = downloadResult.tempFilePath;
  546. var ext = filePath.substring(
  547. filePath.lastIndexOf('.') + 1
  548. );
  549. plus.runtime.install(
  550. downloadResult.tempFilePath, {},
  551. function() {
  552. uni.hideLoading()
  553. plus.runtime.restart();
  554. },
  555. function(e) {
  556. // console.log(e);
  557. }
  558. );
  559. } catch (e) {
  560. // console.log(e);
  561. }
  562. } else {
  563. uni.hideLoading()
  564. uni.showToast({
  565. title: "下载失败",
  566. icon: 'none'
  567. })
  568. }
  569. },
  570. fail: res => {
  571. }
  572. });
  573. },
  574. }
  575. }
  576. </script>
  577. <style lang="scss" scoped>
  578. .choose {
  579. border: 1px solid #409EFF !important;
  580. color: #409EFF;
  581. font-weight: bold;
  582. }
  583. .is-ellipsis {
  584. white-space: nowrap;
  585. overflow: hidden;
  586. text-overflow: ellipsis;
  587. }
  588. .dragSort-wrap {}
  589. .dragSortBox {
  590. padding: 20rpx;
  591. }
  592. .dragSortBox-btns {
  593. padding: 20rpx;
  594. margin-bottom: 20rpx;
  595. text-align: right;
  596. color: red;
  597. }
  598. .dragSortBox-btn {
  599. margin-left: 20rpx;
  600. }
  601. .dragSort-area {
  602. width: 100%;
  603. /* background-color: skyblue; */
  604. }
  605. .dragSort-view {
  606. /* background-color: pink; */
  607. background-color: #eee;
  608. text-align: center;
  609. }
  610. .dragSort-view.is-touched {
  611. opacity: .9;
  612. }
  613. .dragSort-view__con {
  614. position: relative;
  615. height: 100%;
  616. }
  617. .dragSort-view__label {
  618. position: absolute;
  619. left: 50%;
  620. top: 50%;
  621. transform: translate(-50%, -50%);
  622. max-width: 100%;
  623. }
  624. .dragSort-view__btn-del {
  625. position: absolute;
  626. right: 0;
  627. top: 0;
  628. transform: translate(50%, -50%);
  629. }
  630. </style>