index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. <template>
  2. <view class="container" style="background-color: #fff;">
  3. <view style="height: 100rpx;">
  4. <u-tabs :list="lmlist" :current="current" @click="click"></u-tabs>
  5. </view>
  6. <view style="height: 400rpx;">
  7. <u-swiper height="400rpx"
  8. :list="lbList"
  9. keyName="imgUrl"
  10. showTitle
  11. indicator
  12. indicatorMode="line"
  13. @click="info"
  14. ></u-swiper>
  15. </view>
  16. <!-- <view style="height:calc(100% - 400rpx);"> -->
  17. <view style="height:calc(100vh - 502rpx);">
  18. <swiper style="height: 100%;background-color:#F3F4F6 ;" :current="current" @animationfinish="animationfinish">
  19. <swiper-item v-for="(v,i) in list" :key="i" >
  20. <scroll-view scroll-y style="width: 100%;height: 100%;overflow: auto;box-sizing: border-box;" lower-threshold="10" :refresher-enabled="xlList1[i]" :refresher-triggered="xlList2[i]" @scrolltolower="lower(i)" @refresherrefresh="refresherrefresh(i)" @refresherrestore="refresherrestore(i)">
  21. <view>
  22. <view v-for="item in v" :key="item.id" style="padding: 20rpx 40rpx;border-bottom: 1px solid #eaeaea;background-color: #fff;" @click="getinfo(item)">
  23. <view >
  24. <u--text :lines="2" size="32rpx" :text="item.title"></u--text>
  25. </view>
  26. <view style="display: flex;justify-content: flex-end;margin-top: 20rpx;color:#909399;font-size: 28rpx;">{{showtime($u.timeFormat(item.publishTime, 'yyyy-mm-dd'))}}</view>
  27. </view>
  28. <div style="padding: 10rpx 0;" v-if="v.length > 0">
  29. <u-loadmore :status="statusList[i]" />
  30. </div>
  31. <div v-if="v.length == 0">
  32. <u-empty mode="list" icon="/static/list.png" text="暂无内容" textSize="30rpx"></u-empty>
  33. </div>
  34. </view>
  35. </scroll-view>
  36. </swiper-item>
  37. </swiper>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import {showtime} from "@/utils/wjw.js"
  43. export default {
  44. data() {
  45. return {
  46. //新闻列表
  47. list: [],
  48. //栏目列表
  49. lmlist: [],
  50. //当前tabs索引
  51. current: 0,
  52. //新闻分页列表
  53. fyList: [],
  54. //总页数列表
  55. totalList:[],
  56. //分页状态列表
  57. statusList:[],
  58. //下拉刷新列表
  59. xlList1:[],
  60. xlList2:[],
  61. //轮播图列表
  62. lbList:[],
  63. showtime:showtime
  64. }
  65. },
  66. onLoad() {
  67. this.getLmList()
  68. this.getLbList()
  69. this.needUpdateApp()
  70. },
  71. onShow() {
  72. this.getUnreadEmail()
  73. this.getdbNum()
  74. },
  75. methods: {
  76. //获取未读邮件
  77. getUnreadEmail() {
  78. uni.$u.http.get('/oa/mail/count/unread').then(res => {
  79. if (res == 0) {
  80. uni.removeTabBarBadge({ //显示数字
  81. index: 2, //tabbar下标
  82. })
  83. } else {
  84. uni.setTabBarBadge({ //显示数字
  85. index: 2, //tabbar下标
  86. text: '' + res + '' //数字
  87. })
  88. }
  89. })
  90. },
  91. //获取栏目列表
  92. getLmList() {
  93. let that = this
  94. uni.$u.http.get('/oa/column/list?isAppHomePage=1').then(res => {
  95. this.lmlist = res.rows
  96. for (let i in this.lmlist) {
  97. this.list.push([])
  98. this.totalList.push(0)
  99. this.statusList.push('loadmore')
  100. this.fyList.push({
  101. pageSize: 10,
  102. pageNum: 1,
  103. columnId: this.lmlist[i].id
  104. })
  105. if (i == 0) {
  106. this.xlList1.push(true)
  107. this.xlList2.push(true)
  108. uni.showLoading({
  109. title:"加载中...",
  110. })
  111. setTimeout(()=>{
  112. this.getNewsList()
  113. },1000)
  114. }else{
  115. this.xlList1.push(false)
  116. this.xlList2.push(true)
  117. }
  118. }
  119. }).catch(error=>{
  120. uni.hideLoading()
  121. })
  122. },
  123. //获取新闻列表
  124. getNewsList() {
  125. // console.log(this.fyList[this.current])
  126. uni.hideLoading()
  127. uni.$u.http.get("/oa/article/listByColumnId", {
  128. params: this.fyList[this.current],
  129. header: {
  130. // 'Content-Type': 'multipart/form-data'
  131. 'content-Type': 'application/x-www-form-urlencoded'
  132. }
  133. }).then(res => {
  134. uni.hideLoading()
  135. this.list[this.current] = [...this.list[this.current],...res.rows]
  136. if(res.total<=this.fyList[this.current].pageSize){
  137. this.statusList[this.current] = "nomore"
  138. }else{
  139. this.statusList[this.current] = "loadmore"
  140. }
  141. this.totalList[this.current] = Math.ceil(res.total / this.fyList[this.current].pageSize)
  142. this.$forceUpdate()
  143. }).catch(error=>{
  144. uni.hideLoading()
  145. })
  146. },
  147. //tabs点击
  148. click(e) {
  149. let qwe = this.current
  150. this.xlList1[qwe] = false
  151. this.current = e.index
  152. this.xlList1[this.current] = true
  153. },
  154. animationfinish(e) {
  155. let qwe = this.current
  156. this.xlList1[qwe] = false
  157. this.current = e.detail.current;
  158. this.xlList1[this.current] = true
  159. if(this.list[this.current].length == 0){
  160. uni.showLoading({
  161. title:"加载中...",
  162. })
  163. this.getNewsList()
  164. }
  165. },
  166. //触底加载
  167. lower(e){
  168. if(this.fyList[e].pageNum != this.totalList[e] ){
  169. this.fyList[e].pageNum++
  170. this.getNewsList()
  171. }else{
  172. this.statusList[e] = "nomore"
  173. this.$forceUpdate()
  174. }
  175. },
  176. //下拉刷新
  177. refresherrefresh(e){
  178. this.xlList2[this.current] = true
  179. this.fyList[e].pageNum = 1
  180. this.list[e] = []
  181. this.getNewsList()
  182. setTimeout(()=>{
  183. this.xlList2[this.current] = false
  184. this.$forceUpdate()
  185. },2000)
  186. },
  187. refresherrestore(e){
  188. },
  189. //查询轮播图列表
  190. getLbList(){
  191. uni.$u.http.get('/oa/article/listHome?isCarousel=1&pageNum=1&pageSize=100').then(res=>{
  192. this.lbList = res.rows
  193. for(let i in res.rows){
  194. this.lbList[i].imgUrl = getApp().globalData.saveUrl+res.rows[i].imgUrl.split('/public/')[1]
  195. }
  196. })
  197. },
  198. //查看轮播详细信息
  199. info(e){
  200. if(this.lbList[e].urlLink == null){
  201. uni.navigateTo({
  202. url:"/pages/newsContent/newsContent?id="+this.lbList[e].id
  203. })
  204. }else{
  205. uni.navigateTo({
  206. url:"/pages/webView/webView?url="+this.lbList[e].urlLink
  207. })
  208. }
  209. },
  210. //查看文章详情
  211. getinfo(item){
  212. if(item.urlLink != null){
  213. uni.navigateTo({
  214. url:"/pages/webView/webView?url="+item.urlLink
  215. })
  216. }else{
  217. uni.navigateTo({
  218. url:"/pages/newsContent/newsContent?id="+item.id
  219. })
  220. }
  221. },
  222. //查询待办数量
  223. getdbNum(){
  224. uni.$u.http.get('/jflow/restful/DB_Todolist_Num?token='+uni.getStorageSync('jtoken')).then(res=>{
  225. if(res.code==200){
  226. if (res.list.length > 0) {
  227. let qwe = 0
  228. for(let i in res.list){
  229. if(res.list[i].FK_Flow != '008' && res.list[i].FK_Flow != '009'){
  230. qwe = res.list[i].Total + qwe
  231. }
  232. if(i == res.list.length-1){
  233. uni.setTabBarBadge({ //显示数字
  234. index: 1, //tabbar下标
  235. text: '' + qwe + '' //数字
  236. })
  237. }
  238. }
  239. } else {
  240. uni.removeTabBarBadge({ //显示数字
  241. index: 1, //tabbar下标
  242. })
  243. }
  244. }
  245. })
  246. },
  247. //升级
  248. needUpdateApp(i) {
  249. var _this = this;
  250. plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
  251. uni.showLoading({
  252. title:"检查中...",
  253. mask:true
  254. })
  255. uni.$u.http.post('/app/version/advance/'+wgtinfo.versionCode).then(res => {
  256. if(res.code==200){
  257. if(res.data != undefined){
  258. uni.hideLoading()
  259. uni.showModal({
  260. title:"提示",
  261. content:"有新版本是否进行更新",
  262. success(qwe){
  263. if(qwe.confirm){
  264. _this.upgradeApp(getApp().globalData.updateUrl+res.data.url)
  265. }
  266. }
  267. })
  268. }else{
  269. uni.hideLoading()
  270. uni.showToast({
  271. title:"当前为最新版本",
  272. icon:"none"
  273. })
  274. }
  275. }
  276. }).catch(res=>{
  277. uni.hideLoading()
  278. })
  279. })
  280. },
  281. upgradeApp(url) {
  282. uni.showLoading({
  283. title: '更新中……'
  284. });
  285. uni.downloadFile({
  286. url: url,
  287. success: downloadResult => {
  288. if (downloadResult.statusCode === 200) {
  289. try {
  290. var filePath = downloadResult.tempFilePath;
  291. var ext = filePath.substring(
  292. filePath.lastIndexOf('.') + 1
  293. );
  294. plus.runtime.install(
  295. downloadResult.tempFilePath, {},
  296. function() {
  297. uni.hideLoading()
  298. plus.runtime.restart();
  299. },
  300. function(e) {
  301. // console.log(e);
  302. }
  303. );
  304. } catch (e) {
  305. // console.log(e);
  306. }
  307. }else{
  308. uni.hideLoading()
  309. uni.showToast({
  310. title:"下载失败",
  311. icon:'none'
  312. })
  313. }
  314. },
  315. fail: res => {
  316. }
  317. });
  318. }
  319. }
  320. }
  321. </script>
  322. <style lang="scss" scoped>
  323. </style>