|
@@ -1,144 +1,182 @@
|
|
|
<template>
|
|
|
- <div class="main" id="main">
|
|
|
- <!-- <KeepAlive>
|
|
|
+ <div class="main" id="main">
|
|
|
+ <!-- <KeepAlive>
|
|
|
<router-view />
|
|
|
</KeepAlive> -->
|
|
|
- <router-view v-slot="{ Component, route }">
|
|
|
- <keep-alive include="working">
|
|
|
- <component v-if="!route.meta.link" :is="Component" :key="route.fullPath"/>
|
|
|
- </keep-alive>
|
|
|
- </router-view>
|
|
|
-
|
|
|
- </div>
|
|
|
- <van-tabbar v-model="tabType" v-if="routerName != '/main/processDtl'" @change="onChange" :style="isIos() ? 'height:65px' : ''">
|
|
|
- <van-tabbar-item to="/main/message" name="message" :badge="msgCount" :style="isIos() ? 'padding-bottom:15px' : ''">
|
|
|
- {{$t('common.message')}}
|
|
|
- <template #icon="props">
|
|
|
- <i class="icon iconfont icon-btn_shengc_gray1 footer-icon" :class="props.active ? 'footer-icon-active' : ''"></i>
|
|
|
- </template>
|
|
|
- </van-tabbar-item>
|
|
|
- <van-tabbar-item to="/main/working" name="working" :style="isIos() ? 'padding-bottom:15px' : ''">
|
|
|
- {{$t('common.workbench')}}
|
|
|
- <template #icon="props">
|
|
|
- <i class="icon iconfont icon-btn_gongz footer-icon" :class="props.active ? 'footer-icon-active' : ''"></i>
|
|
|
- </template>
|
|
|
- </van-tabbar-item>
|
|
|
- <van-tabbar-item
|
|
|
- :style="isIos() ? 'padding-bottom:15px' : ''"
|
|
|
- :to="tenantId == 'smt' ? '/main/xiamenList' : '/main/equipment'"
|
|
|
- name="equipment"
|
|
|
- >{{$t('common.things')}}
|
|
|
- <template #icon="props">
|
|
|
- <i class="icon iconfont icon-btn_wulw footer-icon" :class="props.active ? 'footer-icon-active' : ''"></i>
|
|
|
- </template>
|
|
|
- </van-tabbar-item>
|
|
|
- <van-tabbar-item icon="setting-o" to="/main/home" :style="isIos() ? 'padding-bottom:15px' : ''" name="home">
|
|
|
- {{$t('common.mine')}}
|
|
|
- <template #icon="props">
|
|
|
- <i class="icon iconfont icon-btn_mine footer-icon" :class="props.active ? 'footer-icon-active' : ''"></i>
|
|
|
- </template>
|
|
|
- </van-tabbar-item>
|
|
|
- </van-tabbar>
|
|
|
+ <router-view v-slot="{ Component, route }">
|
|
|
+ <keep-alive include="working">
|
|
|
+ <component
|
|
|
+ v-if="!route.meta.link"
|
|
|
+ :is="Component"
|
|
|
+ :key="route.fullPath"
|
|
|
+ />
|
|
|
+ </keep-alive>
|
|
|
+ </router-view>
|
|
|
+ </div>
|
|
|
+ <van-tabbar
|
|
|
+ v-model="tabType"
|
|
|
+ v-if="routerName != '/main/processDtl'"
|
|
|
+ @change="onChange"
|
|
|
+ :style="isIos() ? 'height:65px' : ''"
|
|
|
+ >
|
|
|
+ <van-tabbar-item
|
|
|
+ to="/main/message"
|
|
|
+ name="message"
|
|
|
+ :badge="msgCount"
|
|
|
+ :style="isIos() ? 'padding-bottom:15px' : ''"
|
|
|
+ >
|
|
|
+ {{ $t("common.message") }}
|
|
|
+ <template #icon="props">
|
|
|
+ <i
|
|
|
+ class="icon iconfont icon-btn_shengc_gray1 footer-icon"
|
|
|
+ :class="props.active ? 'footer-icon-active' : ''"
|
|
|
+ ></i>
|
|
|
+ </template>
|
|
|
+ </van-tabbar-item>
|
|
|
+ <van-tabbar-item
|
|
|
+ to="/main/working"
|
|
|
+ name="working"
|
|
|
+ :badge="msgCountOne"
|
|
|
+ :style="isIos() ? 'padding-bottom:15px' : ''"
|
|
|
+ >
|
|
|
+ {{ $t("common.workbench") }}
|
|
|
+ <template #icon="props">
|
|
|
+ <i
|
|
|
+ class="icon iconfont icon-btn_gongz footer-icon"
|
|
|
+ :class="props.active ? 'footer-icon-active' : ''"
|
|
|
+ ></i>
|
|
|
+ </template>
|
|
|
+ </van-tabbar-item>
|
|
|
+ <van-tabbar-item
|
|
|
+ :style="isIos() ? 'padding-bottom:15px' : ''"
|
|
|
+ :to="tenantId == 'smt' ? '/main/xiamenList' : '/main/equipment'"
|
|
|
+ name="equipment"
|
|
|
+ >{{ $t("common.things") }}
|
|
|
+ <template #icon="props">
|
|
|
+ <i
|
|
|
+ class="icon iconfont icon-btn_wulw footer-icon"
|
|
|
+ :class="props.active ? 'footer-icon-active' : ''"
|
|
|
+ ></i>
|
|
|
+ </template>
|
|
|
+ </van-tabbar-item>
|
|
|
+ <van-tabbar-item
|
|
|
+ icon="setting-o"
|
|
|
+ to="/main/home"
|
|
|
+ :style="isIos() ? 'padding-bottom:15px' : ''"
|
|
|
+ name="home"
|
|
|
+ >
|
|
|
+ {{ $t("common.mine") }}
|
|
|
+ <template #icon="props">
|
|
|
+ <i
|
|
|
+ class="icon iconfont icon-btn_mine footer-icon"
|
|
|
+ :class="props.active ? 'footer-icon-active' : ''"
|
|
|
+ ></i>
|
|
|
+ </template>
|
|
|
+ </van-tabbar-item>
|
|
|
+ </van-tabbar>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
-import { ref, getCurrentInstance, watch,computed } from 'vue'
|
|
|
-import { getUserInfo,getToken } from '@/utils/auth'
|
|
|
-import { useRouter } from 'vue-router'
|
|
|
-import { lang } from '@/lang/cn'
|
|
|
-import * as dd from 'dingtalk-jsapi'
|
|
|
-import '@/assets/icon/iconfont.css'
|
|
|
-import 'vant/lib/index.css'
|
|
|
-import axios from 'axios'
|
|
|
-import { uploadDdRightBtn } from '@/utils/ddAdapter'
|
|
|
-import { showDialog,showNotify } from 'vant'
|
|
|
-import tabTypeStore from '@/store/modules/tabType'
|
|
|
+import { ref, getCurrentInstance, watch, computed } from "vue";
|
|
|
+import { getUserInfo, getToken } from "@/utils/auth";
|
|
|
+import { useRouter } from "vue-router";
|
|
|
+import { lang } from "@/lang/cn";
|
|
|
+import * as dd from "dingtalk-jsapi";
|
|
|
+import "@/assets/icon/iconfont.css";
|
|
|
+import "vant/lib/index.css";
|
|
|
+import axios from "axios";
|
|
|
+import { uploadDdRightBtn } from "@/utils/ddAdapter";
|
|
|
+import { showDialog, showNotify } from "vant";
|
|
|
+import tabTypeStore from "@/store/modules/tabType";
|
|
|
|
|
|
const onChange = (val) => {
|
|
|
- tabTypeStore().setTabType(val)
|
|
|
+ tabTypeStore().setTabType(val);
|
|
|
|
|
|
- if (val == 'message') {
|
|
|
- router.push('/main/message')
|
|
|
- }
|
|
|
- if (val == 'working') {
|
|
|
- router.push('/main/working')
|
|
|
- }
|
|
|
- if (val == 'equipment') {
|
|
|
- router.push('/main/equipment')
|
|
|
- }
|
|
|
- if (val == 'home') {
|
|
|
- router.push('/main/home')
|
|
|
- }
|
|
|
-}
|
|
|
-const tenantId = getUserInfo().tenantId
|
|
|
-const proxy = getCurrentInstance().proxy
|
|
|
+ if (val == "message") {
|
|
|
+ router.push("/main/message");
|
|
|
+ }
|
|
|
+ if (val == "working") {
|
|
|
+ router.push("/main/working");
|
|
|
+ }
|
|
|
+ if (val == "equipment") {
|
|
|
+ router.push("/main/equipment");
|
|
|
+ }
|
|
|
+ if (val == "home") {
|
|
|
+ router.push("/main/home");
|
|
|
+ }
|
|
|
+};
|
|
|
+const tenantId = getUserInfo().tenantId;
|
|
|
+const proxy = getCurrentInstance().proxy;
|
|
|
const tabType = computed(() => tabTypeStore().tabType);
|
|
|
-const msgCount = ref(0)
|
|
|
+const msgCount = ref(0);
|
|
|
+const msgCountOne = ref(0);
|
|
|
+
|
|
|
const socketInit = () => {
|
|
|
- window.ws = new WebSocket(
|
|
|
- 'ws://'+ process.env.VUE_APP_IP + process.env.VUE_APP_WS_API +'/webStock/' +
|
|
|
- getToken()
|
|
|
- // 'ws://192.168.1.97:8300/webStock/' + window.localStorage.getItem('token')
|
|
|
- )
|
|
|
- //申请一个WebSocket对象,参数是服务端地址,同http协议使用http://开头一样,WebSocket协议的url使用ws://开头,另外安全的WebSocket协议使用wss://开头
|
|
|
- window.ws.onopen = function () {
|
|
|
- //当WebSocket创建成功时,触发onopen事件
|
|
|
- console.log('open')
|
|
|
- }
|
|
|
- window.ws.onmessage = function (e) {
|
|
|
- //当客户端收到服务端发来的消息时,触发onmessage事件,参数e.data包含server传递过来的数据
|
|
|
- //在data.value前面插入
|
|
|
- const res = JSON.parse(e.data)
|
|
|
- console.log(res)
|
|
|
-
|
|
|
-
|
|
|
- if(res.type == 1) {
|
|
|
-
|
|
|
- if(res.list.length > 0) {
|
|
|
- showDialog({
|
|
|
- title: res.list[0].title,
|
|
|
- message: res.list[0].businessData,
|
|
|
- }).then(() => {
|
|
|
- proxy.post('/pushInfo/read', {
|
|
|
- idList: [res.list[0].id],
|
|
|
- }).then((res) => {
|
|
|
- if(res.code == 200) {
|
|
|
- showNotify({ type: 'primary', message: '确认已读' });
|
|
|
- }
|
|
|
- })
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- if(res.type == 2) {
|
|
|
- msgCount.value = res.count * 1
|
|
|
- }
|
|
|
- if(res.type == 3) {
|
|
|
- // ElNotification({
|
|
|
- // title: '提示',
|
|
|
- // message: res.title,
|
|
|
- // position: 'bottom-right',
|
|
|
- // duration:0,
|
|
|
- // })
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- window.ws.onclose = function (e) {
|
|
|
- //当客户端收到服务端发送的关闭连接请求时,触发onclose事件
|
|
|
- console.log('close')
|
|
|
- }
|
|
|
- window.ws.onerror = function (e) {
|
|
|
- //如果出现连接、处理、接收、发送数据失败的时候触发onerror事件
|
|
|
- console.log(e)
|
|
|
- }
|
|
|
-}
|
|
|
-socketInit()
|
|
|
+ window.ws = new WebSocket(
|
|
|
+ "ws://" +
|
|
|
+ process.env.VUE_APP_IP +
|
|
|
+ process.env.VUE_APP_WS_API +
|
|
|
+ "/webStock/" +
|
|
|
+ getToken()
|
|
|
+ // 'ws://192.168.1.97:8300/webStock/' + window.localStorage.getItem('token')
|
|
|
+ );
|
|
|
+ //申请一个WebSocket对象,参数是服务端地址,同http协议使用http://开头一样,WebSocket协议的url使用ws://开头,另外安全的WebSocket协议使用wss://开头
|
|
|
+ window.ws.onopen = function () {
|
|
|
+ //当WebSocket创建成功时,触发onopen事件
|
|
|
+ console.log("open");
|
|
|
+ };
|
|
|
+ window.ws.onmessage = function (e) {
|
|
|
+ //当客户端收到服务端发来的消息时,触发onmessage事件,参数e.data包含server传递过来的数据
|
|
|
+ //在data.value前面插入
|
|
|
+ const res = JSON.parse(e.data);
|
|
|
+ console.log(res);
|
|
|
+
|
|
|
+ if (res.type == 1) {
|
|
|
+ if (res.list.length > 0) {
|
|
|
+ showDialog({
|
|
|
+ title: res.list[0].title,
|
|
|
+ message: res.list[0].businessData,
|
|
|
+ }).then(() => {
|
|
|
+ proxy
|
|
|
+ .post("/pushInfo/read", {
|
|
|
+ idList: [res.list[0].id],
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ if (res.code == 200) {
|
|
|
+ showNotify({ type: "primary", message: "确认已读" });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (res.type == 2) {
|
|
|
+ msgCount.value = res.count * 1;
|
|
|
+ }
|
|
|
+ if (res.type == 3) {
|
|
|
+ // ElNotification({
|
|
|
+ // title: '提示',
|
|
|
+ // message: res.title,
|
|
|
+ // position: 'bottom-right',
|
|
|
+ // duration:0,
|
|
|
+ // })
|
|
|
+ }
|
|
|
+ };
|
|
|
+ window.ws.onclose = function (e) {
|
|
|
+ //当客户端收到服务端发送的关闭连接请求时,触发onclose事件
|
|
|
+ console.log("close");
|
|
|
+ };
|
|
|
+ window.ws.onerror = function (e) {
|
|
|
+ //如果出现连接、处理、接收、发送数据失败的时候触发onerror事件
|
|
|
+ console.log(e);
|
|
|
+ };
|
|
|
+};
|
|
|
+socketInit();
|
|
|
|
|
|
//判断是否是ios系统
|
|
|
const isIos = () => {
|
|
|
- const u = navigator.userAgent
|
|
|
- const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/) //ios终端
|
|
|
- return isIOS
|
|
|
-}
|
|
|
-
|
|
|
+ const u = navigator.userAgent;
|
|
|
+ const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
|
|
|
+ return isIOS;
|
|
|
+};
|
|
|
|
|
|
//判断是否为开发环境.如果是开发环境,则同步前后台中文配置表
|
|
|
// const isDev = process.env.NODE_ENV === 'development'
|
|
@@ -156,68 +194,68 @@ const isIos = () => {
|
|
|
// } catch (error) {}
|
|
|
// }
|
|
|
// }
|
|
|
-const corpId = window.localStorage.getItem('corpId')
|
|
|
-let routerName = ref(null)
|
|
|
+const corpId = window.localStorage.getItem("corpId");
|
|
|
+let routerName = ref(null);
|
|
|
//监听路由变化
|
|
|
-const router = useRouter()
|
|
|
+const router = useRouter();
|
|
|
//获取当前path
|
|
|
-routerName.value = router.currentRoute.value.path
|
|
|
+routerName.value = router.currentRoute.value.path;
|
|
|
watch(router.currentRoute, (to, from) => {
|
|
|
- routerName.value = to.path
|
|
|
- console.log('routerName', routerName.value)
|
|
|
- //滚动条回到顶部
|
|
|
- document.documentElement.scrollTop = 0
|
|
|
- if (!corpId) return
|
|
|
- dd.biz.navigation.setTitle({
|
|
|
- title: router.currentRoute.value.name,
|
|
|
- onSuccess: function (result) {},
|
|
|
- onFail: function (err) {},
|
|
|
- })
|
|
|
- //设置右侧按钮
|
|
|
- proxy.uploadDdRightBtn(function () {}, ' ')
|
|
|
+ routerName.value = to.path;
|
|
|
+ console.log("routerName", routerName.value);
|
|
|
+ //滚动条回到顶部
|
|
|
+ document.documentElement.scrollTop = 0;
|
|
|
+ if (!corpId) return;
|
|
|
+ dd.biz.navigation.setTitle({
|
|
|
+ title: router.currentRoute.value.name,
|
|
|
+ onSuccess: function (result) {},
|
|
|
+ onFail: function (err) {},
|
|
|
+ });
|
|
|
+ //设置右侧按钮
|
|
|
+ proxy.uploadDdRightBtn(function () {}, " ");
|
|
|
|
|
|
- //获取元素的绑定事件
|
|
|
- setTimeout(() => {
|
|
|
- if (!corpId) {
|
|
|
- return
|
|
|
- }
|
|
|
- let el = document.getElementsByClassName('van-nav-bar__content')[0]
|
|
|
- if (el) {
|
|
|
- //删除el元素
|
|
|
- el.parentNode.removeChild(el)
|
|
|
- }
|
|
|
- }, 10)
|
|
|
-})
|
|
|
+ //获取元素的绑定事件
|
|
|
+ setTimeout(() => {
|
|
|
+ if (!corpId) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let el = document.getElementsByClassName("van-nav-bar__content")[0];
|
|
|
+ if (el) {
|
|
|
+ //删除el元素
|
|
|
+ el.parentNode.removeChild(el);
|
|
|
+ }
|
|
|
+ }, 10);
|
|
|
+});
|
|
|
</script>
|
|
|
<style lang="scss">
|
|
|
.main {
|
|
|
- position: absolute;
|
|
|
- top: 0;
|
|
|
- left: 0;
|
|
|
- right: 0;
|
|
|
- bottom: 0;
|
|
|
- padding-bottom:65px;
|
|
|
- overflow-y: auto;
|
|
|
-
|
|
|
- padding-top:46px;
|
|
|
+ position: absolute;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ right: 0;
|
|
|
+ bottom: 0;
|
|
|
+ padding-bottom: 65px;
|
|
|
+ overflow-y: auto;
|
|
|
+
|
|
|
+ padding-top: 46px;
|
|
|
}
|
|
|
-.footer-icon{
|
|
|
- font-size: 20px;
|
|
|
- color: #BBBBBB;
|
|
|
+.footer-icon {
|
|
|
+ font-size: 20px;
|
|
|
+ color: #bbbbbb;
|
|
|
}
|
|
|
-.footer-icon-active{
|
|
|
- color: #3E7BFA;
|
|
|
+.footer-icon-active {
|
|
|
+ color: #3e7bfa;
|
|
|
}
|
|
|
-.footer-icon{
|
|
|
- font-size: 20px;
|
|
|
- color: #BBBBBB;
|
|
|
+.footer-icon {
|
|
|
+ font-size: 20px;
|
|
|
+ color: #bbbbbb;
|
|
|
}
|
|
|
-.footer-icon-active{
|
|
|
- color: #3E7BFA;
|
|
|
+.footer-icon-active {
|
|
|
+ color: #3e7bfa;
|
|
|
}
|
|
|
</style>
|
|
|
<style>
|
|
|
-.van-pull-refresh{
|
|
|
- flex: 1;
|
|
|
+.van-pull-refresh {
|
|
|
+ flex: 1;
|
|
|
}
|
|
|
</style>
|