743d837e by simon

默认提交

1 parent 2aa603f3
NODE_ENV = 'development'
VUE_APP_TITLE = 'development'
VUE_APP_PUBLIC_PATH = './'
VUE_APP_OUTPUT_DIR = 'dist'
\ No newline at end of file
NODE_ENV = 'production'
VUE_APP_TITLE = 'fev'
\ No newline at end of file
NODE_ENV = 'production'
VUE_APP_TITLE = 'production'
VUE_APP_PUBLIC_PATH = './'
VUE_APP_OUTPUT_DIR = 'dist'
\ No newline at end of file
NODE_ENV = 'production'
VUE_APP_TITLE = 'sandbox'
VUE_APP_PUBLIC_PATH = './'
VUE_APP_OUTPUT_DIR = 'sandbox'
......@@ -3,6 +3,8 @@ node_modules
/dist
/fev
sync.sh
# local env files
.env.local
.env.*.local
......
......@@ -6,7 +6,7 @@
"serve": "vue-cli-service serve",
"dev": "vue-cli-service serve",
"build": "vue-cli-service build",
"fev": "vue-cli-service build --mode fev",
"sandbox": "vue-cli-service build --mode sandbox",
"lint": "vue-cli-service lint",
"oss": "node build/oss-released.js"
},
......@@ -17,11 +17,16 @@
"axios-mock-adapter": "^1.16.0",
"co": "^4.6.0",
"core-js": "^2.6.5",
"crypto-js": "^4.0.0",
"jsencrypt": "^3.0.0-rc.1",
"moment": "^2.29.1",
"glob": "^7.1.4",
"js-cookie": "^2.2.1",
"mockjs": "^1.0.1-beta3",
"postcss-px2rem": "^0.3.0",
"postcss-pxtorem": "^4.0.1",
"vant": "^1.6.21",
"sass-resources-loader": "^2.0.3",
"vant": "^2.2.11",
"vue": "^2.6.10",
"vue-router": "^3.0.3",
"vuex": "^3.0.1"
......@@ -34,8 +39,8 @@
"babel-plugin-import": "^1.12.0",
"eslint": "^5.16.0",
"eslint-plugin-vue": "^5.0.0",
"node-sass": "^4.12.0",
"sass-loader": "^7.1.0",
"node-sass": "^5.0.0",
"sass-loader": "^10.1.0",
"vue-template-compiler": "^2.6.10"
}
}
......
......@@ -4,13 +4,11 @@
<router-link to="/">Home</router-link> |
<router-link to="/about">About</router-link>
</div>-->
<router-view/>
<router-view />
</div>
</template>
<style lang="scss">
@import './styles/support.scss';
#app {
/* font-family: 'Avenir', Helvetica, Arial, sans-serif;
-webkit-font-smoothing: antialiased;
......@@ -82,6 +80,4 @@ div {
.app__content {
position: relative;
}
</style>
......
import axios from 'axios';
// import {
// Toast
// } from 'vant';
function Toast(msg) {
console.log("msg:", msg);
}
import {
Toast
} from 'vant';
import router from '@/router'
import {
getToken,
setToken,
removeToken
} from '@/utils/auth'
import {
makeEncrypt
} from '@/utils/encrypt-util'
import api from '@/api/api';
// axios的默认url
// axios.defaults.baseURL = ""
// 服务器地址
// let base = process.env.VUE_APP_API_HOST + "/jxMallApi";
let base = "https://ow.go.qudone.com";
if (location.href.indexOf("//k.wxpai.cn") > 0) {
base = "https://api.k.wxpai.cn/bizproxy"
}
// let base = COM.baseUrl;
// 请求拦截器
// axios.interceptors.request.use(
......@@ -33,11 +43,37 @@ if (location.href.indexOf("//k.wxpai.cn") > 0) {
// 响应拦截器
axios.interceptors.response.use(
response => {
let {
config
} = response;
let {
opt
} = config;
// 服务器状态码
if (response.status === 200) {
// 业务状态码
if (response.data.code === 200) {
return Promise.resolve(response);
} else {
Toast(response.data.bizMsg);
if (typeof (opt) == "undefined" || typeof (opt.toast) == "undefined" || opt.toast) {
Toast(response.data.errMsg);
}
switch (response.data.code) {
/**
* 登陆失败
* 清除cookies
* 根据业务可能要引导回登陆页
*/
case 403:
removeToken();
break;
default:
break;
}
return Promise.reject(response);
}
} else {
......@@ -48,49 +84,7 @@ axios.interceptors.response.use(
error => {
if (error.response.status) {
switch (error.response.status) {
// 401: 未登录
// 未登录则跳转登录页面,并携带当前页面的路径
// 在登录成功后返回当前页面,这一步需要在登录页操作。
case 401:
router.replace({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
});
break;
// 403 token过期
// 登录过期对用户进行提示
// 清除本地token和清空vuex中token对象
// 跳转登录页面
case 403:
Toast({
message: '登录过期,请重新登录',
duration: 1000,
forbidClick: true
});
// 清除token
localStorage.removeItem('token');
store.commit('loginSuccess', null);
// 跳转登录页面,并将要浏览的页面fullPath传过去,登录成功后跳转需要访问的页面
setTimeout(() => {
router.replace({
path: '/login',
query: {
redirect: router.currentRoute.fullPath
}
});
}, 1000);
break;
// 404请求不存在
case 404:
Toast({
message: '网络请求不存在',
duration: 1500,
forbidClick: true
});
break;
// 其他错误,直接抛出错误提示
// 其他错误,直接抛出错误提示
default:
Toast({
message: error.response.data.message,
......@@ -103,6 +97,7 @@ axios.interceptors.response.use(
}
);
//formDataHeaders设置
let formDataHeaders = {
headers: {
......@@ -113,14 +108,31 @@ let formDataHeaders = {
/**
* 封装get方法
* @param {*} params
*
*/
export const httpGet = params => {
let {
url,
data
data,
mode,
opt = Object.assign({}, params.opt),
sid = true
} = params;
return axios.get(`${base}${url}`, {
params: data
if (opt.enc) {
data = makeEncrypt(data);
}
let reqUrl = `${base}${url}`;
if (mode == "custom") {
reqUrl = `${url}`
}
let headers = {}
if (sid) {
headers.sessionId = getToken();
}
return axios.get(reqUrl, {
params: data,
headers,
opt
}).then(res => res.data.content);
}
......@@ -131,9 +143,26 @@ export const httpGet = params => {
export const httpPost = params => {
let {
url,
data
data,
mode,
opt = Object.assign({}, params.opt),
sid = true
} = params;
return axios.post(`${base}${url}`, data).then(res => res.data.content);
if (opt.enc) {
data = makeEncrypt(data);
}
let reqUrl = `${base}${url}`;
if (mode == "custom") {
reqUrl = `${url}`
}
let headers = {}
if (sid) {
headers.sessionId = getToken();
}
return axios.post(reqUrl, data, {
headers,
opt
}).then(res => res.data.content);
}
......@@ -143,14 +172,40 @@ export const httpPost = params => {
* data数据是 formdata格式
* 例如:
* this.file = file
let data = new FormData() //使用formData对象
data.append('path', '/pro/mzczcradmin/')
data.append('file', file.file)
let data = new FormData() //使用formData对象
data.append('path', '/pro/mzczcradmin/')
data.append('file', file.file)
*/
export const formdata = params => {
let {
url,
data
data,
} = params;
return axios.post(`${base}${url}`, data, formDataHeaders).then(res => res.data);
let formData = new FormData(); //使用formData对象
for (let key in data) {
formData.append(key, data[key]);
}
return axios.post(`${base}${url}`, formData, formDataHeaders).then(res => res.data.content);
}
/**
* 打点
* @param {*} params
*/
export const stat = data => {
data.s = encodeURIComponent(getToken());
let reqUrl = `${base}${api.stat}`;
let opt = {
toast: false
}
let headers = {}
// headers.sessionId = getToken();
return axios.get(reqUrl, {
params: data,
headers,
opt
}).then(res => res.data.content);;
}
\ No newline at end of file
......
// 字体放在同目录下
// @font-face {
// font-family: 'vivo-BoldExtended';
// src: url('./vivo-BoldExtended.ttf');
// font-weight: normal;
// font-style: normal;
// font-family: 'BentonSans';
// src: url('BentonSans-Regular_sOT.otf');
// }
// @font-face {
// font-family: 'vivo-Regular';
// src: url('./vivo-Regular.ttf');
// font-weight: normal;
// font-style: normal;
// }
// @font-face {
// font-family: 'regular2';
// src: url('./regular2.otf');
// font-weight: normal;
// font-style: normal;
// }
\ No newline at end of file
\ No newline at end of file
......
......@@ -3,13 +3,45 @@ import App from './App.vue'
import router from './router'
import store from './store'
import Mock from './mock'
Mock.bootstrap();
// import Mock from './mock'
// Mock.bootstrap();
import 'amfe-flexible/index.js'
import '@/styles/index.scss' // global css
import '@/styles/index.scss' // global css
import '@/styles/fonticon.scss' // 图标字体
import '@/assets/fonts/font.scss' // 字体引入
// import '@styles/utils.scss' /*引入公共样式*/
Vue.config.productionTip = false
import {
Swipe,
SwipeItem,
Lazyload,
Tab,
Tabs,
Sticky,
Popup,
Tabbar,
TabbarItem,
Icon,
Toast
} from 'vant';
Vue.use(Swipe).use(SwipeItem)
.use(Lazyload)
.use(Tab).use(Tabs)
.use(Sticky)
.use(Popup)
.use(Tabbar).use(TabbarItem)
.use(Icon)
.use(Toast);
new Vue({
router,
store,
......@@ -17,4 +49,4 @@ new Vue({
isInit: false,
},
render: h => h(App)
}).$mount('#app')
}).$mount('#app')
\ No newline at end of file
......
<template>
<div class="home">home</div>
<div class="home">
<div >旅游必备清单</div>
</div>
</template>
<script>
......@@ -11,5 +14,6 @@ export default {
<style lang="scss" scoped>
.home {
text-align: center;
font-size: 14PX;
}
</style>
......
......@@ -15,7 +15,5 @@ export default {
initData() {}
},
mounted() {},
created() {
console.log("demo created");
}
created() {}
}
\ No newline at end of file
......
File mode changed
<template>
<div class="page">
<div class="app__bgc bgc"></div>
<div class="app__bg bg"></div>
<div class="app__content main">
<div class="top-space"></div>
<div class="content">
<!-- <span class="iconfont iconclose">demo</span> -->
demo
</div>
</div>
</div>
</template>
<script src="./demo.js"></script>
<style lang="scss" scoped>
@import './demo.scss';
</style>
\ No newline at end of file
@import './../../styles/support';
import api from '../../api/api'
import {
httpGet,
httpPost
} from '../../api/fetch-api.js'
export default {
data() {
return {
key: 'value'
}
},
components: {},
methods: {
initData() {},
toLottery() {
this.$router.push({
path: "/lottery"
})
}
},
mounted() {},
created() {
}
}
\ No newline at end of file
......@@ -6,13 +6,13 @@
<div class="app__content main">
<div class="top-space"></div>
<div class="content">
<span class="iconfont iconclose">demo</span>
<div @click="toLottery">Index</div>
</div>
</div>
</div>
</template>
</template>
<script src="./index.js"></script>
<style lang="scss" scoped>
// @import './index.scss';
@import "./index.scss";
</style>
\ No newline at end of file
......
import api from '../../api/api'
import {
httpGet,
httpPost
} from '../../api/fetch-api.js'
export default {
data() {
return {
key: 'value'
}
},
components: {},
methods: {
initData() {},
toIndex() {
this.$router.push({
path: "/"
})
},
},
mounted() {},
created() {}
}
\ No newline at end of file
.content {
color: $colorBlue;
@extend .underline;
}
<template>
<div class="page">
<div class="app__bgc bgc"></div>
<div class="app__bg bg"></div>
<div class="app__content main">
<div class="top-space"></div>
<div class="content">
<div @click="toIndex">lottery</div>
</div>
</div>
</div>
</template>
<script src="./lottery.js"></script>
<style lang="scss" scoped>
@import "./lottery.scss";
</style>
\ No newline at end of file
import Vue from 'vue'
import Router from 'vue-router'
import Home from './pages/Home.vue'
import Index from './pages/index/index.vue'
Vue.use(Router)
const routes = [{
path: '/',
name: 'home',
component: Home,
name: 'index',
component: Index,
meta: {
title: '首页'
title: ''
}
},
{
path: '/lottery',
name: 'lottery',
component: () => import('./pages/lottery/lottery.vue'),
meta: {
title: 'lottery'
}
},
{
path: '/demo',
name: 'demo',
component: () => import('./pages/demo/index.vue'),
component: () => import('./pages/demo/demo.vue'),
meta: {
title: '模板'
}
......
/**
* ------------------------------------------------------------------
* 支持文件
* 需要引用的地方均需要加上这个支持文件
*
* ------------------------------------------------------------------
*
*/
@import "mixins";
@import "var";
// 图标字体
@import "fonticon";
// 字体引入
@import './../assets/fonts/font.scss'
\ No newline at end of file
/**
* ------------------------------------------------------------------
* 原子类
*
* ------------------------------------------------------------------
*
*/
@import "support";
// Margin
.u-mt-smaller {
margin-top: $marginTopSmaller;
}
.u-mt-small {
margin-top: $marginTopSmall;
}
.u-mt-medium {
margin-top: $marginTopMedium;
}
.u-mt-large {
margin-top: $marginTopLarge;
}
.u-mt-larger {
margin-top: $marginTopLarger;
}
.u-mb-smaller {
margin-bottom: $marginTopSmaller;
}
.u-mb-small {
margin-bottom: $marginTopSmall;
}
.u-mb-medium {
margin-bottom: $marginTopMedium;
}
.u-mb-large {
margin-bottom: $marginTopLarge;
}
.u-mb-larger {
margin-bottom: $marginTopLarger;
}
// Padding
.u-pt-smaller {
padding-top: $paddingTopSmaller;
}
.u-pt-small {
padding-top: $paddingTopSmall;
}
.u-pt-medium {
padding-top: $paddingTopMedium;
}
.u-pt-large {
padding-top: $paddingTopLarge;
}
.u-pt-larger {
padding-top: $paddingTopLarger;
}
.u-pb-smaller {
padding-bottom: $paddingTopSmaller;
}
.u-pb-small {
padding-bottom: $paddingTopSmall;
}
.u-pb-medium {
padding-bottom: $paddingTopMedium;
}
.u-pb-large {
padding-bottom: $paddingTopLarge;
}
.u-pb-larger {
padding-bottom: $paddingTopLarger;
}
// 布局方位
.u-ta-c {
text-align: center !important;
}
.u-ta-l {
text-align: left !important;
}
.u-ta-r {
text-align: right !important;
}
.u-fl-l {
float: left;
}
.u-fl-n {
float: none;
}
.u-fl-r {
float: right;
}
.u-d-b {
display: block;
}
.u-d-i {
display: inline !important;
}
.u-d-ib {
display: inline-block !important;
}
.u-d-n {
display: none !important;
}
.u-d-t {
display: table;
table-layout: fixed;
}
.u-d-tc {
display: table-cell;
}
.u-va-b {
vertical-align: bottom;
}
.u-va-m {
vertical-align: middle;
}
.u-va-t {
vertical-align: top;
}
// clearfix
.u-clearfix {
@include clearfix;
}
// 虚拟格式
.u-cur-d {
cursor: default;
}
.u-cur-p {
cursor: pointer;
}
// flex
.u-flex {
display: -webkit-box;
display: -webkit-flex;
display: flex;
}
.u-flex-item {
-webkit-box-flex: 1;
-webkit-flex: 1;
flex: 1;
}
// 小程序中模拟ul、li
.u-ul {
padding-left: 30px;
text-align: left;
display: block;
}
.u-li {
position: relative;
font-size: $fontSizeSmall;
line-height: $fontSizeSmall + 4px;
margin-bottom: $marginTopSmall;
&:before {
position: absolute;
content: " ";
top: 14px;
left: -20px;
width: 8px;
height: 8px;
border-radius: 8px;
background-color: $colorBlack;
}
}
#app {
border: 0;
margin: 0;
padding: 0;
}
body,
div {
border: 0;
margin: 0;
padding: 0;
}
.app__width {
width: 750px;
}
.app__width {
width: 750px;
}
.app__inner {
margin: 20px;
}
.app__title {
font-size: $fontSize;
line-height: $fontSize + 4px;
font-weight: bold;
padding-bottom: 10px;
margin-bottom: 20px;
border-bottom: 0.5px solid #eeeeee;
}
.app__desc {
font-size: $fontSizeSmaller;
line-height: $fontSizeSmaller + 2px;
margin-bottom: 20px;
color: $colorGray;
}
.app__bgc {
position: fixed;
background-color: #ffffff;
width: 100%;
height: 100%;
}
.app__bg {
position: absolute;
width: 100%;
height: 100%;
}
.app__top-shadow {
position: fixed;
width: 750px;
height: 1px;
box-shadow: 0px 4px 0.9px 0.1px rgba(6, 0, 1, 0.07);
background-color: #ffffff;
}
.app__content {
position: relative;
}
/**
* ------------------------------------------------------------------
* Sass Minxins
*
* 参考收集:
* https://github.com/twbs/bootstrap-sass/tree/master/assets/stylesheets/bootstrap/mixins
* ------------------------------------------------------------------
*
*/
// 居中按钮样式
@mixin btn-center($width, $height) {
width: $width;
height: $height;
line-height: $height;
text-align: center;
}
// 超过多少行自动省略 默认一行
@mixin ellipsis($line: 1) {
display: -webkit-box;
word-break: break-all;
-webkit-box-orient: vertical;
-webkit-line-clamp: $line;
overflow: hidden;
text-overflow: ellipsis;
-ms-text-overflow: ellipsis;
}
@mixin ellipsis1() {
display: -webkit-box;
word-break: break-all;
-webkit-box-orient: vertical;
-webkit-line-clamp: 1;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
// 文字截取
@mixin text-overflow() {
overflow: hidden;
white-space: normal;
text-overflow: ellipsis;
word-break: break-all;
word-wrap: normal;
overflow: hidden;
white-space: normal;
text-overflow: ellipsis;
word-break: break-all;
word-wrap: normal;
}
@mixin word-break() {
word-break: break-all;
word-wrap: break-word;
white-space: normal;
word-break: break-all;
word-wrap: break-word;
white-space: normal;
}
// No wrap
@mixin no-wrap() {
word-break: normal;
word-wrap: normal;
white-space: nowrap;
word-break: normal;
word-wrap: normal;
white-space: nowrap;
}
// 清除浮动
@mixin clearfix() {
&:before,
&:after {
content: " "; // 1
display: table; // 2
}
&:after {
clear: both;
}
&:before,
&:after {
content: " "; // 1
display: table; // 2
}
&:after {
clear: both;
}
}
// Single side border-radius
@mixin border-top-radius($radius) {
border-top-right-radius: $radius;
border-top-left-radius: $radius;
border-top-right-radius: $radius;
border-top-left-radius: $radius;
}
@mixin border-right-radius($radius) {
border-bottom-right-radius: $radius;
border-top-right-radius: $radius;
border-bottom-right-radius: $radius;
border-top-right-radius: $radius;
}
@mixin border-bottom-radius($radius) {
border-bottom-right-radius: $radius;
border-bottom-left-radius: $radius;
border-bottom-right-radius: $radius;
border-bottom-left-radius: $radius;
}
@mixin border-left-radius($radius) {
border-bottom-left-radius: $radius;
border-top-left-radius: $radius;
border-bottom-left-radius: $radius;
border-top-left-radius: $radius;
}
// Center-align a block level element
@mixin center-block() {
display: block;
margin-left: auto;
margin-right: auto;
display: block;
margin-left: auto;
margin-right: auto;
}
// CSS image replacement
// Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757
@mixin hide-text() {
font-size: 0;
line-height: 0;
color: transparent;
text-shadow: none;
background-color: transparent;
border: 0;
font-size: 0;
line-height: 0;
color: transparent;
text-shadow: none;
background-color: transparent;
border: 0;
}
// 橙色底实心 自定义圆角按钮
@mixin btc($hei: 22px, $borderRadius: 4px, $padding: 12px, $fontSize: 14px) {
@extend .fcc;
padding: 0 $padding;
height: $hei;
line-height: normal;
text-align: center;
border-radius: $borderRadius;
background-color: $cOrange;
font-size: $fontSize;
color: #ffffff;
letter-spacing: 1.4px;
cursor: pointer;
user-select: none;
}
// 白底空心 自定义圆角按钮
@mixin btc-o($hei: 22px, $borderRadius: 4px, $padding: 12px, $fontSize: 14px) {
@extend .fcc;
@extend .bb;
padding: 0 $padding;
height: $hei;
line-height: normal;
text-align: center;
border-radius: $borderRadius;
font-size: $fontSize;
color: $cOrange;
letter-spacing: 1.4px;
background-color: #ffffff;
cursor: pointer;
border: solid 1px $cOrange;
user-select: none;
}
// 定宽 橙色底实心圆角按钮
@mixin btc2($wid: 118px, $hei: 22px, $fontSize: 14px) {
width: $wid;
height: $hei;
line-height: $hei + 2px;
text-align: center;
border-radius: $hei * 0.5;
background-color: $cOrange;
font-size: $fontSize;
color: #ffffff;
letter-spacing: 1.4px;
cursor: pointer;
user-select: none;
}
// 橙框橙字
@mixin btc3($hei: 22px, $fontSize: 14px) {
height: $hei;
line-height: $hei;
padding: 0 12px;
text-align: center;
border-radius: 2px;
font-size: $fontSize;
letter-spacing: 1.4px;
cursor: pointer;
user-select: none;
color: $cOrange;
border: solid 1px $cOrange;
}
// 定宽 黑色底实心圆角按钮
@mixin btc4($wid: 118px, $hei: 22px, $fontSize: 14px) {
width: $wid;
height: $hei;
line-height: $hei + 2px;
text-align: center;
border-radius: $hei * 0.5;
background-color: $cLightDard;
font-size: $fontSize;
color: #ffffff;
letter-spacing: 1.4px;
cursor: pointer;
user-select: none;
}
......
.bis {
background-repeat: no-repeat;
background-size: 100% 100%;
}
//flex 布局和 子元素 对其方式
.fl {
display: flex;
}
.flc {
display: flex;
justify-content: center;
}
.flb {
display: flex;
justify-content: space-between;
}
.fla {
display: flex;
align-items: center;
}
//水平和垂直居中
.fcc {
display: flex;
justify-content: center;
align-items: center;
}
// 为元素设定的宽度和高度决定了元素的边框盒。
.bb {
box-sizing: border-box;
}
// 满屏
.fullp {
width: 100%;
height: 100%;
}
.pointer {
cursor: pointer;
}
.text-l {
text-align: left;
}
.text-r {
text-align: right;
}
.text-c {
text-align: center;
}
.underline {
text-decoration: underline;
}
.pointer {
cursor: pointer;
}
import Cookies from 'js-cookie'
const TokenKey = 'temp-app-token'
export function getToken() {
return Cookies.get(TokenKey)
}
export function setToken(token) {
return Cookies.set(TokenKey, token)
}
export function removeToken() {
return Cookies.remove(TokenKey)
}
import CryptoJS from "crypto-js";
import JsEncrypt from "jsencrypt";
let rsa = new JsEncrypt();
/*
* 创建加密
* @param data
*
* 设置项
* key 公钥
* iv 偏移量
*/
export function makeEncrypt(param) {
let key = "";
let iv = ""
rsa.setPublicKey(key);
let chars = "0,1,2,3,4,5,6,7,8,9,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(",");
function randomAesKey() {
let res = "";
for (let i = 0; i < 16; i++) {
let id = Math.ceil(Math.random() * (chars.length - 1));
res += chars[id];
}
return res;
};
function encryptContent(obj) {
let aesKey = randomAesKey();
let key = CryptoJS.enc.Utf8.parse(aesKey);
let ivR = CryptoJS.enc.Utf8.parse(iv);
var encrypted = CryptoJS.AES.encrypt(JSON.stringify(obj), key, {
iv: ivR,
mode: CryptoJS.mode.CBC,
padding: CryptoJS.pad.Pkcs7
});
let content = encrypted.toString(); //返回的是base64格式的密文
let securityKey = rsa.encrypt(aesKey);
let result = {
k: securityKey,
v: content
};
return result;
};
let data = encryptContent(param)
return data;
}
\ No newline at end of file
......@@ -8,6 +8,16 @@ export function checkMobile(str) {
return REGEXPS.mobile.test(str);
}
// 判断是否微信环境
export function isWeiXin() {
var ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
return true;
} else {
return false;
}
}
/**
* 链接参数转换为obj
* 入参 完整链接
......@@ -29,33 +39,22 @@ export function param2Obj(url) {
}
//获取cookie、
export function getCookie(name) {
var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
if (arr = document.cookie.match(reg))
return (arr[2]);
else
return null;
/**
* 从数组中获取 key未value的对象
* @param {*} value
* @param {*} key
* @param {*} list
*/
export function getObjByListKeyValue(value, key, list) {
let result = null;
list.forEach(element => {
if (element[key + ""] == value) {
result = element;
}
});
return result;
}
//设置cookie
export function setCookie(c_name, value, expiredays) {
var exdate = new Date();
exdate.setDate(exdate.getDate() + expiredays);
document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
};
//删除cookie
export function delCookie(name) {
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval = getCookie(name);
if (cval != null)
document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
};
/**
* 获取环境信息
* @return {Object} 环境信息对象
......
const Timestamp = new Date().getTime();
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
// 打包目录
let webpack_public_path = 'dist'
if (process.env.NODE_ENV === 'production') {
webpack_public_path = process.env.VUE_APP_TITLE
const path = require('path')
// 配置资源包路径
let webpack_public_path = process.env.VUE_APP_PUBLIC_PATH;
let webpack_output_dir = "dist";
webpack_output_dir = process.env.VUE_APP_OUTPUT_DIR;
function resolve(dir) {
return path.join(__dirname, dir);
}
module.exports = {
chainWebpack: (config) => {
config.resolve.alias
.set('@', resolve('src'))
.set('@public', resolve('public'))
.set('@assets', resolve('src/assets'))
.set('@components', resolve('src/components'))
.set('@pages', resolve('src/pages'))
.set('@api', resolve('src/api'))
.set('@styles', resolve('src/styles'))
.set('@store', resolve('src/store'))
.set('@utils', resolve('src/utils'))
.set('@common', resolve('src/common'));
const oneOfsMap = config.module.rule('scss').oneOfs.store
oneOfsMap.forEach(item => {
item
.use('sass-resources-loader')
.loader('sass-resources-loader')
.options({
// Provide path to the file with resources
// 要公用的scss的路径
resources: ['./src/styles/vars.scss', './src/styles/mixins.scss', './src/styles/utils.scss']
})
.end()
})
},
configureWebpack: { // webpack 配置
// 修改打包后js文件名
output: { // 输出重构 打包编译后的 文件名称 【模块名称.版本号.时间戳】
......@@ -42,10 +77,11 @@ module.exports = {
//例如 https://www.my-app.com/。如果应用被部署在一个子路径上,你就需要用这个选项指定这个子路径。例如,如果你的应用被部署在 https://www.my-app.com/my-app/,则设置 baseUrl 为 /my-app/。
//baseUrl 从 Vue CLI 3.3 起已弃用,请使用publicPath
//baseUrl: process.env.NODE_ENV === "production" ? "./" : "/",
publicPath: process.env.NODE_ENV === "dev" ? "/" : "./",
// publicPath: process.env.NODE_ENV === "dev" ? "/" : "./",
publicPath: process.env.NODE_ENV === "dev" ? "/" : webpack_public_path, // history模式 用短码?
// outputDir: 在npm run build 或 yarn build 时 ,生成文件的目录名称(要和baseUrl的生产环境路径一致)
outputDir: webpack_public_path,
outputDir: webpack_output_dir,
//用于放置生成的静态资源 (js、css、img、fonts) 的;(项目打包之后,静态资源会放在这个文件夹下)
assetsDir: "assets",
//指定生成的 index.html 的输出路径 (打包之后,改变系统默认的index.html的文件名)
......@@ -70,11 +106,11 @@ module.exports = {
productionSourceMap: false,
// 它支持webPack-dev-server的所有选项
devServer: {
host: "localhost",
port: 9001, // 端口号
https: false, // https:{type:Boolean}
open: true, //配置自动启动浏览器
// proxy: 'http://localhost:4000' // 配置跨域处理,只有一个代理
}
// devServer: {
// host: "localhost",
// port: 9001, // 端口号
// https: false, // https:{type:Boolean}
// open: true, //配置自动启动浏览器
// // proxy: 'http://localhost:4000' // 配置跨域处理,只有一个代理
// }
};
\ No newline at end of file
......