index.js
1.12 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
// pages/crowdfunding/components/progress/index.js
Component({
/**
* 组件的属性列表
*/
properties: {
detail: {
type: Object,
value: {}
},
groupInfo: {
type: Object,
value: {},
observer: function (n) {
this.init(n)
}
}
},
/**
* 组件的初始数据
*/
data: {
progress: 0,
count: 0
},
/**
* 组件的方法列表
*/
methods: {
// 初始化
init() {
let data = this.data.groupInfo
let m = 0
let count = 0
if (data.fictitiousLadderQuantity != 0) {
m = this.decimal((data.groupQuantity / data.fictitiousLadderQuantity) * 100, 2)
} else {
m = this.decimal(data.groupQuantity * 100, 2)
}
if (m < 20) {
count = this.decimal(data.progress, 2)
} else {
count = m;
}
this.setData({
progress: Math.min(100,m),
count: Math.min(100,count)
})
},
/**num:要转换的数值,fixed:精确几位小数 */
decimal(num, fixed) {
let pow = Math.pow(10, fixed)
return Math.round(num * pow) / pow
}
}
})