action-bar.js
3.69 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
// page/subPackage/pages/zeroSell/components/action-bar.js
import ZeroSellService from '../../service/zero-sell';
import CommonService from '../../service/common';
import { fomartCountdownTime } from '../../../../utils/util';
const event = global.event;
var app = getApp();
Component({
/**
* 组件的属性列表
*/
properties: {
// UNKNOWN: 0,
// READY: 1, // 未开始
// START: 2, // 参加
// ALEADY: 3, // 已参加活动
// WAIT: 4, // 等待抽奖中
// LUCK: 5, // 抽奖结束
// END: 6, // 活动结束
// PEOPLE_LIMIT_WAIT: 7 // 人数达到活动限制、已满员、人数不足统一为待开奖状态
status: {
type: Number,
value: 1,
},
num: {
type: Number,
value: 0,
},
shareUid: {
type: Number,
value: 0,
},
actId: {
type: Number,
value: 0,
},
copyText: {
type: String,
value: '',
},
text: {
type: String,
value: '',
},
type: {
type: Number,
value: 0,
},
// time in seconds
formatTimeList: {
type: Array,
value: [],
observer(value) {
this.setData({
remainingTime: value.join(':'),
});
},
},
isLogin: {
type: Boolean,
value: false,
},
activityStatus: {
type: Number,
status: 1,
},
},
/**
* 组件的初始数据
*/
data: {
show: false,
code: '',
error: false,
fellow: false,
remainingTime: '',
},
ready() {
this.service = new ZeroSellService();
this.commonService = new CommonService();
},
/**
* 组件的方法列表
*/
methods: {
fetchCode() {
wx.showLoading({
mask: true,
});
event.emit('user-is-login', {
logged: this.getCode.bind(this),
loginSuccess: function() {},
});
},
getCode(userInfo) {
this.service
.fetchCode({
shareUid: this.properties.shareUid,
uid: app.getUid(),
actPrizeId: this.properties.actId,
userThumb: userInfo.avatarUrl,
userName: userInfo.nickName,
})
.then(result => {
wx.hideLoading();
if (result.code === 200) {
this.setData({
show: true,
code: result.data.prizeCode,
});
this.triggerEvent('gaincodesuccess', this.properties.actId);
} else {
this.setData({
error: true,
errorText: result.message,
});
}
});
},
goShare() {
this.triggerEvent('share');
this.setData({
show: false,
error: false,
fellow: false,
});
},
hadJoinToShare() {
this.goShare();
this.triggerEvent('changeStatus');
},
goMyList() {
wx.reLaunch({
url: '/pages/zeroSell/index?tabIndex=3&reload=0',
});
},
goList() {
wx.navigateTo({
url: '/pages/zeroSell/index?reload=0',
});
},
cancelFellow() {
this.setData({
fellow: false,
});
},
cancelAlert() {
this.setData({
show: false,
error: false,
});
this.triggerEvent('changeStatus');
},
openFellowAlert() {
this.setData({
fellow: true,
});
},
hiddenAlert(e) {
this.setData({
show: false,
error: false,
fellow: false,
});
this.triggerEvent('changeStatus');
},
goLogin() {
const event = global.event;
event.emit('user-is-login', {
logged: this.logged,
loginSuccess: this.loginSuccess,
});
},
logged() {},
loginSuccess() {},
},
});