@@ -38,7 +38,13 @@ export class WAUser extends LitElement {
38
38
width: 40px;
39
39
margin-left: -5px;
40
40
display: inline-block;
41
+ transition: color 0.3s ease; /* 添加颜色过渡效果 */
41
42
}
43
+
44
+ #msg.loading {
45
+ color: #777; /* 加载时的灰色 */
46
+ }
47
+
42
48
.user-info-panel {
43
49
position: fixed;
44
50
top: 50px;
@@ -135,6 +141,7 @@ export class WAUser extends LitElement {
135
141
userInfo : { type : Object } ,
136
142
isPopupOpen : { type : Boolean } ,
137
143
registrationCode : { type : String } ,
144
+ isLoading : { type : Boolean } , // 新增加载状态属性
138
145
} ;
139
146
140
147
constructor ( ) {
@@ -146,6 +153,7 @@ export class WAUser extends LitElement {
146
153
} ;
147
154
this . isPopupOpen = false ;
148
155
this . registrationCode = "" ;
156
+ this . isLoading = true ; // 初始化为加载状态
149
157
}
150
158
151
159
firstUpdated ( ) {
@@ -159,8 +167,9 @@ export class WAUser extends LitElement {
159
167
email : window . user . email ,
160
168
role : window . user . role ,
161
169
} ;
170
+ this . isLoading = false ; // 加载完成,更新状态
162
171
this . requestUpdate ( ) ;
163
- console . log ( "userInfo:" , this . userInfo ) ;
172
+ // console.log("userInfo:", this.userInfo);
164
173
clearInterval ( intervalId ) ;
165
174
}
166
175
} , 250 ) ;
@@ -187,6 +196,29 @@ export class WAUser extends LitElement {
187
196
188
197
activateRegistration ( ) {
189
198
console . log ( `註冊碼: ${ this . registrationCode } ` ) ;
199
+ var requestData = JSON . parse ( JSON . stringify ( this . userInfo ) ) ;
200
+ requestData . activationCode = this . registrationCode ;
201
+ // 使用 fetch API 發送 POST 請求
202
+ fetch ( "https://chat.nodered.vip/api/activation" , {
203
+ method : "POST" ,
204
+ headers : {
205
+ "Content-Type" : "application/json" ,
206
+ } ,
207
+ body : JSON . stringify ( requestData ) ,
208
+ } )
209
+ . then ( ( response ) => {
210
+ // 檢查回應是否成功
211
+ if ( ! response . ok ) {
212
+ throw new Error ( "Network response was not ok" ) ;
213
+ }
214
+ return response . json ( ) ;
215
+ } )
216
+ . then ( ( data ) => {
217
+ console . log ( "data:" , data ) ;
218
+ } )
219
+ . catch ( ( error ) => {
220
+ console . log ( "error:" , error ) ;
221
+ } ) ;
190
222
// 在这里添加激活逻辑
191
223
this . closeRegistrationPopup ( ) ;
192
224
}
@@ -205,7 +237,7 @@ export class WAUser extends LitElement {
205
237
d ="M480-480q-66 0-113-47t-47-113q0-66 47-113t113-47q66 0 113 47t47 113q0 66-47 113t-113 47ZM160-160v-112q0-34 17.5-62.5T224-378q62-31 126-46.5T480-440q66 0 130 15.5T736-378q29 15 46.5 43.5T800-272v112H160Z "
206
238
/>
207
239
</ svg >
208
- < span id ="msg "> 帳號</ span >
240
+ < span id ="msg " class =" ${ this . isLoading ? "loading" : "" } " > 帳號</ span >
209
241
</ button >
210
242
211
243
< div class ="user-info-panel ${ this . isOpen ? "open" : "" } ">
0 commit comments