Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ElectricitySheep
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
黄媛媛
ElectricitySheep
Commits
420b73d5
Commit
420b73d5
authored
Aug 06, 2020
by
黄奎
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
页面修改
parent
2dd89b74
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
430 additions
and
435 deletions
+430
-435
index.js
src/plug/index.js
+430
-435
No files found.
src/plug/index.js
View file @
420b73d5
import
md5
from
'js-md5'
import
md5
from
'js-md5'
export
default
{
export
default
{
install
(
Vue
,
options
)
{
install
(
Vue
,
options
)
{
Vue
.
prototype
.
md5
=
md5
;
Vue
.
prototype
.
md5
=
md5
;
//消息成功提示
//消息成功提示
Vue
.
prototype
.
Success
=
function
(
msg
)
{
Vue
.
prototype
.
Success
=
function
(
msg
)
{
this
.
$message
({
this
.
$message
({
message
:
msg
,
message
:
msg
,
duration
:
2000
,
duration
:
2000
,
type
:
"success"
type
:
"success"
});
});
},
},
//错误提示
//错误提示
Vue
.
prototype
.
Error
=
function
(
msg
)
{
Vue
.
prototype
.
Error
=
function
(
msg
)
{
this
.
$message
({
this
.
$message
({
message
:
msg
,
message
:
msg
,
duration
:
2000
,
duration
:
2000
,
type
:
"error"
type
:
"error"
});
});
},
},
//一般提示
//一般提示
Vue
.
prototype
.
Info
=
function
(
msg
)
{
Vue
.
prototype
.
Info
=
function
(
msg
)
{
this
.
$message
({
this
.
$message
({
message
:
msg
,
message
:
msg
,
duration
:
2000
,
duration
:
2000
,
type
:
"info"
type
:
"info"
});
});
},
},
//警告提示
//警告提示
Vue
.
prototype
.
Warning
=
function
(
msg
)
{
Vue
.
prototype
.
Warning
=
function
(
msg
)
{
this
.
$message
({
this
.
$message
({
message
:
msg
,
message
:
msg
,
duration
:
2000
,
duration
:
2000
,
type
:
"warning"
type
:
"warning"
});
});
},
},
//Confirm
//Confirm
Vue
.
prototype
.
Confirm
=
function
(
msg
,
callback
)
{
Vue
.
prototype
.
Confirm
=
function
(
msg
,
callback
)
{
this
.
$confirm
(
msg
,
"提示"
,
{
this
.
$confirm
(
msg
,
"提示"
,
{
confirmButtonText
:
"确定"
,
confirmButtonText
:
"确定"
,
cancelButtonText
:
"取消"
,
cancelButtonText
:
"取消"
,
type
:
"warning"
type
:
"warning"
})
})
.
then
(()
=>
{
.
then
(()
=>
{
if
(
typeof
callback
===
'function'
)
{
if
(
typeof
callback
===
'function'
)
{
callback
();
callback
();
}
})
.
catch
(()
=>
{
this
.
Info
(
"已取消操作"
);
});
},
//域名管理对象
Vue
.
prototype
.
domainManager
=
function
()
{
let
domainUrl
=
''
;
// domainUrl = "https://mallapi.oytour.com";
// domainUrl = "https://localhost:5001";
// domainUrl = "http://192.168.2.65";
domainUrl
=
"http://192.168.2.16:8088"
;
let
locationName
=
window
.
location
.
hostname
;
if
(
locationName
.
indexOf
(
'testmall.oytour'
)
!==
-
1
)
{
domainUrl
=
"https://mallapi.oytour.com"
;
}
else
if
(
locationName
.
indexOf
(
'oytour'
)
!==
-
1
)
{
domainUrl
=
"https://mallapi.oytour.com"
;
}
var
obj
=
{
//主地址npm
DomainUrl
:
domainUrl
,
//资产管理
javaUrl
:
"http://192.168.2.65:8018"
,
// javaUrl: "http://192.168.2.16:8087",
// javaUrl: "http://property.oytour.com",
//常用提交数据URL
PostUrl
:
domainUrl
+
"/api/common/post"
,
ImageUrl
:
'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com'
,
UploadFileUrl
:
domainUrl
+
'/api/File/LocalFileUploadImport'
,
UploadBlob
:
domainUrl
+
'/api/File/UploadBlob'
,
};
return
obj
;
},
//浏览器缓存
Vue
.
prototype
.
getLocalStorage
=
function
()
{
var
localStorageData
=
window
.
localStorage
[
"mall_userInfo"
];
if
(
localStorageData
!==
undefined
&&
localStorageData
!=
'undefined'
)
{
return
JSON
.
parse
(
localStorageData
);
}
else
{
return
null
;
}
},
//验证只能输入2位小数【负数:isMinus传true】
Vue
.
prototype
.
checkPrice
=
function
(
item
,
filed
,
isMinus
)
{
var
value
=
""
+
item
[
filed
];
//转字符串
var
t
=
value
.
charAt
(
0
);
value
=
value
.
replace
(
/
[^\d
.
]
/g
,
""
);
//清除“数字”和“.”以外的字符
value
=
value
.
replace
(
/
\.{2,}
/g
,
"."
);
//只保留第一个. 清除多余的
value
=
value
.
replace
(
"."
,
"$#$"
)
.
replace
(
/
\.
/g
,
""
)
.
replace
(
"$#$"
,
"."
);
value
=
value
.
replace
(
/^
(\-)
*
(\d
+
)\.(\d\d)
.*$/
,
'$1$2.$3'
);
//只能输入两个小数
//如果第一位是负号,则允许添加 如果不允许添加负号 可以把这块注释掉
//是否允许负数
if
(
isMinus
&&
t
==
'-'
)
{
value
=
'-'
+
value
;
}
item
[
filed
]
=
value
;
}
//验证只能输入整数【负数:isMinus传true】
Vue
.
prototype
.
checkInteger
=
function
(
item
,
filed
,
isMinus
)
{
var
value
=
""
+
item
[
filed
];
//转字符串
var
t
=
value
.
charAt
(
0
);
value
=
value
.
replace
(
this
.
$commonUtils
.
Regex
.
isInteger
,
""
);
//是否允许负数
if
(
isMinus
&&
t
==
'-'
)
{
value
=
'-'
+
value
;
}
item
[
filed
]
=
value
;
},
//是否是线上环境【发布时修改为true】
Vue
.
prototype
.
isOnline
=
function
()
{
return
process
.
env
.
NODE_ENV
!==
'development'
;
},
//文件类型数组
Vue
.
prototype
.
FileType
=
function
()
{
var
fileTypeJson
=
{
//主地址npm
UserImg
:
"User"
,
//用户相图片
//常用提交数据URL
GoodsImg
:
"Goods"
,
//素材相关文件
SetImg
:
"Set"
,
//用户相图片
};
return
fileTypeJson
;
},
//上传文件到云存储
Vue
.
prototype
.
UploadFileToTencent
=
function
(
path
,
fileObj
,
callback
)
{
//获取文件扩展名
var
filename
=
fileObj
.
name
;
var
index
=
filename
.
lastIndexOf
(
"."
);
var
suffix
=
filename
.
substr
(
index
);
var
timestamp1
=
Date
.
parse
(
new
Date
())
+
"_"
+
(
Math
.
ceil
(
Math
.
random
()
*
1000
));
let
str
=
''
;
if
(
this
.
isOnline
())
{
str
=
"/Test"
}
var
newFileName
=
str
+
'/Upload/'
+
path
+
"/"
+
timestamp1
+
""
+
suffix
;
var
uploadMsg
=
{
Bucket
:
"viitto-1301420277"
,
Region
:
"ap-chengdu"
,
/* 存储桶所在地域,必须字段 */
SecretId
:
"AKIDDPnbIzi8C1eqEOPP8dw6MNAg9H9ldDKd"
,
SecretKey
:
"PdcLtOjslUzNFYdU4OSI1fKtdHpFT2Ob"
,
};
var
COS
=
require
(
'cos-js-sdk-v5'
);
var
cos
=
new
COS
({
SecretId
:
uploadMsg
.
SecretId
,
SecretKey
:
uploadMsg
.
SecretKey
,
});
cos
.
putObject
({
Bucket
:
uploadMsg
.
Bucket
,
Region
:
uploadMsg
.
Region
,
//存储桶所在地域,必须字段
Key
:
newFileName
,
//文件名
StorageClass
:
'STANDARD'
,
Body
:
fileObj
,
// 上传文件对象
onProgress
:
function
(
progressData
)
{}
},
function
(
err
,
data
)
{
if
(
data
&&
data
.
statusCode
==
200
)
{
var
uploadResult
=
{
resultCode
:
1
,
FileName
:
fileObj
.
name
,
FileUrl
:
"http://"
+
data
.
Location
}
if
(
callback
)
{
callback
(
uploadResult
);
}
}
else
{
/*上传文件异常*/
console
.
log
(
err
||
data
);
}
});
},
//公用跳转
Vue
.
prototype
.
CommonJump
=
function
(
path
,
obj
)
{
this
.
$router
.
push
({
name
:
path
,
query
:
obj
});
}
//公用判断图片地址 判断是否包含http
Vue
.
prototype
.
getIconLink
=
function
(
url
)
{
let
str
=
''
if
(
url
&&
url
!=
''
)
{
if
(
url
.
indexOf
(
'http'
)
!=
-
1
)
{
str
=
url
}
else
{
str
=
this
.
domainManager
().
ImageUrl
+
url
;
}
return
str
;
}
}
}
//HTTP提交数据
})
Vue
.
prototype
.
apipost
=
function
(
cmd
,
msg
,
successCall
,
faildCall
,
isOnline
)
{
.
catch
(()
=>
{
var
apiurl
=
this
.
domainManager
().
DomainUrl
+
cmd
;
this
.
Info
(
"已取消操作"
);
var
postData
=
this
.
GetPostData
(
cmd
,
msg
,
""
);
});
this
.
$http
.
post
(
apiurl
,
postData
,
{
},
headers
:
{
//域名管理对象
'Content-Type'
:
'application/json'
,
Vue
.
prototype
.
domainManager
=
function
()
{
'Referer-Viitto'
:
this
.
$route
.
path
let
domainUrl
=
''
;
}
let
javaUrl
=
'http://192.168.2.65:8018'
;
})
.
then
(
res
=>
{
domainUrl
=
"http://192.168.2.214:8200"
;
if
(
res
.
data
.
resultCode
==
10000
||
res
.
data
.
resultCode
==
10001
)
{
//domainUrl = "https://localhost:5001";
this
.
$router
.
push
({
path
:
'/login'
let
locationName
=
window
.
location
.
hostname
;
});
if
(
locationName
.
indexOf
(
'testmall.oytour'
)
!==
-
1
)
{
}
else
if
(
res
.
resultCode
==
10005
)
{
domainUrl
=
"https://mallapi.oytour.com"
;
this
.
$router
.
go
(
-
1
);
javaUrl
=
"http://property.oytour.com"
;
}
else
{
}
else
if
(
locationName
.
indexOf
(
'oytour'
)
!==
-
1
)
{
successCall
(
res
);
domainUrl
=
"https://mallapi.oytour.com"
;
}
javaUrl
=
"http://property.oytour.com"
;
},
faildCall
)
}
//获取请求参数
Vue
.
prototype
.
GetPostData
=
function
(
cmd
,
msg
,
newCmd
)
{
if
(
msg
==
null
||
msg
==
""
)
{
msg
=
{}
}
var
timestamp
=
(
new
Date
()).
valueOf
();
if
(
!
localStorage
.
mall_userInfo
&&
localStorage
.
mall_userInfo
!=
""
&&
this
.
$route
.
path
.
toLowerCase
()
!=
"/login"
&&
this
.
$route
.
path
.
toLowerCase
()
!=
"/register"
&&
this
.
$route
.
path
.
toLowerCase
()
!=
"/forgetpassword"
)
{
this
.
$router
.
push
({
path
:
'/login'
})
}
var
token
=
""
;
var
key
=
""
;
var
MallBaseId
=
"0"
;
//小程序ID
var
TenantId
=
"0"
;
//商户Id
var
EmpId
=
0
;
//员工编号【员工登录时使用】
if
(
this
.
getLocalStorage
()
!=
null
)
{
token
=
this
.
getLocalStorage
().
Token
;
key
=
this
.
getLocalStorage
().
SecretKey
;
MallBaseId
=
this
.
getLocalStorage
().
MallBaseId
;
TenantId
=
this
.
getLocalStorage
().
TenantId
;
EmpId
=
this
.
getLocalStorage
().
EmpId
;
}
var
encodeMsg
=
encodeURIComponent
(
JSON
.
stringify
(
msg
)).
toLowerCase
();
var
md5Str
=
md5
(
`cmd=
${
cmd
}
&msg=
${
encodeMsg
}
×tamp=
${
timestamp
}
&token=
${
token
}
&key=
${
key
}
`
);
let
tempLanguage
=
0
;
if
(
localStorage
.
language
&&
localStorage
.
language
!=
''
)
{
if
(
localStorage
.
language
==
"zh-TW"
)
{
tempLanguage
=
1
;
}
else
if
(
localStorage
.
language
==
"Japanese"
)
{
tempLanguage
=
2
;
}
}
var
cmdStr
=
""
;
if
(
newCmd
)
{
cmdStr
=
newCmd
;
}
var
postData
=
{
msg
:
msg
,
timestamp
:
timestamp
,
token
:
token
,
sign
:
md5Str
,
languageId
:
tempLanguage
,
cmd
:
cmdStr
,
MallBaseId
:
MallBaseId
,
TenantId
:
TenantId
,
EmpId
:
EmpId
,
// MiniAppId:"wxacd9f8cc3480d29e",
// OpenId:"ow_7I5ZQKhAB66yvOTGI35Xk-Kmg",
// UserId:19992,
}
return
postData
},
//HTTP提交数据资产
Vue
.
prototype
.
assetsApipost
=
function
(
cmd
,
msg
,
successCall
,
faildCall
,
isOnline
)
{
var
apiurl
=
this
.
domainManager
().
DomainUrl
+
cmd
;
var
postData
=
this
.
GetAssetsPostData
(
cmd
,
msg
,
""
);
this
.
$http
.
post
(
apiurl
,
postData
,
{
headers
:
{
'Content-Type'
:
'application/json'
,
'Referer-Viitto'
:
this
.
$route
.
path
}
})
.
then
(
res
=>
{
if
(
res
.
data
.
resultCode
==
10000
||
res
.
data
.
resultCode
==
10001
)
{
this
.
$router
.
push
({
path
:
'/login'
});
}
else
if
(
res
.
resultCode
==
10005
)
{
this
.
$router
.
go
(
-
1
);
}
else
{
successCall
(
res
);
}
},
faildCall
)
}
}
//获取请求参数
var
obj
=
{
Vue
.
prototype
.
GetAssetsPostData
=
function
(
cmd
,
msg
,
newCmd
)
{
//主地址npm
if
(
msg
==
null
||
msg
==
""
)
{
DomainUrl
:
domainUrl
,
msg
=
{}
//资产管理
}
javaUrl
:
javaUrl
,
var
timestamp
=
(
new
Date
()).
valueOf
();
//常用提交数据URL
if
(
!
localStorage
.
mall_userInfo
&&
localStorage
.
mall_userInfo
!=
""
&&
PostUrl
:
domainUrl
+
"/api/common/post"
,
this
.
$route
.
path
.
toLowerCase
()
!=
"/login"
&&
ImageUrl
:
'https://viitto-1301420277.cos.ap-chengdu.myqcloud.com'
,
this
.
$route
.
path
.
toLowerCase
()
!=
"/register"
&&
UploadFileUrl
:
domainUrl
+
'/api/File/LocalFileUploadImport'
,
this
.
$route
.
path
.
toLowerCase
()
!=
"/forgetpassword"
UploadBlob
:
domainUrl
+
'/api/File/UploadBlob'
,
)
{
};
this
.
$router
.
push
({
return
obj
;
path
:
'/login'
},
})
//浏览器缓存
}
Vue
.
prototype
.
getLocalStorage
=
function
()
{
var
token
=
""
;
var
localStorageData
=
window
.
localStorage
[
"mall_userInfo"
];
var
key
=
""
;
if
(
localStorageData
!==
undefined
&&
localStorageData
!=
'undefined'
)
{
var
MallBaseId
=
"0"
;
//小程序ID
return
JSON
.
parse
(
localStorageData
);
var
TenantId
=
"0"
;
//商户Id
}
else
{
var
EmpId
=
0
;
//员工编号【员工登录时使用】
return
null
;
var
ERPGroupId
=
0
;
}
var
ERPEmpId
=
0
;
},
var
ERPBranchId
=
0
;
//验证只能输入2位小数【负数:isMinus传true】
if
(
this
.
getLocalStorage
()
!=
null
)
{
Vue
.
prototype
.
checkPrice
=
function
(
item
,
filed
,
isMinus
)
{
token
=
this
.
getLocalStorage
().
Token
;
var
value
=
""
+
item
[
filed
];
//转字符串
key
=
this
.
getLocalStorage
().
SecretKey
;
var
t
=
value
.
charAt
(
0
);
MallBaseId
=
this
.
getLocalStorage
().
MallBaseId
;
value
=
value
.
replace
(
/
[^\d
.
]
/g
,
""
);
//清除“数字”和“.”以外的字符
TenantId
=
this
.
getLocalStorage
().
TenantId
;
value
=
value
.
replace
(
/
\.{2,}
/g
,
"."
);
//只保留第一个. 清除多余的
EmpId
=
this
.
getLocalStorage
().
EmpId
;
value
=
value
ERPGroupId
=
this
.
getLocalStorage
().
ERPGroupId
;
.
replace
(
"."
,
"$#$"
)
ERPEmpId
=
this
.
getLocalStorage
().
ERPEmpId
;
.
replace
(
/
\.
/g
,
""
)
ERPBranchId
=
this
.
getLocalStorage
().
ERPBranchId
;
.
replace
(
"$#$"
,
"."
);
value
=
value
.
replace
(
/^
(\-)
*
(\d
+
)\.(\d\d)
.*$/
,
'$1$2.$3'
);
//只能输入两个小数
//如果第一位是负号,则允许添加 如果不允许添加负号 可以把这块注释掉
//是否允许负数
if
(
isMinus
&&
t
==
'-'
)
{
value
=
'-'
+
value
;
}
item
[
filed
]
=
value
;
}
//验证只能输入整数【负数:isMinus传true】
Vue
.
prototype
.
checkInteger
=
function
(
item
,
filed
,
isMinus
)
{
var
value
=
""
+
item
[
filed
];
//转字符串
var
t
=
value
.
charAt
(
0
);
value
=
value
.
replace
(
this
.
$commonUtils
.
Regex
.
isInteger
,
""
);
//是否允许负数
if
(
isMinus
&&
t
==
'-'
)
{
value
=
'-'
+
value
;
}
item
[
filed
]
=
value
;
},
//是否是线上环境【发布时修改为true】
Vue
.
prototype
.
isOnline
=
function
()
{
return
process
.
env
.
NODE_ENV
!==
'development'
;
},
//文件类型数组
Vue
.
prototype
.
FileType
=
function
()
{
var
fileTypeJson
=
{
//主地址npm
UserImg
:
"User"
,
//用户相图片
//常用提交数据URL
GoodsImg
:
"Goods"
,
//素材相关文件
SetImg
:
"Set"
,
//用户相图片
};
return
fileTypeJson
;
},
//上传文件到云存储
Vue
.
prototype
.
UploadFileToTencent
=
function
(
path
,
fileObj
,
callback
)
{
//获取文件扩展名
var
filename
=
fileObj
.
name
;
var
index
=
filename
.
lastIndexOf
(
"."
);
var
suffix
=
filename
.
substr
(
index
);
var
timestamp1
=
Date
.
parse
(
new
Date
())
+
"_"
+
(
Math
.
ceil
(
Math
.
random
()
*
1000
));
let
str
=
''
;
if
(
this
.
isOnline
())
{
str
=
"/Test"
}
var
newFileName
=
str
+
'/Upload/'
+
path
+
"/"
+
timestamp1
+
""
+
suffix
;
var
uploadMsg
=
{
Bucket
:
"viitto-1301420277"
,
Region
:
"ap-chengdu"
,
/* 存储桶所在地域,必须字段 */
SecretId
:
"AKIDDPnbIzi8C1eqEOPP8dw6MNAg9H9ldDKd"
,
SecretKey
:
"PdcLtOjslUzNFYdU4OSI1fKtdHpFT2Ob"
,
};
var
COS
=
require
(
'cos-js-sdk-v5'
);
var
cos
=
new
COS
({
SecretId
:
uploadMsg
.
SecretId
,
SecretKey
:
uploadMsg
.
SecretKey
,
});
cos
.
putObject
({
Bucket
:
uploadMsg
.
Bucket
,
Region
:
uploadMsg
.
Region
,
//存储桶所在地域,必须字段
Key
:
newFileName
,
//文件名
StorageClass
:
'STANDARD'
,
Body
:
fileObj
,
// 上传文件对象
onProgress
:
function
(
progressData
)
{}
},
function
(
err
,
data
)
{
if
(
data
&&
data
.
statusCode
==
200
)
{
var
uploadResult
=
{
resultCode
:
1
,
FileName
:
fileObj
.
name
,
FileUrl
:
"http://"
+
data
.
Location
}
}
var
encodeMsg
=
encodeURIComponent
(
JSON
.
stringify
(
msg
)).
toLowerCase
();
if
(
callback
)
{
var
md5Str
=
md5
(
`cmd=
${
cmd
}
&msg=
${
encodeMsg
}
×tamp=
${
timestamp
}
&token=
${
token
}
&key=
${
key
}
`
);
callback
(
uploadResult
);
let
tempLanguage
=
0
;
if
(
localStorage
.
language
&&
localStorage
.
language
!=
''
)
{
if
(
localStorage
.
language
==
"zh-TW"
)
{
tempLanguage
=
1
;
}
else
if
(
localStorage
.
language
==
"Japanese"
)
{
tempLanguage
=
2
;
}
}
}
var
cmdStr
=
""
;
}
else
{
if
(
newCmd
)
{
/*上传文件异常*/
cmdStr
=
newCmd
;
console
.
log
(
err
||
data
);
}
});
},
//公用跳转
Vue
.
prototype
.
CommonJump
=
function
(
path
,
obj
)
{
this
.
$router
.
push
({
name
:
path
,
query
:
obj
});
}
//公用判断图片地址 判断是否包含http
Vue
.
prototype
.
getIconLink
=
function
(
url
)
{
let
str
=
''
if
(
url
&&
url
!=
''
)
{
if
(
url
.
indexOf
(
'http'
)
!=
-
1
)
{
str
=
url
}
else
{
str
=
this
.
domainManager
().
ImageUrl
+
url
;
}
return
str
;
}
}
//HTTP提交数据
Vue
.
prototype
.
apipost
=
function
(
cmd
,
msg
,
successCall
,
faildCall
,
isOnline
)
{
var
apiurl
=
this
.
domainManager
().
DomainUrl
+
cmd
;
var
postData
=
this
.
GetPostData
(
cmd
,
msg
,
""
);
this
.
$http
.
post
(
apiurl
,
postData
,
{
headers
:
{
'Content-Type'
:
'application/json'
,
'Referer-Viitto'
:
this
.
$route
.
path
}
})
.
then
(
res
=>
{
if
(
res
.
data
.
resultCode
==
10000
||
res
.
data
.
resultCode
==
10001
)
{
this
.
$router
.
push
({
path
:
'/login'
});
}
else
if
(
res
.
resultCode
==
10005
)
{
this
.
$router
.
go
(
-
1
);
}
else
{
successCall
(
res
);
}
},
faildCall
)
}
//获取请求参数
Vue
.
prototype
.
GetPostData
=
function
(
cmd
,
msg
,
newCmd
)
{
if
(
msg
==
null
||
msg
==
""
)
{
msg
=
{}
}
var
timestamp
=
(
new
Date
()).
valueOf
();
if
(
!
localStorage
.
mall_userInfo
&&
localStorage
.
mall_userInfo
!=
""
&&
this
.
$route
.
path
.
toLowerCase
()
!=
"/login"
&&
this
.
$route
.
path
.
toLowerCase
()
!=
"/register"
&&
this
.
$route
.
path
.
toLowerCase
()
!=
"/forgetpassword"
)
{
this
.
$router
.
push
({
path
:
'/login'
})
}
var
token
=
""
;
var
key
=
""
;
var
MallBaseId
=
"0"
;
//小程序ID
var
TenantId
=
"0"
;
//商户Id
var
EmpId
=
0
;
//员工编号【员工登录时使用】
if
(
this
.
getLocalStorage
()
!=
null
)
{
token
=
this
.
getLocalStorage
().
Token
;
key
=
this
.
getLocalStorage
().
SecretKey
;
MallBaseId
=
this
.
getLocalStorage
().
MallBaseId
;
TenantId
=
this
.
getLocalStorage
().
TenantId
;
EmpId
=
this
.
getLocalStorage
().
EmpId
;
}
var
encodeMsg
=
encodeURIComponent
(
JSON
.
stringify
(
msg
)).
toLowerCase
();
var
md5Str
=
md5
(
`cmd=
${
cmd
}
&msg=
${
encodeMsg
}
×tamp=
${
timestamp
}
&token=
${
token
}
&key=
${
key
}
`
);
let
tempLanguage
=
0
;
if
(
localStorage
.
language
&&
localStorage
.
language
!=
''
)
{
if
(
localStorage
.
language
==
"zh-TW"
)
{
tempLanguage
=
1
;
}
else
if
(
localStorage
.
language
==
"Japanese"
)
{
tempLanguage
=
2
;
}
}
var
cmdStr
=
""
;
if
(
newCmd
)
{
cmdStr
=
newCmd
;
}
var
postData
=
{
msg
:
msg
,
timestamp
:
timestamp
,
token
:
token
,
sign
:
md5Str
,
languageId
:
tempLanguage
,
cmd
:
cmdStr
,
MallBaseId
:
MallBaseId
,
TenantId
:
TenantId
,
EmpId
:
EmpId
,
MiniAppId
:
"wxacd9f8cc3480d29e"
,
OpenId
:
"ow_7I5ZQKhAB66yvOTGI35Xk-Kmg"
,
// UserId:19992,
}
return
postData
},
//HTTP提交数据资产
Vue
.
prototype
.
assetsApipost
=
function
(
cmd
,
msg
,
successCall
,
faildCall
,
isOnline
)
{
var
apiurl
=
this
.
domainManager
().
DomainUrl
+
cmd
;
var
postData
=
this
.
GetAssetsPostData
(
cmd
,
msg
,
""
);
this
.
$http
.
post
(
apiurl
,
postData
,
{
headers
:
{
'Content-Type'
:
'application/json'
,
'Referer-Viitto'
:
this
.
$route
.
path
}
}
var
postData
=
{
})
msg
:
msg
,
.
then
(
res
=>
{
timestamp
:
timestamp
,
if
(
res
.
data
.
resultCode
==
10000
||
res
.
data
.
resultCode
==
10001
)
{
token
:
token
,
this
.
$router
.
push
({
sign
:
md5Str
,
path
:
'/login'
languageId
:
tempLanguage
,
});
cmd
:
cmdStr
,
}
else
if
(
res
.
resultCode
==
10005
)
{
MallBaseId
:
MallBaseId
,
this
.
$router
.
go
(
-
1
);
TenantId
:
TenantId
,
}
else
{
EmpId
:
EmpId
,
successCall
(
res
);
ERPGroupId
:
ERPGroupId
,
ERPEmpId
:
ERPEmpId
,
ERPBranchId
:
ERPBranchId
,
// MiniAppId:"wxacd9f8cc3480d29e",
// OpenId:"ow_7I5ZQKhAB66yvOTGI35Xk-Kmg",
// UserId:19992,
}
}
return
postData
},
faildCall
)
},
}
//文件下载
Vue
.
prototype
.
GetLocalFile
=
function
(
cmd
,
msg
,
fileName
,
newCmd
,
successCall
)
{
//获取请求参数
var
apiurl
=
this
.
domainManager
().
DomainUrl
+
cmd
;
Vue
.
prototype
.
GetAssetsPostData
=
function
(
cmd
,
msg
,
newCmd
)
{
var
postData
=
this
.
GetPostData
(
cmd
,
msg
,
newCmd
);
if
(
msg
==
null
||
msg
==
""
)
{
this
.
$http
.
post
(
apiurl
,
postData
,
{
msg
=
{}
responseType
:
'arraybuffer'
}
}).
then
((
res
)
=>
{
var
timestamp
=
(
new
Date
()).
valueOf
();
let
blob
=
new
Blob
([
res
.
data
],
{
if
(
!
localStorage
.
mall_userInfo
&&
localStorage
.
mall_userInfo
!=
""
&&
type
:
"application/vnd.ms-excel"
this
.
$route
.
path
.
toLowerCase
()
!=
"/login"
&&
})
this
.
$route
.
path
.
toLowerCase
()
!=
"/register"
&&
let
url
=
URL
.
createObjectURL
(
blob
);
this
.
$route
.
path
.
toLowerCase
()
!=
"/forgetpassword"
let
link
=
document
.
createElement
(
'a'
);
)
{
link
.
href
=
url
;
this
.
$router
.
push
({
link
.
setAttribute
(
"download"
,
fileName
);
path
:
'/login'
document
.
body
.
appendChild
(
link
);
})
link
.
click
();
}
successCall
(
res
);
var
token
=
""
;
}).
catch
(
function
(
res
)
{});
var
key
=
""
;
},
var
MallBaseId
=
"0"
;
//小程序ID
//调用资产的接口
var
TenantId
=
"0"
;
//商户Id
Vue
.
prototype
.
apiJavaPost
=
function
(
cmd
,
msg
,
successCall
,
faildCall
)
{
var
EmpId
=
0
;
//员工编号【员工登录时使用】
if
(
msg
==
null
||
msg
==
""
)
{
var
ERPGroupId
=
0
;
msg
=
{}
var
ERPEmpId
=
0
;
}
var
ERPBranchId
=
0
;
var
apiurl
=
this
.
domainManager
().
javaUrl
+
cmd
;
if
(
this
.
getLocalStorage
()
!=
null
)
{
var
timestamp
=
(
new
Date
()).
valueOf
();
token
=
this
.
getLocalStorage
().
Token
;
this
.
apiurl
=
apiurl
;
key
=
this
.
getLocalStorage
().
SecretKey
;
var
token
=
""
;
MallBaseId
=
this
.
getLocalStorage
().
MallBaseId
;
var
key
=
""
;
TenantId
=
this
.
getLocalStorage
().
TenantId
;
var
MallBaseId
=
"0"
;
//小程序ID
EmpId
=
this
.
getLocalStorage
().
EmpId
;
var
TenantId
=
"0"
;
//商户Id
ERPGroupId
=
this
.
getLocalStorage
().
ERPGroupId
;
var
uid
=
"0"
ERPEmpId
=
this
.
getLocalStorage
().
ERPEmpId
;
if
(
this
.
getLocalStorage
()
!=
null
)
{
ERPBranchId
=
this
.
getLocalStorage
().
ERPBranchId
;
token
=
this
.
getLocalStorage
().
Token
;
}
key
=
this
.
getLocalStorage
().
SecretKey
;
var
encodeMsg
=
encodeURIComponent
(
JSON
.
stringify
(
msg
)).
toLowerCase
();
MallBaseId
=
this
.
getLocalStorage
().
MallBaseId
;
var
md5Str
=
md5
(
`cmd=
${
cmd
}
&msg=
${
encodeMsg
}
×tamp=
${
timestamp
}
&token=
${
token
}
&key=
${
key
}
`
);
TenantId
=
this
.
getLocalStorage
().
TenantId
;
let
tempLanguage
=
0
;
uid
=
this
.
getLocalStorage
().
ERPEmpId
if
(
localStorage
.
language
&&
localStorage
.
language
!=
''
)
{
}
if
(
localStorage
.
language
==
"zh-TW"
)
{
tempLanguage
=
1
;
var
encodeMsg
=
encodeURIComponent
(
JSON
.
stringify
(
msg
)).
toLowerCase
();
}
else
if
(
localStorage
.
language
==
"Japanese"
)
{
var
md5Str
=
md5
(
`msg=YXZCGL2020×tamp=
${
timestamp
}
&token=
${
token
}
&key=
${
key
}
`
);
tempLanguage
=
2
;
// var md5Str = md5(`msg=${encodeMsg}×tamp=${timestamp}&token=${token}&key=${key}`);
}
}
var
cmdStr
=
""
;
if
(
newCmd
)
{
cmdStr
=
newCmd
;
}
var
postData
=
{
msg
:
msg
,
timestamp
:
timestamp
,
token
:
token
,
sign
:
md5Str
,
languageId
:
tempLanguage
,
cmd
:
cmdStr
,
MallBaseId
:
MallBaseId
,
TenantId
:
TenantId
,
EmpId
:
EmpId
,
ERPGroupId
:
ERPGroupId
,
ERPEmpId
:
ERPEmpId
,
ERPBranchId
:
ERPBranchId
,
// MiniAppId:"wxacd9f8cc3480d29e",
// OpenId:"ow_7I5ZQKhAB66yvOTGI35Xk-Kmg",
// UserId:19992,
}
return
postData
},
var
postData
=
{
//文件下载
"msg"
:
msg
,
Vue
.
prototype
.
GetLocalFile
=
function
(
cmd
,
msg
,
fileName
,
newCmd
,
successCall
)
{
"timestamp"
:
timestamp
,
var
apiurl
=
this
.
domainManager
().
DomainUrl
+
cmd
;
"token"
:
token
,
var
postData
=
this
.
GetPostData
(
cmd
,
msg
,
newCmd
);
"sign"
:
md5Str
,
this
.
$http
.
post
(
apiurl
,
postData
,
{
"MallBaseId"
:
MallBaseId
,
responseType
:
'arraybuffer'
"TenantId"
:
TenantId
,
}).
then
((
res
)
=>
{
'uid'
:
uid
let
blob
=
new
Blob
([
res
.
data
],
{
type
:
"application/vnd.ms-excel"
})
let
url
=
URL
.
createObjectURL
(
blob
);
let
link
=
document
.
createElement
(
'a'
);
link
.
href
=
url
;
link
.
setAttribute
(
"download"
,
fileName
);
document
.
body
.
appendChild
(
link
);
link
.
click
();
successCall
(
res
);
}).
catch
(
function
(
res
)
{});
},
}
//调用资产的接口
if
(
localStorage
.
g
&&
localStorage
.
g
!=
'undefined'
)
{
Vue
.
prototype
.
apiJavaPost
=
function
(
cmd
,
msg
,
successCall
,
faildCall
)
{
// postData.groupId = parseInt(JSON.parse(localStorage.g).i)
if
(
msg
==
null
||
msg
==
""
)
{
postData
.
groupId
=
2
;
msg
=
{}
}
}
this
.
$http
.
post
(
apiurl
,
postData
,
{
var
apiurl
=
this
.
domainManager
().
javaUrl
+
cmd
;
headers
:
{
var
timestamp
=
(
new
Date
()).
valueOf
();
'Content-Type'
:
'application/json'
,
this
.
apiurl
=
apiurl
;
'Referer-Viitto'
:
this
.
$route
.
path
var
token
=
""
;
}
var
key
=
""
;
})
var
MallBaseId
=
"0"
;
//小程序ID
.
then
(
res
=>
{
var
TenantId
=
"0"
;
//商户Id
if
(
res
.
data
.
resultCode
==
10000
||
res
.
data
.
resultCode
==
10001
)
{
var
uid
=
"0"
this
.
$router
.
push
({
if
(
this
.
getLocalStorage
()
!=
null
)
{
path
:
'/login'
token
=
this
.
getLocalStorage
().
Token
;
})
key
=
this
.
getLocalStorage
().
SecretKey
;
}
else
if
(
res
.
data
.
resultCode
==
10005
)
{
MallBaseId
=
this
.
getLocalStorage
().
MallBaseId
;
this
.
$router
.
go
(
-
1
)
TenantId
=
this
.
getLocalStorage
().
TenantId
;
}
else
{
uid
=
this
.
getLocalStorage
().
ERPEmpId
successCall
(
res
)
}
}
var
md5Str
=
md5
(
`msg=YXZCGL2020×tamp=
${
timestamp
}
&token=
${
token
}
&key=
${
key
}
`
);
},
faildCall
)
var
postData
=
{
"msg"
:
msg
,
"timestamp"
:
timestamp
,
"token"
:
token
,
"sign"
:
md5Str
,
"MallBaseId"
:
MallBaseId
,
"TenantId"
:
TenantId
,
'uid'
:
uid
}
if
(
localStorage
.
g
&&
localStorage
.
g
!=
'undefined'
)
{
postData
.
groupId
=
2
;
}
this
.
$http
.
post
(
apiurl
,
postData
,
{
headers
:
{
'Content-Type'
:
'application/json'
,
'Referer-Viitto'
:
this
.
$route
.
path
}
}
})
}
.
then
(
res
=>
{
if
(
res
.
data
.
resultCode
==
10000
||
res
.
data
.
resultCode
==
10001
)
{
this
.
$router
.
push
({
path
:
'/login'
})
}
else
if
(
res
.
data
.
resultCode
==
10005
)
{
this
.
$router
.
go
(
-
1
)
}
else
{
successCall
(
res
)
}
},
faildCall
)
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment