123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335 |
- <template>
- <view class="container" style="background-color: #fff;">
- <view style="height: 100rpx;">
- <u-tabs :list="lmlist" :current="current" @click="click"></u-tabs>
- </view>
- <view style="height: 400rpx;">
- <u-swiper height="400rpx"
- :list="lbList"
- keyName="imgUrl"
- showTitle
- indicator
- indicatorMode="line"
- @click="info"
- ></u-swiper>
- </view>
- <!-- <view style="height:calc(100% - 400rpx);"> -->
- <view style="height:calc(100vh - 502rpx);">
- <swiper style="height: 100%;background-color:#F3F4F6 ;" :current="current" @animationfinish="animationfinish">
- <swiper-item v-for="(v,i) in list" :key="i" >
- <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)">
- <view>
- <view v-for="item in v" :key="item.id" style="padding: 20rpx 40rpx;border-bottom: 1px solid #eaeaea;background-color: #fff;" @click="getinfo(item)">
- <view >
- <u--text :lines="2" size="32rpx" :text="item.title"></u--text>
- </view>
- <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>
- </view>
- <div style="padding: 10rpx 0;" v-if="v.length > 0">
- <u-loadmore :status="statusList[i]" />
- </div>
- <div v-if="v.length == 0">
- <u-empty mode="list" icon="/static/list.png" text="暂无内容" textSize="30rpx"></u-empty>
- </div>
- </view>
- </scroll-view>
- </swiper-item>
- </swiper>
- </view>
- </view>
- </template>
- <script>
- import {showtime} from "@/utils/wjw.js"
- export default {
- data() {
- return {
- //新闻列表
- list: [],
- //栏目列表
- lmlist: [],
- //当前tabs索引
- current: 0,
- //新闻分页列表
- fyList: [],
- //总页数列表
- totalList:[],
- //分页状态列表
- statusList:[],
- //下拉刷新列表
- xlList1:[],
- xlList2:[],
- //轮播图列表
- lbList:[],
- showtime:showtime
- }
- },
- onLoad() {
- this.getLmList()
- this.getLbList()
- this.needUpdateApp()
- },
- onShow() {
- this.getUnreadEmail()
- this.getdbNum()
- },
- methods: {
- //获取未读邮件
- getUnreadEmail() {
- uni.$u.http.get('/oa/mail/count/unread').then(res => {
- if (res == 0) {
- uni.removeTabBarBadge({ //显示数字
- index: 2, //tabbar下标
- })
- } else {
- uni.setTabBarBadge({ //显示数字
- index: 2, //tabbar下标
- text: '' + res + '' //数字
- })
- }
- })
- },
- //获取栏目列表
- getLmList() {
- let that = this
- uni.$u.http.get('/oa/column/list?isAppHomePage=1').then(res => {
- this.lmlist = res.rows
- for (let i in this.lmlist) {
- this.list.push([])
- this.totalList.push(0)
- this.statusList.push('loadmore')
-
- this.fyList.push({
- pageSize: 10,
- pageNum: 1,
- columnId: this.lmlist[i].id
- })
- if (i == 0) {
- this.xlList1.push(true)
- this.xlList2.push(true)
- uni.showLoading({
- title:"加载中...",
- })
- setTimeout(()=>{
- this.getNewsList()
- },1000)
- }else{
- this.xlList1.push(false)
- this.xlList2.push(true)
- }
- }
- }).catch(error=>{
- uni.hideLoading()
- })
- },
- //获取新闻列表
- getNewsList() {
- // console.log(this.fyList[this.current])
- uni.hideLoading()
- uni.$u.http.get("/oa/article/listByColumnId", {
- params: this.fyList[this.current],
- header: {
- // 'Content-Type': 'multipart/form-data'
- 'content-Type': 'application/x-www-form-urlencoded'
- }
- }).then(res => {
- uni.hideLoading()
- this.list[this.current] = [...this.list[this.current],...res.rows]
- if(res.total<=this.fyList[this.current].pageSize){
- this.statusList[this.current] = "nomore"
- }else{
- this.statusList[this.current] = "loadmore"
- }
- this.totalList[this.current] = Math.ceil(res.total / this.fyList[this.current].pageSize)
- this.$forceUpdate()
- }).catch(error=>{
- uni.hideLoading()
- })
- },
- //tabs点击
- click(e) {
- let qwe = this.current
- this.xlList1[qwe] = false
- this.current = e.index
- this.xlList1[this.current] = true
-
- },
- animationfinish(e) {
- let qwe = this.current
- this.xlList1[qwe] = false
- this.current = e.detail.current;
- this.xlList1[this.current] = true
- if(this.list[this.current].length == 0){
- uni.showLoading({
- title:"加载中...",
- })
- this.getNewsList()
- }
- },
- //触底加载
- lower(e){
- if(this.fyList[e].pageNum != this.totalList[e] ){
- this.fyList[e].pageNum++
- this.getNewsList()
- }else{
- this.statusList[e] = "nomore"
- this.$forceUpdate()
- }
- },
- //下拉刷新
- refresherrefresh(e){
- this.xlList2[this.current] = true
- this.fyList[e].pageNum = 1
- this.list[e] = []
- this.getNewsList()
- setTimeout(()=>{
- this.xlList2[this.current] = false
- this.$forceUpdate()
- },2000)
-
- },
- refresherrestore(e){
-
- },
- //查询轮播图列表
- getLbList(){
- uni.$u.http.get('/oa/article/listHome?isCarousel=1&pageNum=1&pageSize=100').then(res=>{
- this.lbList = res.rows
- for(let i in res.rows){
- this.lbList[i].imgUrl = getApp().globalData.saveUrl+res.rows[i].imgUrl.split('/public/')[1]
- }
- })
- },
- //查看轮播详细信息
- info(e){
- if(this.lbList[e].urlLink == null){
- uni.navigateTo({
- url:"/pages/newsContent/newsContent?id="+this.lbList[e].id
- })
- }else{
- uni.navigateTo({
- url:"/pages/webView/webView?url="+this.lbList[e].urlLink
- })
- }
-
- },
- //查看文章详情
- getinfo(item){
- if(item.urlLink != null){
- uni.navigateTo({
- url:"/pages/webView/webView?url="+item.urlLink
- })
- }else{
- uni.navigateTo({
- url:"/pages/newsContent/newsContent?id="+item.id
- })
- }
-
- },
- //查询待办数量
- getdbNum(){
- uni.$u.http.get('/jflow/restful/DB_Todolist_Num?token='+uni.getStorageSync('jtoken')).then(res=>{
- if(res.code==200){
- if (res.list.length > 0) {
- let qwe = 0
- for(let i in res.list){
- if(res.list[i].FK_Flow != '008' && res.list[i].FK_Flow != '009'){
- qwe = res.list[i].Total + qwe
- }
- if(i == res.list.length-1){
- uni.setTabBarBadge({ //显示数字
- index: 1, //tabbar下标
- text: '' + qwe + '' //数字
- })
- }
- }
- } else {
- uni.removeTabBarBadge({ //显示数字
- index: 1, //tabbar下标
- })
- }
- }
-
- })
- },
- //升级
- needUpdateApp(i) {
- var _this = this;
- plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
- uni.showLoading({
- title:"检查中...",
- mask:true
- })
- uni.$u.http.post('/app/version/advance/'+wgtinfo.versionCode).then(res => {
- if(res.code==200){
- if(res.data != undefined){
- uni.hideLoading()
- uni.showModal({
- title:"提示",
- content:"有新版本是否进行更新",
- success(qwe){
-
- if(qwe.confirm){
- _this.upgradeApp(getApp().globalData.updateUrl+res.data.url)
- }
- }
- })
- }else{
- uni.hideLoading()
- uni.showToast({
- title:"当前为最新版本",
- icon:"none"
- })
- }
- }
- }).catch(res=>{
- uni.hideLoading()
- })
- })
- },
- upgradeApp(url) {
- uni.showLoading({
- title: '更新中……'
- });
- uni.downloadFile({
- url: url,
- success: downloadResult => {
- if (downloadResult.statusCode === 200) {
- try {
- var filePath = downloadResult.tempFilePath;
- var ext = filePath.substring(
- filePath.lastIndexOf('.') + 1
- );
- plus.runtime.install(
- downloadResult.tempFilePath, {},
- function() {
- uni.hideLoading()
- plus.runtime.restart();
- },
- function(e) {
- // console.log(e);
- }
- );
- } catch (e) {
- // console.log(e);
- }
- }else{
- uni.hideLoading()
- uni.showToast({
- title:"下载失败",
- icon:'none'
- })
- }
- },
- fail: res => {
-
- }
- });
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- </style>
|