-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
Copy pathbutton.js
70 lines (59 loc) · 1.18 KB
/
button.js
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
66
67
68
69
70
const types = ['default', 'primary', 'warn']
const pageObject = {
data: {
defaultSize: 'default',
primarySize: 'default',
warnSize: 'default',
disabled: false,
plain: false,
loading: false
},
onShareAppMessage() {
return {
title: 'button',
path: 'page/component/pages/button/button'
}
},
setDisabled() {
this.setData({
disabled: !this.data.disabled
})
},
setPlain() {
this.setData({
plain: !this.data.plain
})
},
setLoading() {
this.setData({
loading: !this.data.loading
})
},
handleContact(e) {
console.log(e.detail)
},
handleGetPhoneNumber(e) {
console.log(e.detail)
},
handleGetUserInfo(e) {
console.log(e.detail)
},
handleOpenSetting(e) {
console.log(e.detail.authSetting)
},
handleGetUserInfo(e) {
console.log(e.detail.userInfo)
}
}
for (let i = 0; i < types.length; ++i) {
(function (type) {
pageObject[type] = function () {
const key = type + 'Size'
const changedData = {}
changedData[key] =
this.data[key] === 'default' ? 'mini' : 'default'
this.setData(changedData)
}
}(types[i]))
}
Page(pageObject)