|
|
@@ -4,14 +4,6 @@
|
|
|
|
|
|
class Utils {
|
|
|
/*
|
|
|
- 获取实际数据类型
|
|
|
- @data {any} 数据
|
|
|
- */
|
|
|
- getDataType(data) {
|
|
|
- return /^\[object (.*)\]$/.exec(Object.prototype.toString.call(data))[1];
|
|
|
- }
|
|
|
-
|
|
|
- /*
|
|
|
格式化时间
|
|
|
@date {Date} 传入的时间
|
|
|
@status {Boolean} 是否需要时分秒开关 true 关闭时分秒选项 false 打开时分秒选项
|
|
|
@@ -37,6 +29,35 @@ class Utils {
|
|
|
return n[1] ? n : '0' + n;
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ 获取实际数据类型
|
|
|
+ @data {any} 数据
|
|
|
+ */
|
|
|
+ getDataType(data) {
|
|
|
+ return /^\[object (.*)\]$/.exec(Object.prototype.toString.call(data))[1];
|
|
|
+ }
|
|
|
+
|
|
|
+ /*
|
|
|
+ 获取url
|
|
|
+ @url {String} 待处理的URL
|
|
|
+ @return {String} 处理过的字符串
|
|
|
+ 根据URL是否有http或者https判断是否拼接字符串
|
|
|
+ */
|
|
|
+ getUrl(url) {
|
|
|
+ return new Promise(reslove => {
|
|
|
+ const apiUrl = require('../config.js').apiUrl; // 加载接口地址文件
|
|
|
+ if (url.indexOf('https://') === -1 && url.indexOf('http://') === -1) {
|
|
|
+ reslove(apiUrl + url)
|
|
|
+ } else {
|
|
|
+ if (url.indexOf('http://') === -1) {
|
|
|
+ reslove(url)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ reslove(url.replace('http://', 'https://'))
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 获取网络状态
|
|
|
*/
|
|
|
@@ -75,27 +96,6 @@ class Utils {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- 获取url
|
|
|
- @url {String} 待处理的URL
|
|
|
- @return {String} 处理过的字符串
|
|
|
- 根据URL是否有http或者https判断是否拼接字符串
|
|
|
- */
|
|
|
- getUrl(url) {
|
|
|
- return new Promise(reslove => {
|
|
|
- const apiUrl = require('../config.js').apiUrl; // 加载接口地址文件
|
|
|
- if (url.indexOf('https://') === -1 && url.indexOf('http://') === -1) {
|
|
|
- reslove(apiUrl + url)
|
|
|
- } else {
|
|
|
- if (url.indexOf('http://') === -1) {
|
|
|
- reslove(url)
|
|
|
- return
|
|
|
- }
|
|
|
- reslove(url.replace('http://', 'https://'))
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-
|
|
|
/**
|
|
|
* 上传图片
|
|
|
* @pic_arr {Array} 图片数组
|