help.js
1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var moment = require('moment');
// eslint-disable-next-line no-undef
var Helps = {};
Helps.install = function (Vue, options) {
Vue.prototype.$myMethod = function(){
console.log(options)
}
// 获取单个平台数据
Vue.prototype.$getPlatformItem = function(index){
var platformConfigItem
var platformConfig = this.$store.getters.platformConfig
for(let i = 0; i< platformConfig.length; i++){
if(platformConfig[i].id == index){
platformConfigItem = platformConfig[i]
}
}
return platformConfigItem || {title: "未知"}
}
// 格式化日期
Vue.prototype.$formatUnixDate = function(unix, format = "YYYY-MM-DD HH:mm:ss"){
return moment(parseInt(unix + '000')).format(format)
}
// 格式化日期(相对日期)
Vue.prototype.$formatDate = function (unix, format = "YYYY-MM-DD HH:mm:ss") {
return moment(parseInt(unix + '000')).format(format)
}
// 格式化日期(相对日期)
Vue.prototype.$formatFromNowDate = function(unix){
if(moment().format("YYYYMMDD") == moment(parseInt(unix + '000')).format("YYYYMMDD")){
return moment(parseInt(unix + '000')).format("HH:mm")
}
return moment(parseInt(unix + '000')).format("YYYY-MM-DD HH:mm")
}
Vue.prototype.$robotNickname = function(id){
var nickname
var robots = this.$store.getters.robots
for(let i = 0; i< robots.length; i++){
if(robots[i].id == id){
nickname = robots[i].nickname
}
}
return nickname
}
}
export default Helps;