首页 - 样本管理系统
<template>
<view>
<u-toast ref="uToast" />
<pre><code><!-- 滚动通知开始 -->
<view v-if="notice">
<u-notice-bar :text="notice" mode="closable" @click="selectbox(4)" />
</view>
<!-- 滚动通知结束 -->
<!-- 首页轮播图开始 -->
<view class="swiper">
<u-swiper
:list="swiperlist"
keyName="bannerUrl"
autoplay
circular
height="350rpx"
indicator
indicatorMode="line"
/>
</view>
<!-- 首页轮播图结束 -->
<!-- 今日详情开始 -->
<view class="layout">
<view class="title">今日详情</view>
<view class="content">
<view class="box1" @click="selectbox(1)">
<view class="text1">样本箱</view>
<view class="text2">
<text class="text3">{{ boxNum }}</text>
<text class="text4">箱</text>
</view>
</view>
<view class="box2" @click="selectbox(2)">
<view class="text1">样本</view>
<view class="text2">
<text class="text3">{{ packageNum }}</text>
<text class="text4">袋</text>
</view>
</view>
<view class="box3" @click="selectbox(3)">
<view class="text1">第三方</view>
<view class="text2">
<text class="text3">{{ thirdPartyNum }}</text>
<text class="text4">个</text>
</view>
</view>
</view>
</view>
<!-- 今日详情结束 -->
<!-- 常用开始 -->
<view class="layout myview">
<view class="title">常用</view>
<view class="content2">
<u-grid :border="false" @click="commonclick">
<u-grid-item v-for="(item, index) in baseList" :key="index">
<view style="position: absolute;top: -1rpx;left: 30rpx;" v-if="index === 1">
<u-badge type="error" numberType="overflow" max="10" :value="messageNum" />
</view>
<image style="width: 80rpx;height: 80rpx;" mode="aspectFill" :src="item.imgurl" />
<text class="grid-text" style="margin-bottom: 30rpx;">{{ item.title }}</text>
</u-grid-item>
</u-grid>
</view>
</view>
<!-- 常用结束 -->
<!-- 车辆管理开始 -->
<view class="layout myview">
<view class="title">车辆管理</view>
<view class="content2">
<u-grid :border="false" @click="carclick">
<u-grid-item v-for="(item, index) in carList" :key="index" v-if="index !== 1 || license_plate.length !== 0">
<image style="width: 80rpx;height: 80rpx;" mode="aspectFill" :src="item.imgurl" />
<text class="grid-text" style="margin-bottom: 30rpx;">{{ item.title }}</text>
</u-grid-item>
</u-grid>
</view>
</view>
<!-- 车辆管理结束 -->
<!-- 调度管理开始 -->
<view class="layout myview">
<view class="title">调度管理</view>
<view class="content2">
<u-grid :border="false" @click="dispatchclick">
<u-grid-item v-for="(item, index) in dispatchlist" :key="index" v-if="expressRoleId < item.role">
<image style="width: 80rpx;height: 80rpx;" mode="aspectFill" :src="item.imgurl" />
<text class="grid-text" style="margin-bottom: 30rpx;">{{ item.title }}</text>
</u-grid-item>
</u-grid>
</view>
</view>
<!-- 调度管理结束 -->
<view style="height: 30rpx;" />
</code></pre>
</view>
</template>
<script>
export default {
data() {
return {
notice: '', //首页滚动消息标题
swiperlist: [], //首页轮播图
boxNum: 0, //样本箱数量
packageNum: 0, //样本袋数量
thirdPartyNum: 0, //第三方数量
messageNum: 0, //未读消息数量
license_plate: [], //车牌判断加油图标显示
account: uni.getStorageSync('account'),
expressRoleId: uni.getStorageSync('expressRoleId'),
baseList: [
{
imgurl: '/static/images/client.png',
title: '客户管理',
path: '/pages/tabbar1/customer/customer',
},
{
imgurl: '/static/images/message.png',
title: '消息中心',
path: '/pages/tabbar1/message/message',
},
{
imgurl: '/static/images/confirmed.png',
title: '录单查询',
path: '/pages/tabbar1/record/record',
},
], //常用的数据宫格图
carList: [
{
imgurl: '/static/images/car.png',
title: '出车检查',
path: '/pages/tabbar1/checkcar/checkcar',
},
{
imgurl: '/static/images/refuel.png',
title: '车辆加油',
path: '/pages/tabbar1/refuel/refuel',
},
], //车辆管理宫格图
dispatchlist: [
{
imgurl: '/static/images/Hospital.png',
title: '医院派单',
path: '/pages/tabbar1/dispatch/dispatch',
role: 1004,
},
{
imgurl: '/static/images/car2.png',
title: '车辆调度',
path: '/pages/tabbar1/VehicleDispatch/VehicleDispatch',
role: 1004,
},
], //调度管理
};
},
methods: {
location() { //获取定位
uni.getLocation({
isHighAccuracy: true, // 开启地图精准定位
type: 'gcj02', // 地图类型写这个
success: (res) => {
console.log(res)
this.$request.get('/getaddress', {
location: res.latitude + ',' + res.longitude
}).then(res => {
console.log(res)
})
}
})
},
selectbox(e) { //点击箱子,进入领取样本箱页面
if (e == 1) { uni.navigateTo({ url: '/pages/tabbar1/boxs/boxs' }); }
if (e == 2) { uni.navigateTo({ url: '/pages/tabbar1/samplebag/samplebag' }); }
if (e == 3) { uni.navigateTo({ url: '/pages/tabbar1/thirdpart/thirdpart' }); }
if (e == 4) { uni.navigateTo({ url: '/pages/tabbar1/message/message' }); }
},
workbenchInfo() { //获取首页数据
this.$request.post('/app/workbench/workbenchInfo', {}
).then(res => {
console.log('获取首页数据')
console.log(res.data.data)
if (res.data.code == 200) {
this.messageNum = res.data.data.messageNum
if (this.messageNum > 0) {
this.notice = '您有' + res.data.data.messageNum + '条新消息!'
} else {
this.notice = ''
}
this.boxNum = res.data.data.boxNum
this.packageNum = res.data.data.packageNum
this.thirdPartyNum = res.data.data.thirdPartyNum
} else {
if (res.data.message == '未登录') {
uni.removeStorageSync('token');
uni.reLaunch({
url: '/pages/other/login/login'
});
} else {
this.$refs.uToast.error(res.data.message)
}
}
})
this.getbanner()
uni.stopPullDownRefresh(); //停止刷新
},
getbanner() { //获取首页轮播图
if (this.swiperlist.length < 1) {
this.$request.post('/app/workbench/banner_list', {}
).then(res => {
console.log('获取首页轮播图数据')
console.log(res.data.data)
this.swiperlist = res.data.code == 200 ? res.data.data : []
})
}
},
commonclick(index) { //点击常用宫格中的图标
uni.navigateTo({
url: this.baseList[index]['path']
});
},
carclick(index) { //点击车辆管理宫格中的图标
uni.navigateTo({
url: this.carList[index]['path']
});
},
dispatchclick(index) { //点击调度管理图标
uni.navigateTo({
url: this.dispatchlist[index]['path']
});
}
},
onPullDownRefresh() { //监听该页面用户下拉刷新事件
console.log('刷新首页页面数据');
this.workbenchInfo()
// this.getbanner()
},
onLoad() {
console.log('首次进入刷新首页页面数据');
// this.getbanner()
if (this.account !== 'test' && this.account) {
this.location()
}
},
onShow() {
if (!uni.getStorageSync('token')) {
uni.reLaunch({
url: '/pages/other/login/login'
});
} else {
this.workbenchInfo()
if (uni.getStorageSync('license_plate')) {
this.license_plate = uni.getStorageSync('license_plate')
console.log(uni.getStorageSync('license_plate'))
}
}
},
};
</script>
<style lang="scss">
.layout {
.title {
margin: 30rpx 30rpx 30rpx 30rpx;
font-size: 40rpx;
font-weight: bold;
}
.content {
display: flex;
justify-content: space-around;
.box1 {
width: 200rpx;
height: 200rpx;
background-color: #87CEFA;
border-radius: 15rpx;
background-image: url('https://img.alicdn.com/imgextra/i1/752202202/O1CN01S9OqZl1S8Yw4n2GMx_!!752202202.png');
background-size: cover;
}
.box2 {
width: 200rpx;
height: 200rpx;
background-color: #70DB93;
border-radius: 15rpx;
background-image: url('https://img.alicdn.com/imgextra/i3/752202202/O1CN01aP7l171S8YwACW3xn_!!752202202.png');
background-size: cover;
}
.box3 {
width: 200rpx;
height: 200rpx;
background-color: #FFB6C1;
border-radius: 15rpx;
background-image: url('https://img.alicdn.com/imgextra/i4/752202202/O1CN01yb6s2K1S8YvzGIja9_!!752202202.png');
background-size: cover;
}
.text1 {
font-size: 40rpx;
color: #FFFFFF;
text-align: center;
margin-top: 20rpx;
}
.text2 {
text-align: center;
.text3 {
font-size: 80rpx;
color: #FFFFFF;
}
.text4 {
font-size: 40rpx;
color: #FFFFFF;
}
}
}
}
</style>
原文地址: https://www.cveoy.top/t/topic/nGOt 著作权归作者所有。请勿转载和采集!