MainPage.ets
22.1 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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
import { router } from '@kit.ArkUI'
import preferencesUtil from '../utils/preferences'
import loginOut from '../utils/loginOut'
import { personData, personCertificateRow, companyWalletTest, companyWalletRow, companyData } from '../api/userType'
import baseUrl from '../utils/baseUrl'
import { getCompanyPersonList } from '../api/originalRecords'
import { companyPersonTest, companyPersonRow } from '../api/recordsType'
import { getCompanyWallet, updateState } from '../api/user'
import { AxiosResponse } from '@ohos/axios'
import { promptAction } from '@kit.ArkUI'
import LoadingDialog from '../dialog/LoadingDialog'
import updatePasswordDialog from '../dialog/updatePasswordDialog'
@Extend(Text)
function textExtend() {
.fontSize(14).lineHeight(19).fontColor('#3d3d3d')
}
@Extend(Text)
function textRight() {
.fontSize(14).lineHeight(19).fontColor('#999')
}
let getTextInfo = (state: string | null) => {
if(state == '0') {
return '已离职'
} else if(state == '1') {
return '确认从业'
} else if(state == '2') {
return '确认离职'
} else {
return ''
}
}
@Component
export default struct MainPage {
dialogController: CustomDialogController = new CustomDialogController({
builder: updatePasswordDialog(),
cornerRadius: 10
})
loadingController: CustomDialogController = new CustomDialogController({
builder: LoadingDialog(),
customStyle: true,
offset: { dx: 0, dy: 0 },
alignment: DialogAlignment.Center,
autoCancel: false
})
@Link userInfo: personData
@Link companyInfo: companyData
@Link personCertificateInfo: personCertificateRow
@State walletData: companyWalletRow | null = null
@State companyData: companyPersonRow | null = null
@Link isEdit: boolean
roleName = preferencesUtil.get('XF_ROLE_NAME', '')
async aboutToAppear() {
let personId = preferencesUtil.get('XF_PERSON_ID', 0)
let companyId = preferencesUtil.get('XF_COMPANY_ID', 0)
if(this.roleName == 'person' && preferencesUtil.get('XF_PERSON_INFO', '')) {
this.userInfo = JSON.parse(preferencesUtil.get('XF_PERSON_INFO', '') as string)
}
if(this.roleName == 'person' || this.roleName == 'unapprovedPerson') {
// 获取公司人员个人信息
const companyInfo: AxiosResponse<companyPersonTest> = await getCompanyPersonList({pageNum: 1, pageSize: 10, personId: Number(personId)})
this.companyData = companyInfo.data.rows[0]
}
// 获取公司钱包信息
const walletInfo: AxiosResponse<companyWalletTest> = await getCompanyWallet({pageNum: 1, pageSize: 10, companyId: Number(companyId)})
this.walletData = walletInfo.data.rows[0]
}
build() {
Stack(){
Column(){
Row(){
Image((baseUrl + this.userInfo?.personalImg) || $r('app.media.userAvatar')).width(80).height(80).borderRadius(40).margin({right: 10})
Text(this.userInfo?.personName).fontSize(16).lineHeight(21).fontWeight(600).fontColor('#fff')
}.width('100%').padding({left: 15,right: 15}).margin({top: 44})
.visibility(this.roleName == 'person' || this.roleName == 'unapprovedPerson' ? Visibility.Visible: Visibility.None)
Row(){
Row(){
Image((baseUrl + this.companyInfo?.businessLicensePic) || $r('app.media.userAvatar')).width(60).height(60).borderRadius(30).margin({right: 10})
Text(this.companyInfo?.companyName).fontSize(14).lineHeight(21).fontWeight(600).fontColor('#fff')
}.layoutWeight(1).justifyContent(FlexAlign.Start)
Column({space: 4}){
Image($r('app.media.wallet')).width(30)
Text(this.walletData?.bean.toString() + '(豆)').fontSize(12).fontColor('#fff')
}.width(80).onClick(() => {
router.pushUrl({
url: "pages/MyWallet"
})
})
}.width('100%').padding({left: 10,right: 10}).margin({top: 44})
.visibility(this.roleName == 'company' ? Visibility.Visible: Visibility.None)
}.width('100%').height(256).padding({left: 15,right: 15})
.linearGradient({angle: 63 ,colors: [['#1B65FD', 0], ['#6D9DFF', 0.5]]})
List(){
// 公司基本信息
ListItem(){
Column(){
Row(){
Text('基本信息').fontWeight(600).textExtend()
Row(){
Text('编辑').fontSize(12).fontColor('#999')
Image($r('app.media.right_4')).width(12).margin({left: 4})
}.onClick(() => {
router.pushUrl({
url: 'pages/EditCompanyInfo'
})
})
}.padding(10).border({width: {bottom: 2}, color: '#eee'})
.justifyContent(FlexAlign.SpaceBetween).width('100%')
Column(){
Row(){
Row(){
Image($r('app.media.username')).width(16).margin({right: 5})
Text('用户名').textExtend()
}
Text(this.companyInfo?.username).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
Row(){
Row(){
Image($r('app.media.enterprise')).width(16).margin({right: 5})
Text('企业名称').textExtend()
}
Text(this.companyInfo?.companyName).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
Row(){
Row(){
Image($r('app.media.business_license')).width(16).margin({right: 5})
Text('营业执照编号').textExtend()
}
Text(this.companyInfo?.businessLicenseNo).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
Row(){
Row(){
Image($r('app.media.idcard')).width(16).margin({right: 5})
Text('联系人').textExtend()
}
Text(this.companyInfo?.linkMan).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
Row(){
Row(){
Image($r('app.media.phone')).width(16).margin({right: 5})
Text('联系人手机号').textExtend()
}
Text(this.companyInfo?.lmTel).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
Row(){
Row(){
Image($r('app.media.email')).width(16).margin({right: 5})
Text('电子邮箱').textExtend()
}
Text(this.companyInfo?.email).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.padding({top: 15, bottom: 15})
.border({width: {bottom: 1}, color: '#eee'})
}.padding({left: 10, right: 10})
}.width('100%').backgroundColor('#fff').borderRadius(10).clip(true)
}.visibility(this.roleName == 'company' ? Visibility.Visible: Visibility.None).margin({bottom: 10})
// 个人基本信息
ListItem(){
Column(){
Row(){
Text('基本信息').fontWeight(600).textExtend()
Row(){
Text('编辑').fontSize(12).fontColor('#999')
Image($r('app.media.right_4')).width(12).margin({left: 4})
}.onClick(() => {
router.pushUrl({
url: 'pages/EditUser'
})
})
}.padding(10).border({width: {bottom: 2}, color: '#eee'})
.justifyContent(FlexAlign.SpaceBetween).width('100%')
Column(){
Row(){
Row(){
Image($r('app.media.username')).width(16).margin({right: 5})
Text('用户名').textExtend()
}
Text(this.userInfo?.username).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
Row(){
Row(){
Image($r('app.media.idcard')).width(16).margin({right: 5})
Text('身份证号').textExtend()
}
Text(this.userInfo?.idNo).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
Row(){
Row(){
Image($r('app.media.sex')).width(16).margin({right: 5})
Text('性别').textExtend()
}
Text(this.userInfo?.gender == '0' ? '男' : '女').textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
Row(){
Row(){
Image($r('app.media.phone')).width(16).margin({right: 5})
Text('手机号码').textExtend()
}
Text(this.userInfo?.phone).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
Row(){
Row(){
Image($r('app.media.email')).width(16).margin({right: 5})
Text('电子邮箱').textExtend()
}
Text(this.userInfo?.email).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.padding({top: 15, bottom: 15})
.border({width: {bottom: 1}, color: '#eee'})
Row(){
Row(){
Image($r('app.media.brithday')).width(16).margin({right: 5})
Text('出生日期').textExtend()
}
Text(this.userInfo?.birthDate).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.padding({top: 15, bottom: 15})
}.padding({left: 10, right: 10})
}.width('100%').backgroundColor('#fff').borderRadius(10).clip(true)
}.visibility(this.roleName == 'person' || this.roleName == 'unapprovedPerson' ? Visibility.Visible: Visibility.None).margin({bottom: 10})
// 证书信息
ListItem(){
Column(){
Row(){
Row({ space: 5 }){
Text('证书信息').fontWeight(600).textExtend()
}
Row(){
Text(this.isEdit ? '编辑' : '添加').fontSize(12).fontColor('#999')
Image($r('app.media.right_4')).width(12).margin({left: 4})
}.onClick(() => {
router.pushUrl({
url: 'pages/CertificateInfo'
})
})
}.padding(10).border({width: {bottom: 2}, color: '#eee'})
.justifyContent(FlexAlign.SpaceBetween).width('100%')
Column(){
Row(){
Row(){
Image($r('app.media.certificate_type')).width(16).margin({right: 5})
Text('证书类型').textExtend()
}
Text(`${this.personCertificateInfo?.certificateLevel}${this.personCertificateInfo?.certificateName}`).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
Row(){
Row(){
Image($r('app.media.certificate_num')).width(16).margin({right: 5})
Text('证书编号').textExtend()
}
Text(this.personCertificateInfo?.certificateNo).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
Row(){
Row(){
Image($r('app.media.date')).width(16).margin({right: 5})
Text('颁发时间').textExtend()
}
Text(this.personCertificateInfo?.issueDate).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.padding({top: 15, bottom: 15})
}.padding({left: 10, right: 10})
}.width('100%').backgroundColor('#fff').borderRadius(10).clip(true)
}.visibility(this.roleName == 'person' || this.roleName == 'unapprovedPerson' ? Visibility.Visible: Visibility.None).margin({bottom: 10})
// 从业信息
ListItem(){
Column(){
Row(){
Text('从业信息').fontWeight(600).textExtend()
Image($r('app.media.refresh')).width(12)
.onClick(async () => {
this.loadingController.open()
let personId = preferencesUtil.get('XF_PERSON_ID', 0)
const companyInfo: AxiosResponse<companyPersonTest> = await getCompanyPersonList({pageNum: 1, pageSize: 10, personId: Number(personId)})
if(companyInfo.data.rows.length > 0) {
this.companyData = companyInfo.data.rows[0]
}
this.loadingController.close()
})
}.padding(10).border({width: {bottom: 2}, color: '#eee'})
.justifyContent(FlexAlign.Start).width('100%')
Column(){
Row(){
Row(){
Image($r('app.media.enterprise')).width(16).margin({right: 5})
Text('所属公司').textExtend()
}
Text(this.companyData?.companyName).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
Row(){
Row(){
Image($r('app.media.certificate_num')).width(16).margin({right: 5})
Text('报告豆余额').textExtend()
}
Text(`${this.walletData?.bean}`).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
Row(){
Row(){
Image($r('app.media.date')).width(16).margin({right: 5})
Text('添加时间').textExtend()
}
Text(this.companyData?.createTime).textRight()
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15})
}.padding({left: 10, right: 10})
Row(){
Row(){
Image($r('app.media.edit')).width(16).margin({right: 5})
Text('操作').textExtend()
}
Text(getTextInfo(this.companyData?.state || '0')).width(80).height(25)
.backgroundColor(this.companyData?.state == '1' ? '#1890ff' : '#C80000')
.fontSize(14).textAlign(TextAlign.Center).fontColor('#fff').borderRadius(8)
.visibility(this.companyData?.state == '0' ? Visibility.None : Visibility.Visible)
.onClick(() => {
AlertDialog.show({
title: '提示',
message: this.companyData?.state == '2' ? `是否从${this.companyData?.companyName}离职` : `是否在${this.companyData?.companyName}就职`,
alignment: DialogAlignment.Center,
primaryButton: {
value: '取消',
action: () => {
console.info('Callback when the first button is clicked')
}
},
secondaryButton: {
enabled: true,
defaultFocus: true,
style: DialogButtonStyle.HIGHLIGHT,
value: '确认',
action: async () => {
if(this.companyData?.state == '2') {
await updateState({ relateId: this.companyData?.relateId, state: '0' })
promptAction.showToast({
message: '已成功离职',
duration: 2000
})
await loginOut()
router.replaceUrl({
url: 'pages/Login'
})
}else {
await updateState({ relateId: this.companyData?.relateId, state: '2' })
promptAction.showToast({
message: '已恢复职位,请重新登录获取新数据',
duration: 2000
})
await loginOut()
router.replaceUrl({
url: 'pages/Login'
})
}
}
}
})
})
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.padding({top: 15, bottom: 15, left: 10, right: 10})
}.width('100%').backgroundColor('#fff').borderRadius(10).clip(true)
}.visibility(this.roleName == 'person' || this.roleName == 'unapprovedPerson' ? Visibility.Visible: Visibility.None).margin({bottom: 10})
// APP信息
ListItem(){
Column(){
Row(){
Text('APP信息').fontWeight(600).textExtend()
}.padding(10).border({width: {bottom: 2}, color: '#eee'})
.justifyContent(FlexAlign.SpaceBetween).width('100%')
Column(){
Row(){
Row(){
Image($r('app.media.user_agreement')).width(16).margin({right: 5})
Text('用户协议').textExtend()
}
Image($r('app.media.right_4')).width(12).margin({left: 4})
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15}).onClick(() => {
router.pushUrl({
url: 'pages/UserAgreement'
})
})
Row(){
Row(){
Image($r('app.media.privacy')).width(16).margin({right: 5})
Text('隐私政策').textExtend()
}
Image($r('app.media.right_4')).width(12).margin({left: 4})
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.border({width: {bottom: 1}, color: '#eee'})
.padding({top: 15, bottom: 15}).onClick(() => {
router.pushUrl({
url: 'pages/PrivacyPolicy'
})
})
Row(){
Row(){
Image($r('app.media.delete')).width(16).margin({right: 5})
Text('注销协议').textExtend()
}
Image($r('app.media.right_4')).width(12).margin({left: 4})
}.width('100%').justifyContent(FlexAlign.SpaceBetween)
.padding({top: 15, bottom: 15}).onClick(() => {
router.pushUrl({
url: 'pages/CancellationAgreement'
})
})
}.padding({left: 10, right: 10})
}.width('100%').backgroundColor('#fff').borderRadius(10).clip(true)
}.margin({bottom: 10})
// 操作按钮
ListItem(){
Column({space: 10}){
Text('修改密码').width('100%').height(50).backgroundColor('#4ECDBE').borderRadius(10)
.fontSize(16).fontColor(Color.White).fontWeight(600).textAlign(TextAlign.Center)
.onClick(() => {
this.dialogController.open()
})
Text('退出登录').width('100%').height(50).backgroundColor('#6D9DFF').borderRadius(10)
.fontSize(16).fontColor(Color.White).fontWeight(600).textAlign(TextAlign.Center)
.onClick(() => {
AlertDialog.show({
title: '提示',
message: '是否退出登录?',
autoCancel: true,
alignment: DialogAlignment.Center,
gridCount: 4,
offset: { dx: 0, dy: -20 },
buttonDirection: DialogButtonDirection.HORIZONTAL,
buttons: [
{
value: '取消',
action: () => {
console.info('Callback when button1 is clicked')
}
},
{
value: '确认',
action: async () => {
await loginOut()
router.replaceUrl({
url: 'pages/Login'
})
}
}
],
cancel: () => {
console.info('Closed callbacks')
}
})
})
Column(){
Text('http://xfapp.crgx.net').fontSize(10).fontColor('#999').lineHeight(18)
Text('非广西消防救援总队官方出品Copyright@广西世纪创软信息技术有限公司').fontSize(10).fontColor('#999').lineHeight(18)
.maxLines(2).textAlign(TextAlign.Center)
}
}
}
}.margin({left: 15, right: 15, top: 144}).borderRadius(10).scrollBar(BarState.Off).layoutWeight(1)
}.height('100%').backgroundColor('#f3f2f7').alignContent(Alignment.Top).padding({bottom: 20})
}
}