Commit a519bfcb by 林永鑫

初始化项目

parent 1a98d217
> 1%
last 2 versions
not dead
module.exports = {
root: true,
env: {
node: true
},
extends: ["plugin:vue/essential", "eslint:recommended", "@vue/prettier"],
parserOptions: {
parser: "babel-eslint"
},
rules: {
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off"
},
};
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# test
## Project setup
```
yarn install
```
### Compiles and hot-reloads for development
```
yarn serve
```
### Compiles and minifies for production
```
yarn build
```
### Lints and fixes files
```
yarn lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
module.exports = {
presets: ["@vue/cli-plugin-babel/preset"]
};
This source diff could not be displayed because it is too large. You can view the blob instead.
{
"name": "test",
"version": "0.1.0",
"private": true,
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"core-js": "^3.6.5",
"echarts": "^4.9.0",
"element-ui": "^2.4.5",
"js-cookie": "^2.2.1",
"qs": "^6.9.4",
"sass-resources-loader": "^2.1.1",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vue-wechat-title": "^2.0.7",
"vuex": "^3.4.0",
"vuex-persistedstate": "^4.0.0-beta.1"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^4.5.0",
"@vue/cli-plugin-eslint": "^4.5.0",
"@vue/cli-plugin-router": "^4.5.0",
"@vue/cli-plugin-vuex": "^4.5.0",
"@vue/cli-service": "^4.5.0",
"@vue/eslint-config-prettier": "^6.0.0",
"axios": "^0.18.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.1.3",
"eslint-plugin-vue": "^6.2.2",
"node-sass": "^4.12.0",
"prettier": "^1.19.1",
"sass-loader": "^8.0.2",
"vue-cli-plugin-axios": "^0.0.4",
"vue-cli-plugin-element": "^1.0.1",
"vue-template-compiler": "^2.6.11"
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>
</head>
<body>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
</body>
</html>
<template>
<div id="app">
<router-view v-wechat-title="$route.meta.title"></router-view>
</div>
</template>
<script>
export default {};
</script>
<style></style>
var relUrlIp = window.location.host.substring(
0,
window.location.host.length - 5
);
let base = {
bigurl: "",
mapurl: "",
bigwfwurl: "",
bigservicesurl: "",
alyIP: "",
naotuPath: "",
XingZhen: "",
ZhiTu_url: "",
naotuurl: "",
Ptlogin: "",
ebss: "",
test: ""
};
if (
relUrlIp == "68.174.69.46" ||
relUrlIp == "68.175.7.118" ||
relUrlIp == "65.65.100.205" ||
relUrlIp == "68.175.7.150" ||
relUrlIp == "68.175.7.95" ||
relUrlIp == "68.174.25.98" ||
relUrlIp == "68.175.7.120"
) {
//地图后台服务路径 公安网
base.XingZhen = "http://68.174.69.95";
base.mapurl = "http://68.174.25.99:8051";
/*登陆*/
base.Ptlogin = "http://68.174.25.99:8061";
base.ebss = "http://68.174.25.107:8090";
/*脑图服务旧 公安网*/
base.bigurl = "http://77.1.24.51:8080";
/*东莞智通服务*/
base.ZhiTu_url = "http://39.99.159.210:8053";
/*脑图微服务新*/
base.bigwfwurl = "http://77.1.24.51:8050";
/*以图搜图*/
base.naotuurl = "http://47.92.226.24:8051";
base.bigservicesurl = "http://77.1.24.51:9040";
base.naotuPath = "http://68.174.25.90:8101";
/*阿里云ip*/
base.alyIP = "47.92.48.137";
} else if (relUrlIp == "47.92.48.137") {
debugger;
//地图后台服务路径
base.XingZhen = "http://68.174.69.95";
base.mapurl = "http://47.92.48.137:8050";
base.bigurl = "http://47.92.48.137:8080";
base.bigwfwurl = "http://47.92.225.109:8050";
base.bigservicesurl = "http://47.92.225.109:9040";
base.naotuPath = "http://47.92.48.137:9099";
base.naotuurl = "http://39.99.159.210:8051";
base.ZhiTu_url = "http://39.99.159.210:8053";
/*阿里云ip*/
base.alyIP = "47.92.48.137";
base.test = "http://39.99.159.210:8052";
} else {
//地图后台服务路径
base.XingZhen = "http://192.168.1.110";
base.mapurl = "http://39.99.159.210:8051";
base.bigurl = "http://47.92.48.137:8080";
base.bigwfwurl = "http://47.92.225.109:8050";
base.bigservicesurl = "http://47.92.225.109:9040";
base.naotuPath = "http://47.92.48.137:9099";
base.naotuurl = "http://39.99.159.210:8051";
base.ZhiTu_url = "http://39.99.159.210:8053";
base.Ptlogin = "http://39.99.159.210:8052";
/*阿里云ip*/
base.alyIP = "localhost";
base.test = "http://39.99.159.210:8052";
}
export default base;
import { get, post } from "@/utils/http.js";
import base from "@/api/base";
// import qs from "qs";
export const Home = params => post(`${base.test}/getNewRelationInfo`, params);
export const test = params =>
post("http://39.99.159.210:8052/getCarRyxx", params);
export const test1 = params =>
get("http://39.99.159.210:8051/getXyrSaxxDg", params);
export const login = params =>
post("https://uniapp.b2b2c.niuteam.cn/api/login/login", params);
export const code = params =>
post("https://uniapp.b2b2c.niuteam.cn/api/captcha/captcha", params);
// 参考文档:https://element.faas.ele.me/#/zh-CN/component/color#fu-zhu-se
//主色调,红色:#FF0036,绿色 #4CAF50,蓝色:#03A9F4,黄色:#FF9800,粉色:#FF547B,棕色:#C3A769,浅绿色:#65C4AA,黑色:#333333,紫色:#B323B4,淡粉色:#FF8B8B,element UI:#409eff
$base-color: #ff547b;
$base-color-success: #4caf50;
$base-color-warning: #e6a23c;
$base-color-danger: #f56c6c;
$base-color-info: #909399;
/* 文字基本颜色 */
$ns-text-color-black: #303133; //基本色
/* 文字尺寸 */
$ns-font-size-sm: 12px;
$ns-font-size-base: 14px;
$ns-font-size-lg: 16px;
$width: 1210px;
// 小
.ns-font-size-sm {
font-size: $ns-font-size-sm;
}
// 标准
.ns-font-size-base {
font-size: $ns-font-size-base;
}
// 标准
.ns-font-size-lg {
font-size: $ns-font-size-lg;
}
//文字颜色
.ns-text-color {
color: $base-color !important;
}
.ns-text-color-black {
color: $ns-text-color-black !important;
}
//边框
.ns-border-color {
border-color: $base-color !important;
}
//背景色
.ns-bg-color {
background-color: $base-color !important;
}
body {
line-height: 1.8;
font-family: 'Helvetica Neue', Helvetica, 'Microsoft Yahei', 'PingFang SC', 'Hiragino Sans GB', 'WenQuanYi Micro Hei', sans-serif;
background-color: #f7f7f7;
font-size: $ns-font-size-base;
color: $ns-text-color-black;
}
#nprogress .bar {
background: $base-color !important; //自定义颜色
}
html,
body,
dl,
dt,
dd,
ol,
ul,
h1,
h2,
h3,
h4,
h5,
h6,
p {
margin: 0;
padding: 0;
}
article,
aside,
details,
figcaption,
figure,
footer,
header,
hgroup,
menu,
nav,
section {
display: block;
}
ol,
ul,
li {
list-style: none;
}
i,
em {
font-style: normal;
}
// 去掉a标签的默认样式
a {
text-decoration: none;
color: $ns-text-color-black;
&:hover {
color: $base-color;
}
}
.el-main {
border-top: solid 1px #f2f2f2;
overflow: initial;
width: $width;
margin: 0 auto;
padding: 0;
}
img {
border-style: none;
max-width: 100%;
vertical-align: middle;
}
// 居中
.ns-text-align {
text-align: center;
}
<template>
<div class="loading-layer" v-show="isShow">
<div class="loading-anim">
<div class="box">
<div class="border out ns-border-color"></div>
<div class="border in ns-border-color"></div>
<div class="border mid ns-border-color"></div>
</div>
</div>
</div>
</template>
<script>
export default {
name: "loading-cover",
data() {
return {
isShow: true
};
},
created() {},
methods: {
show() {
this.isShow = true;
},
hide() {
this.isShow = false;
}
}
};
</script>
<style lang="scss">
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
.box {
background: red;
}
.loading-layer {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
z-index: 997;
}
.loading-anim {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
.loading-anim > view {
position: relative;
width: 40px;
height: 40px;
perspective: 800px;
transform-style: preserve-3d;
transition: all 0.2s ease-out;
}
.loading-anim .border {
position: absolute;
border-radius: 50%;
border: 2px solid;
}
.loading-anim .out {
top: 15%;
left: 15%;
width: 70%;
height: 70%;
border-left-color: transparent !important;
border-right-color: transparent !important;
animation: spin 0.8s linear reverse infinite;
}
.loading-anim .in {
top: 25%;
left: 25%;
width: 50%;
height: 50%;
border-top-color: transparent !important;
border-bottom-color: transparent !important;
animation: spin 0.8s linear infinite;
}
.loading-anim .mid {
top: 40%;
left: 40%;
width: 20%;
height: 20%;
border-left-color: transparent;
border-right-color: transparent;
animation: spin 0.6s linear infinite;
}
</style>
import Vue from "vue";
import "./plugins/axios";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "./plugins/element.js";
import Util from "./utils/util";
import VueWechatTitle from "vue-wechat-title";
import Nsloading from "./components/Loading.vue";
Vue.prototype.$store = store;
const LoadingCons = Vue.extend(Nsloading);
// 常用工具函数
Vue.prototype.$util = Util;
window.util = Util;
Vue.use(VueWechatTitle);
Vue.directive("nsLoading", {
bind(el, binding) {
const instance = new LoadingCons({
el: document.createElement("div"),
data: {}
});
el.appendChild(instance.$el);
el.instance = instance;
Vue.nextTick(() => {
el.instance.isShow = binding.value;
console.log(123);
});
console.log(el.instance);
console.log(binding);
},
/**
* 所在组件的 VNode 更新时调用
* @param {*} el
* @param {*} binding
*/
update(el, binding) {
// 通过对比值的变化判断loading是否显示
if (binding.oldValue !== binding.value) {
el.instance.isShow = binding.value;
console.log(123456);
}
// console.log(binding);
},
/**
* 只调用一次,在 指令与元素解绑时调用
* @param {*} el
*/
unbind(el) {
const mask = el.instance.$el;
if (mask.parentNode) {
mask.parentNode.removeChild(mask);
}
el.instance.$destroy();
el.instance = undefined;
}
});
new Vue({
router,
store,
render: h => h(App)
}).$mount("#app");
"use strict";
import Vue from "vue";
import axios from "axios";
// Full config: https://github.com/axios/axios#request-config
// axios.defaults.baseURL = process.env.baseURL || process.env.apiUrl || '';
// axios.defaults.headers.common['Authorization'] = AUTH_TOKEN;
// axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
let config = {
// baseURL: process.env.baseURL || process.env.apiUrl || ""
// timeout: 60 * 1000, // Timeout
// withCredentials: true, // Check cross-site Access-Control
};
const _axios = axios.create(config);
_axios.interceptors.request.use(
function(config) {
// Do something before request is sent
return config;
},
function(error) {
// Do something with request error
return Promise.reject(error);
}
);
// Add a response interceptor
_axios.interceptors.response.use(
function(response) {
// Do something with response data
return response;
},
function(error) {
// Do something with response error
return Promise.reject(error);
}
);
Plugin.install = function(Vue) {
Vue.axios = _axios;
window.axios = _axios;
Object.defineProperties(Vue.prototype, {
axios: {
get() {
return _axios;
}
},
$axios: {
get() {
return _axios;
}
}
});
};
Vue.use(Plugin);
export default Plugin;
import Vue from "vue";
import Element from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
Vue.use(Element);
import Vue from "vue";
import VueRouter from "vue-router";
import store from "../store";
import { getToken } from "../utils/auth";
import { Message } from "element-ui";
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
if (location && typeof location == "string" && location.indexOf("http") != -1)
return window.location.open(location, "_self");
return originalPush.call(this, location).catch(err => err);
};
const originalResolve = VueRouter.prototype.resolve;
VueRouter.prototype.pushToTab = function pushToTab(location) {
if (!location) return;
if (location && typeof location == "string" && location.indexOf("http") != -1)
return window.open(location, "_blank");
const { href } = originalResolve.call(this, location);
window.open(href, "_blank");
};
Vue.use(VueRouter);
const routes = [
{
path: "/",
redirect: "/home"
},
{
path: "/home",
name: "Home",
meta: {
title: "test",
auth: 5
},
component: () => import("@/views/Home.vue")
},
{
path: "/asdw",
name: "asdw",
meta: {
title: "时空大数据分析作战平台",
auth: 1
},
component: () => import("@/views/asdw.vue")
},
{
path: "*",
name: "error",
meta: {
module: "index"
},
component: () => import("@/views/index/error.vue")
},
{
path: "/login",
name: "Login",
meta: {
auth: "5"
},
component: () => import("@/views/login.vue")
}
];
const router = new VueRouter({
mode: "history",
base: process.env.BASE_URL,
routes
});
router.beforeEach((to, from, next) => {
const token = getToken();
console.log(token);
if (!token) {
return next({
path: "/login",
query: { redirect: to.fullPath }
});
}
debugger;
if (to.meta.auth < store.state.user.userAuth) {
Message.error("暂无权限");
return;
}
next();
});
export default router;
{
"token":"ashnksaifjiwemvoier",
"auth":"1"
}
\ No newline at end of file
const getters = {
token: state => state.user.token,
defaultGoodsImage: state => state.user.defaultGoodsImage,
defaultCarImage: state => state.user.defaultCarImage,
logs: state => state.user.logs,
userAuth: state => state.user.userAuth
};
export default getters;
import Vue from "vue";
import Vuex from "vuex";
import getters from "./getters";
import createPersistedState from "vuex-persistedstate";
import user from "./modules/user";
Vue.use(Vuex);
const store = new Vuex.Store({
modules: {
user
},
getters,
plugins: [
createPersistedState({
storage: window.localStorage,
reducer(val) {
const { user } = val;
return { user };
}
})
]
});
export default store;
import { getToken, removeToken, setToken } from "@/utils/auth";
import { login } from "@/api/home";
const state = {
token: getToken(),
defaultGoodsImage: require("@/assets/img/defaultGoods.jpg"),
defaultCarImage: require("@/assets/img/defaultCar.jpg"),
// logs: {
// ip: "",
// request: ""
// }
logs: [],
userAuth: ""
};
const mutations = {
SET_TOKEN: (state, token) => {
state.token = token;
},
SET_Logs: (state, content) => {
state.logs.push(content);
},
SET_Auth: (state, content) => {
state.userAuth = content;
}
};
const actions = {
remove_token({ commit }) {
commit("SET_TOKEN", "");
removeToken();
},
login({ commit }, userInfo) {
const { username, password, captcha_id, captcha_code } = userInfo;
return new Promise((resolve, reject) => {
return login({ username, password, captcha_id, captcha_code })
.then(res => {
const { code, data } = res;
if (code == 0) {
commit("SET_TOKEN", data.token);
commit("SET_Auth", "3");
if (userInfo.autoLoginRange !== undefined) {
commit("SET_AUTOLOGIN_FLAG", userInfo.autoLoginRange);
}
setToken(data.token, userInfo.autoLoginRange);
resolve(res);
}
reject();
})
.catch(_err => {
reject(_err);
});
});
}
};
export default {
namespaced: true,
state,
mutations,
actions
};
import Cookies from "js-cookie";
const TokenKey = "SDrxEA%_tWW6ezd3";
export function getToken() {
return Cookies.get(TokenKey);
}
export function setToken(token, expires = 0) {
if (expires) return Cookies.set(TokenKey, token, { expires });
return Cookies.set(TokenKey, token);
}
export function removeToken() {
return Cookies.remove(TokenKey);
}
import axios from "axios";
import { getToken } from "./auth.js";
import { Message } from "element-ui";
import store from "@/store";
let http = axios.create({
// baseURL: Config.baseUrl,
timeout: 60 * 1000
});
axios.defaults.headers = {
"X-Requested-With": "XMLHttpRequest"
};
axios.defaults.responseType = "json";
// request 请求拦截器
http.interceptors.request.use(
config => {
debugger;
config.headers["Content-Type"] = "application/json; charset=utf-8";
// 请求前进行拦截, 验证是否已经登录等
const token = getToken();
if (token) {
if (config.url.indexOf("/login") === -1) {
config.headers.common["Authorization"] = token;
}
}
if (config.contentType) {
config.headers["Content-Type"] = config.contentType;
}
return config;
},
error => {
return Promise.reject(error);
}
);
// response 响应拦截器
http.interceptors.response.use(
response => {
return response.data;
},
error => {
switch (error.response && error.response.status) {
case 500:
Message({
type: "error",
message: "网络错误, 请稍候再试",
duration: 3000
});
break;
case 504:
Message({
type: "error",
message: error.response
? `请求失败:${error.response.statusText}`
: `请求失败`,
duration: 3000
});
break;
case 404:
Message({
type: "error",
message: "请求错误,未找到该请求",
duration: 3000
});
break;
case 401:
Message({
type: "warning",
message: "登录已失效, 请重新登录",
duration: 3000
});
this.$store.dispatch("user/remove_token");
this.router.replace({
path: "/login",
query: {
redirect: this.router.currentRoute.fullPath
}
});
break;
default:
Message({
type: "error",
message: error.response
? `请求失败:${error.response.message}`
: `请求失败`,
duration: 3000
});
}
return Promise.reject(error);
}
);
var relUrlIp = window.location.host.substring(
0,
window.location.host.length - 5
);
let base = {
bigurl: "",
mapurl: "",
bigwfwurl: "",
bigservicesurl: "",
alyIP: "",
naotuPath: "",
XingZhen: "",
ZhiTu_url: "",
naotuurl: "",
Ptlogin: "",
ebss: "",
test: ""
};
if (
relUrlIp == "68.174.69.46" ||
relUrlIp == "68.175.7.118" ||
relUrlIp == "65.65.100.205" ||
relUrlIp == "68.175.7.150" ||
relUrlIp == "68.175.7.95" ||
relUrlIp == "68.174.25.98" ||
relUrlIp == "68.175.7.120"
) {
//地图后台服务路径 公安网
base.XingZhen = "http://68.174.69.95";
base.mapurl = "http://68.174.25.99:8051";
/*登陆*/
base.Ptlogin = "http://68.174.25.99:8061";
base.ebss = "http://68.174.25.107:8090";
/*脑图服务旧 公安网*/
base.bigurl = "http://77.1.24.51:8080";
/*东莞智通服务*/
base.ZhiTu_url = "http://39.99.159.210:8053";
/*脑图微服务新*/
base.bigwfwurl = "http://77.1.24.51:8050";
/*以图搜图*/
base.naotuurl = "http://47.92.226.24:8051";
base.bigservicesurl = "http://77.1.24.51:9040";
base.naotuPath = "http://68.174.25.90:8101";
/*阿里云ip*/
base.alyIP = "47.92.48.137";
} else if (relUrlIp == "47.92.48.137") {
//地图后台服务路径
base.XingZhen = "http://68.174.69.95";
base.mapurl = "http://47.92.48.137:8050";
base.bigurl = "http://47.92.48.137:8080";
base.bigwfwurl = "http://47.92.225.109:8050";
base.bigservicesurl = "http://47.92.225.109:9040";
base.naotuPath = "http://47.92.48.137:9099";
base.naotuurl = "http://39.99.159.210:8051";
base.ZhiTu_url = "http://39.99.159.210:8053";
/*阿里云ip*/
base.alyIP = "47.92.48.137";
base.test = "http://39.99.159.210:8052";
} else {
//地图后台服务路径
base.XingZhen = "http://192.168.1.110";
base.mapurl = "http://39.99.159.210:8051";
base.bigurl = "http://47.92.48.137:8080";
base.bigwfwurl = "http://47.92.225.109:8050";
base.bigservicesurl = "http://47.92.225.109:9040";
base.naotuPath = "http://47.92.48.137:9099";
base.naotuurl = "http://39.99.159.210:8051";
base.ZhiTu_url = "http://39.99.159.210:8053";
base.Ptlogin = "http://39.99.159.210:8052";
/*阿里云ip*/
base.alyIP = "localhost";
base.test = "http://39.99.159.210:8052";
}
/**
* 封装get方法
* @param url
* @param data
* @returns {Promise}
*/
export function get(url, params) {
return new Promise((resolve, reject) => {
axios
.get(url, {
params: params
})
.then(res => {
resolve(res.data);
})
.catch(err => {
reject(err.data);
});
});
}
/**
* 封装post请求
* @param url
* @param data
* @returns {Promise}
*/
export function post(url, params) {
return new Promise((resolve, reject) => {
axios.post(url, params).then(
response => {
resolve(response.data);
var urlIp = window.location.host.substring(
0,
window.location.host.length - 5
);
var logs = {
ip: urlIp,
request: url,
params: params
};
store.commit("user/SET_Logs", logs);
},
err => {
reject(err);
}
);
});
}
export default {
/**
* 时间戳转日期格式
* @param {Object} timeStamp
*/
timeStampTurnTime(timeStamp) {
if (timeStamp != undefined && timeStamp != "" && timeStamp > 0) {
var date = new Date();
date.setTime(timeStamp * 1000);
var y = date.getFullYear();
var m = date.getMonth() + 1;
m = m < 10 ? "0" + m : m;
var d = date.getDate();
d = d < 10 ? "0" + d : d;
var h = date.getHours();
h = h < 10 ? "0" + h : h;
var minute = date.getMinutes();
var second = date.getSeconds();
minute = minute < 10 ? "0" + minute : minute;
second = second < 10 ? "0" + second : second;
return y + "-" + m + "-" + d + " " + h + ":" + minute + ":" + second;
} else {
return "";
}
},
/**
* 数值去重
* @param {Array} arr 数组
* @param {string} field 字段
*/
unique(arr, field) {
const res = new Map();
return arr.filter(a => !res.has(a[field]) && res.set(a[field], 1));
},
/**
* 判断值是否在数组中
* @param {Object} elem
* @param {Object} arr
* @param {Object} i
*/
inArray: function(elem, arr) {
return arr == null ? -1 : arr.indexOf(elem);
},
/**
* 获取某天日期
* @param {Object} day
*/
getDay: function(day) {
var today = new Date();
var targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * day;
today.setTime(targetday_milliseconds);
const doHandleMonth = function(month) {
var m = month;
if (month.toString().length == 1) {
m = "0" + month;
}
return m;
};
var tYear = today.getFullYear();
var tMonth = today.getMonth();
var tDate = today.getDate();
var tWeek = today.getDay();
var time = parseInt(today.getTime() / 1000);
tMonth = doHandleMonth(tMonth + 1);
tDate = doHandleMonth(tDate);
const week = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"];
return {
t: time,
y: tYear,
m: tMonth,
d: tDate,
w: week[tWeek]
};
},
/**
* 深度拷贝对象
* @param {Object} obj
*/
deepClone(obj) {
const isObject = function(obj) {
return typeof obj == "object";
};
if (!isObject(obj)) {
throw new Error("obj 不是一个对象!");
}
//判断传进来的是对象还是数组
let isArray = Array.isArray(obj);
let cloneObj = isArray ? [] : {};
//通过for...in来拷贝
for (let key in obj) {
cloneObj[key] = isObject(obj[key]) ? this.deepClone(obj[key]) : obj[key];
}
return cloneObj;
}
};
<template>
<div class="home">
<img :src="captcha.img ? 'captcha.img' : defaultGoodsImage" />
<div class="demo" @click="toBar"></div>
<div>{{ tokeb }}</div>
<el-select v-model="value" placeholder="请选择">
<el-option
v-for="item in options"
:key="item.value"
:label="item.label"
:value="item.value"
>
</el-option>
</el-select>
<div class="demo" @click="toLogin"></div>
<el-tabs v-model="activeName" @tab-click="handleClick">
<el-tab-pane label="用户管理" name="first" v-if="userAuth < 2"
>用户管理</el-tab-pane
>
<el-tab-pane label="配置管理" name="second" v-if="userAuth < 1"
>配置管理</el-tab-pane
>
<el-tab-pane label="角色管理" name="third" v-if="userAuth < 5"
>角色管理</el-tab-pane
>
<el-tab-pane label="定时任务补偿" name="fourth" v-if="userAuth < 6"
>定时任务补偿</el-tab-pane
>
</el-tabs>
</div>
</template>
<script>
import { Home, test, test1 } from "@/api/home.js";
import { mapGetters } from "vuex";
export default {
name: "Home",
data() {
return {
tokeb: "",
captcha: {
id: "",
img: ""
},
options: [
{
value: "选项1",
label: "黄金糕"
},
{
value: "选项2",
label: "双皮奶"
},
{
value: "选项3",
label: "蚵仔煎"
},
{
value: "选项4",
label: "龙须面"
},
{
value: "选项5",
label: "北京烤鸭"
}
],
value: "",
activeName: ""
};
},
created() {
this.getHome();
this.getH();
this.getT();
},
computed: {
...mapGetters(["defaultGoodsImage", "userAuth"])
},
methods: {
getHome() {
Home({
objectValue: "粤sty989"
}).then(res => {
console.log(res);
});
},
getH() {
test({
objectValue: "粤sty989"
}).then(res => {
console.log(res);
});
},
getT() {
test1({
zjhm: 412721197608203413
}).then(res => {
console.log(res);
});
},
toBar() {
this.$router.push("/asdw");
},
toLogin() {
this.$router.push("/Login");
},
handleClick(tab, event) {
console.log(tab, event);
}
}
};
</script>
<style lang="scss">
.demo {
width: 100px;
height: 100px;
background: $base-color;
}
</style>
<template>
<div class="asdw">
<img alt="Vue logo" src="@/assets/logo.png" />
</div>
</template>
<script>
export default {
name: "asdw"
};
</script>
<template>
<div class="error-wrap">
<!-- <i class="iconfont icon404"></i>
<h2>抱歉!页面无法访问……</h2> -->
<div>
<img src="@/assets/img/404.png" />
</div>
<el-link :underline="false" @click="$router.go(-1)" class="go-back"
>返回上一页</el-link
>
<router-link to="/" class="go-index">返回首页</router-link>
</div>
</template>
<script>
export default {
name: "error",
components: {},
data: () => {
return {};
},
created() {},
methods: {}
};
</script>
<style lang="scss" scoped>
.error-wrap {
text-align: center;
padding: 40px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
div {
margin-bottom: 30px;
}
i {
font-size: 60px;
}
h2 {
margin: 0 0 30px;
}
.go-back {
margin-right: 10px;
color: $base-color;
}
.go-index {
color: $base-color;
}
}
</style>
<template>
<div class="login">
<el-form>
<el-form-item prop="vercode">
<el-input
v-model="vercode"
autocomplete="off"
placeholder="请输入验证码"
maxlength="4"
>
<template slot="prepend">
<i class="iconfont iconyanzhengma"></i>
</template>
<template slot="append">
<img :src="captcha.img" mode class="captcha" @click="getCaptcha" />
</template>
</el-input>
</el-form-item>
<el-form-item
><el-button type="primary" @click="toLogin"
>登录</el-button
></el-form-item
>
</el-form>
</div>
</template>
<script>
import { code } from "@/api/home.js";
export default {
name: "Login",
components: {},
data() {
return {
vercode: "",
captcha: {
id: "",
img: ""
}
};
},
created() {
this.getCaptcha();
},
methods: {
getCaptcha() {
code({
captcha_id: this.captcha.id
}).then(res => {
if (res.code >= 0) {
this.captcha.id = res.data.id;
this.captcha.img = res.data.img;
this.captcha.img = this.captcha.img.replace(/\r\n/g, "");
}
console.log(res);
});
},
toLogin() {
var self = this;
// login({
// username: "xxs",
// password: "123456",
// captcha_code: this.vercode,
// captcha_id: this.captcha.id
// }).then(res => {
// self.$store.commit("user/SET_TOKEN", res.data.token);
// self.$message.success("登陆成功");
// self.$router.push("/home");
// });
var data = {
username: "xxs",
password: "123456",
captcha_code: this.vercode,
captcha_id: this.captcha.id
};
self.$store
.dispatch("user/login", data)
.then(res => {
if (res.code >= 0) {
self.$message({
message: "登录成功!",
type: "success"
});
this.$router.push("/home");
} else {
self.getCaptcha();
self.$message({
message: res.message,
type: "warning"
});
}
})
.catch(err => {
self.$message.error(err.message);
self.getCaptcha();
});
}
}
};
</script>
<style lang="scss" scoped>
.el-form {
.captcha {
vertical-align: top;
max-width: inherit;
max-height: 38px;
line-height: 38px;
cursor: pointer;
}
.dynacode {
cursor: pointer;
}
[class*=" el-icon-"],
[class^="el-icon-"] {
font-size: 16px;
}
}
</style>
<template>
<div></div>
</template>
<script>
export default {
components: {},
data() {
return {};
},
created() {},
methods: {}
};
</script>
<style lang="scss" scoped></style>
const path = require("path");
// function resolve(dir) {
// return path.join(__dirname, dir);
// }
module.exports = {
publicPath: process.env.NODE_ENV === "development" ? "/" : "./",
assetsDir: "static",
configureWebpack: config => {
"#source-map";
if (process.env.NODE_ENV === "production") {
// 为生产环境修改配置...
config.mode = "production";
} else {
// 为开发环境修改配置...
config.mode = "development";
}
Object.assign(config, {
// 开发生产共同配置
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
"@c": path.resolve(__dirname, "./src/components"),
"@p": path.resolve(__dirname, "./src/pages")
} // 别名配置
}
});
},
chainWebpack: config => {
const oneOfsMap = config.module.rule("scss").oneOfs.store;
oneOfsMap.forEach(item => {
item
.use("sass-resources-loader")
.loader("sass-resources-loader")
.options({
resources: "./src/assets/styles/main.scss"
})
.end();
});
},
productionSourceMap: false, //关闭生产映射
devServer: {
overlay: {
warnings: false,
errors: false
},
proxy: {
"/api": {
target: "http://192.168.1.103:8050", //统一的请求头部每次修改都要重启才会生效
ws: true,
changeOrigin: true,
pathRewrite: {
"^/api": "/api"
}
}
}
}
};
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment