newsee-cli 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +36 -36
- package/README.md +36 -36
- package/bin/init.js +1 -1
- package/micro_11111/.editorconfig +10 -0
- package/micro_11111/.eslintignore +9 -0
- package/micro_11111/.eslintrc.js +33 -0
- package/micro_11111/.postcssrc.js +21 -0
- package/micro_11111/.prettierignore +10 -0
- package/micro_11111/.prettierrc +12 -0
- package/micro_11111/.stylelintignore +8 -0
- package/micro_11111/.stylelintrc.json +303 -0
- package/micro_11111/README.md +3 -0
- package/micro_11111/babel.config.js +34 -0
- package/micro_11111/env.config.js +62 -0
- package/micro_11111/env.param.config.js +112 -0
- package/micro_11111/favicon.ico +0 -0
- package/micro_11111/index.html +28 -0
- package/micro_11111/jsconfig.json +25 -0
- package/micro_11111/package.json +60 -0
- package/micro_11111/src/App.vue +32 -0
- package/micro_11111/src/Layout/Layout.vue +28 -0
- package/micro_11111/src/UI/index.js +1 -0
- package/micro_11111/src/assets/iconfont/DIN.Alternate.Bold.ttf +0 -0
- package/micro_11111/src/assets/layout/empty.png +0 -0
- package/micro_11111/src/assets/layout/prelogin-header.png +0 -0
- package/micro_11111/src/assets/trigger/close.png +0 -0
- package/micro_11111/src/assets/trigger/company.png +0 -0
- package/micro_11111/src/assets/trigger/department.png +0 -0
- package/micro_11111/src/assets/trigger/left-arrow.png +0 -0
- package/micro_11111/src/assets/trigger/pwd.png +0 -0
- package/micro_11111/src/assets/trigger/right-arrow-gray.png +0 -0
- package/micro_11111/src/assets/trigger/search-gray.png +0 -0
- package/micro_11111/src/assets/trigger/user.png +0 -0
- package/micro_11111/src/assets/trigger/weixin-work.png +0 -0
- package/micro_11111/src/components/Selector/Selector.vue +254 -0
- package/micro_11111/src/components/Selector/components/abyss.vue +308 -0
- package/micro_11111/src/components/Selector/components/search.vue +307 -0
- package/micro_11111/src/config.js +20 -0
- package/micro_11111/src/main.js +14 -0
- package/micro_11111/src/mixins/base.js +57 -0
- package/micro_11111/src/mixins/extension/app.js +80 -0
- package/micro_11111/src/mixins/extension/cryptoPassWord.js +15 -0
- package/micro_11111/src/mixins/extension/wx-relative.js +42 -0
- package/micro_11111/src/mixins/index.js +5 -0
- package/micro_11111/src/router/index.js +12 -0
- package/micro_11111/src/router/routes.js +55 -0
- package/micro_11111/src/service/common.js +72 -0
- package/micro_11111/src/service/preload.js +19 -0
- package/micro_11111/src/service/selector.js +114 -0
- package/micro_11111/src/store/getters.js +10 -0
- package/micro_11111/src/store/index.js +18 -0
- package/micro_11111/src/store/modules/Account.js +27 -0
- package/micro_11111/src/store/modules/Base.js +38 -0
- package/micro_11111/src/style/index.scss +3 -0
- package/micro_11111/src/style/mixins/mixins.scss +11 -0
- package/micro_11111/src/style/public.scss +32 -0
- package/micro_11111/src/style/reset.scss +814 -0
- package/micro_11111/src/utils/core/create-basic.js +16 -0
- package/micro_11111/src/utils/core/create.js +13 -0
- package/micro_11111/src/utils/core/reprefix.js +8 -0
- package/micro_11111/src/utils/fetch/fetch.js +66 -0
- package/micro_11111/src/utils/fetch/fetchDataType.js +53 -0
- package/micro_11111/src/utils/index.js +0 -0
- package/micro_11111/src/utils/library/aes.js +834 -0
- package/micro_11111/src/utils/library/crypto.js +130 -0
- package/micro_11111/src/utils/library/date.js +62 -0
- package/micro_11111/src/utils/library/debounce.js +34 -0
- package/micro_11111/src/utils/library/event.js +45 -0
- package/micro_11111/src/utils/library/image.js +14 -0
- package/micro_11111/src/utils/library/stringcover.js +9 -0
- package/micro_11111/src/utils/library/urlhandle.js +14 -0
- package/micro_11111/src/utils/library/video.js +156 -0
- package/micro_11111/src/views/Home/Home.vue +23 -0
- package/micro_11111/src/views/Login/Login.vue +65 -0
- package/micro_11111/src/views/Login/LoginApp.vue +72 -0
- package/micro_11111/src/views/Login/LoginThirdApp.vue +77 -0
- package/micro_11111/src/views/Login/LoginThirdParty.vue +59 -0
- package/micro_11111/src/views/Prelogin/index.vue +199 -0
- package/micro_11111/static/loadBuffer/loadBuffer.js +19 -0
- package/micro_11111/static/loadBuffer/loading.gif +0 -0
- package/micro_11111/tag.js +19 -0
- package/package.json +46 -46
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import Cookies from 'js-cookie';
|
|
2
|
+
import CryptoJS from 'crypto-js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* setCrypto
|
|
6
|
+
* @param val
|
|
7
|
+
* @param key crypto-password
|
|
8
|
+
* @returns {*}
|
|
9
|
+
*/
|
|
10
|
+
export const setCrypto = (val, key) => {
|
|
11
|
+
if (!CryptoJS) {
|
|
12
|
+
throw 'CryptoJS is undefined, you need to load it';
|
|
13
|
+
}
|
|
14
|
+
if (typeof val === 'string' && typeof key === 'string') {
|
|
15
|
+
return CryptoJS.AES.encrypt(val, key);
|
|
16
|
+
} else {
|
|
17
|
+
throw 'The data format of encrypted content and key should be string,find it.';
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* deCrypto
|
|
23
|
+
* @param val
|
|
24
|
+
* @param key crypto-password
|
|
25
|
+
* @returns {string}
|
|
26
|
+
*/
|
|
27
|
+
export const deCrypto = (val, key) => {
|
|
28
|
+
if (!CryptoJS) {
|
|
29
|
+
throw 'CryptoJS is undefined, you need to load it';
|
|
30
|
+
}
|
|
31
|
+
if (typeof key === 'string') {
|
|
32
|
+
return CryptoJS.AES.decrypt(val, key).toString(CryptoJS.enc.Utf8);
|
|
33
|
+
} else {
|
|
34
|
+
throw 'The decrypt-key should be string,find it.';
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Crypto and set into Cookie
|
|
40
|
+
* @param name stroe name
|
|
41
|
+
* @param val stroe value
|
|
42
|
+
* @param key stroe password
|
|
43
|
+
* @param time stroe time
|
|
44
|
+
*/
|
|
45
|
+
export const cryptoCookie = (name, val, key, time) => {
|
|
46
|
+
//get crypto password
|
|
47
|
+
const mi = setCrypto(JSON.stringify(val), key);
|
|
48
|
+
time ? Cookies.set(name, mi, time) : Cookies.set(name, mi);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* deCrypto
|
|
53
|
+
* @param cookieName
|
|
54
|
+
* @param cookieKey passwoed
|
|
55
|
+
* @returns {{}}
|
|
56
|
+
*/
|
|
57
|
+
export const deCryptoCookie = (cookieName, cookieKey) => {
|
|
58
|
+
return Cookies.get(cookieName)
|
|
59
|
+
? JSON.parse(
|
|
60
|
+
CryptoJS.AES.decrypt(Cookies.get(cookieName), cookieKey).toString(CryptoJS.enc.Utf8)
|
|
61
|
+
)
|
|
62
|
+
: {};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* encrypt by Base64
|
|
67
|
+
* @param val
|
|
68
|
+
* @param key
|
|
69
|
+
* @returns {string}
|
|
70
|
+
*/
|
|
71
|
+
export const encryptBase64 = (val, key) => {
|
|
72
|
+
if (!CryptoJS) {
|
|
73
|
+
throw 'CryptoJS is undefined, you need to load it';
|
|
74
|
+
}
|
|
75
|
+
if (typeof val === 'string' && typeof key === 'string') {
|
|
76
|
+
if (key) {
|
|
77
|
+
var keyStr = CryptoJS.enc.Utf8.parse(key);
|
|
78
|
+
var iv = CryptoJS.enc.Utf8.parse(key);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let srcs = CryptoJS.enc.Utf8.parse(val);
|
|
82
|
+
|
|
83
|
+
const encrypted = CryptoJS.AES.encrypt(srcs, keyStr, {
|
|
84
|
+
iv: iv,
|
|
85
|
+
mode: CryptoJS.mode.CBC,
|
|
86
|
+
padding: CryptoJS.pad.ZeroPadding,
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const res = CryptoJS.enc.Base64.stringify(encrypted.ciphertext);
|
|
90
|
+
|
|
91
|
+
// console.log(res);
|
|
92
|
+
// console.log(encodeURIComponent(res));
|
|
93
|
+
// console.log('%2Fz1XaCurZ4jawo8D51dO%2BQ==')
|
|
94
|
+
|
|
95
|
+
return res;
|
|
96
|
+
} else {
|
|
97
|
+
throw 'The data format of encrypted content and key should be string,find it.';
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* deCrypto by Base64
|
|
103
|
+
* @param val
|
|
104
|
+
* @param key crypto-password
|
|
105
|
+
* @returns {string}
|
|
106
|
+
*/
|
|
107
|
+
export const deCryptoBase64 = (val, key) => {
|
|
108
|
+
if (!CryptoJS) {
|
|
109
|
+
throw 'CryptoJS is undefined, you need to load it';
|
|
110
|
+
}
|
|
111
|
+
if (typeof key === 'string') {
|
|
112
|
+
if (key) {
|
|
113
|
+
var keyStr = CryptoJS.enc.Utf8.parse(key);
|
|
114
|
+
var iv = CryptoJS.enc.Utf8.parse(key);
|
|
115
|
+
}
|
|
116
|
+
let base64 = CryptoJS.enc.Base64.parse(val);
|
|
117
|
+
let src = CryptoJS.enc.Base64.stringify(base64);
|
|
118
|
+
|
|
119
|
+
const decrypt = CryptoJS.AES.decrypt(src, keyStr, {
|
|
120
|
+
iv: iv,
|
|
121
|
+
mode: CryptoJS.mode.CBC,
|
|
122
|
+
padding: CryptoJS.pad.ZeroPadding,
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
const decryptedStr = decrypt.toString(CryptoJS.enc.Utf8);
|
|
126
|
+
return decryptedStr.toString();
|
|
127
|
+
} else {
|
|
128
|
+
throw 'The decrypt-key should be string,find it.';
|
|
129
|
+
}
|
|
130
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/** * 处理将 Date 转化为指定格式的String * 月(M)、日(d)、12小时(h)、24小时(H)、分(m)、秒(s)、周(E)、季度(q)
|
|
2
|
+
可以用 1-2 个占位符 * 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
|
|
3
|
+
* eg: * (patternDate(new Date(),"yyyy-MM-dd hh:mm:ss.S")==> 2006-07-02 08:09:04.423
|
|
4
|
+
* (patternDate("new Date(),yyyy-MM-dd E HH:mm:ss") ==> 2009-03-10 二 20:09:04
|
|
5
|
+
* (patternDate(new Date(),"yyyy-MM-dd EE hh:mm:ss") ==> 2009-03-10 周二 08:09:04
|
|
6
|
+
* (patternDate(new Date(),yyyy-MM-dd EEE hh:mm:ss") ==> 2009-03-10 星期二 08:09:04
|
|
7
|
+
* (patternDate(new Date(),"yyyy-M-d h:m:s.S") ==> 2006-7-2 8:9:4.18
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export function patternDate(date, fmt) {
|
|
11
|
+
var o = {
|
|
12
|
+
'M+': date.getMonth() + 1, //月份
|
|
13
|
+
'd+': date.getDate(), //日
|
|
14
|
+
'h+': date.getHours() % 12 === 0 ? 12 : date.getHours() % 12, //小时
|
|
15
|
+
'H+': date.getHours(), //小时
|
|
16
|
+
'm+': date.getMinutes(), //分
|
|
17
|
+
's+': date.getSeconds(), //秒
|
|
18
|
+
'q+': Math.floor((date.getMonth() + 3) / 3), //季度
|
|
19
|
+
S: date.getMilliseconds(), //毫秒
|
|
20
|
+
};
|
|
21
|
+
var week = {
|
|
22
|
+
'0': '/u65e5',
|
|
23
|
+
'1': '/u4e00',
|
|
24
|
+
'2': '/u4e8c',
|
|
25
|
+
'3': '/u4e09',
|
|
26
|
+
'4': '/u56db',
|
|
27
|
+
'5': '/u4e94',
|
|
28
|
+
'6': '/u516d',
|
|
29
|
+
};
|
|
30
|
+
if (/(y+)/.test(fmt)) {
|
|
31
|
+
fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
|
|
32
|
+
}
|
|
33
|
+
if (/(E+)/.test(fmt)) {
|
|
34
|
+
fmt = fmt.replace(
|
|
35
|
+
RegExp.$1,
|
|
36
|
+
(RegExp.$1.length > 1 ? (RegExp.$1.length > 2 ? '/u661f/u671f' : '/u5468') : '') +
|
|
37
|
+
week[date.getDay() + '']
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
for (var k in o) {
|
|
41
|
+
if (new RegExp('(' + k + ')').test(fmt)) {
|
|
42
|
+
fmt = fmt.replace(
|
|
43
|
+
RegExp.$1,
|
|
44
|
+
RegExp.$1.length === 1 ? o[k] : ('00' + o[k]).substr(('' + o[k]).length)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return fmt;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 获取相隔N天的具体日期
|
|
53
|
+
* @param {Number} days 天数
|
|
54
|
+
* @param {Date} startDay 开始日期
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
export function getTargetDay(days, startDay) {
|
|
58
|
+
let today = startDay || new Date();
|
|
59
|
+
let targetday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24 * days;
|
|
60
|
+
today.setTime(targetday_milliseconds);
|
|
61
|
+
return patternDate(today, 'yyyy-MM-dd');
|
|
62
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export default (func, wait, immediate) => {
|
|
2
|
+
let timeout, args, context, timestamp, result;
|
|
3
|
+
|
|
4
|
+
const later = function() {
|
|
5
|
+
// 据上一次触发时间间隔
|
|
6
|
+
const last = +new Date() - timestamp;
|
|
7
|
+
|
|
8
|
+
// 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
|
|
9
|
+
if (last < wait && last > 0) {
|
|
10
|
+
timeout = setTimeout(later, wait - last);
|
|
11
|
+
} else {
|
|
12
|
+
timeout = null;
|
|
13
|
+
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
|
14
|
+
if (!immediate) {
|
|
15
|
+
result = func.apply(context, args);
|
|
16
|
+
if (!timeout) context = args = null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
return function(...args) {
|
|
22
|
+
context = this;
|
|
23
|
+
timestamp = +new Date();
|
|
24
|
+
const callNow = immediate && !timeout;
|
|
25
|
+
// 如果延时不存在,重新设定延时
|
|
26
|
+
if (!timeout) timeout = setTimeout(later, wait);
|
|
27
|
+
if (callNow) {
|
|
28
|
+
result = func.apply(context, args);
|
|
29
|
+
context = args = null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* addEventListener(绑定Dom元素的监听事件)
|
|
3
|
+
* @param target 监听对象
|
|
4
|
+
* @param type 监听函数类型,如 click,mouseover
|
|
5
|
+
* @param func 监听函数
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const addEventHandler = (target, type, func) => {
|
|
9
|
+
if (target.addEventListener) {
|
|
10
|
+
target.addEventListener(type, func, false);
|
|
11
|
+
} else if (target.attachEvent) {
|
|
12
|
+
target.attachEvent('on' + type, func);
|
|
13
|
+
} else {
|
|
14
|
+
target['on' + type] = func;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* removeEventHandler (移除Dom元素的监听事件)
|
|
20
|
+
* target:监听对象
|
|
21
|
+
* type:监听函数类型,如click,mouseover
|
|
22
|
+
* func:监听函数
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
export const removeEventHandler = (target, type, func) => {
|
|
26
|
+
if (target.removeEventListener) {
|
|
27
|
+
target.removeEventListener(type, func, false);
|
|
28
|
+
} else if (target.detachEvent) {
|
|
29
|
+
target.detachEvent('on' + type, func);
|
|
30
|
+
} else {
|
|
31
|
+
delete target['on' + type];
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* stop propagation
|
|
37
|
+
* @param e
|
|
38
|
+
*/
|
|
39
|
+
export const stopPropagation = e => {
|
|
40
|
+
if (e && e.stopPropagation) {
|
|
41
|
+
e.stopPropagation(); //W3C stop propagation
|
|
42
|
+
} else {
|
|
43
|
+
window.event.cancelBubble = true; //IE stop propagation
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
//将base64转换为文件
|
|
2
|
+
export const dataURLtoFile = function (dataurl, filename = `${Date.now()}`) {
|
|
3
|
+
let arr = dataurl.split(','),
|
|
4
|
+
mime = arr[0].match(/:(.*?);/)[1],
|
|
5
|
+
bstr = atob(arr[1]),
|
|
6
|
+
n = bstr.length,
|
|
7
|
+
u8arr = new Uint8Array(n);
|
|
8
|
+
while (n--) {
|
|
9
|
+
u8arr[n] = bstr.charCodeAt(n);
|
|
10
|
+
}
|
|
11
|
+
return new File([u8arr], filename, {
|
|
12
|
+
type: mime,
|
|
13
|
+
});
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* get param from url
|
|
3
|
+
* @param name
|
|
4
|
+
* @returns {*}
|
|
5
|
+
*/
|
|
6
|
+
export const getUrlParam = name => {
|
|
7
|
+
const reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)');
|
|
8
|
+
const r =
|
|
9
|
+
window.location.search.substr(1).match(reg) ||
|
|
10
|
+
window.location.hash.substring(window.location.hash.search(/\?/) + 1).match(reg);
|
|
11
|
+
if (r != null) {
|
|
12
|
+
return decodeURIComponent(r[2]);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { Notify } from 'vant';
|
|
2
|
+
// 类型判断比较僵硬
|
|
3
|
+
const videoTypes = [
|
|
4
|
+
'video/mp4',
|
|
5
|
+
'video/ogg',
|
|
6
|
+
'video/flv',
|
|
7
|
+
'video/avi',
|
|
8
|
+
'video/wmv',
|
|
9
|
+
'video/rmvb',
|
|
10
|
+
'video/mov',
|
|
11
|
+
'video/quicktime',
|
|
12
|
+
];
|
|
13
|
+
const videoLimit = 20;
|
|
14
|
+
const duration = 10;
|
|
15
|
+
const videoEleSet = new WeakSet();
|
|
16
|
+
|
|
17
|
+
const isIos = function() {
|
|
18
|
+
let ua = navigator.userAgent;
|
|
19
|
+
return ua.indexOf('iPhone') > -1 || ua.indexOf('iOS') > -1 || ua.indexOf('iPad') > -1;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const toThumbFile = blob => new File([blob], 'thumb__img.png');
|
|
23
|
+
|
|
24
|
+
export function isVideo(strType) {
|
|
25
|
+
return videoTypes.includes(strType) || strType.includes('video');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function createObjectURL(object) {
|
|
29
|
+
if (!window.URL && !window.webkitURL) {
|
|
30
|
+
Notify({
|
|
31
|
+
type: 'warning',
|
|
32
|
+
message: `浏览器版本过低,无法支持视频预览`,
|
|
33
|
+
});
|
|
34
|
+
return require('../../assets/layout/empty.png');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return window.URL ? window.URL.createObjectURL(object) : window.webkitURL.createObjectURL(object);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// file为视频的文件对象,可使用 input[file] 进行获取
|
|
41
|
+
export function loadVideo(file) {
|
|
42
|
+
return new Promise(function(resolve, reject) {
|
|
43
|
+
const videoElem = document.createElement('video');
|
|
44
|
+
const dataUrl = file instanceof File ? createObjectURL(file) : file;
|
|
45
|
+
// 当前帧的数据是可用的
|
|
46
|
+
videoElem.onloadeddata = function(e) {
|
|
47
|
+
resolve(videoElem);
|
|
48
|
+
URL.revokeObjectURL(dataUrl);
|
|
49
|
+
};
|
|
50
|
+
videoElem.onerror = function(e) {
|
|
51
|
+
reject('video 后台加载失败');
|
|
52
|
+
};
|
|
53
|
+
// 设置 auto 预加载数据, 否则会出现截图为黑色图片的情况
|
|
54
|
+
videoElem.setAttribute('preload', 'auto');
|
|
55
|
+
videoElem.src = dataUrl;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function calcVideoImage(file) {
|
|
60
|
+
if (isVideo(file.type || file.file.type)) {
|
|
61
|
+
if (URL)
|
|
62
|
+
return {
|
|
63
|
+
title: file.fileName || '视频' + Date.now(),
|
|
64
|
+
type: file.type || 'video/mp4',
|
|
65
|
+
href: file.url ? file.url : createObjectURL(file.file),
|
|
66
|
+
poster: null,
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
title: file.fileName || '水印图片',
|
|
72
|
+
type: file.type || 'image/jpeg',
|
|
73
|
+
href: file.url ? file.url : file.content,
|
|
74
|
+
thumbnail: file.content,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// 抽取第一帧图片
|
|
79
|
+
export async function firstPingImage(file) {
|
|
80
|
+
if (isVideo(file.type || file.file.type) && isIos())
|
|
81
|
+
return await Promise.resolve({
|
|
82
|
+
title: file.fileName || '视频' + Date.now(),
|
|
83
|
+
type: file.type || 'video/mp4',
|
|
84
|
+
href: file.url ? file.url : createObjectURL(file.file),
|
|
85
|
+
poster: null,
|
|
86
|
+
});
|
|
87
|
+
if (!isVideo(file.type || file.file.type))
|
|
88
|
+
return await Promise.resolve({
|
|
89
|
+
title: file.fileName || '水印图片',
|
|
90
|
+
type: file.type || 'image/jpeg',
|
|
91
|
+
href: file.url ? file.url : file.content,
|
|
92
|
+
thumbnail: file.content,
|
|
93
|
+
});
|
|
94
|
+
return await loadVideo(file.url || file.file).then(videoElem => {
|
|
95
|
+
const canvasElem = document.createElement('canvas');
|
|
96
|
+
const { videoWidth, videoHeight } = videoElem;
|
|
97
|
+
canvasElem.width = videoWidth;
|
|
98
|
+
canvasElem.height = videoHeight;
|
|
99
|
+
canvasElem.getContext('2d').drawImage(videoElem, 0, 0, videoWidth, videoHeight);
|
|
100
|
+
// 导出成可读文件
|
|
101
|
+
// cb(canvasElem.toDataURL('image/png', 1))
|
|
102
|
+
return {
|
|
103
|
+
title: file.fileName || '视频' + Date.now(),
|
|
104
|
+
type: file.type || 'video/mp4',
|
|
105
|
+
href: URL.createObjectURL(file.file),
|
|
106
|
+
poster: canvasElem.toDataURL('image/png', 1),
|
|
107
|
+
};
|
|
108
|
+
// canvasElem.toBlob(blob => {
|
|
109
|
+
// const thumbFile = toThumbFile(blob)
|
|
110
|
+
// }, 'image/png')
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export function fileLimit(file) {
|
|
115
|
+
let fileSize = file.size / 1024 / 1024 < videoLimit;
|
|
116
|
+
if (!fileSize) {
|
|
117
|
+
Notify({
|
|
118
|
+
type: 'warning',
|
|
119
|
+
message: `视频大小不能超过${videoLimit}MB`,
|
|
120
|
+
});
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
return true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function validVideo(file) {
|
|
127
|
+
return new Promise((resolve, reject) => {
|
|
128
|
+
if (!fileLimit(file)) reject();
|
|
129
|
+
const url = URL.createObjectURL(file);
|
|
130
|
+
const video = document.createElement('video');
|
|
131
|
+
videoEleSet.add(video);
|
|
132
|
+
video.crossOrigin = 'anonymous';
|
|
133
|
+
video.oncanplaythrough = evt => {
|
|
134
|
+
// 释放缓存空间
|
|
135
|
+
URL.revokeObjectURL(url);
|
|
136
|
+
if (duration < Math.ceil(video.duration)) {
|
|
137
|
+
Notify({
|
|
138
|
+
type: 'warning',
|
|
139
|
+
message: `视频时长不能超过${duration}秒`,
|
|
140
|
+
});
|
|
141
|
+
resolve('fail');
|
|
142
|
+
} else {
|
|
143
|
+
resolve(true);
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
video.onerror = evt => {
|
|
147
|
+
Notify({
|
|
148
|
+
type: 'danger',
|
|
149
|
+
message: '视频格式不支持',
|
|
150
|
+
});
|
|
151
|
+
reject('fail');
|
|
152
|
+
};
|
|
153
|
+
video.src = url;
|
|
154
|
+
video.load();
|
|
155
|
+
});
|
|
156
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<!-- 主页 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div style="text-align: center;">主页</div>
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<script>
|
|
7
|
+
import create from '../../utils/core/create-basic';
|
|
8
|
+
import mixins from '../../mixins/index';
|
|
9
|
+
|
|
10
|
+
export default create({
|
|
11
|
+
name: 'Home',
|
|
12
|
+
mixins: [mixins],
|
|
13
|
+
components: {},
|
|
14
|
+
data() {
|
|
15
|
+
return {};
|
|
16
|
+
},
|
|
17
|
+
computed: {},
|
|
18
|
+
methods: {},
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<style lang="scss" scoped>
|
|
23
|
+
</style>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span></span>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import mixins from '../../mixins';
|
|
7
|
+
import wxRelative from '../../mixins/extension/wx-relative';
|
|
8
|
+
import { mapGetters } from 'vuex';
|
|
9
|
+
import { login } from '../../service/common';
|
|
10
|
+
import { encrypt } from '../../utils/library/aes';
|
|
11
|
+
import { getUrlParam } from '../../utils/library/urlhandle';
|
|
12
|
+
|
|
13
|
+
export default {
|
|
14
|
+
name: 'Login',
|
|
15
|
+
mixins: [mixins, wxRelative],
|
|
16
|
+
computed: {
|
|
17
|
+
...mapGetters(['token', 'account']),
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
methods: {
|
|
21
|
+
//获取登录信息
|
|
22
|
+
login(type) {
|
|
23
|
+
login(
|
|
24
|
+
encrypt(
|
|
25
|
+
JSON.stringify({
|
|
26
|
+
Request: {
|
|
27
|
+
Head: { NWVersion: '1', NWCode: '1SR', NWGUID: '', NWExID: '' },
|
|
28
|
+
Data: { account: this.account, type: type || '' },
|
|
29
|
+
},
|
|
30
|
+
})
|
|
31
|
+
)
|
|
32
|
+
).then(async (res) => {
|
|
33
|
+
this.$store.dispatch('setUserInfo', {
|
|
34
|
+
...res,
|
|
35
|
+
token: res.userToken,
|
|
36
|
+
});
|
|
37
|
+
this.redirect();
|
|
38
|
+
});
|
|
39
|
+
},
|
|
40
|
+
//重定向
|
|
41
|
+
redirect() {
|
|
42
|
+
localStorage.setItem('source', 'wx');
|
|
43
|
+
this.$router.replace({ path: 'home', query: { timestamp: Date.now() } });
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
created() {
|
|
48
|
+
//进入页面前先清空一下localStorage
|
|
49
|
+
localStorage.clear();
|
|
50
|
+
|
|
51
|
+
//url查询是否包含用户账号
|
|
52
|
+
if (getUrlParam('userId') === undefined) {
|
|
53
|
+
let redirectUri = encodeURIComponent(`${location.origin}/api/warehouse/wechat/getCode`);
|
|
54
|
+
this.getWxParams((obj) => {
|
|
55
|
+
location.replace(
|
|
56
|
+
`https://open.weixin.qq.com/connect/oauth2/authorize?appid=${obj.appId}&redirect_uri=${redirectUri}&response_type=code&scope=snsapi_base#wechat_redirect`
|
|
57
|
+
);
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
this.$store.dispatch('setAccount', getUrlParam('userId'));
|
|
61
|
+
this.login();
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
</script>
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span></span>
|
|
3
|
+
</template>
|
|
4
|
+
|
|
5
|
+
<script>
|
|
6
|
+
import mixins from '../../mixins';
|
|
7
|
+
import { Toast } from 'vant';
|
|
8
|
+
import { mapGetters } from 'vuex';
|
|
9
|
+
import { login } from '../../service/common';
|
|
10
|
+
import { encrypt } from '../../utils/library/aes';
|
|
11
|
+
import { getUrlParam } from '../../utils/library/urlhandle';
|
|
12
|
+
import Cookie from 'js-cookie';
|
|
13
|
+
|
|
14
|
+
export default {
|
|
15
|
+
name: 'Login',
|
|
16
|
+
mixins: [mixins],
|
|
17
|
+
computed: {
|
|
18
|
+
...mapGetters(['token', 'account']),
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
methods: {
|
|
22
|
+
//获取登录信息
|
|
23
|
+
login() {
|
|
24
|
+
login(
|
|
25
|
+
encrypt(
|
|
26
|
+
JSON.stringify({
|
|
27
|
+
Request: {
|
|
28
|
+
Head: { NWVersion: '1', NWCode: '1SR', NWGUID: '', NWExID: '' },
|
|
29
|
+
Data: { account: getUrlParam('userId') },
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
)
|
|
33
|
+
).then(async (res) => {
|
|
34
|
+
this.$store.dispatch('setUserInfo', {
|
|
35
|
+
...res,
|
|
36
|
+
token: res.userToken,
|
|
37
|
+
});
|
|
38
|
+
Cookie.set('token', res.userToken, { expires: 3 });
|
|
39
|
+
Cookie.set('app-id', '4ce19ca8fcd150a4', { expires: 3 });
|
|
40
|
+
Cookie.set('app-client-type', 'mb', { expires: 3 });
|
|
41
|
+
|
|
42
|
+
this.redirect();
|
|
43
|
+
});
|
|
44
|
+
},
|
|
45
|
+
//重定向
|
|
46
|
+
redirect() {
|
|
47
|
+
localStorage.setItem('source', 'app');
|
|
48
|
+
this.$router.replace({ path: 'home', query: { timestamp: Date.now() } });
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
created() {
|
|
53
|
+
//进入页面前先清空一下localStorage
|
|
54
|
+
localStorage.clear();
|
|
55
|
+
//在线时
|
|
56
|
+
if (navigator.onLine) {
|
|
57
|
+
if (getUrlParam('userId')) {
|
|
58
|
+
this.login();
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
Toast('登录信息缺失');
|
|
62
|
+
} else {
|
|
63
|
+
//缓存登录
|
|
64
|
+
if (this.token) {
|
|
65
|
+
this.redirect();
|
|
66
|
+
} else {
|
|
67
|
+
Toast.fail('网络状态不佳,请先去有网的地方加载数据');
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
</script>
|