time.js
1.3 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// components/time/time.js
const h=function(){
let hs=[]
for(let i=0;i<24;i++){
hs.push((i>9?i:'0'+i)+' 时')
}
return hs
}
Component({
/**
* 组件的属性列表
*/
properties: {
ustime:{
type:String,
value:''
}
},
observers:{
"ustime":function(ustime){
this.initMultiIndex(ustime)
},
},
attached: function() {
// 在组件实例进入页面节点树时执行
this.initMultiIndex(this.data.value)
},
/**
* 组件的初始数据
*/
data: {
multiArray: [
h(),
['00 分', '30 分']
],
multiIndex:[0,0]
},
/**
* 组件的方法列表
*/
methods: {
initMultiIndex(time=''){
time=time.split(':')
let index1=0,index2=0
this.data.multiArray[0].some((v,i)=>{
if(v.indexOf(time[0])>-1){
index1=i;
return true;
}
})
console.log('initMultiIndex',time,time[1]==30)
index2=time[1]==30?1:0;
this.setData({
multiIndex:[index1,index2],
})
},
bindPickerChange(e){
console.log(e.detail.value)
let multiIndex=e.detail.value
let h=this.data.multiArray[0][multiIndex[0]].substr(0,2)
let m=this.data.multiArray[1][multiIndex[1]].substr(0,2)
this.triggerEvent('event',{time:h+':'+m})
},
}
})