user-center.js
3.47 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
import {
getBindtapData
} from '../../utils/util';
let app = getApp();
Page({
data: {
authorizeVisible: false,
commonTipsCompVisible: false,
signTipsCompVisible: false,
innerTitle: "留言提交成功!",
innerText: "感谢您宝贵的意见\n我们将尽快回电或回复信息",
// innerButton: "",
userInfo: {}, // 用户数据
signInfo: [], // 签到数据
signNum: 0, // 签到天数
},
onShareAppMessage() {},
showAuth() {
this.setData({
authorizeVisible: true
})
},
onShow() {
},
onLoad(options) {
this.initData();
},
initData() {
this.queryMember().then((result) => {
this.querySignInfo();
});
},
/**
* 点击签到
*/
onSignHandler(evt) {
console.log("onSignHandler");
return new Promise((resolve, reject) => {
app.post({
toast: false,
url: app.api.sign,
}).then((result) => {
this.querySignInfo().then((result2) => {
wx.showModal({
content: '签到成功',
showCancel: false,
success(res) {}
})
})
}).catch((err) => {
let {
code
} = err;
// 用户未审核
if (code == 1002) {
this.setData({
signTipsCompVisible: true
})
}
});
});
},
/**
* 我的二维码
*/
onMyQrcodeHandler(evt) {
app.router.push({
path: "myQrcode"
})
},
/**
* 排行榜
*/
onRankHandler(evt) {
app.router.push({
path: "rank"
})
},
/**
* 点击联系我们
*/
onContactUsHandler(evt) {
app.router.push({
path: "contact"
})
},
/**
* 获取会员信息
*/
queryMember() {
return new Promise((resolve, reject) => {
app.post({
url: app.api.member,
data: {}
}).then((result) => {
this.setData({
userInfo: result
})
resolve();
})
});
},
/**
* 签到信息
*/
querySignInfo() {
return new Promise((resolve, reject) => {
app.post({
url: app.api.signInfo,
data: {}
}).then((result) => {
let signNum = result.signRecord && result.signRecord.length || 0;
console.log("signNum:", signNum);
let resultList = result.signRecord || [];
let signInfo = [];
for (let index = 0; index < 7; index++) {
signInfo.push(resultList[index] ? resultList[index] : "");
}
this.setData({
signInfo: signInfo,
signNum: signNum
})
console.log("signInfo:", signInfo);
resolve();
})
});
},
/**
* 去验证
*/
toVipLogin() {
app.router.push({
path: "vipLogin"
})
},
// 隐藏蒙层
hideMask() {
this.setData({
authorizeVisible: false,
commonTipsCompVisible: false,
signTipsCompVisible: false
})
},
// 子组件事件
evtcomp(evt) {
let {
name,
data
} = evt.detail;
switch (name) {
// 授权完毕
case "_evt_auth_complete":
this.initData();
this.hideMask();
break;
// 通用弹窗组件按钮
case "_evt_common_comp_button":
this.hideMask();
break;
// 去验证
case "_evt_to_verify":
this.hideMask();
this.toVipLogin();
break;
// 隐藏弹窗
case "_evt_hide_mask":
this.hideMask();
break;
default:
break;
}
},
})