Commit 844b0d17 by YoMon

首次提交

parents
module.exports = {
root: true,
parser: 'babel-eslint',
env: {
browser: true,
node: true
},
extends: 'standard',
// required to lint *.vue files
plugins: [
'html'
],
// add your custom rules here
rules: {
'space-before-function-paren': [
2,
{
anonymous: 'always',
named: 'never'
}
],
},
globals: {}
}
/node_modules
/.nuxt
/build
/.editorconfig
/.git-credentials
/wlog.log
/session.log
/package-lock.json
from node:8.11.3-alpine
VOLUME /home/app
COPY .nuxt /home/app/.nuxt
COPY assets /home/app/assets
COPY static /home/app/static
COPY build /home/app/build
COPY node_modules /home/app/node_modules
COPY package.json /home/app/package.json
COPY nuxt.config.js /home/app/nuxt.config.js
COPY nuxt.config-test.js /home/app/nuxt.config-test.js
COPY nuxt.config-prod.js /home/app/nuxt.config-prod.js
RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \
echo "Asia/Shanghai" > /etc/timezone
WORKDIR /home/app
EXPOSE 8080
CMD npm run start
\ No newline at end of file
# admin-yweb
> This is the admin project for yweb
## Build Setup
``` bash
# install dependencies
$ npm install # Or yarn install*[see note below]
# serve with hot reload at localhost:3000
$ npm run dev
# build for production and launch server
$ npm run build
$ npm start
# generate static project
$ npm run generate
```
*Note: Due to a bug in yarn's engine version detection code if you are
using a prerelease version of Node (i.e. v7.6.0-rc.1) you will need to either:
1. Use `npm install`
2. Run `yarn` with a standard release of Node and then switch back
For detailed explanation on how things work, checkout the [Nuxt.js docs](https://github.com/nuxt/nuxt.js).
{
"host":"http:/localhost:3000",
"redis":{
"host":"192.168.20.199",
"pwd":"",
"port":"6379"
},
"logpath":"./",
"uploadImgPath":"http://192.168.20.35:8084"
}
\ No newline at end of file
{
"host":"http://www.yang800.com",
"redis":{
"host":"192.168.187.75",
"pwd":"dd654321",
"port":"6379"
},
"logpath":"/nfs/yang_online/y-web",
"uploadImgPath":"http://admin.yang800.com"
}
\ No newline at end of file
{
"host":"http://webtest.yang800.cn",
"redis":{
"host":"redis.test",
"pwd":"dd654321",
"port":"6379"
},
"logpath":"./",
"uploadImgPath":"http://admintest.yang800.cn"
}
\ No newline at end of file
html, body
{
color: #2e2f30;
letter-spacing: 0.5px;
font-family: 微软雅黑, "Microsoft Yahei";
margin: 0;
}
footer
{
padding: 20px;
text-align: center;
border-top: 1px solid #ddd;
}
a, a:hover, a:focus, a:visited
{
cursor:pointer;
text-decoration:none;
}
a:-webkit-any-link {
cursor:pointer;
text-decoration: none;
}
p, h1, h2, h3{
margin: 0;
}
:focus{
outline: 0px;
}
input{-webkit-appearance: none; }
.page-enter-active, .page-leave-active
{
transition: opacity .5s
}
.page-enter, .page-leave-active
{
opacity: 0
}
.gray_out_box {
background-color: #f4f4f4;
}
.white_out_box {
background-color: #ffffff;
}
.f_mask {
position: fixed;
left: 0px;
top: 0px;
right: 0px;
bottom: 0px;
display: none;
background: rgba(0, 0, 0, 0.4);
}
.f_mask_show {
display: block;
}
.clearfix:after{
content:".";/*加一段内容*/
display:block;/*让生成的元素以块级元素显示,占满剩余空间*/
height:0;/*避免生成的内容破坏原有布局高度*/
clear:both;/*清除浮动*/
visibility:hidden;/*让生成的内容不可见*/
}
.clearfix{
zoom:1;/*为IE6,7的兼容性设置*/
}
.none_wrap {
white-space: nowrap;
overflow: hidden;
/*text-overflow: ellipsis;*/
}
.ellipsis_none_wrap {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.word_000 {
color: #000000;
}
.word_333 {
color: #333333;
}
.word_3a {
color: #3a3a3a;
}
.word_666 {
color: #666666;
}
.word_c01e {
color: #C01E00;
}
.word_a5 {
color: #a5a5a5;
}
.word_b5 {
color: #B5B5B5;
}
.word_53 {
color: #535353;
}
.word_76 {
color: #767676;
}
.word_4a9 {
color: #4A90E2;
}
.word_90 {
color: #909090;
}
.word_9a {
color: #9a9a9a;
}
.word_040001 {
color: #040001;
}
.f_10 {
font-size: 10px;
}
.f_12 {
font-size: 12px;
}
.f_14 {
font-size: 14px;
}
.f_15 {
font-size: 15px;
}
.f_16 {
font-size: 16px;
}
.f_18 {
font-size: 18px;
}
.f_22 {
font-size: 22px;
}
.text_del {
text-decoration: line-through;
}
.f_normal {
font-style: normal;
}
.f_bold {
-webkit-font-weight: bold;
font-weight: bold;
}
/*flex布局*/
.y_default_center {
display: box;
display: -moz-box; /* OLD - Firefox 19- (buggy but mostly works) */
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-pack: center;
/* 12版 */
-webkit-justify-content: center;
-moz-justify-content: center;
-ms-justify-content: center;
-o-justify-content: center;
justify-content: center;
}
.y_default_end {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-pack: flex-end;
/* 12版 */
-webkit-justify-content: flex-end;
-moz-justify-content: flex-end;
-ms-justify-content: flex-end;
-o-justify-content: flex-end;
justify-content: flex-end;
}
.y_default_start{
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
}
.y_default_between{
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-pack: space-between;
/* 12版 */
-webkit-justify-content: space-between;
-moz-justify-content: space-between;
-ms-justify-content: space-between;
-o-justify-content: space-between;
justify-content: space-between;
}
.y_flex_center {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-align: center;
/* 12版 */
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
-o-align-items: center;
align-items: center;
/* 09版 */
-webkit-box-pack: center;
/* 12版 */
-webkit-justify-content: center;
-moz-justify-content: center;
-ms-justify-content: center;
-o-justify-content: center;
justify-content: center;
}
.y_flex_end {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-align: center;
/* 12版 */
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
-o-align-items: center;
align-items: center;
/* 09版 */
-webkit-box-pack: flex-end;
/* 12版 */
-webkit-justify-content: flex-end;
-moz-justify-content: flex-end;
-ms-justify-content: flex-end;
-o-justify-content: flex-end;
justify-content: flex-end;
}
.y_flex_start{
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-align: center;
/* 12版 */
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
-o-align-items: center;
align-items: center;
}
.y_flex_between{
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-align: center;
/* 12版 */
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
-o-align-items: center;
align-items: center;
/* 09版 */
-webkit-box-pack: space-between;
/* 12版 */
-webkit-justify-content: space-between;
-moz-justify-content: space-between;
-ms-justify-content: space-between;
-o-justify-content: space-between;
justify-content: space-between;
}
.y_flex_around{
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-align: center;
/* 12版 */
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
-o-align-items: center;
align-items: center;
/* 09版 */
-webkit-box-pack: space-around;
/* 12版 */
-webkit-justify-content: space-around;
-moz-justify-content: space-around;
-ms-justify-content: space-around;
-o-justify-content: space-around;
justify-content: space-around;
}
.y_top_center {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-align: flex-start;
/* 12版 */
-webkit-align-items: flex-start;
-moz-align-items: flex-start;
-ms-align-items: flex-start;
-o-align-items: flex-start;
align-items: flex-start;
/* 09版 */
-webkit-box-pack: center;
/* 12版 */
-webkit-justify-content: center;
-moz-justify-content: center;
-ms-justify-content: center;
-o-justify-content: center;
justify-content: center;
}
.y_top_end {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-align: flex-start;
/* 12版 */
-webkit-align-items: flex-start;
-moz-align-items: flex-start;
-ms-align-items: flex-start;
-o-align-items: flex-start;
align-items: flex-start;
/* 09版 */
-webkit-box-pack: flex-end;
/* 12版 */
-webkit-justify-content: flex-end;
-moz-justify-content: flex-end;
-ms-justify-content: flex-end;
-o-justify-content: flex-end;
justify-content: flex-end;
}
.y_top_start{
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-align: flex-start;
/* 12版 */
-webkit-align-items: flex-start;
-moz-align-items: flex-start;
-ms-align-items: flex-start;
-o-align-items: flex-start;
align-items: flex-start;
/* 09版 */
-webkit-box-pack: flex-start;
/* 12版 */
-webkit-justify-content: flex-start;
-moz-justify-content: flex-start;
-ms-justify-content: flex-start;
-o-justify-content: flex-start;
justify-content: flex-start;
}
.y_top_between{
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-align: flex-start;
/* 12版 */
-webkit-align-items: flex-start;
-moz-align-items: flex-start;
-ms-align-items: flex-start;
-o-align-items: flex-start;
align-items: flex-start;
/* 09版 */
-webkit-box-pack: space-between;
/* 12版 */
-webkit-justify-content: space-between;
-moz-justify-content: space-between;
-ms-justify-content: space-between;
-o-justify-content: space-between;
justify-content: space-between;
}
.y_bottom_center {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-align: flex-end;
/* 12版 */
-webkit-align-items: flex-end;
-moz-align-items: flex-end;
-ms-align-items: flex-end;
-o-align-items: flex-end;
align-items: flex-end;
/* 09版 */
-webkit-box-pack: center;
/* 12版 */
-webkit-justify-content: center;
-moz-justify-content: center;
-ms-justify-content: center;
-o-justify-content: center;
justify-content: center;
}
.y_bottom_end {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-align: flex-end;
/* 12版 */
-webkit-align-items: flex-end;
-moz-align-items: flex-end;
-ms-align-items: flex-end;
-o-align-items: flex-end;
align-items: flex-end;
/* 09版 */
-webkit-box-pack: flex-end;
/* 12版 */
-webkit-justify-content: flex-end;
-moz-justify-content: flex-end;
-ms-justify-content: flex-end;
-o-justify-content: flex-end;
justify-content: flex-end;
}
.y_bottom_start{
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-align: flex-end;
/* 12版 */
-webkit-align-items: flex-end;
-moz-align-items: flex-end;
-ms-align-items: flex-end;
-o-align-items: flex-end;
align-items: flex-end;
/* 09版 */
-webkit-box-pack: flex-start;
/* 12版 */
-webkit-justify-content: flex-start;
-moz-justify-content: flex-start;
-ms-justify-content: flex-start;
-o-justify-content: flex-start;
justify-content: flex-start;
}
.y_bottom_between{
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: horizontal;
/* 12版 */
-webkit-flex-direction: row;
-moz-flex-direction: row;
-ms-flex-direction: row;
-o-flex-direction: row;
flex-direction: row;
/* 09版 */
-webkit-box-align: flex-end;
/* 12版 */
-webkit-align-items: flex-end;
-moz-align-items: flex-end;
-ms-align-items: flex-end;
-o-align-items: flex-end;
align-items: flex-end;
/* 09版 */
-webkit-box-pack: space-between;
/* 12版 */
-webkit-justify-content: space-between;
-moz-justify-content: space-between;
-ms-justify-content: space-between;
-o-justify-content: space-between;
justify-content: space-between;
}
/*column布局*/
.col_jus_space {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: vertical;
/* 12版 */
-webkit-flex-direction: column;
-moz-flex-direction: column;
-ms-flex-direction: column;
-o-flex-direction: column;
flex-direction: column;
/* 09版 */
-webkit-box-pack: space-between;
/* 12版 */
-webkit-justify-content: space-between;
-moz-justify-content: space-between;
-ms-justify-content: space-between;
-o-justify-content: space-between;
justify-content: space-between;
}
.col_jus_end {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: vertical;
/* 12版 */
-webkit-flex-direction: column;
-moz-flex-direction: column;
-ms-flex-direction: column;
-o-flex-direction: column;
flex-direction: column;
/* 09版 */
-webkit-box-pack: flex-end;
/* 12版 */
-webkit-justify-content: flex-end;
-moz-justify-content: flex-end;
-ms-justify-content: flex-end;
-o-justify-content: flex-end;
justify-content: flex-end;
}
.col_jus_start {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: vertical;
/* 12版 */
-webkit-flex-direction: column;
-moz-flex-direction: column;
-ms-flex-direction: column;
-o-flex-direction: column;
flex-direction: column;
/* 09版 */
-webkit-box-pack: flex-start;
/* 12版 */
-webkit-justify-content: flex-start;
-moz-justify-content: flex-start;
-ms-justify-content: flex-start;
-o-justify-content: flex-start;
justify-content: flex-start;
}
.col_jus_align_center {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: vertical;
/* 12版 */
-webkit-flex-direction: column;
-moz-flex-direction: column;
-ms-flex-direction: column;
-o-flex-direction: column;
flex-direction: column;
/* 09版 */
-webkit-box-pack: center;
/* 12版 */
-webkit-justify-content: center;
-moz-justify-content: center;
-ms-justify-content: center;
-o-justify-content: center;
justify-content: center;
/* 09版 */
-webkit-box-align: center;
/* 12版 */
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
-o-align-items: center;
align-items: center;
}
.col_align_center {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: vertical;
/* 12版 */
-webkit-flex-direction: column;
-moz-flex-direction: column;
-ms-flex-direction: column;
-o-flex-direction: column;
flex-direction: column;
/* 09版 */
-webkit-box-align: center;
/* 12版 */
-webkit-align-items: center;
-moz-align-items: center;
-ms-align-items: center;
-o-align-items: center;
align-items: center;
}
.col_align_space {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: vertical;
/* 12版 */
-webkit-flex-direction: column;
-moz-flex-direction: column;
-ms-flex-direction: column;
-o-flex-direction: column;
flex-direction: column;
/* 09版 */
-webkit-box-pack: space-between;
/* 12版 */
-webkit-justify-content: space-between;
-moz-justify-content: space-between;
-ms-justify-content: space-between;
-o-justify-content: space-between;
justify-content: space-between;
}
.col_align_end_jus_space {
display: box;
display: -moz-box;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
/* 09版 */
-webkit-box-orient: vertical;
/* 12版 */
-webkit-flex-direction: column;
-moz-flex-direction: column;
-ms-flex-direction: column;
-o-flex-direction: column;
flex-direction: column;
/* 09版 */
-webkit-box-align: flex-end;
/* 12版 */
-webkit-align-items: flex-end;
-moz-align-items: flex-end;
-ms-align-items: flex-end;
-o-align-items: flex-end;
align-items: flex-end;
/* 09版 */
-webkit-box-pack: space-between;
/* 12版 */
-webkit-justify-content: space-between;
-moz-justify-content: space-between;
-ms-justify-content: space-between;
-o-justify-content: space-between;
justify-content: space-between;
}
\ No newline at end of file
/*!
* Log.js
* Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
* MIT Licensed
*/
/**
* Module dependencies.
*/
var colors = require('colors');
var fmt = require('util').format;
var EventEmitter = require('events').EventEmitter;
/**
* Initialize a `Loggeer` with the given log `level` defaulting
* to __DEBUG__ and `stream` defaulting to _stdout_.
*
* @param {Number} level
* @param {Object} stream
* @api public
*/
var Log = exports = module.exports = function Log(level, stream){
if ('string' == typeof level) level = exports[level.toUpperCase()];
this.level = isFinite(level) ? level : this.DEBUG;
if(!process.browser) {
this.stream = stream || process.stdout;
if (this.stream.readable) this.read();
}
};
/**
* System is unusable.
*
* @type Number
*/
exports.EMERGENCY = 0;
/**
* Action must be taken immediately.
*
* @type Number
*/
exports.ALERT = 1;
/**
* Critical condition.
*
* @type Number
*/
exports.CRITICAL = 2;
/**
* Error condition.
*
* @type Number
*/
exports.ERROR = 3;
/**
* Warning condition.
*
* @type Number
*/
exports.WARNING = 4;
/**
* Normal but significant condition.
*
* @type Number
*/
exports.NOTICE = 5;
/**
* Purely informational message.
*
* @type Number
*/
exports.INFO = 6;
/**
* Application debug messages.
*
* @type Number
*/
exports.DEBUG = 7;
/**
* prototype.
*/
Log.prototype = {
/**
* Start emitting "line" events.
*
* @api public
*/
read: function(){
var buf = ''
, self = this
, stream = this.stream;
stream.setEncoding('utf8');
stream.on('data', function(chunk){
buf += chunk;
if ('\n' != buf[buf.length - 1]) return;
buf.split('\n').map(function(line){
if (!line.length) return;
try {
var captures = line.match(/^\[([^\]]+)\] (\w+) (.*)/);
var obj = {
date: new Date(captures[1])
, level: exports[captures[2]]
, levelString: captures[2]
, msg: captures[3]
};
self.emit('line', obj);
} catch (err) {
// Ignore
}
});
buf = '';
});
stream.on('end', function(){
self.emit('end');
});
},
isEnable: function(levelStr) {
return exports[levelStr] <= this.level;
},
getTimeStr: function() {
var date = '[' + new Date + ']';
if (this.stream === process.stdout) {
return date.grey;
}
return date;
},
getLevelStr: function(levelStr) {
if (this.stream === process.stdout) {
var result;
switch (levelStr) {
case 'DEBUG':
result = levelStr.cyan;
break;
case 'INFO':
result = levelStr.green;
break;
case 'NOTICE':
result = levelStr.blue;
break;
case 'WARNING':
result = levelStr.yellow;
break;
case 'ERROR':
result = levelStr.red;
break;
case 'CRITICAL':
result = levelStr.red.bold;
break;
case 'ALERT':
result = levelStr.magenta;
break;
case 'EMERGENCY':
result = levelStr.black.bgRed;
break;
default:
result = levelStr;
}
return result;
}
return levelStr;
},
/**
* Log output message.
*
* @param {String} levelStr
* @param {Array} args
* @api private
*/
log: function(levelStr, args) {
if (this.isEnable(levelStr)) {
var msg = fmt.apply(null, args);
if (!process.browser) {
this.stream.write(
this.getTimeStr()
+ ' ' + this.getLevelStr(levelStr)
+ ' ' + msg
+ '\n'
)
console.log(this.getTimeStr()
+ ' ' + this.getLevelStr(levelStr)
+ ' ' + msg)
} else {
if (window.console) {
console.log(this.getTimeStr()
+ ' ' + this.getLevelStr(levelStr)
+ ' ' + msg)
}
}
}
},
/**
* Log emergency `msg`.
*
* @param {String} msg
* @api public
*/
emergency: function(msg){
this.log('EMERGENCY', arguments);
},
/**
* Log alert `msg`.
*
* @param {String} msg
* @api public
*/
alert: function(msg){
this.log('ALERT', arguments);
},
/**
* Log critical `msg`.
*
* @param {String} msg
* @api public
*/
critical: function(msg){
this.log('CRITICAL', arguments);
},
/**
* Log error `msg`.
*
* @param {String} msg
* @api public
*/
error: function(msg){
this.log('ERROR', arguments);
},
/**
* Log warning `msg`.
*
* @param {String} msg
* @api public
*/
warning: function(msg){
this.log('WARNING', arguments);
},
/**
* Log notice `msg`.
*
* @param {String} msg
* @api public
*/
notice: function(msg){
this.log('NOTICE', arguments);
},
/**
* Log info `msg`.
*
* @param {String} msg
* @api public
*/
info: function(msg){
this.log('INFO', arguments);
},
/**
* Log debug `msg`.
*
* @param {String} msg
* @api public
*/
debug: function(msg){
this.log('DEBUG', arguments);
}
};
/**
* Inherit from `EventEmitter`.
*/
Log.prototype.__proto__ = EventEmitter.prototype;
var QRCode;
(function () {
//---------------------------------------------------------------------
// QRCode for JavaScript
//---------------------------------------------------------------------
function QR8bitByte(data) {
this.mode = QRMode.MODE_8BIT_BYTE;
this.data = data;
this.parsedData = [];
// Added to support UTF-8 Characters
for (var i = 0, l = this.data.length; i < l; i++) {
var byteArray = [];
var code = this.data.charCodeAt(i);
if (code > 0x10000) {
byteArray[0] = 0xF0 | ((code & 0x1C0000) >>> 18);
byteArray[1] = 0x80 | ((code & 0x3F000) >>> 12);
byteArray[2] = 0x80 | ((code & 0xFC0) >>> 6);
byteArray[3] = 0x80 | (code & 0x3F);
} else if (code > 0x800) {
byteArray[0] = 0xE0 | ((code & 0xF000) >>> 12);
byteArray[1] = 0x80 | ((code & 0xFC0) >>> 6);
byteArray[2] = 0x80 | (code & 0x3F);
} else if (code > 0x80) {
byteArray[0] = 0xC0 | ((code & 0x7C0) >>> 6);
byteArray[1] = 0x80 | (code & 0x3F);
} else {
byteArray[0] = code;
}
this.parsedData.push(byteArray);
}
this.parsedData = Array.prototype.concat.apply([], this.parsedData);
if (this.parsedData.length != this.data.length) {
this.parsedData.unshift(191);
this.parsedData.unshift(187);
this.parsedData.unshift(239);
}
}
QR8bitByte.prototype = {
getLength: function (buffer) {
return this.parsedData.length;
},
write: function (buffer) {
for (var i = 0, l = this.parsedData.length; i < l; i++) {
buffer.put(this.parsedData[i], 8);
}
}
};
function QRCodeModel(typeNumber, errorCorrectLevel) {
this.typeNumber = typeNumber;
this.errorCorrectLevel = errorCorrectLevel;
this.modules = null;
this.moduleCount = 0;
this.dataCache = null;
this.dataList = [];
}
function QRPolynomial(num, shift) {
if (num.length == undefined) throw new Error(num.length + "/" + shift);
var offset = 0;
while (offset < num.length && num[offset] == 0) offset++;
this.num = new Array(num.length - offset + shift);
for (var i = 0; i < num.length - offset; i++) this.num[i] = num[i + offset];
}
function QRRSBlock(totalCount, dataCount) {
this.totalCount = totalCount, this.dataCount = dataCount;
}
function QRBitBuffer() {
this.buffer = [], this.length = 0;
}
QRCodeModel.prototype = {
"addData": function(data) {
var newData = new QR8bitByte(data);
this.dataList.push(newData), this.dataCache = null;
},
"isDark": function(row, col) {
if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) throw new Error(row + "," + col);
return this.modules[row][col];
},
"getModuleCount": function() {
return this.moduleCount;
},
"make": function() {
this.makeImpl(!1, this.getBestMaskPattern());
},
"makeImpl": function(test, maskPattern) {
this.moduleCount = this.typeNumber * 4 + 17, this.modules = new Array(this.moduleCount);
for (var row = 0; row < this.moduleCount; row++) {
this.modules[row] = new Array(this.moduleCount);
for (var col = 0; col < this.moduleCount; col++) this.modules[row][col] = null;
}
this.setupPositionProbePattern(0, 0),
this.setupPositionProbePattern(this.moduleCount - 7, 0),
this.setupPositionProbePattern(0, this.moduleCount - 7),
this.setupPositionAdjustPattern(), this.setupTimingPattern(),
this.setupTypeInfo(test, maskPattern),
this.typeNumber >= 7 && this.setupTypeNumber(test),
this.dataCache == null && (this.dataCache = QRCodeModel.createData(this.typeNumber, this.errorCorrectLevel, this.dataList)), this.mapData(this.dataCache, maskPattern);
},
"setupPositionProbePattern": function(row, col) {
for (var r = -1; r <= 7; r++) {
if (row + r <= -1 || this.moduleCount <= row + r) continue;
for (var c = -1; c <= 7; c++) {
if (col + c <= -1 || this.moduleCount <= col + c) continue;
0 <= r && r <= 6 && (c == 0 || c == 6) || 0 <= c && c <= 6 && (r == 0 || r == 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4 ? this.modules[row + r][col + c] = !0 : this.modules[row + r][col + c] = !1;
}
}
},
"getBestMaskPattern": function() {
var minLostPoint = 0, pattern = 0;
for (var i = 0; i < 8; i++) {
this.makeImpl(!0, i);
var lostPoint = QRUtil.getLostPoint(this);
if (i == 0 || minLostPoint > lostPoint) minLostPoint = lostPoint, pattern = i;
}
return pattern;
},
"createMovieClip": function(target_mc, instance_name, depth) {
var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth), cs = 1;
this.make();
for (var row = 0; row < this.modules.length; row++) {
var y = row * cs;
for (var col = 0; col < this.modules[row].length; col++) {
var x = col * cs, dark = this.modules[row][col];
dark && (qr_mc.beginFill(0, 100), qr_mc.moveTo(x, y), qr_mc.lineTo(x + cs, y), qr_mc.lineTo(x + cs, y + cs), qr_mc.lineTo(x, y + cs), qr_mc.endFill());
}
}
return qr_mc;
},
"setupTimingPattern": function() {
for (var r = 8; r < this.moduleCount - 8; r++) {
if (this.modules[r][6] != null) continue;
this.modules[r][6] = r % 2 == 0;
}
for (var c = 8; c < this.moduleCount - 8; c++) {
if (this.modules[6][c] != null) continue;
this.modules[6][c] = c % 2 == 0;
}
},
"setupPositionAdjustPattern": function() {
var pos = QRUtil.getPatternPosition(this.typeNumber);
for (var i = 0; i < pos.length; i++) for (var j = 0; j < pos.length; j++) {
var row = pos[i], col = pos[j];
if (this.modules[row][col] != null) continue;
for (var r = -2; r <= 2; r++) for (var c = -2; c <= 2; c++) r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0 ? this.modules[row + r][col + c] = !0 : this.modules[row + r][col + c] = !1;
}
},
"setupTypeNumber": function(test) {
var bits = QRUtil.getBCHTypeNumber(this.typeNumber);
for (var i = 0; i < 18; i++) {
var mod = !test && (bits >> i & 1) == 1;
this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
}
for (var i = 0; i < 18; i++) {
var mod = !test && (bits >> i & 1) == 1;
this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
}
},
"setupTypeInfo": function(test, maskPattern) {
var data = this.errorCorrectLevel << 3 | maskPattern, bits = QRUtil.getBCHTypeInfo(data);
for (var i = 0; i < 15; i++) {
var mod = !test && (bits >> i & 1) == 1;
i < 6 ? this.modules[i][8] = mod : i < 8 ? this.modules[i + 1][8] = mod : this.modules[this.moduleCount - 15 + i][8] = mod;
}
for (var i = 0; i < 15; i++) {
var mod = !test && (bits >> i & 1) == 1;
i < 8 ? this.modules[8][this.moduleCount - i - 1] = mod : i < 9 ? this.modules[8][15 - i - 1 + 1] = mod : this.modules[8][15 - i - 1] = mod;
}
this.modules[this.moduleCount - 8][8] = !test;
},
"mapData": function(data, maskPattern) {
var inc = -1, row = this.moduleCount - 1, bitIndex = 7, byteIndex = 0;
for (var col = this.moduleCount - 1; col > 0; col -= 2) {
col == 6 && col--;
for (;;) {
for (var c = 0; c < 2; c++) if (this.modules[row][col - c] == null) {
var dark = !1;
byteIndex < data.length && (dark = (data[byteIndex] >>> bitIndex & 1) == 1);
var mask = QRUtil.getMask(maskPattern, row, col - c);
mask && (dark = !dark), this.modules[row][col - c] = dark, bitIndex--, bitIndex == -1 && (byteIndex++, bitIndex = 7);
}
row += inc;
if (row < 0 || this.moduleCount <= row) {
row -= inc, inc = -inc;
break;
}
}
}
}
}, QRCodeModel.PAD0 = 236, QRCodeModel.PAD1 = 17, QRCodeModel.createData = function(typeNumber, errorCorrectLevel, dataList) {
var rsBlocks = QRRSBlock.getRSBlocks(typeNumber, errorCorrectLevel), buffer = new QRBitBuffer;
for (var i = 0; i < dataList.length; i++) {
var data = dataList[i];
buffer.put(data.mode, 4), buffer.put(data.getLength(), QRUtil.getLengthInBits(data.mode, typeNumber)), data.write(buffer);
}
var totalDataCount = 0;
for (var i = 0; i < rsBlocks.length; i++) totalDataCount += rsBlocks[i].dataCount;
if (buffer.getLengthInBits() > totalDataCount * 8) throw new Error("code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")");
buffer.getLengthInBits() + 4 <= totalDataCount * 8 && buffer.put(0, 4);
while (buffer.getLengthInBits() % 8 != 0) buffer.putBit(!1);
for (;;) {
if (buffer.getLengthInBits() >= totalDataCount * 8) break;
buffer.put(QRCodeModel.PAD0, 8);
if (buffer.getLengthInBits() >= totalDataCount * 8) break;
buffer.put(QRCodeModel.PAD1, 8);
}
return QRCodeModel.createBytes(buffer, rsBlocks);
}, QRCodeModel.createBytes = function(buffer, rsBlocks) {
var offset = 0, maxDcCount = 0, maxEcCount = 0, dcdata = new Array(rsBlocks.length), ecdata = new Array(rsBlocks.length);
for (var r = 0; r < rsBlocks.length; r++) {
var dcCount = rsBlocks[r].dataCount, ecCount = rsBlocks[r].totalCount - dcCount;
maxDcCount = Math.max(maxDcCount, dcCount), maxEcCount = Math.max(maxEcCount, ecCount), dcdata[r] = new Array(dcCount);
for (var i = 0; i < dcdata[r].length; i++) dcdata[r][i] = 255 & buffer.buffer[i + offset];
offset += dcCount;
var rsPoly = QRUtil.getErrorCorrectPolynomial(ecCount), rawPoly = new QRPolynomial(dcdata[r], rsPoly.getLength() - 1), modPoly = rawPoly.mod(rsPoly);
ecdata[r] = new Array(rsPoly.getLength() - 1);
for (var i = 0; i < ecdata[r].length; i++) {
var modIndex = i + modPoly.getLength() - ecdata[r].length;
ecdata[r][i] = modIndex >= 0 ? modPoly.get(modIndex) : 0;
}
}
var totalCodeCount = 0;
for (var i = 0; i < rsBlocks.length; i++) totalCodeCount += rsBlocks[i].totalCount;
var data = new Array(totalCodeCount), index = 0;
for (var i = 0; i < maxDcCount; i++) for (var r = 0; r < rsBlocks.length; r++) i < dcdata[r].length && (data[index++] = dcdata[r][i]);
for (var i = 0; i < maxEcCount; i++) for (var r = 0; r < rsBlocks.length; r++) i < ecdata[r].length && (data[index++] = ecdata[r][i]);
return data;
};
var QRMode = {
"MODE_NUMBER": 1,
"MODE_ALPHA_NUM": 2,
"MODE_8BIT_BYTE": 4,
"MODE_KANJI": 8
}, QRErrorCorrectLevel = {
"L": 1,
"M": 0,
"Q": 3,
"H": 2
}, QRMaskPattern = {
"PATTERN000": 0,
"PATTERN001": 1,
"PATTERN010": 2,
"PATTERN011": 3,
"PATTERN100": 4,
"PATTERN101": 5,
"PATTERN110": 6,
"PATTERN111": 7
}, QRUtil = {
"PATTERN_POSITION_TABLE": [ [], [ 6, 18 ], [ 6, 22 ], [ 6, 26 ], [ 6, 30 ], [ 6, 34 ], [ 6, 22, 38 ], [ 6, 24, 42 ], [ 6, 26, 46 ], [ 6, 28, 50 ], [ 6, 30, 54 ], [ 6, 32, 58 ], [ 6, 34, 62 ], [ 6, 26, 46, 66 ], [ 6, 26, 48, 70 ], [ 6, 26, 50, 74 ], [ 6, 30, 54, 78 ], [ 6, 30, 56, 82 ], [ 6, 30, 58, 86 ], [ 6, 34, 62, 90 ], [ 6, 28, 50, 72, 94 ], [ 6, 26, 50, 74, 98 ], [ 6, 30, 54, 78, 102 ], [ 6, 28, 54, 80, 106 ], [ 6, 32, 58, 84, 110 ], [ 6, 30, 58, 86, 114 ], [ 6, 34, 62, 90, 118 ], [ 6, 26, 50, 74, 98, 122 ], [ 6, 30, 54, 78, 102, 126 ], [ 6, 26, 52, 78, 104, 130 ], [ 6, 30, 56, 82, 108, 134 ], [ 6, 34, 60, 86, 112, 138 ], [ 6, 30, 58, 86, 114, 142 ], [ 6, 34, 62, 90, 118, 146 ], [ 6, 30, 54, 78, 102, 126, 150 ], [ 6, 24, 50, 76, 102, 128, 154 ], [ 6, 28, 54, 80, 106, 132, 158 ], [ 6, 32, 58, 84, 110, 136, 162 ], [ 6, 26, 54, 82, 110, 138, 166 ], [ 6, 30, 58, 86, 114, 142, 170 ] ],
"G15": 1335,
"G18": 7973,
"G15_MASK": 21522,
"getBCHTypeInfo": function(data) {
var d = data << 10;
while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) d ^= QRUtil.G15 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15);
return (data << 10 | d) ^ QRUtil.G15_MASK;
},
"getBCHTypeNumber": function(data) {
var d = data << 12;
while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) d ^= QRUtil.G18 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18);
return data << 12 | d;
},
"getBCHDigit": function(data) {
var digit = 0;
while (data != 0) digit++, data >>>= 1;
return digit;
},
"getPatternPosition": function(typeNumber) {
return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
},
"getMask": function(maskPattern, i, j) {
switch (maskPattern) {
case QRMaskPattern.PATTERN000:
return (i + j) % 2 == 0;
case QRMaskPattern.PATTERN001:
return i % 2 == 0;
case QRMaskPattern.PATTERN010:
return j % 3 == 0;
case QRMaskPattern.PATTERN011:
return (i + j) % 3 == 0;
case QRMaskPattern.PATTERN100:
return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
case QRMaskPattern.PATTERN101:
return i * j % 2 + i * j % 3 == 0;
case QRMaskPattern.PATTERN110:
return (i * j % 2 + i * j % 3) % 2 == 0;
case QRMaskPattern.PATTERN111:
return (i * j % 3 + (i + j) % 2) % 2 == 0;
default:
throw new Error("bad maskPattern:" + maskPattern);
}
},
"getErrorCorrectPolynomial": function(errorCorrectLength) {
var a = new QRPolynomial([ 1 ], 0);
for (var i = 0; i < errorCorrectLength; i++) a = a.multiply(new QRPolynomial([ 1, QRMath.gexp(i) ], 0));
return a;
},
"getLengthInBits": function(mode, type) {
if (1 <= type && type < 10) switch (mode) {
case QRMode.MODE_NUMBER:
return 10;
case QRMode.MODE_ALPHA_NUM:
return 9;
case QRMode.MODE_8BIT_BYTE:
return 8;
case QRMode.MODE_KANJI:
return 8;
default:
throw new Error("mode:" + mode);
} else if (type < 27) switch (mode) {
case QRMode.MODE_NUMBER:
return 12;
case QRMode.MODE_ALPHA_NUM:
return 11;
case QRMode.MODE_8BIT_BYTE:
return 16;
case QRMode.MODE_KANJI:
return 10;
default:
throw new Error("mode:" + mode);
} else {
if (!(type < 41)) throw new Error("type:" + type);
switch (mode) {
case QRMode.MODE_NUMBER:
return 14;
case QRMode.MODE_ALPHA_NUM:
return 13;
case QRMode.MODE_8BIT_BYTE:
return 16;
case QRMode.MODE_KANJI:
return 12;
default:
throw new Error("mode:" + mode);
}
}
},
"getLostPoint": function(qrCode) {
var moduleCount = qrCode.getModuleCount(), lostPoint = 0;
for (var row = 0; row < moduleCount; row++) for (var col = 0; col < moduleCount; col++) {
var sameCount = 0, dark = qrCode.isDark(row, col);
for (var r = -1; r <= 1; r++) {
if (row + r < 0 || moduleCount <= row + r) continue;
for (var c = -1; c <= 1; c++) {
if (col + c < 0 || moduleCount <= col + c) continue;
if (r == 0 && c == 0) continue;
dark == qrCode.isDark(row + r, col + c) && sameCount++;
}
}
sameCount > 5 && (lostPoint += 3 + sameCount - 5);
}
for (var row = 0; row < moduleCount - 1; row++) for (var col = 0; col < moduleCount - 1; col++) {
var count = 0;
qrCode.isDark(row, col) && count++, qrCode.isDark(row + 1, col) && count++, qrCode.isDark(row, col + 1) && count++, qrCode.isDark(row + 1, col + 1) && count++;
if (count == 0 || count == 4) lostPoint += 3;
}
for (var row = 0; row < moduleCount; row++) for (var col = 0; col < moduleCount - 6; col++) qrCode.isDark(row, col) && !qrCode.isDark(row, col + 1) && qrCode.isDark(row, col + 2) && qrCode.isDark(row, col + 3) && qrCode.isDark(row, col + 4) && !qrCode.isDark(row, col + 5) && qrCode.isDark(row, col + 6) && (lostPoint += 40);
for (var col = 0; col < moduleCount; col++) for (var row = 0; row < moduleCount - 6; row++) qrCode.isDark(row, col) && !qrCode.isDark(row + 1, col) && qrCode.isDark(row + 2, col) && qrCode.isDark(row + 3, col) && qrCode.isDark(row + 4, col) && !qrCode.isDark(row + 5, col) && qrCode.isDark(row + 6, col) && (lostPoint += 40);
var darkCount = 0;
for (var col = 0; col < moduleCount; col++) for (var row = 0; row < moduleCount; row++) qrCode.isDark(row, col) && darkCount++;
var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
return lostPoint += ratio * 10, lostPoint;
}
}, QRMath = {
"glog": function(n) {
if (n < 1) throw new Error("glog(" + n + ")");
return QRMath.LOG_TABLE[n];
},
"gexp": function(n) {
while (n < 0) n += 255;
while (n >= 256) n -= 255;
return QRMath.EXP_TABLE[n];
},
"EXP_TABLE": new Array(256),
"LOG_TABLE": new Array(256)
};
for (var i = 0; i < 8; i++) QRMath.EXP_TABLE[i] = 1 << i;
for (var i = 8; i < 256; i++) QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8];
for (var i = 0; i < 255; i++) QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i;
QRPolynomial.prototype = {
"get": function(index) {
return this.num[index];
},
"getLength": function() {
return this.num.length;
},
"multiply": function(e) {
var num = new Array(this.getLength() + e.getLength() - 1);
for (var i = 0; i < this.getLength(); i++) for (var j = 0; j < e.getLength(); j++) num[i + j] ^= QRMath.gexp(QRMath.glog(this.get(i)) + QRMath.glog(e.get(j)));
return new QRPolynomial(num, 0);
},
"mod": function(e) {
if (this.getLength() - e.getLength() < 0) return this;
var ratio = QRMath.glog(this.get(0)) - QRMath.glog(e.get(0)), num = new Array(this.getLength());
for (var i = 0; i < this.getLength(); i++) num[i] = this.get(i);
for (var i = 0; i < e.getLength(); i++) num[i] ^= QRMath.gexp(QRMath.glog(e.get(i)) + ratio);
return (new QRPolynomial(num, 0)).mod(e);
}
}, QRRSBlock.RS_BLOCK_TABLE = [ [ 1, 26, 19 ], [ 1, 26, 16 ], [ 1, 26, 13 ], [ 1, 26, 9 ], [ 1, 44, 34 ], [ 1, 44, 28 ], [ 1, 44, 22 ], [ 1, 44, 16 ], [ 1, 70, 55 ], [ 1, 70, 44 ], [ 2, 35, 17 ], [ 2, 35, 13 ], [ 1, 100, 80 ], [ 2, 50, 32 ], [ 2, 50, 24 ], [ 4, 25, 9 ], [ 1, 134, 108 ], [ 2, 67, 43 ], [ 2, 33, 15, 2, 34, 16 ], [ 2, 33, 11, 2, 34, 12 ], [ 2, 86, 68 ], [ 4, 43, 27 ], [ 4, 43, 19 ], [ 4, 43, 15 ], [ 2, 98, 78 ], [ 4, 49, 31 ], [ 2, 32, 14, 4, 33, 15 ], [ 4, 39, 13, 1, 40, 14 ], [ 2, 121, 97 ], [ 2, 60, 38, 2, 61, 39 ], [ 4, 40, 18, 2, 41, 19 ], [ 4, 40, 14, 2, 41, 15 ], [ 2, 146, 116 ], [ 3, 58, 36, 2, 59, 37 ], [ 4, 36, 16, 4, 37, 17 ], [ 4, 36, 12, 4, 37, 13 ], [ 2, 86, 68, 2, 87, 69 ], [ 4, 69, 43, 1, 70, 44 ], [ 6, 43, 19, 2, 44, 20 ], [ 6, 43, 15, 2, 44, 16 ], [ 4, 101, 81 ], [ 1, 80, 50, 4, 81, 51 ], [ 4, 50, 22, 4, 51, 23 ], [ 3, 36, 12, 8, 37, 13 ], [ 2, 116, 92, 2, 117, 93 ], [ 6, 58, 36, 2, 59, 37 ], [ 4, 46, 20, 6, 47, 21 ], [ 7, 42, 14, 4, 43, 15 ], [ 4, 133, 107 ], [ 8, 59, 37, 1, 60, 38 ], [ 8, 44, 20, 4, 45, 21 ], [ 12, 33, 11, 4, 34, 12 ], [ 3, 145, 115, 1, 146, 116 ], [ 4, 64, 40, 5, 65, 41 ], [ 11, 36, 16, 5, 37, 17 ], [ 11, 36, 12, 5, 37, 13 ], [ 5, 109, 87, 1, 110, 88 ], [ 5, 65, 41, 5, 66, 42 ], [ 5, 54, 24, 7, 55, 25 ], [ 11, 36, 12 ], [ 5, 122, 98, 1, 123, 99 ], [ 7, 73, 45, 3, 74, 46 ], [ 15, 43, 19, 2, 44, 20 ], [ 3, 45, 15, 13, 46, 16 ], [ 1, 135, 107, 5, 136, 108 ], [ 10, 74, 46, 1, 75, 47 ], [ 1, 50, 22, 15, 51, 23 ], [ 2, 42, 14, 17, 43, 15 ], [ 5, 150, 120, 1, 151, 121 ], [ 9, 69, 43, 4, 70, 44 ], [ 17, 50, 22, 1, 51, 23 ], [ 2, 42, 14, 19, 43, 15 ], [ 3, 141, 113, 4, 142, 114 ], [ 3, 70, 44, 11, 71, 45 ], [ 17, 47, 21, 4, 48, 22 ], [ 9, 39, 13, 16, 40, 14 ], [ 3, 135, 107, 5, 136, 108 ], [ 3, 67, 41, 13, 68, 42 ], [ 15, 54, 24, 5, 55, 25 ], [ 15, 43, 15, 10, 44, 16 ], [ 4, 144, 116, 4, 145, 117 ], [ 17, 68, 42 ], [ 17, 50, 22, 6, 51, 23 ], [ 19, 46, 16, 6, 47, 17 ], [ 2, 139, 111, 7, 140, 112 ], [ 17, 74, 46 ], [ 7, 54, 24, 16, 55, 25 ], [ 34, 37, 13 ], [ 4, 151, 121, 5, 152, 122 ], [ 4, 75, 47, 14, 76, 48 ], [ 11, 54, 24, 14, 55, 25 ], [ 16, 45, 15, 14, 46, 16 ], [ 6, 147, 117, 4, 148, 118 ], [ 6, 73, 45, 14, 74, 46 ], [ 11, 54, 24, 16, 55, 25 ], [ 30, 46, 16, 2, 47, 17 ], [ 8, 132, 106, 4, 133, 107 ], [ 8, 75, 47, 13, 76, 48 ], [ 7, 54, 24, 22, 55, 25 ], [ 22, 45, 15, 13, 46, 16 ], [ 10, 142, 114, 2, 143, 115 ], [ 19, 74, 46, 4, 75, 47 ], [ 28, 50, 22, 6, 51, 23 ], [ 33, 46, 16, 4, 47, 17 ], [ 8, 152, 122, 4, 153, 123 ], [ 22, 73, 45, 3, 74, 46 ], [ 8, 53, 23, 26, 54, 24 ], [ 12, 45, 15, 28, 46, 16 ], [ 3, 147, 117, 10, 148, 118 ], [ 3, 73, 45, 23, 74, 46 ], [ 4, 54, 24, 31, 55, 25 ], [ 11, 45, 15, 31, 46, 16 ], [ 7, 146, 116, 7, 147, 117 ], [ 21, 73, 45, 7, 74, 46 ], [ 1, 53, 23, 37, 54, 24 ], [ 19, 45, 15, 26, 46, 16 ], [ 5, 145, 115, 10, 146, 116 ], [ 19, 75, 47, 10, 76, 48 ], [ 15, 54, 24, 25, 55, 25 ], [ 23, 45, 15, 25, 46, 16 ], [ 13, 145, 115, 3, 146, 116 ], [ 2, 74, 46, 29, 75, 47 ], [ 42, 54, 24, 1, 55, 25 ], [ 23, 45, 15, 28, 46, 16 ], [ 17, 145, 115 ], [ 10, 74, 46, 23, 75, 47 ], [ 10, 54, 24, 35, 55, 25 ], [ 19, 45, 15, 35, 46, 16 ], [ 17, 145, 115, 1, 146, 116 ], [ 14, 74, 46, 21, 75, 47 ], [ 29, 54, 24, 19, 55, 25 ], [ 11, 45, 15, 46, 46, 16 ], [ 13, 145, 115, 6, 146, 116 ], [ 14, 74, 46, 23, 75, 47 ], [ 44, 54, 24, 7, 55, 25 ], [ 59, 46, 16, 1, 47, 17 ], [ 12, 151, 121, 7, 152, 122 ], [ 12, 75, 47, 26, 76, 48 ], [ 39, 54, 24, 14, 55, 25 ], [ 22, 45, 15, 41, 46, 16 ], [ 6, 151, 121, 14, 152, 122 ], [ 6, 75, 47, 34, 76, 48 ], [ 46, 54, 24, 10, 55, 25 ], [ 2, 45, 15, 64, 46, 16 ], [ 17, 152, 122, 4, 153, 123 ], [ 29, 74, 46, 14, 75, 47 ], [ 49, 54, 24, 10, 55, 25 ], [ 24, 45, 15, 46, 46, 16 ], [ 4, 152, 122, 18, 153, 123 ], [ 13, 74, 46, 32, 75, 47 ], [ 48, 54, 24, 14, 55, 25 ], [ 42, 45, 15, 32, 46, 16 ], [ 20, 147, 117, 4, 148, 118 ], [ 40, 75, 47, 7, 76, 48 ], [ 43, 54, 24, 22, 55, 25 ], [ 10, 45, 15, 67, 46, 16 ], [ 19, 148, 118, 6, 149, 119 ], [ 18, 75, 47, 31, 76, 48 ], [ 34, 54, 24, 34, 55, 25 ], [ 20, 45, 15, 61, 46, 16 ] ], QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
if (rsBlock == undefined) throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
var length = rsBlock.length / 3, list = [];
for (var i = 0; i < length; i++) {
var count = rsBlock[i * 3 + 0], totalCount = rsBlock[i * 3 + 1], dataCount = rsBlock[i * 3 + 2];
for (var j = 0; j < count; j++) list.push(new QRRSBlock(totalCount, dataCount));
}
return list;
}, QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {
switch (errorCorrectLevel) {
case QRErrorCorrectLevel.L:
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
case QRErrorCorrectLevel.M:
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
case QRErrorCorrectLevel.Q:
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
case QRErrorCorrectLevel.H:
return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
default:
return undefined;
}
}, QRBitBuffer.prototype = {
"get": function(index) {
var bufIndex = Math.floor(index / 8);
return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
},
"put": function(num, length) {
for (var i = 0; i < length; i++) this.putBit((num >>> length - i - 1 & 1) == 1);
},
"getLengthInBits": function() {
return this.length;
},
"putBit": function(bit) {
var bufIndex = Math.floor(this.length / 8);
this.buffer.length <= bufIndex && this.buffer.push(0), bit && (this.buffer[bufIndex] |= 128 >>> this.length % 8), this.length++;
}
};
var QRCodeLimitLength=[[17,14,11,7],[32,26,20,14],[53,42,32,24],[78,62,46,34],[106,84,60,44],[134,106,74,58],[154,122,86,64],[192,152,108,84],[230,180,130,98],[271,213,151,119],[321,251,177,137],[367,287,203,155],[425,331,241,177],[458,362,258,194],[520,412,292,220],[586,450,322,250],[644,504,364,280],[718,560,394,310],[792,624,442,338],[858,666,482,382],[929,711,509,403],[1003,779,565,439],[1091,857,611,461],[1171,911,661,511],[1273,997,715,535],[1367,1059,751,593],[1465,1125,805,625],[1528,1190,868,658],[1628,1264,908,698],[1732,1370,982,742],[1840,1452,1030,790],[1952,1538,1112,842],[2068,1628,1168,898],[2188,1722,1228,958],[2303,1809,1283,983],[2431,1911,1351,1051],[2563,1989,1423,1093],[2699,2099,1499,1139],[2809,2213,1579,1219],[2953,2331,1663,1273]];
function _isSupportCanvas() {
return typeof CanvasRenderingContext2D != "undefined";
}
// android 2.x doesn't support Data-URI spec
function _getAndroid() {
var android = false;
var sAgent = navigator.userAgent;
if (/android/i.test(sAgent)) { // android
android = true;
aMat = sAgent.toString().match(/android ([0-9]\.[0-9])/i);
if (aMat && aMat[1]) {
android = parseFloat(aMat[1]);
}
}
return android;
}
var svgDrawer = (function() {
var Drawing = function (el, htOption) {
this._el = el;
this._htOption = htOption;
};
Drawing.prototype.draw = function (oQRCode) {
var _htOption = this._htOption;
var _el = this._el;
var nCount = oQRCode.getModuleCount();
var nWidth = Math.floor(_htOption.width / nCount);
var nHeight = Math.floor(_htOption.height / nCount);
this.clear();
function makeSVG(tag, attrs) {
var el = document.createElementNS('http://www.w3.org/2000/svg', tag);
for (var k in attrs)
if (attrs.hasOwnProperty(k)) el.setAttribute(k, attrs[k]);
return el;
}
var svg = makeSVG("svg" , {'viewBox': '0 0 ' + String(nCount) + " " + String(nCount), 'width': '100%', 'height': '100%', 'fill': _htOption.colorLight});
svg.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink");
_el.appendChild(svg);
svg.appendChild(makeSVG("rect", {"fill": _htOption.colorDark, "width": "1", "height": "1", "id": "template"}));
for (var row = 0; row < nCount; row++) {
for (var col = 0; col < nCount; col++) {
if (oQRCode.isDark(row, col)) {
var child = makeSVG("use", {"x": String(row), "y": String(col)});
child.setAttributeNS("http://www.w3.org/1999/xlink", "href", "#template")
svg.appendChild(child);
}
}
}
};
Drawing.prototype.clear = function () {
while (this._el.hasChildNodes())
this._el.removeChild(this._el.lastChild);
};
return Drawing;
})();
var useSVG = document.documentElement.tagName.toLowerCase() === "svg";
// Drawing in DOM by using Table tag
var Drawing = useSVG ? svgDrawer : !_isSupportCanvas() ? (function () {
var Drawing = function (el, htOption) {
this._el = el;
this._htOption = htOption;
};
/**
* Draw the QRCode
*
* @param {QRCode} oQRCode
*/
Drawing.prototype.draw = function (oQRCode) {
var _htOption = this._htOption;
var _el = this._el;
var nCount = oQRCode.getModuleCount();
var nWidth = Math.floor(_htOption.width / nCount);
var nHeight = Math.floor(_htOption.height / nCount);
var aHTML = ['<table style="border:0;border-collapse:collapse;">'];
for (var row = 0; row < nCount; row++) {
aHTML.push('<tr>');
for (var col = 0; col < nCount; col++) {
aHTML.push('<td style="border:0;border-collapse:collapse;padding:0;margin:0;width:' + nWidth + 'px;height:' + nHeight + 'px;background-color:' + (oQRCode.isDark(row, col) ? _htOption.colorDark : _htOption.colorLight) + ';"></td>');
}
aHTML.push('</tr>');
}
aHTML.push('</table>');
_el.innerHTML = aHTML.join('');
// Fix the margin values as real size.
var elTable = _el.childNodes[0];
var nLeftMarginTable = (_htOption.width - elTable.offsetWidth) / 2;
var nTopMarginTable = (_htOption.height - elTable.offsetHeight) / 2;
if (nLeftMarginTable > 0 && nTopMarginTable > 0) {
elTable.style.margin = nTopMarginTable + "px " + nLeftMarginTable + "px";
}
};
/**
* Clear the QRCode
*/
Drawing.prototype.clear = function () {
this._el.innerHTML = '';
};
return Drawing;
})() : (function () { // Drawing in Canvas
function _onMakeImage() {
this._elImage.src = this._elCanvas.toDataURL("image/png");
this._elImage.style.display = "block";
this._elCanvas.style.display = "none";
}
// Android 2.1 bug workaround
// http://code.google.com/p/android/issues/detail?id=5141
if (this._android && this._android <= 2.1) {
var factor = 1 / window.devicePixelRatio;
var drawImage = CanvasRenderingContext2D.prototype.drawImage;
CanvasRenderingContext2D.prototype.drawImage = function (image, sx, sy, sw, sh, dx, dy, dw, dh) {
if (("nodeName" in image) && /img/i.test(image.nodeName)) {
for (var i = arguments.length - 1; i >= 1; i--) {
arguments[i] = arguments[i] * factor;
}
} else if (typeof dw == "undefined") {
arguments[1] *= factor;
arguments[2] *= factor;
arguments[3] *= factor;
arguments[4] *= factor;
}
drawImage.apply(this, arguments);
};
}
/**
* Check whether the user's browser supports Data URI or not
*
* @private
* @param {Function} fSuccess Occurs if it supports Data URI
* @param {Function} fFail Occurs if it doesn't support Data URI
*/
function _safeSetDataURI(fSuccess, fFail) {
var self = this;
self._fFail = fFail;
self._fSuccess = fSuccess;
// Check it just once
if (self._bSupportDataURI === null) {
var el = document.createElement("img");
var fOnError = function() {
self._bSupportDataURI = false;
if (self._fFail) {
_fFail.call(self);
}
};
var fOnSuccess = function() {
self._bSupportDataURI = true;
if (self._fSuccess) {
self._fSuccess.call(self);
}
};
el.onabort = fOnError;
el.onerror = fOnError;
el.onload = fOnSuccess;
el.src = "data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg=="; // the Image contains 1px data.
return;
} else if (self._bSupportDataURI === true && self._fSuccess) {
self._fSuccess.call(self);
} else if (self._bSupportDataURI === false && self._fFail) {
self._fFail.call(self);
}
};
/**
* Drawing QRCode by using canvas
*
* @constructor
* @param {HTMLElement} el
* @param {Object} htOption QRCode Options
*/
var Drawing = function (el, htOption) {
this._bIsPainted = false;
this._android = _getAndroid();
this._htOption = htOption;
this._elCanvas = document.createElement("canvas");
this._elCanvas.width = htOption.width;
this._elCanvas.height = htOption.height;
el.appendChild(this._elCanvas);
this._el = el;
this._oContext = this._elCanvas.getContext("2d");
this._bIsPainted = false;
this._elImage = document.createElement("img");
this._elImage.alt = "Scan me!";
this._elImage.style.display = "none";
this._el.appendChild(this._elImage);
this._bSupportDataURI = null;
};
/**
* Draw the QRCode
*
* @param {QRCode} oQRCode
*/
Drawing.prototype.draw = function (oQRCode) {
var _elImage = this._elImage;
var _oContext = this._oContext;
var _htOption = this._htOption;
var nCount = oQRCode.getModuleCount();
var nWidth = _htOption.width / nCount;
var nHeight = _htOption.height / nCount;
var nRoundedWidth = Math.round(nWidth);
var nRoundedHeight = Math.round(nHeight);
_elImage.style.display = "none";
this.clear();
for (var row = 0; row < nCount; row++) {
for (var col = 0; col < nCount; col++) {
var bIsDark = oQRCode.isDark(row, col);
var nLeft = col * nWidth;
var nTop = row * nHeight;
_oContext.strokeStyle = bIsDark ? _htOption.colorDark : _htOption.colorLight;
_oContext.lineWidth = 1;
_oContext.fillStyle = bIsDark ? _htOption.colorDark : _htOption.colorLight;
_oContext.fillRect(nLeft, nTop, nWidth, nHeight);
_oContext.strokeRect(
Math.floor(nLeft) + 0.5,
Math.floor(nTop) + 0.5,
nRoundedWidth,
nRoundedHeight
);
_oContext.strokeRect(
Math.ceil(nLeft) - 0.5,
Math.ceil(nTop) - 0.5,
nRoundedWidth,
nRoundedHeight
);
}
}
this._bIsPainted = true;
};
/**
* Make the image from Canvas if the browser supports Data URI.
*/
Drawing.prototype.makeImage = function () {
if (this._bIsPainted) {
_safeSetDataURI.call(this, _onMakeImage);
}
};
/**
* Return whether the QRCode is painted or not
*
* @return {Boolean}
*/
Drawing.prototype.isPainted = function () {
return this._bIsPainted;
};
/**
* Clear the QRCode
*/
Drawing.prototype.clear = function () {
this._oContext.clearRect(0, 0, this._elCanvas.width, this._elCanvas.height);
this._bIsPainted = false;
};
/**
* @private
* @param {Number} nNumber
*/
Drawing.prototype.round = function (nNumber) {
if (!nNumber) {
return nNumber;
}
return Math.floor(nNumber * 1000) / 1000;
};
return Drawing;
})();
/**
* Get the type by string length
*
* @private
* @param {String} sText
* @param {Number} nCorrectLevel
* @return {Number} type
*/
function _getTypeNumber(sText, nCorrectLevel) {
var nType = 1;
var length = _getUTF8Length(sText);
for (var i = 0, len = QRCodeLimitLength.length; i <= len; i++) {
var nLimit = 0;
switch (nCorrectLevel) {
case QRErrorCorrectLevel.L :
nLimit = QRCodeLimitLength[i][0];
break;
case QRErrorCorrectLevel.M :
nLimit = QRCodeLimitLength[i][1];
break;
case QRErrorCorrectLevel.Q :
nLimit = QRCodeLimitLength[i][2];
break;
case QRErrorCorrectLevel.H :
nLimit = QRCodeLimitLength[i][3];
break;
}
if (length <= nLimit) {
break;
} else {
nType++;
}
}
if (nType > QRCodeLimitLength.length) {
throw new Error("Too long data");
}
return nType;
}
function _getUTF8Length(sText) {
var replacedText = encodeURI(sText).toString().replace(/\%[0-9a-fA-F]{2}/g, 'a');
return replacedText.length + (replacedText.length != sText ? 3 : 0);
}
/**
* @class QRCode
* @constructor
* @example
* new QRCode(document.getElementById("test"), "http://jindo.dev.naver.com/collie");
*
* @example
* var oQRCode = new QRCode("test", {
* text : "http://naver.com",
* width : 128,
* height : 128
* });
*
* oQRCode.clear(); // Clear the QRCode.
* oQRCode.makeCode("http://map.naver.com"); // Re-create the QRCode.
*
* @param {HTMLElement|String} el target element or 'id' attribute of element.
* @param {Object|String} vOption
* @param {String} vOption.text QRCode link data
* @param {Number} [vOption.width=256]
* @param {Number} [vOption.height=256]
* @param {String} [vOption.colorDark="#000000"]
* @param {String} [vOption.colorLight="#ffffff"]
* @param {QRCode.CorrectLevel} [vOption.correctLevel=QRCode.CorrectLevel.H] [L|M|Q|H]
*/
QRCode = function (el, vOption) {
this._htOption = {
width : 256,
height : 256,
typeNumber : 4,
colorDark : "#000000",
colorLight : "#ffffff",
correctLevel : QRErrorCorrectLevel.H
};
if (typeof vOption === 'string') {
vOption = {
text : vOption
};
}
// Overwrites options
if (vOption) {
for (var i in vOption) {
this._htOption[i] = vOption[i];
}
}
if (typeof el == "string") {
el = document.getElementById(el);
}
this._android = _getAndroid();
this._el = el;
this._oQRCode = null;
this._oDrawing = new Drawing(this._el, this._htOption);
if (this._htOption.text) {
this.makeCode(this._htOption.text);
}
};
/**
* Make the QRCode
*
* @param {String} sText link data
*/
QRCode.prototype.makeCode = function (sText) {
this._oQRCode = new QRCodeModel(_getTypeNumber(sText, this._htOption.correctLevel), this._htOption.correctLevel);
this._oQRCode.addData(sText);
this._oQRCode.make();
this._el.title = sText;
this._oDrawing.draw(this._oQRCode);
this.makeImage();
};
/**
* Make the Image from Canvas element
* - It occurs automatically
* - Android below 3 doesn't support Data-URI spec.
*
* @private
*/
QRCode.prototype.makeImage = function () {
if (typeof this._oDrawing.makeImage == "function" && (!this._android || this._android >= 3)) {
this._oDrawing.makeImage();
}
};
/**
* Clear the QRCode
*/
QRCode.prototype.clear = function () {
this._el.innerHTML = '';
this._oDrawing.clear();
};
/**
* @name QRCode.CorrectLevel
*/
QRCode.CorrectLevel = QRErrorCorrectLevel;
})();
\ No newline at end of file
var qs = require('qs')
export default {
wRequest: async function (url, obj, params) {
if (params !== undefined) {
let param = qs.stringify(params)
let result = await obj.$axios.$post(url, param)
// console.log('test api3 == ' + JSON.stringify(result) + 'result type ==== ' + typeof result)
return result
}
let result = await obj.$axios.$post(url)
// console.log('test api1 == ' + JSON.stringify(result) + 'result type ==== ' + typeof result)
return result
},
getRequest: async function (url, obj, params) {
if (params !== undefined) {
let param = qs.stringify(params)
let result = await obj.$axios.$get(url, param)
// console.log('test api1 == ' + JSON.stringify(result.data))
return result
}
let result = await obj.$axios.$get(url)
// console.log('test api2 == ' + JSON.stringify(result.data))
return result
},
postByJson: async function (url, obj, params) {
// json格式的网络请求,需要指定content-type,并且参数不能用qs转化成key=value的形式,直接以json对象传递就可以
let result = await obj.$axios({
headers: {
'Content-Type': 'application/json'
},
method: 'post',
url: url,
data: params
})
return result // 返回数据的异常
},
// 开始定时器
startTimer(obj) {
let that = obj
const TIME_COUNT = 60
if (!obj.timer) {
obj.count = TIME_COUNT
obj.timer = setInterval(() => {
if (that.count > 0 && that.count <= TIME_COUNT) {
that.count--
that.btnText = '已发送(' + that.count + ')'
} else {
clearInterval(that.timer)
that.timer = null
that.btnText = '重新发送'
that.btnDisable = false
}
}, 1000)
}
},
// 验证手机号码
identyTelNumber(tel) {
if (tel === undefined || tel === null || tel === '') {
return false
}
var reg = 11 && /^((13|14|15|17|18)[0-9]{1}\d{8})$/
if (!reg.test(tel)) {
return false
}
return true
},
// 验证中文字符
hasChinese(checkStr) {
var reg = /[\u4E00-\u9FA5]/g
if (reg.test(checkStr)) {
return false
}
return true
},
identyEmail(email) {
if (email === undefined || email === '') {
alert('请输入邮箱')
return false
}
var reg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/ // eslint-disable-line no-useless-escape
if (!reg.test(email)) {
alert('请输入正确的邮箱')
return false
}
return true
},
// 获取搜索页头部列表
searchGoods(obj, param) { return this.wRequest('/xhr/goods/search', obj, param) },
// 获取订单列表
getOrderList(obj, param) { return this.wRequest('/xhr/order/searchList.json', obj, param) },
// 获取所有订单页面,广州二次支付订单导入按钮是否显示
orderPageBtnShow(obj) { return this.wRequest('/xhr/order/orderPageStatus.json', obj) },
// 获取未支付订单列表
getUnpaylist(obj, param) { return this.wRequest('/xhr/order/unpaidOrderList.json', obj, param) },
// 获取选中未支付订单,应支付金额明细
getUnpayAmount(obj, param) { return this.wRequest('/xhr/order/neddedFees.json', obj, param) },
// 获取需要编辑的订单的地址信息
editOrderAddress(obj, param) { return this.wRequest('/xhr/order/getOrderAddress.json', obj, param) },
// 保存编辑的订单的地址信息
saveOrderAddr(obj, param) { return this.wRequest('/xhr/order/orderAddressUpdate.json', obj, param) },
// 获取购物车列表
getCartlist(obj, param) { return this.postByJson('/xhr/cart/list.json', obj, param) },
// 更改购物车数量
changeNumInCart(obj, param) { return this.wRequest('/xhr/cart/updateById.json', obj, param) },
// 添加到购物车
addGoodToCart(obj, param) { return this.wRequest('/xhr/cart/addCartByCode.json', obj, param) },
// 获取购物车数量
cartGoodNum(obj) { return this.wRequest('/xhr/cart/getCount.json', obj) },
// 删除购物车商品
delCartGoods(obj, param) { return this.wRequest('/xhr/cart/deleteById.json', obj, param) },
// 获取头部类目列表
getClassify(obj) { return this.wRequest('/xhr/category/all.json', obj) },
// 获取商品详情
getGoodsDetail(obj, goodCode) { return this.wRequest('/xhr/goods/' + goodCode + '.json', obj) },
// 商品详情推荐商品
detailHotGoods(obj) { return this.wRequest('/xhr/goods/recommend.json', obj) },
// 获取首页内容
getIndexGoods(obj) { return this.wRequest('/xhr/goods/indexGoods', obj) },
getAddressById(obj, param) { return this.wRequest('/xhr/area/child.json', obj, param) },
// 获取平台分销列表
getPlatformList(obj, param) { return this.wRequest('/xhr/financial/orderPackageList/queryByPage.json', obj, param) },
// 获取采购财务列表
getPurchaseList(obj, param) { return this.wRequest('/xhr/report/purchaseFinancial.json', obj, param) },
// 获取供货财务列表
getSupplyList(obj, param) { return this.wRequest('/xhr/report/supplyFinancial.json', obj, param) },
// 取消订单
cancelOrder(obj, param) { return this.wRequest('/xhr/order/orderCancel', obj, param) },
// 删除订单
deleteOrder(obj, param) { return this.wRequest('/xhr/order/orderDelete.json', obj, param) },
// 订单详情获取商品和订单编号等
orderDetailInfo(obj, param) { return this.wRequest('/xhr/order/detail.json', obj, param) },
// 订单详情-获取海关状态
orderCustomSts(obj, param) { return this.wRequest('/xhr/order/packageCustomsLog.json', obj, param) },
// 修改身份证号
changePaper(obj, param) { return this.wRequest('/xhr/order/changePaper.json', obj, param) },
// 获取确认订单页面商品信息
getConfirmOrder(obj) { return this.wRequest('/xhr/order/confirmOrder', obj) },
// 获取用户地址列表
addressListGet(obj) { return this.wRequest('/xhr/userAddress/list.json', obj) },
// 设置为用户默认地址
setAddrDefault(obj, param) { return this.wRequest('/xhr/userAddress/setDefault.json', obj, param) },
// 删除用户地址
delUserAddr(obj, param) { return this.wRequest('/xhr/userAddress/delete.json', obj, param) },
// 根据地址id获取单个地址详细信息
getAddrFullById(obj, param) { return this.wRequest('/xhr/userAddress/getById.json', obj, param) },
// 添加或者修改地址
updateAddrById(obj, param) { return this.wRequest('/xhr/userAddress/upsert.json', obj, param) },
// 地址-添加身份证
addIdentityNumber(obj, param) { return this.wRequest('/xhr/userAddress/addIdentityNumber.json', obj, param) },
// 提交订单
submitOrder(obj, param) { return this.postByJson('/xhr/order/submitOrder2.json', obj, param) },
// 去支付页面获取可使用支付方式和收款方信息
goPayInfo(obj, param) { return this.wRequest('/xhr/pay/payWay.json', obj, param) },
// 支付(包含单个订单直接付款和未支付订单页面整体提交)
ordersPay(obj, param) { return this.wRequest('/xhr/pay/payment.json', obj, param) },
// 获取账户明细列表
getFinanceDetail(obj, param) { return this.wRequest('/xhr/financial/accountDetail/queryByPage.json', obj, param) },
// 获取余额提现列表
getwithdrawList(obj) { return this.wRequest('/xhr/finance/withdrawList', obj) },
// 获取自有货源列表
getSourceList(obj, param) { return this.wRequest('/xhr/goods/supplierSearch.json', obj, param) },
// 获取库存变动列表
getInventoryList(obj, param) { return this.wRequest('/xhr/goods/inventoryLogSum.json', obj, param) },
// 获取库存变动详情
getInventoryDetail(obj, param) { return this.wRequest('/xhr/goods/inventoryLog.json', obj, param) },
// 库存变动详情导出
InventoryExport(obj, param) { return this.wRequest('/xhr/goods/exportInventoryLog', obj, param) },
// 登录页面相关
usrLogin(obj, param) { return this.wRequest('/xhr/login/submit.json', obj, param) },
// 退出登录
usrLogout(obj) { return this.wRequest('/xhr/login/logout.json', obj) },
placeOrderInfo(obj, param) { return this.postByJson('/xhr/order/initOrder2.json', obj, param) },
// 获取包裹状态
getPackageType(obj) { return this.wRequest('/xhr/order/packageStatus.json', obj) },
// 获取海关状态
getCustomType(obj) { return this.wRequest('/xhr/order/customsStatus.json', obj) },
// 快递接口
getExpress(obj, param) { return this.wRequest('/xhr/order/getPackageExpInfo.json', obj, param) },
// 手机验证码(注册用)
getMobileCode(obj, param) { return this.wRequest('/xhr/login/mobileCode', obj, param) },
// 注册
register(obj, param) { return this.wRequest('/xhr/login/register', obj, param) },
// 获取用户信息
getUserInfo(obj) { return this.wRequest('/xhr/web/user/getInfo', obj) },
// 手机验证码(修改手机号、修改密码用)
getChangeMobileCode(obj, param) { return this.wRequest('/xhr/findPassword/getMobileCode.json', obj, param) },
// 确认输入的验证码是否正确(修改手机号、修改密码用)
confirmMobileCode(obj, param) { return this.wRequest('/xhr/findPassword/verifyMobileCode.json', obj, param) },
// 更新手机号码接口
updateMobile(obj, param) { return this.wRequest('/xhr/web/user/updateMobile.json', obj, param) },
// 更新用户名
updateName(obj, param) { return this.wRequest('/xhr/web/user/updateName.json', obj, param) },
// 修改用户密码
changePassword(obj, param) { return this.wRequest('/xhr/login/changePassword', obj, param) },
// 上传头像信息
saveHeadr(obj, param) { return this.wRequest('/xhr/web/user/updateAvatar.json', obj, param) },
// 找回密码(第一步):账号验证
verifyAccount(obj, param) { return this.wRequest('/xhr/findPassword/verifyAccount.json', obj, param) },
// 找回密码(第三步):手机验证码修改密码
retrievePassword(obj, param) { return this.wRequest('/xhr/findPassword/retrievePw.json', obj, param) },
// 找回密码(第二步):发送邮件
sendEmail(obj, param) { return this.wRequest('/xhr/findPassword/sendEmail.json', obj, param) },
// 找回密码(第三步):邮件验证
verifyEmail(obj, param) { return this.wRequest('/xhr/findPassword/verifyEmail.json', obj, param) },
// 仓库列表
depotList(obj) { return this.wRequest('/xhr/depot/list.json', obj) },
// 供应商自有货源导出
sourceExport(obj, param) { return this.wRequest('/xhr/goods/selfGoodsDerive.json', obj, param) },
// 批量提货即批量添加购物车
addCartBatch(obj, param) { return this.postByJson('/xhr/cart/addCartBatch', obj, param) },
// 用户余额信息
moneyInfo(obj) { return this.wRequest('/xhr/financial/moneyInfo.json', obj) },
// 余额充值
recharge(obj, param) { return this.wRequest('/xhr/order/recharge.json', obj, param) },
// 售后申请页面初始化数据
afterSaleInit(obj, param) { return this.wRequest('/xhr/order/afterSale/applyDetail.json', obj, param) },
// 售后申请提交
afterSaleSubmit(obj, param) { return this.wRequest('/xhr/order/afterSale/applySubmit.json', obj, param) },
// 售后详情
afterSaleDetail(obj, param) { return this.wRequest('/xhr/order/afterSale/detail.json', obj, param) },
// 提交售后发货信息
afterSaleSubmitLogis(obj, param) { return this.wRequest('/xhr/order/afterSale/deliverySubmit.json', obj, param) },
// 售后申请取消
afterSalecancel(obj, param) { return this.wRequest('/xhr/order/afterSale/applyCancel.json', obj, param) },
// 提现页面-提现提交
withdrawCash(obj, param) { return this.wRequest('/cashWithdraw/confirm.json', obj, param) },
// 获取订单数量
getSearchCount(obj, param) { return this.wRequest('/xhr/order/searchCount.json', obj, param) },
// 获取支付信息
getPayInfo(obj) { return this.wRequest('/mock/47/api/shop/profile/pay/list', obj) },
server_getConfig(key) {
if (process.env.WD_ENV === 'production') {
var configp = require('../config/config-prod.json')
return configp[key]
} else if (process.env.WD_ENV === 'test') {
var configt = require('../config/config-test.json')
return configt[key]
}
var configdev = require('../config/config-dev.json')
return configdev[key]
},
client_getConfig(key) {
if (window.location.href.indexOf('m.yang800.com') !== -1) {
var configp = require('../config/config-prod.json')
return configp[key]
} else if (window.location.href.indexOf('mtest.yang800.cn') !== -1) {
var configt = require('../config/config-test.json')
return configt[key]
}
var configdev = require('../config/config-dev.json')
return configdev[key]
}
}
import requestApi from './requestApi.js'
export default {
wxPayInfo: async function (orderSn, cobj, from) {
console.log('支付的订单编号=== ' + orderSn)
let va = navigator.userAgent.toLowerCase()
let inWeixin = false
if (va.indexOf('micromessenger') > 0) {
inWeixin = true
}
let param = {
orderSn: orderSn,
inWeixin: inWeixin
}
let obj = await requestApi.getWxPayInfo(cobj, param)
console.log('getWxPayInfo === ' + JSON.stringify(obj))
if (obj.code === 'success') {
let res = obj.data
if (res.testFlag) {
} else if (res.h5Flag) {
var url = res.data
let host = requestApi.client_getConfig('host')
window.location.href = url + '&redirect_url=' + encodeURI(host + '/order/order?tab=1')
} else {
this.wxPay(JSON.parse(res.data), cobj, from, orderSn)
}
}
},
// 支付
wxPay(res, cobj, from, orderSn) {
let param = {
appId: res.appId,
timeStamp: res.timeStamp,
nonceStr: res.nonceStr,
package: res.package,
signType: res.signType,
paySign: res.paySign
}
console.log()
if (typeof WeixinJSBridge !== 'undefined') {
this.onBridgeReady(param, cobj, from, orderSn)
}
},
onBridgeReady(param, cobj, from, orderSn) {
let that = cobj
WeixinJSBridge.invoke('getBrandWCPayRequest', param, // eslint-disable-line no-undef
function (res) {
// alert('errormsg == ' + JSON.stringify(res))
let success = 1
if (res.err_msg === 'get_brand_wcpay_request:ok') {
success = 0
}
if (from === 1) {
that.$router.push({
path: '/order/pay_success',
query: {
success: success,
orderNo: orderSn
}
})
}
})
}
}
export default {
readLocalCookie(name) {
// console.log('processs == ' + JSON.stringify(process))
// console.log('read cookie' + document.cookie)
let cookieValue = ''
let search = name + '='
if (document.cookie.length > 0) {
let offset = document.cookie.indexOf(search)
if (offset !== -1) {
offset += search.length
let end = document.cookie.indexOf(';', offset)
if (end === -1) {
end = document.cookie.length
}
cookieValue = unescape(document.cookie.substring(offset, end))
}
}
return cookieValue
},
setLocalCookie(name, value) {
this.clearLocalCookie(name)
let ckr = name + '=' + escape(value) + ';'
ckr += 'path=/;'
// console.log('set cookie' + ckr)
document.cookie = ckr
},
clearLocalCookie(name) {
let exp = new Date()
exp.setTime(exp.getTime() - 1)
let cval = this.readLocalCookie(name)
if (cval !== undefined && cval !== null && cval !== '') {
document.cookie = name + '=' + cval + ';expires=' + exp.toGMTString()
}
}
}
module.exports = {
webpack: (config, options, webpack) => {
config.entry.main = './server/index.js'
return config
}
}
<template>
<footer>
Visit our website for more documentation : <a href="https://nuxtjs.org" target="_blank">nuxtjs.org</a>
</footer>
</template>
var gulp = require('gulp')
os = require('os')
path = require('path')
var config = require('./folder.config.json')
var upload = require('./upload.js')
var appConfig = config;
var staticDir = appConfig.staticPath;
var buildDir = appConfig.build
var uploadPrefix = appConfig.uploadPrefix;
/***--------------------useref start ----------------------***/
var uglifyJs = function(file){
console.log('js:' + file);
// if(/\-min.js$/.test(file.path)){
// return false;
// }
// else if(/.js$/.test(file.path)) {
// return true;
// }
return true;
}
gulp.task('uploadImg',function(){
return gulp.src(path.join(staticDir,'**/*{.png, .jpeg, .jpg}'))
.pipe(upload({'uploadPrefix':uploadPrefix,
'baseDir':staticDir}))
.pipe(gulp.dest(buildDir));
});
gulp.task('upload', function(cb) {
gulp.src(path.join(staticDir,'**/*{.png, .jpeg, .jpg}'))
//每一个文件都会执行一次on & .on('data'可以获取匹配到的文件路径 & rename模块也可以获取到
.on('data', function(file) {
console.log(file.path);
});
});
gulp.task('default', ['uploadImg']);
\ No newline at end of file
<template>
<div>
<div>
<div class="head y_flex_between">
<div class="dl-title">管理系统</div>
<div class="dl-log">欢迎您,admin[退出]</div>
</div>
<div class="nav_tab y_flex_start">
<div v-for="(item, index) in tab" :class="{'nav_item': true, 'nav_active': tabNow === index}" @click="switchTab(index)">
{{item}}
</div>
</div>
<div class="y_default_start">
<div class="main_left" :style="{height: clientHeight + 'px'}">
<div class="orderCtg_txt">
<p v-for="(item, index) in orderList" :class="$route.path===item.pagePath?'orderCtg_list_now':''" @click="entriesClick(item)">{{item.name}}</p>
</div>
<div class="orderCtg_txt">
<p v-for="(item, index) in lapsList" :class="$route.path===item.pagePath?'orderCtg_list_now':''" @click="entriesClick(item)">{{item.name}}</p>
</div>
<div class="orderCtg_txt">
<p v-for="(item, index) in financeList" :class="$route.path===item.pagePath?'orderCtg_list_now':''" @click="entriesClick(item)">{{item.name}}</p>
</div>
</div>
<div class="main_right">
<div class="crumbs">
<span class="crumbs_list" v-for="(item, index) in Array.from(visitedViews)">{{item.name}}</span>
</div>
<nuxt class="content"/>
</div>
</div>
</div>
</div>
</template>
<script>
import YCookie from '../assets/js/yCookie.js'
export default {
data() {
return {
tab: ['系统管理', '商品管理', '订单管理', '财务管理'],
tabNow: 0,
orderList: [],
lapsList: [],
financeList: [],
clientHeight: 0
}
},
computed: {
visitedViews() {
// return this.$store.state.systemTags.sVisitedViews
if (this.tabNow === 0) {
return this.$store.state.systemTags.sVisitedViews
} else if (this.tabNow === 1) {
return this.$store.state.goodsTags.gVisitedViews
} else if (this.tabNow === 2) {
return this.$store.state.orderTags.oVisitedViews
} else {
return this.$store.state.financalTags.fVisitedViews
}
}
},
watch: {
$route() {
this.addViewTags()
}
},
methods: {
generateRoute() {
if (this.$route.name) {
return this.$route
}
return false
},
addViewTags() {
const route = this.generateRoute()
if (!route) {
return false
}
// this.$store.dispatch('sAddVisitedViews', route)
if (this.tabNow === 0) {
this.$store.dispatch('sAddVisitedViews', route)
} else if (this.tabNow === 1) {
this.$store.dispatch('gAddVisitedViews', route)
} else if (this.tabNow === 2) {
this.$store.dispatch('oAddVisitedViews', route)
} else {
this.$store.dispatch('fAddVisitedViews', route)
}
},
// 获取列表数据
getOrderCtg() {
let order = []
let orderPath = []
let orderId = []
let laps = []
let lapPath = []
let lapId = []
let finance = []
let accountPath = []
let accountId = []
if (this.tabNow === 0) {
order = ['所有订单']
orderPath = ['/y-order/order']
orderId = ['0']
laps = []
lapPath = []
lapId = []
finance = ['账户安全', '账户信息']
accountPath = ['/account/security', '/account/message']
accountId = ['0', '1']
} else if (this.tabNow === 1) {
order = ['所有订单', '导入订单', '未支付订单']
orderPath = ['/y-order/order', '/y-order/order-import', '/y-order/order-unpaid']
orderId = ['0', '1', '2']
laps = ['账户明细', '采购财务']
lapPath = ['/finance/finance-detail', '/finance/purchase']
lapId = ['0', '2']
finance = ['账户安全', '账户信息']
accountPath = ['/account/security', '/account/message']
accountId = ['0', '1']
} else if (this.tabNow === 2) {
order = ['所有订单', '导入订单', '未支付订单']
orderPath = ['/y-order/order', '/y-order/order-import', '/y-order/order-unpaid']
orderId = ['0', '1', '2']
laps = ['账户明细', '采购财务', '供货财物', '平台分销']
lapPath = ['/finance/finance-detail', '/finance/purchase', '/finance/supply', '/finance/platform']
lapId = ['0', '2', '3', '4']
finance = ['账户安全', '账户信息']
accountPath = ['/account/security', '/account/message']
accountId = ['0', '1']
} else {
order = ['所有订单', '未支付订单']
orderPath = ['/y-order/order', '/y-order/order-unpaid']
orderId = ['0', '2']
laps = ['账户明细', '采购财务', '供货财物', '平台分销']
lapPath = ['/finance/finance-detail', '/finance/purchase', '/finance/supply', '/finance/platform']
lapId = ['0', '2', '3', '4']
finance = ['账户安全', '账户信息']
accountPath = ['/account/security', '/account/message']
accountId = ['0', '1']
}
for (let i = 0; i < order.length; i++) {
let itemOrder = {name: order[i], id: orderId[i], pagePath: orderPath[i]}
this.orderList.push(itemOrder)
}
for (let i = 0; i < laps.length; i++) {
let itemLaps = {name: laps[i], id: lapId[i], pagePath: lapPath[i]}
this.lapsList.push(itemLaps)
}
for (let i = 0; i < finance.length; i++) {
let itemFinance = {name: finance[i], id: accountId[i], pagePath: accountPath[i]}
this.financeList.push(itemFinance)
}
},
switchTab(e) {
this.tabNow = e
YCookie.setLocalCookie('tabNow', this.tabNow)
this.orderList = []
this.lapsList = []
this.financeList = []
this.getOrderCtg()
this.$router.push({
path: '/'
})
console.log(this.$store.state.tagsView.visitedViews)
},
entriesClick(item) {
this.$router.push({
path: item.pagePath
})
console.log(this.$store.state.tagsView.visitedViews)
},
// 获取窗口可视范围的高度
getClientHeight() {
// let clientHeight = 0
// if (document.body.clientHeight && document.documentElement.clientHeight) {
// clientHeight = (document.body.clientHeight < document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
// } else {
// clientHeight = (document.body.clientHeight > document.documentElement.clientHeight) ? document.body.clientHeight : document.documentElement.clientHeight
// }
this.clientHeight = document.documentElement.clientHeight - 76
}
},
mounted() {
this.getClientHeight()
if (YCookie.readLocalCookie('tabNow') === undefined || YCookie.readLocalCookie('tabNow') === '') {
this.tabNow = 0
} else {
this.tabNow = parseInt(YCookie.readLocalCookie('tabNow'))
}
this.getOrderCtg()
this.addViewTags()
}
}
</script>
<style>
.container
{
margin: 0;
width: 100%;
padding: 100px 0;
text-align: center;
}
.button, .button:visited
{
display: inline-block;
color: #3B8070;
letter-spacing: 1px;
background-color: #fff;
border: 2px solid #3B8070;
text-decoration: none;
text-transform: uppercase;
padding: 15px 45px;
}
.button:hover, .button:focus
{
color: #fff;
background-color: #3B8070;
}
.title
{
color: #505153;
font-weight: 300;
font-size: 2.5em;
margin: 0;
}
/*头部*/
.head{
background-color: #1B3160;
height: 36px;
width: 100%;
overflow: hidden;
}
.dl-title {
color: #c1d5ec;
font-family: "Microsoft YaHei";
margin-left: 12px;
font-size: 18px;
line-height: 36px;
}
.dl-log {
color: #C1D5EC;
font-size: 12px;
line-height: 18px;
margin-right: 30px;
}
.nav_tab{
height: 40px;
background: #204077;
}
.nav_item{
color: #D4D4D4;
overflow: hidden;
font-size: 14px;
position: relative;
width: 130px;
padding-left: 8px;
cursor: pointer;
}
.nav_active{
background: #E8E9EE;
color: #43478e;
font-weight: bold;
}
.main_left{
width: 10%;
background: #E8E9EE;
}
.main_right{
width: 90%;
position: relative;
}
.crumbs{
background: #E8E9EE;
width: 100%;
z-index: 1;
overflow: hidden;
height: 21px;
}
.crumbs_list{
border: 1px solid #fff;
margin-right: 15px;
}
.orderCtg_txt{
}
.orderCtg_txt p{
font-size: 14px;
line-height: 20px;
color: #3A3A3A;
padding-left: 20px;
margin-bottom: 4px;
cursor: pointer;
}
.orderCtg_txt .orderCtg_list_now{
color: #C01E00;
position: relative;
min-height: ;
}
.content{
width: 100%;
box-sizing: border-box;
border-top: 1px solid #000;
border-left: 1px solid #000;
position: absolute;
top: 21px;
bottom: 0px;
right: 0px;
}
</style>
<template>
<section class="container">
<img src="../assets/img/logo.png" alt="Nuxt.js Logo" />
<h1 class="title">
{{ error.statusCode }}
</h1>
<h2 class="info">
{{ error.message }}
</h2>
<nuxt-link class="button" to="/" v-if="error.statusCode === 404">
Homepage
</nuxt-link>
</section>
</template>
<script>
export default {
props: ['error']
}
</script>
<style scoped>
.title
{
margin-top: 15px;
font-size: 5em;
}
.info
{
font-weight: 300;
color: #9aabb1;
margin: 0;
}
.button
{
margin-top: 50px;
}
</style>
export default function ({store, redirect}) {
console.log('aut userId' + store.state.auth)
if (store.state.auth === undefined || store.state.auth === null || Object.keys(store.state.auth).length === 0 || store.state.auth.userId === 0) {
redirect('/login/login')
}
}
export default function ({store, redirect}) {
}
export default function ({ route, redirect, store }) {
console.log('route.fullPath == ' + route.fullPath)
if (route.fullPath === '/login') {
store.state.loginPath = store.state.forePath
}
store.state.forePath = route.fullPath
}
var merge = require('webpack-merge')
var baseConfig = require('./nuxt.config.js')
module.exports = merge(baseConfig, {
proxy: {
'/xhr/': 'http://www.yang800.com/backend',
'/order': 'http://www.yang800.com/backend'
}
})
var merge = require('webpack-merge')
var baseConfig = require('./nuxt.config.js')
module.exports = merge(baseConfig, {
proxy: {
'/xhr/': 'http://www.yang800.com/backend',
'/order': 'http://www.yang800.com/backend'
}
})
var merge = require('webpack-merge')
var baseConfig = require('./nuxt.config.js')
module.exports = merge(baseConfig, {
proxy: {
'/xhr/': 'http://yang-web.test:8080',
'/order': 'http://yang-web.test:8080'
}
})
var path = require('path')
module.exports = {
/*
** Headers of the page
*/
head: {
title: '洋800',
meta: [
{ charset: 'utf-8' },
{ name: 'viewport', content: 'width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' },
{ hid: 'description', name: 'description', content: '洋800是一家专注于跨境电商保税仓的服务商,职责是做您的"正品保税仓",您只需负责挑选进口商品和分享全球好货,我拥有强大的商品、物流团队,让您安心做海外代购专家。洋800拥有各种高品质的进口商品和品牌方,多年来为各大平台提供优质的跨境保税服务,让洋800可以更从容的为您服务,为您带来全新的跨境电商体验,让您瞬间成为国际买手达人。洋800,专业的国际买手服务商。' }
],
link: [
{ rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
],
script:[{ innerHTML: 'var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id=\'cnzz_stat_icon_1273890888\'%3E%3C/span%3E%3Cscript src=\'" + cnzz_protocol + "s19.cnzz.com/z_stat.php%3Fid%3D1273890888%26show%3Dpic\' type=\'text/javascript\'%3E%3C/script%3E"))', type: 'text/javascript', charset: 'utf-8'},
{innerHTML: 'document.write(unescape("%3Cscript src=\'https://hm.baidu.com/hm.js?15740c19dd8c24913adccb501a340e74\' type=\'text/javascript\'%3E%3C/script%3E"))', type: 'text/javascript', charset: 'utf-8'},
{innerHTML: 'document.write(unescape("%3Cscript src=\'https://qiyukf.com/script/d0783d6d8af7d0426096a6c18ffc223e.js\' type=\'text/javascript\'%3E%3C/script%3E"))', type: 'text/javascript', charset: 'utf-8'}],
__dangerouslyDisableSanitizers: ['script']
},
/*
** Global CSS
*/
css: [
'~assets/css/main.css',
'element-ui/lib/theme-chalk/index.css'
// 'vant/lib/vant-css/index.css'
],
/*
** Customize the progress-bar color
*/
loading: {
color: '#3B8070',
duration: 10
},
transition: {
name: 'page',
mode: 'out-in',
duration: 10
},
modules:[
'@nuxtjs/axios'
],
axios: {
proxy: true, // Can be also an object with default options
withCredentials: true
},
plugins: [
// {src: '@/plugins/element-ui'},
{src: '@/plugins/filters'},
{src: '@/plugins/axios'}
],
/*
** Build configuration
*/
build: {
/*
** Run ESLINT on save
*/
extend (config, ctx) {
if (ctx.isClient) {
config.node = {
setImmediate: false,
dgram: 'empty',
fs: 'empty',
net: 'empty',
tls: 'empty',
cluster: 'empty',
child_process: 'empty'
}
config.module.rules.push({
enforce: 'pre',
test: /\.(js|vue)$/,
loader: 'eslint-loader',
exclude: [/(node_modules)/, /(log.js)/, /(vue-page.js)/]
})
}
}
},
router: {
middleware: 'authenticated',
middleware: 'notAuthenticated',
middleware: 'stats'
}
}
{
"name": "admin-yweb",
"version": "1.1.0",
"description": "This is the admin project for yweb",
"author": "YoMon <xumengzhu@edanding.com>",
"private": true,
"scripts": {
"dev": "backpack dev",
"build": "nuxt build && backpack build",
"start": "cross-env NODE_ENV=production node build/main.js",
"precommit": "npm run lint",
"lint": "eslint --ext .js,.vue --ignore-path .gitignore ."
},
"dependencies": {
"@nuxtjs/axios": "5.3.1",
"cross-env": "^5.0.1",
"element-ui": "^2.4.6",
"ioredis": "^4.0.0",
"jsonwebtoken": "^8.3.0",
"koa": "^2.4.1",
"koa-router": "^7.4.0",
"koa-send": "^5.0.0",
"nuxt": "latest",
"source-map-support": "^0.4.15",
"webpack-merge": "^4.1.4"
},
"devDependencies": {
"babel-eslint": "^7.1.1",
"backpack-core": "^0.3.0",
"eslint": "^3.13.1",
"eslint-loader": "^1.9.0",
"eslint-config-standard": "^10.2.1",
"eslint-plugin-html": "^2.0.3",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-node": "^4.2.2",
"eslint-plugin-promise": "^3.4.0",
"eslint-plugin-standard": "^3.0.1",
"nodemon": "^1.11.0",
"scmp": "^2.0.0"
}
}
<template>
<section class="container">
<img src="../assets/img/logo.png" alt="Nuxt.js Logo" class="logo" />
<h1 class="title">
This page is loaded from the {{ name }}
</h1>
<h2 class="info" v-if="name === 'client'">
Please refresh the page
</h2>
<nuxt-link class="button" to="/">
Home page
</nuxt-link>
</section>
</template>
<script>
export default {
asyncData({ req }) {
return {
name: req ? 'server' : 'client'
}
},
head() {
return {
title: `About Page (${this.name}-side)`
}
}
}
</script>
<style scoped>
.title
{
margin-top: 50px;
}
.info
{
font-weight: 300;
color: #9aabb1;
margin: 0;
margin-top: 10px;
}
.button
{
margin-top: 50px;
}
</style>
<template>
<div>
message
</div>
</template>
<script>
export default {
}
</script>
<style scoped>
</style>
<template>
<div>
security
</div>
</template>
<script>
export default {
}
</script>
<style scoped>
</style>
<template>
<div>
finance-detail
</div>
</template>
<script>
export default {
}
</script>
<style scoped>
</style>
<template>
<div>
platform
</div>
</template>
<script>
export default {
}
</script>
<style scoped>
</style>
<template>
<div>
purchase
</div>
</template>
<script>
export default {
}
</script>
<style scoped>
</style>
<template>
<div>
supply
</div>
</template>
<script>
export default {
}
</script>
<style scoped>
</style>
<template>
<section class="container">
<img src="../assets/img/logo.png" alt="Nuxt.js Logo" class="logo" />
<h1 class="title">
Universal Vue.js Application Framework
</h1>
<nuxt-link class="button" to="/about">
About page
</nuxt-link>
</section>
</template>
<style scoped>
.title
{
margin: 50px 0;
}
</style>
<template>
<div>
order-important
</div>
</template>
<script>
export default {
}
</script>
<style scoped>
</style>
<template>
<div>
order-unpaid
</div>
</template>
<script>
export default {
}
</script>
<style scoped>
</style>
<template>
<div>
order
</div>
</template>
<script>
export default {
}
</script>
<style scoped>
</style>
export default function ({ $axios, req, redirect }) {
$axios.onRequest(config => {
// console.log('tongyong request')
if (req) {
config.headers['y-token'] = req.token
}
})
$axios.onResponse(response => {
if (response) {
// console.log('通用respons插件入口打印')
// if (response.data.errorCode === 401) {
// // 表示没登录,需要登录,,跳转到登录页面
// }
}
})
$axios.onError(error => {
const code = parseInt(error.response && error.response.status)
if (code === 400) {
redirect('/400')
}
})
}
import Vue from 'vue'
import Element from 'element-ui'
export default () => {
Vue.use(Element)
}
import Vue from 'vue'
Date.prototype.format = function (format) { // eslint-disable-line no-extend-native
// console.log('start format ====' + typeof this)
var date = {
'M+': this.getMonth() + 1,
'd+': this.getDate(),
'h+': this.getHours(),
'm+': this.getMinutes(),
's+': this.getSeconds(),
'q+': Math.floor((this.getMonth() + 3) / 3)
}
if (/(y+)/i.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length))
}
for (var k in date) {
if (new RegExp('(' + k + ')').test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length === 1 ? date[k] : ('00' + date[k]).substr(('' + date[k]).length))
}
}
return format
}
export function ymdsTrim(timestamp3) {
if (timestamp3 === 0 || timestamp3 === undefined) {
return ''
}
var newDate = new Date()
newDate.setTime(timestamp3 * 1000)
return newDate.format('yyyy-MM-dd hh:mm:ss')
}
export function ymdTrim(timestamp3) {
if (timestamp3 === 0 || timestamp3 === undefined) {
return ''
}
var newDate = new Date()
newDate.setTime(timestamp3 * 1000)
return newDate.format('yyyy-MM-dd')
}
export function ymTrim(timestamp3) {
if (timestamp3 === 0 || timestamp3 === undefined) {
return ''
}
var newDate = new Date()
newDate.setTime(timestamp3 * 1000)
return newDate.format('yyyy-MM')
}
const filters = {
ymdsTrim, ymdTrim, ymTrim
}
export default filters
Object.keys(filters).forEach(key => {
Vue.filter(key, filters[key])
})
import Koa from 'koa'
import Router from 'koa-router'
import { Nuxt, Builder } from 'nuxt'
import Log from '../assets/js/log.js'
import qs from 'qs'
import requestApi from '../assets/js/requestApi.js'
// const send = require('koa-send')
const fs = require('fs')
var path = require('path')
let logpath = requestApi.server_getConfig('logpath')
var filep = path.join(logpath, 'wlog.log')
console.log(filep)
const stream = fs.createWriteStream(filep, { flags: 'a', defaultEncoding: 'utf8' })
const log = new Log('debug', stream)
const session = require('../session')
const RedisStore = require('../session/RedisStore')
async function start () {
const app = new Koa()
const router = new Router()
// 要区分是线上环境还是开发环境,端口号还有redis都不同
let config = {}
let env = process.env.WD_ENV
let redis = requestApi.server_getConfig('redis')
console.log('get redis info ===' + redis.host + '=====' + redis.pwd + '=====' + redis.port)
let port = process.env.PORT || 3000
log.info('use ' + env + ' configuration')
app.use(session({
store: new RedisStore(redis.host, redis.port, redis.pwd)
}))
if (env === 'production') {
config = require('../nuxt.config-prod.js')
port = process.env.PORT || 8080
config.dev = false
} else if (env === 'test') {
config = require('../nuxt.config-test.js')
port = process.env.PORT || 8080
config.dev = false
} else {
console.log('dev--------')
config = require('../nuxt.config-dev.js')
console.log('config dev --- ====' + config)
config.dev = true
}
console.log('33333')
// Instantiate nuxt.js
const nuxt = new Nuxt(config)
// 生产模式不需要 build
if (config.dev) {
console.log('4444')
const builder = new Builder(nuxt)
await builder.build()
console.log('55555')
}
/* 
router.get('/excel/download', async function(ctx) {
var fileName = ctx.originalUrl
var ls = fileName.split('?name=')
console.dir(ls)
var file = ls[1]
var currFile = path.join('static/file/',file)
console.log('file name === ' + currFile)
// const path = `upload/${name}'
ctx.attachment(currFile)
  await send(ctx, currFile)
})
*/
console.log('2222')
app
.use(router.routes())
.use(router.allowedMethods())
app.use(async (ctx, next) => {
await next()
ctx.status = 200 // koa defaults to 404 when it sees that status is unset
return new Promise((resolve, reject) => {
ctx.res.on('close', resolve)
ctx.res.on('finish', resolve)
log.debug('ctx.request == ' + ctx.req.url + ', ctx.statuscode === ' + ctx.res.statusCode)
nuxt.render(ctx.req, ctx.res, promise => {
// nuxt.render passes a rejected promise into callback on error.
promise.then(resolve).catch(reject)
})
})
})
console.log('111111')
app.listen(port)
console.log('Server listening on '+ ':' + port) // eslint-disable-line no-console
}
start()
const Redis = require('ioredis')
const { randomBytes } = require('crypto')
class RedisStore {
constructor(host, port, pass) {
if(pass ==undefined || pass == '') {
this.redis = new Redis({
host: host,
port: port
})
}
else {
this.redis = new Redis( {
host: host,
port: port,
password: pass
})
}
}
getID(length) {
return randomBytes(length).toString('hex');
}
async get(sid, ctx) {
let data = await this.redis.get(`YSESSION:${sid}`)
return JSON.parse(data)
}
async set(session, { sid = this.getID(24), maxAge= 1000000} = {} , ctx) {
try {
await this.redis.set(`YSESSION:${sid}`, JSON.stringify(session), 'EX', maxAge/1000)
}catch(e) {
}
return sid;
}
async destroy(sid, ctx) {
return await this.redis.del(`YSESSION:${sid}`)
}
}
module.exports = RedisStore
\ No newline at end of file
// id值一旦前台生成,发送给后台,前后台都不会改变这个值,只有前台清除了cookie,会再重新生成,token的刷新还有过期都是用jwt做验证的
const jwt = require('jsonwebtoken')
import Log from '../assets/js/log.js'
import requestApi from '../assets/js/requestApi.js'
const fs = require('fs')
var path = require('path')
let logpath = requestApi.server_getConfig('logpath')
var filep = path.join(logpath, 'session.log')
console.log(filep)
const stream = fs.createWriteStream(filep, { flags: 'a', defaultEncoding: 'utf8' })
const log = new Log('debug', stream)
module.exports = (opts = {}) => {
let env = process.env.WD_ENV
// log.info('session env === ' + env)
let redis = requestApi.server_getConfig('redis')
const { key = "y-token", store = new RedisStore(redis.host, redis.port, redis.pwd) } = opts
return async (ctx, next) => {
let token = ctx.cookies.get(key, opts);
// log.info(ctx.req.url + ' ======token value ==== ' + token)
let id = undefined
let isExpire = false //已过期
let isRefresh = false //需要刷新
let isCreate = false
let sec = 'dd^$token2018'
//如果token存在
if(token) {
try{
let content = jwt.verify(token, sec)
if(content) {
id = content.key
if (ctx.url.indexOf('/xhr') !== -1) {
log.info(ctx.url + '-----------get token key ' + id)
}
if(content.exp) {
if(content.exp < Date.now()/1000) {
isExpire = true
}
else if(content.exp > (content.exp + Date.now()/1000)/2) {
isRefresh = true
}
}
}
}
catch(err) {
ctx.throw(401, 'invalid token')
// log.info('invalid token key ' + id)
}
}
if(!id) {
if (ctx.url.indexOf('/xhr') !== -1) {
log.info(ctx.url + '-----------need create token key ')
}
isCreate = true
ctx.session = {}
}
else {
ctx.session = await store.get(id, ctx)
// console.log('judg type == ' + typeof ctx.session + 'ctx.session === ' + ctx.session + 'keys.lenght === ' + Object.keys(ctx.session).length)
if((typeof ctx.session !== "object" && typeof ctx.session !== 'string') || ctx.session == null || Object.keys(ctx.session).length === 0 ) {
ctx.session = {}
if (ctx.url.indexOf('/xhr') !== -1) {
log.info(ctx.url + '-----------token key1 ' + id)
}
store.destroy(id, ctx)
isCreate = true
// log.info('session has no value ')
}else{
// log.info(ctx.url + '-------session has value-----' + JSON.stringify(ctx.session))
ctx.req.session = ctx.session // for nuxtServerInit
ctx.req.token = token
// store.state.auth = ctx.session
}
}
if(Object.keys(ctx.session).length && ctx.session.nextToken) { //其它请求已经刷新过token了
// console.log('session has been freshed')
token = ctx.session.nextToken
ctx.cookies.set(key, ctx.session.nextToken, opts)
}
else {
if(isCreate || isRefresh || isExpire) {
log.info('session need create ' + isCreate + ',need fresh ' + isRefresh + ', isExpire ' + isExpire)
let expTime = Date.now()/1000 + 7 * 24 * 3600
ctx.session = {userId: 0, userName: '', type: 0}
const sid = await store.set(ctx.session, Object.assign({}, opts, {sid:undefined, exp: expTime}), ctx)
console.log('sid:' + sid)
if(isRefresh) {
ctx.session.nextToken = sid
await store.set(ctx.session, Object.assign({}, opts, {sid:id, maxAge:2800000}), ctx) //原来的key设置为8小时后过期
ctx.session.nextToken = undefined
}
token = jwt.sign({'key':sid, expiresIn: '8h', notBefore:-3600000}, sec)
// log.info('new token value' + token)
ctx.cookies.set(key, token, opts)
}
}
ctx.req.session = ctx.session // for nuxtServerInit
ctx.req.token = token
await next()
ctx.req.token = null
ctx.req.session = null
}
}
const getters = {
sVisitedViews: state => state.systemTags.sVisitedViews,
sCachedViews: state => state.systemTags.sCachedViews,
gVisitedViews: state => state.goodsTags.gVisitedViews,
gCachedViews: state => state.goodsTags.gCachedViews,
oVisitedViews: state => state.goodsTags.oVisitedViews,
oCachedViews: state => state.goodsTags.oCachedViews,
fVisitedViews: state => state.financalTags.fVisitedViews,
fCachedViews: state => state.financalTags.fCachedViews
}
export default getters
import Vue from 'vue'
import Vuex from 'vuex'
import systemTags from './modules/system-tags'
import usrAuth from './modules/usr-auth'
import goodsTags from './modules/goods-tags'
import orderTags from './modules/order-manage-tags'
import financalTags from './modules/financal-tags'
import getters from './getters'
Vue.use(Vuex)
const store = () => {
console.log('creating the store')
return new Vuex.Store({
modules: {
usrAuth,
systemTags,
goodsTags,
orderTags,
financalTags
},
getters
})
}
export default store
const financalTags = {
state: {
fVisitedViews: [],
fCachedViews: []
},
mutations: {
F_ADD_VISITED_VIEWS: (state, view) => {
if (state.fVisitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.fVisitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.fCachedViews.push(view.name)
}
},
F_DEL_VISITED_VIEWS: (state, view) => {
for (const [i, v] of state.fVisitedViews.entries()) {
if (v.path === view.path) {
state.fVisitedViews.splice(i, 1)
break
}
}
for (const i of state.fCachedViews) {
if (i === view.name) {
const index = state.fCachedViews.indexOf(i)
state.fCachedViews.splice(index, 1)
break
}
}
},
F_DEL_OTHERS_VIEWS: (state, view) => {
for (const [i, v] of state.fVisitedViews.entries()) {
if (v.path === view.path) {
state.fVisitedViews = state.fVisitedViews.slice(i, i + 1)
break
}
}
for (const i of state.fCachedViews) {
if (i === view.name) {
const index = state.fCachedViews.indexOf(i)
state.fCachedViews = state.fCachedViews.slice(index, index + 1)
break
}
}
},
F_DEL_ALL_VIEWS: state => {
state.sVisitedViews = []
state.fCachedViews = []
}
},
actions: {
fAddVisitedViews({ commit }, view) {
commit('F_ADD_VISITED_VIEWS', view)
},
fDelVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('F_DEL_VISITED_VIEWS', view)
resolve([...state.fVisitedViews])
})
},
fDelOthersViews({ commit, state }, view) {
return new Promise(resolve => {
commit('F_DEL_OTHERS_VIEWS', view)
resolve([...state.fVisitedViews])
})
},
fDelAllViews({ commit, state }) {
return new Promise(resolve => {
commit('F_DEL_ALL_VIEWS')
resolve([...state.fVisitedViews])
})
}
}
}
export default financalTags
const goodsTags = {
state: {
gVisitedViews: [],
gCachedViews: []
},
mutations: {
G_ADD_VISITED_VIEWS: (state, view) => {
if (state.gVisitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.gVisitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.gCachedViews.push(view.name)
}
},
G_DEL_VISITED_VIEWS: (state, view) => {
for (const [i, v] of state.gVisitedViews.entries()) {
if (v.path === view.path) {
state.gVisitedViews.splice(i, 1)
break
}
}
for (const i of state.gCachedViews) {
if (i === view.name) {
const index = state.gCachedViews.indexOf(i)
state.gCachedViews.splice(index, 1)
break
}
}
},
G_DEL_OTHERS_VIEWS: (state, view) => {
for (const [i, v] of state.gVisitedViews.entries()) {
if (v.path === view.path) {
state.gVisitedViews = state.gVisitedViews.slice(i, i + 1)
break
}
}
for (const i of state.gCachedViews) {
if (i === view.name) {
const index = state.gCachedViews.indexOf(i)
state.gCachedViews = state.gCachedViews.slice(index, index + 1)
break
}
}
},
G_DEL_ALL_VIEWS: state => {
state.gVisitedViews = []
state.gCachedViews = []
}
},
actions: {
gaddVisitedViews({ commit }, view) {
commit('G_ADD_VISITED_VIEWS', view)
},
gdelVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('G_DEL_VISITED_VIEWS', view)
resolve([...state.gVisitedViews])
})
},
gdelOthersViews({ commit, state }, view) {
return new Promise(resolve => {
commit('G_DEL_OTHERS_VIEWS', view)
resolve([...state.gVisitedViews])
})
},
gdelAllViews({ commit, state }) {
return new Promise(resolve => {
commit('G_DEL_ALL_VIEWS')
resolve([...state.gVisitedViews])
})
}
}
}
export default goodsTags
const orderTags = {
state: {
oVisitedViews: [],
oCachedViews: []
},
mutations: {
O_ADD_VISITED_VIEWS: (state, view) => {
if (state.oVisitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.oVisitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.oCachedViews.push(view.name)
}
},
O_DEL_VISITED_VIEWS: (state, view) => {
for (const [i, v] of state.oVisitedViews.entries()) {
if (v.path === view.path) {
state.oVisitedViews.splice(i, 1)
break
}
}
for (const i of state.oCachedViews) {
if (i === view.name) {
const index = state.oCachedViews.indexOf(i)
state.oCachedViews.splice(index, 1)
break
}
}
},
O_DEL_OTHERS_VIEWS: (state, view) => {
for (const [i, v] of state.oVisitedViews.entries()) {
if (v.path === view.path) {
state.oVisitedViews = state.oVisitedViews.slice(i, i + 1)
break
}
}
for (const i of state.oCachedViews) {
if (i === view.name) {
const index = state.oCachedViews.indexOf(i)
state.oCachedViews = state.oCachedViews.slice(index, index + 1)
break
}
}
},
O_DEL_ALL_VIEWS: state => {
state.oVisitedViews = []
state.oCachedViews = []
}
},
actions: {
oAddVisitedViews({ commit }, view) {
commit('O_ADD_VISITED_VIEWS', view)
},
oDelVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('O_DEL_VISITED_VIEWS', view)
resolve([...state.visitedViews])
})
},
oDelOthersViews({ commit, state }, view) {
return new Promise(resolve => {
commit('O_DEL_OTHERS_VIEWS', view)
resolve([...state.oVisitedViews])
})
},
oDelAllViews({ commit, state }) {
return new Promise(resolve => {
commit('O_DEL_ALL_VIEWS')
resolve([...state.oVisitedViews])
})
}
}
}
export default orderTags
\ No newline at end of file
const systemTags = {
state: {
sVisitedViews: [],
sCachedViews: []
},
mutations: {
S_ADD_VISITED_VIEWS: (state, view) => {
if (state.sVisitedViews.some(v => v.path === view.path)) return
if (view.path === '/') return
state.sVisitedViews.push(
Object.assign({}, view, {
title: view.meta.title || 'no-name'
})
)
if (!view.meta.noCache) {
state.sCachedViews.push(view.name)
}
},
S_DEL_VISITED_VIEWS: (state, view) => {
for (const [i, v] of state.sVisitedViews.entries()) {
if (v.path === view.path) {
state.sVisitedViews.splice(i, 1)
break
}
}
for (const i of state.sCachedViews) {
if (i === view.name) {
const index = state.sCachedViews.indexOf(i)
state.sCachedViews.splice(index, 1)
break
}
}
},
S_DEL_OTHERS_VIEWS: (state, view) => {
for (const [i, v] of state.sVisitedViews.entries()) {
if (v.path === view.path) {
state.sVisitedViews = state.sVisitedViews.slice(i, i + 1)
break
}
}
for (const i of state.sCachedViews) {
if (i === view.name) {
const index = state.sCachedViews.indexOf(i)
state.sCachedViews = state.sCachedViews.slice(index, index + 1)
break
}
}
},
S_DEL_ALL_VIEWS: state => {
state.sVisitedViews = []
state.sCachedViews = []
}
},
actions: {
sAddVisitedViews({ commit }, view) {
commit('S_ADD_VISITED_VIEWS', view)
},
sDelVisitedViews({ commit, state }, view) {
return new Promise(resolve => {
commit('S_DEL_VISITED_VIEWS', view)
resolve([...state.sVisitedViews])
})
},
sDelOthersViews({ commit, state }, view) {
return new Promise(resolve => {
commit('S_DEL_OTHERS_VIEWS', view)
resolve([...state.sVisitedViews])
})
},
sDelAllViews({ commit, state }) {
return new Promise(resolve => {
commit('S_DEL_ALL_VIEWS')
resolve([...state.sVisitedViews])
})
}
}
}
export default systemTags
const usrAuth = {
state: {
auth: null,
forePath: '',
loginPath: '',
isAuth: 'false',
keyword: ''
},
mutations: {
identyAuth(state, authInfo) {
state.auth = authInfo
if (authInfo === undefined || authInfo === null || Object.keys(authInfo).length === 0 || authInfo.userId < 1) {
state.isAuth = false
console.log('isAuth === false')
} else {
state.isAuth = true
console.log('isAuth === true')
}
},
cancelAuth(state) {
state.auth = {userId: 0, userName: ''}
},
storeKeyword(state, skeyword) {
state.keyword = skeyword
}
},
actions: {
identyAuth: ({ commit }) => commit('identyAuth'),
cancelAuth: ({ commit }) => commit('cancelAuth'),
storeKeyword: ({ commit }) => commit('storeKeyword'),
nuxtServerInit({commit}, {req}) {
console.log('页面重载')
let accessToken = null
console.log('cookie1111:' + JSON.stringify(req.session) + 'userId==' + typeof req.session)
let session = req.session
if (typeof req.session === 'string') {
session = JSON.parse(req.session)
}
if (session && session.userId !== undefined && session.userId !== null && session.userId > 0) {
console.log('enter this store')
var parsed = session
accessToken = parsed
}
console.log('cookie:' + accessToken)
commit('identyAuth', accessToken)
console.log('state:' + JSON.stringify(this.state))
}
}
}
export default usrAuth
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