| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557 |
- // The Vue build version to load with the `import` command
- // (runtime-only or standalone) has been set in webpack.base.conf with an alias.
- import Vue from 'vue';
- // import 'element-ui/lib/theme-chalk/index.css';
- import App from './App';
- import router from './router';
- import { message } from './util/resetMessage';
- import CryptoJS from 'crypto-js';
- import NProgress from 'nprogress';
- import 'nprogress/nprogress.css';
- import './util/http.js';
- import { VueJsonp } from 'vue-jsonp';
- import JSONView from 'vue-json-viewer';
- import store from '@/store/store.js';
- // 打印
- import Print from 'vue-print-nb';
- // 滚动
- import scroll from 'vue-seamless-scroll';
- // 三级权限查询
- import { QueryPermission } from './util/QueryPermission';
- import './plugin/index';
- import VueLazyLoad from 'vue-lazyload';
- import VueClipBoard from 'vue-clipboard2'
- // 使用VueClipBoard插件,主要功能:类似于剪切板
- // import 'babel-polyfill'; // 兼容IE11
- // import promise from 'es6-promise'
- // promise.polyfill();
- // 导入全局样式
- // import './assets/css/global.css'
- // 样式
- import './assets/icon/iconfont.css';
- import './assets/css/theme/ffffff/index.css'; // 皮肤一
- import './assets/css/theme/hhhh/index.css'; // 皮肤一
- // import '../theme/index.css' //皮肤一
- import VueHighcharts from 'vue-highcharts';
- import Viewer from 'v-viewer';
- import 'viewerjs/dist/viewer.css';
- import './assets/svg'; // icon
- // 引入百度地图
- import BaiduMap from 'vue-baidu-map';
- import { BmPolygon, BmControl, BmMarker } from 'vue-baidu-map';
- // 动态网站标题
- import VueWechatTitle from 'vue-wechat-title';
- // 导入全局样式
- import './assets/css/global.css';
- import './assets/css/listCard.less';
- // 图片放大
- import preview from 'vue-photo-preview';
- import 'vue-photo-preview/dist/skin.css';
- // 图片裁剪
- import VueCropper from 'vue-cropper';
- import { loginPath, isFJ } from '@/util/constants';
- // 格式化时间戳
- import './util/formatTime';
- // 引入全局组件
- import Dialog from '@/components/Dialog';
- import Drawer from '@/components/Drawer';
- Vue.use(VueClipBoard)// 使用剪切板
- Vue.use(VueHighcharts);
- // let Vue = require('vue')
- // Vue=Vue.default
- Vue.config.productionTip = false;
- Vue.config.devtools = true;
- // import ElementUI from 'element-ui';
- const ElementUI = require('element-ui');
- // import axios from 'axios'
- // import VueAMap from 'vue-amap';
- // const ElementUI = require('element-ui')
- const axios = require('axios');
- const Qs = require('qs');
- Vue.prototype.$axios = axios; // 全局注册,使用方法为:this.$axios
- Vue.prototype.$EventBus = new Vue(); // 解决百度地图跨域
- Vue.use(VueJsonp); // JSON格式化高亮
- Vue.use(JSONView); // JSON格式化高亮
- // import qs from 'qs'
- Vue.prototype.qs = Qs; // 全局注册,使用方法为:this.qs
- Vue.prototype.$EventBus = new Vue(); // 中央时间总线
- Vue.use(ElementUI);
- Vue.prototype.$resetMessage = message;
- Vue.prototype.$store = store;
- // 注册
- Vue.use(Print);
- Vue.use(scroll);
- // Vue.use(QueryPermission)
- Vue.prototype.$QueryPermission = QueryPermission;
- Vue.component('CommonDialog', Dialog);
- Vue.component('CommonDrawer', Drawer);
- // 节流
- function throttle() {
- let prev = 0;
- Vue.prototype.$throttle = function(func, wait) {
- let now = Date.now();
- if (now - prev > wait) {
- func.apply(this);
- prev = now;
- }
- };
- }
- throttle();
- // 全局过滤 - 文本超出显示省略号 - -目前只在杀虫灯列表中使用
- Vue.filter('csdname', function(value) {
- if (!value) return '';
- if (value.length > 6) {
- return value.slice(0, 6) + '...';
- }
- return value;
- });
- // 实时监听本地存储
- Vue.prototype.resetSetItem = function(key, newVal) {
- if (key === 'btnName') {
- // 创建一个StorageEvent事件
- var newStorageEvent = document.createEvent('StorageEvent');
- const storage = {
- setItem: function(k, val) {
- sessionStorage.setItem(k, val);
- // 初始化创建的事件
- newStorageEvent.initStorageEvent(
- 'setItem',
- false,
- false,
- k,
- null,
- val,
- null,
- null
- );
- // 派发对象
- window.dispatchEvent(newStorageEvent);
- }
- };
- return storage.setItem(key, newVal);
- }
- };
- Vue.use(VueLazyLoad, {
- preLoad: 1,
- error: require('./assets/images/newImg/noimage.png'),
- loading: require('./assets/images/newImg/shot-1.gif'),
- attempt: 2
- });
- // Vue.prototype.jsonUrl = 'http://8.136.98.49'; //地图三级下钻页面使用-韩有波
- Vue.prototype.$amapKey = 'b96a1c32b0bb828f1d153b219fa59ecc'; // 高德地图 web服务 key
- Vue.prototype.$imageURL = 'https://s3.hnyfwlw.com/webstaticimg'; // 线上图片服务器路径常量1
- Vue.prototype.$imghost = 'https://s3.hnyfwlw.com/webstaticimg/projectimg'; // 线上图片服务器路径常量2
- Vue.prototype.$insectHost = 'https://images.weserv.nl/?url='; // 线上图片服务器路径常量
- Vue.prototype.$deriveData = Vue.prototype.DOMIN; // 导出
- // Vue.prototype.$deriveData = 'http://192.168.1.112:8002' // 导出
- Vue.prototype.$faultvideo = 'http://192.168.1.3:8000'; // 售后视频地址前缀
- Vue.config.productionTip = false;
- Vue.use(Viewer, {
- defaultOptions: {
- zIndex: 9999
- }
- });
- Vue.use(BaiduMap, BmPolygon, BmControl, BmMarker, {
- ak: 'pAT8YhkMx1HVQIWOLZcYoQAty1myB4Sn'
- });
- Vue.use(VueWechatTitle);
- Vue.use(preview);
- Vue.use(VueCropper);
- // 设备类型
- Vue.filter('equipType', function(i) {
- switch (i) {
- case '2':
- return '杀虫灯';
- case '3':
- return '虫情测报灯';
- case '4':
- return '性诱测报';
- case '5':
- return '环境监测';
- case '6':
- return '监控';
- case '7':
- return '孢子仪';
- case '8':
- return '性诱3.0';
- case '9':
- return '糖醋测报';
- case '10':
- return '性诱2.0';
- case '11':
- return '小麦赤霉病';
- case '12':
- return '吸虫塔';
- case '13':
- return '水肥一体化';
- case '14':
- return '虫害可视监测';
- case '15':
- return '管式墒情';
- case '16':
- return '温室大棚';
- case '17':
- return '水电双计';
- case '18':
- return '水肥一体化';
- case '19':
- return '玉米大斑病';
- case '20':
- return '小麦条锈病';
- }
- });
- Vue.directive('btnRight', {
- inserted: function(el, binding, vnode) {
- const optName = binding.arg;
- const routeName = binding.value.slice(7); // 路由地址
- const authName = `${routeName}_${optName}`; // 这里根据路由名和操作类型拼出按钮名 overview-edit
- const btnRightList = store.getters.btnRight;
- if (btnRightList[authName] == 0) {
- el.parentNode.removeChild(el);
- } else if (btnRightList[authName] == 1) {
- }
- }
- });
- let webTitle = '大数据平台';
- var getPath = arr => {
- const firstMenu = 'systemManagement';
- const secondMenu = 'userManger';
- const thirdMenu = 'add_user_purview';
- const firstData = arr.children.find(v => v.menu === firstMenu);
- if (firstData) {
- const secondData = firstData.children.find(v => v.menu === secondMenu);
- if (secondData) {
- const thirdData = secondData.children.find(v => v.menu === thirdMenu);
- if (thirdData) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- } else {
- return false;
- }
- };
- router.beforeEach(async (to, from, next) => {
- // console.log(to.path, to.name, from);
- let isSy =
- to.path.indexOf('syIndex') != -1 ||
- to.path.indexOf('syLogin') != -1 ||
- to.path.indexOf('bsy_park') != -1 ||
- to.path.indexOf('sySys_v2_1') != -1 ||
- to.path.indexOf('syIndex_v2_1') != -1 ||
- to.path.indexOf('syLogin_v2_1') != -1 ||
- to.path.indexOf('/syM/') != -1 ||
- to.path.indexOf('/syM_v2_1/') != -1 ||
- to.path.indexOf('/syLoading') != -1 ||
- to.name == 'downApk' ||
- to.name == 'downApk_v2_1' ||
- to.name == 'bSy_v2';
- NProgress.start();
- if (to.meta.title) {
- // document.title = to.meta.title + ' - ' + webTitle;
- if (to.meta.isAbsoluteTitle) {
- document.title = to.meta.title;
- } else {
- document.title = webTitle + ' - ' + to.meta.title;
- }
- } else {
- document.title = webTitle;
- }
- if (to.meta.title == '数联设备预警页' || to.meta.title == '农产品溯源系统') {
- document.title = to.meta.title;
- }
- const isLogin = store.state.isLogin; // 大数据平台登录状态
- if (to.path == '/login' || to.path == '/fjlogin') {
- if (isLogin) {
- if (isFJ) {
- next({
- path: '/fengjiang/index'
- });
- } else {
- next({
- path: '/index/' + store.state.firstPage
- });
- }
- } else {
- next();
- }
- } else if (
- to.path == '/recognition' ||
- to.path == '/externalindex' ||
- to.path == '/warning' ||
- to.path == '/qualitytesting' ||
- to.path == '/qualitytestinginfo' ||
- to.path == '/pestanalysis' ||
- to.path == '/retrospect' ||
- to.path == '/recognitionpaddyfield' ||
- to.path == '/external-env-setting' ||
- to.path == '/external-env-setting/list' ||
- to.path == '/external-env-setting/factor' ||
- to.path == '/external-env-setting/sensor' ||
- to.name == 'TracebackDetailApp' ||
- to.name == 'TracebackDetail' ||
- to.name == 'FaultUp' ||
- to.name == 'expertDatabase' ||
- to.name == 'cbdFile' ||
- to.name == 'scdFile' ||
- to.name == 'bzyFile' ||
- to.name == 'xycbFile' ||
- to.name == 'qxzFile' ||
- to.name == 'nlxyFile' ||
- to.name == 'sqtxFile' ||
- to.name == 'xctFile'
- ) {
- next();
- } else {
- // 白名单
- // //console.log(to.query.token)
- if (to.query.type == 'xctx') {
- var key = 'hnyfkj_yfb_zhang';
- var iv = 11;
- let secreIv = CryptoJS.enc.Utf8.parse(iv);
- let secreKey = CryptoJS.enc.Utf8.parse(key);
- let decrypt = CryptoJS.AES.decrypt(to.query.username, secreKey, {
- iv: secreIv,
- mode: CryptoJS.mode.ECB,
- padding: CryptoJS.pad.Pkcs7
- });
- let decrypt2 = CryptoJS.AES.decrypt(to.query.passwold, secreKey, {
- iv: secreIv,
- mode: CryptoJS.mode.ECB,
- padding: CryptoJS.pad.Pkcs7
- });
- var username = CryptoJS.enc.Utf8.stringify(decrypt);
- var password = CryptoJS.enc.Utf8.stringify(decrypt2);
- axios({
- method: 'POST',
- url: '/api/api_gateway?method=user.login.login_user',
- data: Qs.stringify({
- username: username,
- password: password
- })
- }).then(res => {
- if (res.data.message == '') {
- // 菜单第一项
- let first = res.data.data.data.children[0];
- // console.log(first);
- let firstPage = '';
- // console.log(res.data.data.data);
- const isNotToIndex = res.data.data.data.children.find(
- v => v.menu === 'bHome'
- );
- localStorage.setItem('isQuanXian', getPath(res.data.data.data)); // 当前用户权限
- if (first.children) {
- firstPage = first.children[0].menu; // 有二级菜单
- } else {
- firstPage = first.menu; // 首页
- }
- localStorage.setItem('firstPage', firstPage);
- localStorage.setItem('cUsername', res.data.params.username);
- if (to.path == '/index/pestsStats') {
- next({
- path: to.path + '?identify_model=A'
- });
- } else {
- next({
- path: to.path
- });
- }
- } else {
- next({
- path: loginPath
- });
- }
- });
- } else if (to.query.type == 'dhkj') {
- // 针对大华 登录
- // 校验token
- axios({
- method: 'POST',
- url: '/api/api_gateway?method=user.login.dh_login_user',
- data: Qs.stringify({
- dh_token: to.query.token,
- addr: to.query.addr,
- uid: to.query.uid,
- type: to.query.type
- })
- }).then(res => {
- if (res.data.message == '') {
- // console.log(res.data.data.data);
- // 菜单第一项
- let first = res.data.data.data.children[0];
- let firstPage = '';
- // console.log(res.data.data.data);
- // const isNotToIndex = res.data.data.data.children.find(
- // v => v.menu === 'bHome'
- // );
- // 去除中间页跳转
- const isNotToIndex = false
- localStorage.setItem('isQuanXian', getPath(res.data.data.data)); // 当前用户权限
- if (isNotToIndex) {
- // this.$router.push("/SwitchPages");
- next({
- path: '/SwitchPages'
- });
- } else {
- if (first.children) {
- firstPage = first.children[0].menu; // 有二级菜单
- } else {
- firstPage = first.menu; // 首页
- }
- let selHome = sessionStorage.getItem('selHome');
- if (selHome) {
- next({
- path: selHome
- });
- } else {
- next({
- path: '/index/' + firstPage
- });
- localStorage.setItem('firstPage', firstPage);
- }
- }
- // console.log(res);
- localStorage.setItem('cUsername', res.data.params.username);
- next();
- } else {
- next({
- path: loginPath
- });
- }
- });
- // next({
- // path: '/login'
- // });
- } else if (isLogin) {
- next();
- } else {
- try {
- if (!isSy) {
- // 进入大数据平台
- var box = document.getElementById('app-loading');
- box.style.zIndex = '1000';
- var boxText = document.getElementById('app-loading-text');
- boxText.innerText = '玩命加载中...';
- // 获取用户信息和权限信息及网站信息
- await store.dispatch('loginUsersCheck');
- await store.dispatch('getUserInfo');
- const userName = await store.dispatch('getNavList');
- boxText.innerText = '欢迎您,' + userName;
- if (to.path == '/') {
- if (isFJ) {
- next({
- path: '/fengjiang/index'
- });
- } else {
- next({
- path: '/index/' + store.state.firstPage
- });
- }
- } else {
- next({
- ...to,
- replace: true
- });
- }
- } else {
- // //console.log(to, from, 'to, from')
- // 进入溯源系统
- document.title = '溯源平台';
- let sy_isLogin = sessionStorage.getItem('sy_isLogin'); // 溯源2.0登录状态
- if (to.path === '/syLogin') {
- // 溯源2.0登录
- if (sy_isLogin) {
- next('/syLoading');
- } else {
- next();
- }
- } else if (to.path === '/syLogin_v2_1') {
- // 溯源2.1
- if (sy_isLogin == true) {
- next('/syLoading_v2_1');
- } else {
- next();
- }
- } else if (to.path === '/syLoading') {
- // 进入的是2.0
- next('/syIndex');
- } else if (to.path === '/syLoading_v2_1') {
- // 进入的是2.1
- next('/syIndex_v2_1');
- } else if (
- to.name === 'sanCode' ||
- to.name === 'downApk' ||
- to.name === 'sanCode_v2_1' ||
- to.name === 'downApk_v2_1'
- ) {
- // 扫溯源码页面,扫码下载app页面
- next();
- } else if (to.path.indexOf('/syM/') != -1) {
- // 操作员手机端
- next();
- } else {
- if (sy_isLogin) {
- next();
- } else {
- next('/syLogin');
- }
- }
- }
- } catch (error) {
- await store.dispatch('loginOut');
- next({
- path: loginPath
- });
- }
- }
- }
- });
- router.afterEach(() => {
- NProgress.done();
- var box = document.getElementById('app-loading');
- box.style.zIndex = '-1';
- });
- /* eslint-disable no-new */
- new Vue({
- el: '#app',
- router,
- store,
- components: {
- App
- },
- template: '<App/>'
- });
|