index.vue 16 KB

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