123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- <template>
- <view>
- <image :src="worktop" style="height: 340rpx;width: 90%;margin-left: 40rpx;"></image>
- <!-- <uni-segmented-control :current="current" :values="items" @clickItem="onClickItem" styleType="text"
- activeColor="#4cd964"></uni-segmented-control>
- <view v-if="current === 0"> -->
- <view class="grid-body">
- <uni-card :border="false">
- <uni-section title="事件中心" type="line" titleFontSize='18px'>
- <uni-grid :column="3" :showBorder="false" @change="changeGrid">
- <uni-grid-item v-for="(item, index) in urlList1" :key="index">
- <view class="example-body">
- <view class="grid-item-box" @click="handleToInfo(item.menuUrl,item.menuName)">
- <image :src="urlIconTran(item.menuIcon)" class="tubiao"></image>
- <text class="text">{{ item.menuName }}</text>
- <u-badge v-if="item.menuName == '指令'&&unread != 0" :value="unread" type="error"
- class="huibiao"></u-badge>
- <u-badge v-if="item.menuName == '重要提醒'&&unreadTips != 0" :value="unreadTips" type="error"
- class="huibiao"></u-badge>
- </view>
- </view>
- </uni-grid-item>
- </uni-grid>
- </uni-section>
- <uni-section title="管理中心" type="line" titleFontSize='18px'>
- <uni-grid :column="3" :showBorder="false" @change="changeGrid">
- <uni-grid-item v-for="(item, index1) in urlList" :key="index1">
- <view class="example-body">
- <view class="grid-item-box" @click="handleToInfo(item.menuUrl,item.menuName)">
- <image :src="urlIconTran(item.menuIcon)" class="tubiao"></image>
- <text class="text">{{ item.menuName }}</text>
- <u-badge v-if="item.menuName == '指令'&&unread != 0" :value="unread" type="error"
- class="huibiao"></u-badge>
- <u-badge v-if="item.menuName == '重要提醒'&&unreadTips != 0" :value="unreadTips" type="error"
- class="huibiao"></u-badge>
- </view>
- </view>
- </uni-grid-item>
- </uni-grid>
- </uni-section>
- <uni-section title="乡镇消防工作档案" type="line" titleFontSize='18px'
- v-if="urlList2.length&&urlList2.length>0">
- <uni-grid :column="3" :showBorder="false" @change="changeGrid">
- <uni-grid-item v-for="(item, index) in urlList2" :key="index">
- <view class="example-body">
- <view class="grid-item-box" @click="handleToInfo(item.menuUrl,item.menuName)">
- <image :src="urlIconTran(item.menuIcon)" class="tubiao"></image>
- <text class="text">{{ item.menuName }}</text>
- <u-badge v-if="item.menuName == '指令'&&unread != 0" :value="unread" type="error"
- class="huibiao"></u-badge>
- <u-badge v-if="item.menuName == '重要提醒'&&unread != 0" :value="unread" type="error"
- class="huibiao"></u-badge>
- </view>
- </view>
- </uni-grid-item>
- </uni-grid>
- </uni-section>
- </uni-card>
- </view>
- </view>
- </template>
- <script>
- import storage from '@/utils/storage';
- import {
- getNoticeList, // 通知公告列表
- getNoticeReadData //指令未读的数量
- } from '@/api/notice';
- import {
- getRemindReadData //重要通知未读的数量
- } from "@/api/remind";
- import {
- getMenusByUser
- } from '@/api/login';
- import config from '@/config'
- const baseUrlImg = config.baseUrlImg
- export default {
- data() {
- return {
- urls: baseUrlImg,
- roles: this.$store.state.user.roles,
- current: 0,
- swiperDotIndex: 0,
- worktop: `${baseUrlImg}/working/worktop.png`, //图片
- zhudongjiancha: `${baseUrlImg}/working/zhudongjiancha.png`,
- yinhuanguanli: `${baseUrlImg}/working/yinhuanguanli.png`,
- yinhuanfucha: `${baseUrlImg}/working/yinhuanfucha.png`, //隐患复查
- check_inspection: `${baseUrlImg}/working/check_inspection.png`, //主动检查
- user_business: `${baseUrlImg}/working/user_business.png`,
- tabler_clock_edit: `${baseUrlImg}/working/tabler_clock_edit.png`,
- tabler_chart_histogram: `${baseUrlImg}/working/tabler_chart_histogram.png`, //数据统计
- outline_trumpet: `${baseUrlImg}/working/outline_trumpet.png`, //通知公告
- outline_permissions: `${baseUrlImg}/working/outline_permissions.png`,
- meirixuncha: `${baseUrlImg}/working/big1.png`,
- // fire_extinguishe: `${baseUrlImg}/working/weixingxiaofang.png`,
- fire_extinguishe: `${baseUrlImg}/working/fire_extinguishe.png`,
- unit_info: `${baseUrlImg}/working/danweixinxi.png`,
- zhilin: `${baseUrlImg}/working/zhilin.png`,
- // unit_arc: `${baseUrlImg}/working/danweijianzhu.png`,
- unit_arc: `${baseUrlImg}/working/unit_arc.png`,
- xiaofangsheshi: `${baseUrlImg}/working/xiaofangsheshi.png`,
- renyuan: `${baseUrlImg}/working/renyuan.png`,
- drill: `${baseUrlImg}/working/drill.png`,
- // archive: `${baseUrlImg}/working/gongzuodangan.png`,
- archive: `${baseUrlImg}/working/archive.png`,
- fireSpecial: `${baseUrlImg}/working/fireSpecial.png`,
- remind:`${baseUrlImg}/working/remind.png`,
- fireWork: `${baseUrlImg}/working/fireWork.png`,
- fire_inspetItem: `${baseUrlImg}/working/fire_inspetItem.png`,
- fire_street: `${baseUrlImg}/working/fire_street.png`,
- items: ['事件中心', '管理中心'],
- current: 0,
- urlList: [],
- urlList1: [],
- unread: 0, //未读数量
- unreadTips:0,//重要提醒未读数量
- urlList2: []
- };
- },
- onLoad() {
- },
- onShow() {
- this.urlList = []
- this.urlList1 = []
- this.urlList2 = [];
- let count = 0;
- const intervalId = setInterval(() => {
- if (this.$store.state.user && this.$store.state.user.id) {
- this.getData();
- this.getRemind();
- this.getMenu();
- clearInterval(intervalId); // 中止循环
- }
- count++;
- if (count >= 5) {
- clearInterval(intervalId); // 如果超过5秒仍未找到用户ID,中止循环
- }
- }, 1000);
- },
- methods: {
- getData() {
- getNoticeReadData({
- userId: this.$store.state.user.id
- }).then(response => {
- this.unread = response.data
- })
- },
- getRemind() {
- getRemindReadData({
- userId: this.$store.state.user.id
- }).then(response => {
- this.unreadTips = response.data
- })
- },
- getMenu() {
- getMenusByUser({
- id: this.$store.state.user.id
- }).then(response => {
- console.log('response======',response)
- response.data.map(i => {
- if (i.menuSort.toString().startsWith("1")) {
- this.urlList1.push(i);
- this.urlList1 = this.urlList1.sort((a, b) => a.menuSort - b.menuSort);
- } else if (i.menuSort.toString().startsWith("2")) {
- this.urlList.push(i);
- this.urlList = this.urlList.sort((a, b) => a.menuSort - b.menuSort);
- } else if (i.menuSort.toString().startsWith("3")) {
- this.urlList2.push(i);
- this.urlList2 = this.urlList2.sort((a, b) => a.menuSort - b.menuSort);
- }
- });
- });
- },
- urlIconTran(val) {
- if (val == 'outline_permissions') {
- return this.outline_permissions;
- } else if (val == 'meirixuncha') {
- return this.meirixuncha;
- } else if (val == 'zhudongjiancha') {
- return this.zhudongjiancha;
- } else if (val == 'check_inspection') {
- // return this.zhudongjiancha;
- return this.check_inspection
- } else if (val == 'yinhuanfucha') {
- // return this.yinhuanguanli
- return this.yinhuanfucha
- } else if (val == 'tabler_clock_edit') {
- return this.tabler_clock_edit;
- } else if (val == 'outline_trumpet') {
- return this.outline_trumpet;
- } else if (val == 'outline_trumpet') {
- return this.outline_trumpet;
- } else if (val == 'yinhuanguanli') {
- return this.yinhuanguanli;
- } else if (val == 'user_business') {
- return this.user_business;
- } else if (val == 'fire_extinguishe') {
- return this.fire_extinguishe;
- } else if (val == 'unit_info') {
- return this.unit_info;
- } else if (val == 'unit_arc') {
- return this.unit_arc;
- } else if (val == 'drill') {
- return this.drill;
- } else if (val == 'xiaofangsheshi') {
- return this.xiaofangsheshi;
- } else if (val == 'archive') {
- return this.archive;
- } else if (val == 'renyuan') {
- return this.renyuan;
- } else if (val == 'tabler_chart_histogram') {
- return this.tabler_chart_histogram;
- } else if (val == 'zhilin') {
- return this.zhilin;
- } else if (val == 'zlgztzs_icon') {
- return this.renyuan
- } else if (val == 'fire_inspetItem') {
- // return this.archive;
- return this.fire_inspetItem
- } else if (val == 'fire_street') {
- // return this.archive;
- return this.fire_street
- } else if (val == 'fireWork') {
- // return this.archive;
- return this.fireWork
- } else if (val == 'fireSpecial') {
- // return this.archive;
- return this.fireSpecial
- }else if (val == 'remind') {
- // return this.archive;
- return this.remind
- }
- },
- // 顶部个人信息跳转
- onClick() {
- uni.switchTab({
- url: '/pages/mine/index'
- });
- },
- changeGrid(e) {},
- // 根据不同的url,进行页面的跳转
- handleToInfo(url, name) {
- this.$tab.navigateTo(url);
- },
- // 分段器点击 事件中心、管理中心转换
- onClickItem(e) {
- if (this.current != e.currentIndex) {
- this.current = e.currentIndex;
- }
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- /* #ifndef APP-NVUE */
- page {
- display: flex;
- flex-direction: column;
- box-sizing: border-box;
- min-height: 100%;
- height: auto;
- }
- .tubiao {
- width: 142upx;
- height: 142upx;
- }
- view {
- font-size: 14px;
- line-height: inherit;
- }
- .tabIcon {
- color: white;
- }
- /* #endif */
- .text {
- text-align: center;
- color: #000;
- font-size: 26rpx;
- margin-top: -18upx;
- // margin-top: 10rpx;
- }
- .grid-item-box {
- position: relative;
- flex: 1;
- /* #ifndef APP-NVUE */
- display: flex;
- /* #endif */
- flex-direction: column;
- align-items: center;
- justify-content: center;
- padding: 15px 0;
- }
- // 按钮样式
- button {
- width: 132rpx;
- height: 52rpx;
- border-radius: 50rpx;
- background-color: #f7d1dc;
- border-color: #d51a52;
- color: #d51a52;
- font-size: 25rpx;
- border: 3rpx solid;
- font-weight: bold;
- padding: 0;
- margin-left: 70rpx;
- }
- ::v-deep .u-navbar__content {
- // background-color: #4cb2b6 !important;
- }
- .container {
- height: 140vh;
- // height: 100vh;
- background-color: #fff;
- }
- // 修改分段器默认样式
- ::v-deep .segmented-control {
- border-bottom: 1px solid #e5e5e5;
- }
- ::v-deep .segmented-control__text {
- color: #4cb2b6 !important;
- }
- ::v-deep .segmented-control__text span {
- color: #3d3d3d !important;
- }
- ::v-deep .segmented-control__item--text {
- padding: 8px 0;
- }
- //徽标
- // /deep/.u-page__tag-item {
- // margin-right: 40px;
- // margin-top: 0 !important;
- // }
- /deep/.u-badge[data-v-662d25bf] {}
- .huibiao,
- /deep/.u-badge--error.data-v-662d25bf,
- /deep/.u-badge--error {
- position: absolute;
- right: 56rpx;
- top: 46rpx;
- }
- </style>
|