Files

719 lines
20 KiB
Vue
Executable File

<template>
<view class="home">
<view class="topBar">
<view class="topBar-text">首页</view>
<view class="msg" @click="msgClick">
<image class="msg-img" src="../../../static/home/msg.png"/>
<text class="msg-text">{{count}}</text>
</view>
</view>
<!-- <view class="home-swiper" style="margin-top: 199.27rpx;">
<swiper :style="{'height':bannerHeight+'px'}" class="swiper" :autoplay="true" :indicator-dots="true" :interval="2000" :duration="500" circular="true"
previous-margin="24px" next-margin="24px" indicator-active-color="#FFFFFF" indicator-color="#BFBFBF"
@change="bannerChange">
<swiper-item v-if="listBanner.length>0" :class="[currentBanner==index?'swiper-item':'swiper-item-banner']"
v-for="(item,index) in listBanner" :key='index'>
<image :src="'data:image/jpeg;base64,'+item.FIMAGEBASE64"
:style="{'height':(currentBanner==index?bannerHeight+'px':bannerHeight*0.8+'px')}"
:class="[currentBanner==index?'swiper-item-image':'swiper-item-banner-image']" />
</swiper-item>
<swiper-item v-if="listBanner.length==0" :class="[currentBanner==index?'swiper-item':'swiper-item-banner']"
v-for="(item,index) in listBannerBlank" :key='index'>
<image :src="item.url" :style="{'height':(currentBanner==index?bannerHeight+'px':bannerHeight*0.8+'px')}"
:class="[currentBanner==index?'swiper-item-image':'swiper-item-banner-image']" />
</swiper-item>
</swiper>
</view> -->
<view class="home-news-title" style="margin-top: 199.27rpx;">
<text class="news-info">新闻资讯</text>
<text class="news-more">更多</text>
</view>
<view class="home-news">
<view class="home-news-detail">
<scroll-view scroll-x="true" show-scrollbar="false">
<view class="home-news-detail-outline">
<view class="home-news-detail-item" v-if="listNews.length>0"
v-for="(item,index) in listNews" :key='index'>
<image class="home-news-detail-item-img" :src="'data:image/jpeg;base64,'+item.FImage"
:style="{'height':newsHeight+'px','width':newsWidth+'px'}"/>
<view class="home-news-detail-item-text" :style="{'width':newsWidth-2+'px'}">
<text class="home-news-detail-item-text-title">{{item.FName}}</text>
<text class="home-news-detail-item-text-time">{{item.C_YMD}}</text>
</view>
</view>
<view class="home-news-detail-item" v-if="listNews.length==0"
v-for="(item,index) in listNewsBlank" :key='index'>
<image class="home-news-detail-item-img" src="../../../static/home/news1.png"
:style="{'height':newsHeight+'px','width':newsWidth+'px'}"/>
<view class="home-news-detail-item-text" :style="{'width':newsWidth-2+'px'}">
<text class="home-news-detail-item-text-title">{{item.FName}}</text>
<text class="home-news-detail-item-text-time">{{item.C_YMD}}</text>
</view>
</view>
</view>
</scroll-view>
</view>
</view>
<view class="home-apply">
<view class="home-news-title">
<text class="news-info">常用应用</text>
</view>
<view class="home-apply-item">
<uni-grid :column="4" :show-border="false" :square="false">
<uni-grid-item v-for="(subitem ,subindex) in comList" :key="subindex">
<view class="grid-item-box" @click="NavigateApplyKanban(subitem)" v-if="subitem.PrgType== 4">
<image class="image" src="../../../static/icon/unchecked.png" />
<text class="text">{{subitem.NAME}}</text>
</view>
<view class="grid-item-box" @click="NavigateApply(subitem.KEY)" v-else>
<image class="image" :src="require('../../../static/icon/'+subitem.KEY+'.png')" />
<text class="text">{{subitem.NAME}}</text>
</view>
</uni-grid-item>
<uni-grid-item>
<view class="grid-item-box" @click="PageNavigate">
<image class="image" src="../../../static/com/more.png" />
<text class="text">应用设置</text>
</view>
</uni-grid-item>
</uni-grid>
</view>
</view>
<view class="tabBar">
<view class="tabBar-item" @click="mainSelectF">
<view v-show="mainSelect" class="tabBar-item-view">
<image class="tabBar-item-img" src="../../../static/tabbar/home.png"></image>
<text class="tabBar-item-text" style="color:#007AFF">首页</text>
</view>
<view v-show="!mainSelect" class="tabBar-item-view">
<image class="tabBar-item-img" src="../../../static/tabbar/home.png"></image>
<text class="tabBar-item-text" style="color: #666666;">首页</text>
</view>
</view>
<view class="tabBar-item" @click="applySelectF">
<view v-show="applySelect" class="tabBar-item-view">
<image class="tabBar-item-img" src="../../../static/tabbar/apply.png"></image>
<text class="tabBar-item-text" style="color:#007AFF">应用</text>
</view>
<view v-show="!applySelect" class="tabBar-item-view">
<image class="tabBar-item-img" src="../../../static/tabbar/apply.png"></image>
<text class="tabBar-item-text" style="color: #666666;">应用</text>
</view>
</view>
<!-- <view class="tabBar-item" @click="cleandarSelectF">
<view v-show="cleandarSelect" class="tabBar-item-view">
<image class="tabBar-item-img" src="../../../static/tabbar/cleandar.png"></image>
<text class="tabBar-item-text" style="color:#007AFF">日程</text>
</view>
<view v-show="!cleandarSelect" class="tabBar-item-view">
<image class="tabBar-item-img" src="../../../static/tabbar/cleandar.png"></image>
<text class="tabBar-item-text" style="color: #666666;">日程</text>
</view>
</view> -->
<view class="tabBar-item" @click="mySelectF">
<view v-show="mySelect" class="tabBar-item-view">
<image class="tabBar-item-img" src="../../../static/tabbar/my.png"></image>
<text class="tabBar-item-text" style="color:#007AFF">我的</text>
</view>
<view v-show="!mySelect" class="tabBar-item-view">
<image class="tabBar-item-img" src="../../../static/tabbar/my.png"></image>
<text class="tabBar-item-text" style="color: #666666;">我的</text>
</view>
</view>
</view>
<!-- 系统升级 -->
<yomol-upgrade ref="yomolUpgrade"></yomol-upgrade>
</view>
</template>
<script>
import uniBadge from "@/components/uni-badge/uni-badge.vue"
import faIcon from "@/components/fa-icon/fa-icon.vue";
import navigationTitle from '@/components/navigation-title/navigation-title.vue';
import uniGrid from '@/components/uni-grid/uni-grid.vue';
import uniGridItem from '@/components/uni-grid-item/uni-grid-item.vue';
import yomolUpgrade from '@/components/yomol-upgrade/yomol-upgrade.vue';
import Vue from 'vue';
import { mapState } from 'vuex';
export default {
components: {
faIcon,
navigationTitle,
yomolUpgrade,
uniBadge
},
data() {
return {
infoList:[],
count:0,
orgid:"",
windowWidth:"",
windowHeight:"",
bannerHeight:"",
bannerWidth:"",
newsHeight:"",
newsWidth:"",
currentBanner:'',
mainSelect:true,
applySelect:false,
cleandarSelect:false,
mySelect:false,
listBanner: [],
listBannerBlank:[
{"url":'../../../static/home/banner1.png'},
{"url":'../../../static/home/banner2.png'},
{"url":'../../../static/home/banner3.png'},
],
listNews: [],
listNewsBlank:[
{"FImage":'../../../static/home/news1.png',"FName":"电子公司引入WMS解决仓储","C_YMD":"2021-1-11 18:00:00"},
{"FImage":'../../../static/home/news2.png',"FName":"电子公司引入WMS解决仓储","C_YMD":"2021-1-11 18:00:00"},
{"FImage":'../../../static/home/news3.png',"FName":"电子公司引入WMS解决仓储","C_YMD":"2021-1-11 18:00:00"},
],
list:[],
pageIndex: 0,
loadingText: '下拉加载',
comList: [],
}
},
beforeMount() {
if(this.userInfo.UserID) {
this.checkVersion();
}
},
computed: {
...mapState(['hasLogin', 'userInfo'])
},
onShow() {
this.getFavoritesMenu();
this.getInfoNumber();
this.getBannerInfo();
console.log("++++++++++++++++++++++++++++"+this.listNewsBlank[0].FImage)
},
onLoad() {
// debugger
const res = uni.getSystemInfoSync();
this.windowHeight = res.windowHeight;
this.windowWidth = res.windowWidth;
let sWindow = this.windowHeight*this.windowWidth;
let sBaseBanner = 366*200;
let sBaseWindow = 414*896;
let basePrecent = sBaseBanner/sBaseWindow;
let baseWHprecent = 366/200;233
let sWindowBanner = sWindow*basePrecent;
this.bannerHeight = Math.sqrt((sWindowBanner/baseWHprecent));
this.bannerWidth = this.bannerHeight*baseWHprecent;
let sBaseNews = 140*90;
let basePrecentNews = sBaseNews/sBaseWindow;
let baseWHprecentNews = 140/90;
let sWindowNews = sWindow*basePrecentNews;
this.newsHeight = Math.sqrt((sWindowNews/baseWHprecentNews));
this.newsWidth = this.newsHeight*baseWHprecentNews;
this.getAllMenu();
this.getFavoritesMenu();
this.GetOrgInfo();
},
methods: {
getNews(){
let _self = this;
this.orgid = uni.getStorageSync('orgid');
let requestParams = {
"id": this.userInfo.token,
"basicType":1,
"uid":1,
"pageSize":'',
"pageIndex":''
};
this.$request.post(
{
data: {
action: 'Notice',
params: requestParams
}
}
).then(res => {
let datalist = JSON.parse(res);
_self.listNews = datalist;
});
},
getInfoNumber(){
let _self = this;
let loginId = uni.getStorageSync('loginId');
let requestParams;
this.$request.get('ReportInfoLoad/GetReportMessage',{
params:{
loginId:loginId,
page:1,
size:20
}
}).then(res => {
this.count = res.toltalCount;
});
},
getBannerInfo(){
let _self = this;
this.$request.get('/SysConfigData/CarouselMap').then(res => {
let datalist = res;
_self.listBanner = datalist;
});
},
msgClick(){
uni.navigateTo({
url:'./msg'
})
},
bannerChange(event) {
let current = event.detail.current
this.currentBanner = current
},
NavigateApplyKanban(subitem) {
let page=subitem.KEY;
if (page) {
let tempurl='../../views/KanBan/KanBan'+'?pageNumber='+page;
uni.navigateTo({
url: tempurl
})
}
},
NavigateApply(page) {
if(page=='SingleResRpt'){
uni.navigateTo({
url: '../SingleResRpt/SingleResRpt'
})
}else{
uni.navigateTo({
url: '../../views/' + page + '/' + page
})
}
console.log('../../views/' + page + '/' + page)
},
PageNavigate: function() {
uni.navigateTo({
url: '../apply/applymanage'
})
},
mainSelectF(){
this.mainSelect = true;
this.applySelect = false;
this.cleandarSelect = false;
this.mySelect = false;
},
applySelectF(){
this.mainSelect = false;
this.applySelect = true;
this.cleandarSelect = false;
this.mySelect = false;
uni.redirectTo({
url:'../apply/apply'
})
},
// cleandarSelectF(){
// this.mainSelect = false;
// this.applySelect = false;
// this.cleandarSelect = true;
// this.mySelect = false;
// uni.redirectTo({
// url:'../calendar/calender'
// })
// },
mySelectF(){
this.mainSelect = false;
this.applySelect = false;
this.cleandarSelect = false;
this.mySelect = true;
uni.redirectTo({
url:'../myinfo/myinfo'
})
},
loadMore: function() {
if (this.loadingText == "没有更多了") {
return
}
//currentTab表示当前所在页数 根据当前所在页数发起请求并带上page页数
this.loadingText=='加载中...'
uni.showLoading({
content: '加载中',
mask: true
})
this.GetPublicInfo()
setTimeout(function() {
uni.hideLoading();
}, 500)
},
//新闻详情
goDetail(item, index) {
console.log(item)
let data=item
uni.navigateTo({
url: `/pages/home/detail/detail?data=${JSON.stringify(data)}`
})
},
GetPublicInfo() {
this.pageIndex++;
let requestParams = {
"id": this.userInfo.token,
};
this.$request.post(
{
data: {
action: 'GetPublicMessage',
params: requestParams,
data: {
page: this.pageIndex
}
}
}
).then(res => {
let _self = this;
let data = JSON.parse(res)
if (data.length == 0) {
this.loadingText = "没有更多了"
return
}
for (let item of data) {
var obj = {};
obj.interId=item.FInterID
obj.datetime = item.FDateTime;
obj.title = item.FTitle
obj.article_type = 0;
// obj.source = _self.userInfo.OrgStructures.FName.substr(0, 4)
obj.comment_count = 0
obj.content=item.FInfo
_self.list.push(obj)
}
});
},
//系统升级
checkVersion() {
let verCode = 62300;
// #ifdef APP-PLUS
plus.runtime.getProperty(plus.runtime.appid,(wgtinfo)=>{
verCode = wgtinfo.versionCode;
});
// #endif
let appType = uni.getStorageSync("appType");
let requestParams = {
"id": this.$store.state.userInfo.token,
"appType":appType
};
this.$request.post(
{
data: {
action: 'GetLastestAppInfo',
params: requestParams
}
}
).then(res => {
console.log("GetLastestAppInfo------------");
let data = JSON.parse(res);
let urlVerCode = parseInt(data.FVersionCode);
console.log('当前APP版本'+verCode);
console.log('服务器APP版本'+urlVerCode);
console.log('APP更新地址'+data.FVersionDownloadUrl);
if(urlVerCode > verCode ){
this.$refs.yomolUpgrade.show(data);
}
});
},
getAllMenu(){
// debugger
this.$request.post('/Service/GetAllMenu')
.then(res => {
let data = res.MainMenu;
if(data&&data.length>0){
data = data.filter(e => {
return e.NAME == "生产汇报" || e.NAME == "生产检验" || e.NAME=='安灯预警' ||e.NAME=='预警平台'
});
}
uni.setStorageSync('AllMenu',data);
})
.catch(err => {
console.log(err);
});
},
getFavoritesMenu(){
this.$request.post('/Service/GetFavoritesMenu')
.then(res => {
let datas = res;
datas.forEach((item, index) => {
let subdata = item.SubMenus
subdata.forEach((item, index) => {
if (item.NAME.length > 6) {
item.NAME = item.NAME.substr(0, 6)
}
})
})
this.comList = datas;
uni.setStorageSync('ComMenu',this.comList);
})
.catch(err => {
console.log(err);
});
},
GetOrgInfo:function(){
uni.showLoading({
mask: true
});
this.$request.get('/Service/GetSysOrgForUser').then(res => {
uni.hideLoading()
let orgInfo = res
uni.setStorageSync('orgInfo',orgInfo)
}).catch(err => {
uni.hideLoading()
errorUtil.handle(err)
});
},
}
}
</script>
<style>
.home {
height: 100%;
width: 100%;
overflow-x: hidden;
}
.topBar{
/* position: absolute; */
display: flex;
flex-direction: row;
align-items: center;
justify-content: center;
height: 181.15rpx;
line-height: 181.15rpx;
width: 100%;
background: #2560C9;
font-size: 32.6rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #FFFFFF;
text-align: center;
position: fixed;
z-index: 999;
}
.topBar-text{
width: 100%;
height: 181.15rpx;
line-height: 181.15rpx;
font-size: 32.6rpx;
font-family: PingFangSC-Semibold, PingFang SC;
font-weight: 600;
color: #FFFFFF;
margin-left: 43.47rpx;
text-align: center;
}
.msg{
position: relative;
display: flex;
margin-right: 43.47rpx;
}
.msg-img{
height: 36.23rpx;
width: 36.23rpx;
}
.msg-text{
height: 13px;
line-height: 12px;
width: 13px;
background: #FF5353;
text-align: center;
color: #FFFFFF;
border-radius: 100px;
font-size: 12px;
position: absolute;
left: 21.73rpx;
top: -7.24rpx;
}
.home-swiper view {
height: 100%;
}
.swiper-item{
display: flex;
align-items: center;
}
.swiper-item-image {
border-radius: 10upx;
height: 100%;
width: 100%;
}
.swiper-item-banner{
display: flex;
align-items: center;
}
.swiper-item-banner-image{
border-radius: 10upx;
height: 80%;
width: 100%;
}
.home-news{width: 100%;margin-top: 36.23rpx;/* border: #000000 solid 1.81rpx; */}
.home-news-title{
width: 100%;
height: 45.28rpx;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
margin-top: 36.23rpx;
}
.news-info{
height: 45.28rpx;
line-height: 45.28rpx;
width: 100%;
font-size: 32.6rpx;
font-family: PingFangSC-Medium, PingFang SC;
font-weight: 500;
color: #000000;
margin-left: 43.47rpx;
}
.news-more{
height: 45.28rpx;
line-height: 45.28rpx;
width: 72.46rpx;
font-size: 25.36rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #4688FD;
margin-right: 43.47rpx;
}
.home-news-detail{
margin-left: 43.47rpx;margin-top: 28.98rpx;margin-right: 43.47rpx;
}
.home-news-detail-outline{
display: flex;flex-direction: row;
}
.home-news-detail-item{
display: flex;flex-direction: column;margin-right: 43.47rpx;
}
.home-news-detail-item-img{
border-radius: 9.05rpx 9.05rpx 0 0;
}
.home-news-detail-item-text{
display: flex;flex-direction: column;border-radius: 0 0 9.05rpx 9.05rpx;
/* border: #333333 solid 1.81rpx; */
background: #FFFFFF;
border-bottom: 1px solid rgba(0, 0, 0, 0.1);
border-left: 1px solid rgba(0, 0, 0, 0.1);
border-right: 1px solid rgba(0, 0, 0, 0.1);
}
.home-news-detail-item-text-title{
font-size: 21.73rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #000000;
overflow: hidden;
text-overflow: ellipsis;
/* white-space: nowrap; */
word-break: break-all;
width: 90%;
margin-left: 5%;
margin-right: 5%;
margin-top: 21.73rpx;
}
.home-news-detail-item-text-time{
font-size: 18.11rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #787878;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
word-break: break-all;
width: 90%;
margin-left: 5%;
margin-right: 5%;
}
.home-apply{width: 100%;margin-top: 36.23rpx;/* border: #000000 solid 1.81rpx; */margin-bottom: 126.81rpx;}
.home-apply-item{
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
padding: 0;
font-size: 14px;
background-color: #ffffff;
}
.grid-item-box {
flex: 1;
/* position: relative;
*/
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
flex-direction: column;
align-items: center;
justify-content: center;
padding: 15px 0;
}
.image{
height: 79.71rpx;
width: 79.71rpx;
}
.text {
padding: 10upx 0;
}
.tabBar{
display: flex;
position: fixed;
flex-direction: row;
left: 0;
right: 0;
bottom: 0;
height: 119.56rpx;
background: rgba(255, 255, 255, 1);
box-shadow:2px 2px 10px rgba(0, 0, 0, 1);
}
.tabBar-item{
display: flex;
flex-direction: column;
flex-shrink: 1;
flex-grow: 1;
align-items: center ;
width: 100%;
}
.tabBar-item-view{
display: flex;
flex-direction: column;
flex-shrink: 1;
flex-grow: 1;
align-items: center ;
}
.tabBar-item-img{
height: 54.34rpx;
width: 54.34rpx;
margin-top: 16.3rpx;
}
.tabBar-item-text{
text-align: center;
height: 28.98rpx;
font-size: 28.98rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #515151;
line-height: 28.98rpx;
margin-left:0
}
</style>