jmash-core-mp 0.1.21 → 0.1.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/.editorconfig +9 -9
  2. package/README.md +60 -60
  3. package/babel.config.json +34 -34
  4. package/eslint.config.mjs +7 -7
  5. package/lib/api/auth/index.d.ts +21 -21
  6. package/lib/api/auth/index.js +199 -199
  7. package/lib/api/auth/types.d.ts +86 -86
  8. package/lib/api/auth/types.js +9 -9
  9. package/lib/api/cms/index.d.ts +20 -20
  10. package/lib/api/cms/index.js +161 -161
  11. package/lib/api/cms/types.d.ts +200 -200
  12. package/lib/api/cms/types.js +1 -1
  13. package/lib/api/constant.d.ts +5 -5
  14. package/lib/api/constant.js +6 -6
  15. package/lib/api/dict/index.d.ts +18 -18
  16. package/lib/api/dict/index.js +34 -34
  17. package/lib/api/dict/types.d.ts +28 -28
  18. package/lib/api/dict/types.js +1 -1
  19. package/lib/api/dicts.d.ts +18 -18
  20. package/lib/api/dicts.js +67 -67
  21. package/lib/api/files/index.d.ts +25 -25
  22. package/lib/api/files/index.js +135 -135
  23. package/lib/api/files/types.d.ts +38 -38
  24. package/lib/api/files/types.js +1 -1
  25. package/lib/api/index.d.ts +4 -4
  26. package/lib/api/index.js +6 -6
  27. package/lib/api/myorgan/types.d.ts +22 -22
  28. package/lib/api/myorgan/types.js +1 -1
  29. package/lib/api/region/index.d.ts +7 -7
  30. package/lib/api/region/index.js +19 -19
  31. package/lib/api/region/types.d.ts +19 -19
  32. package/lib/api/region/types.js +1 -1
  33. package/lib/api/storage/index.d.ts +10 -10
  34. package/lib/api/storage/index.js +43 -43
  35. package/lib/api/storage/types.d.ts +28 -28
  36. package/lib/api/storage/types.js +1 -1
  37. package/lib/api/types.d.ts +42 -42
  38. package/lib/api/types.js +1 -1
  39. package/lib/app.mpx.d.ts +1 -1
  40. package/lib/components/auth-user/jmash-update-user.mpx.d.ts +1 -1
  41. package/lib/components/auth-user/jmash-user.mpx.d.ts +1 -1
  42. package/lib/components/cms/jmash-cms-acticle-list.mpx.d.ts +1 -1
  43. package/lib/components/cms/jmash-cms-article-item.mpx.d.ts +1 -1
  44. package/lib/components/cms/jmash-cms-article-view.mpx.d.ts +1 -0
  45. package/lib/components/cms/jmash-cms-article.mpx.d.ts +1 -1
  46. package/lib/components/cms/jmash-cms-like.mpx.d.ts +1 -1
  47. package/lib/components/common/jmash-upload-picture.mpx.d.ts +1 -0
  48. package/lib/components/core/jmash-login.mpx.d.ts +1 -0
  49. package/lib/index.d.ts +21 -21
  50. package/lib/index.js +14 -14
  51. package/lib/packages/pages/cms/cms-article-list.mpx.d.ts +1 -1
  52. package/lib/pages/index.mpx.d.ts +1 -0
  53. package/lib/store/user.d.ts +31 -31
  54. package/lib/store/user.js +227 -227
  55. package/lib/utils/common.d.ts +35 -35
  56. package/lib/utils/common.js +166 -166
  57. package/lib/utils/config.d.ts +5 -5
  58. package/lib/utils/config.js +29 -29
  59. package/lib/utils/db.d.ts +21 -21
  60. package/lib/utils/db.js +84 -84
  61. package/lib/utils/grpc.d.ts +5 -5
  62. package/lib/utils/grpc.js +20 -20
  63. package/lib/utils/net.d.ts +7 -7
  64. package/lib/utils/net.js +15 -15
  65. package/lib/utils/request.d.ts +2 -2
  66. package/lib/utils/request.js +123 -123
  67. package/mpx.config.js +27 -27
  68. package/package.json +1 -1
  69. package/postcss.config.js +11 -11
  70. package/project.config.json +24 -24
  71. package/project.private.config.json +13 -13
  72. package/public/index.html +15 -15
  73. package/src/api/auth/index.ts +227 -227
  74. package/src/api/auth/types.ts +166 -166
  75. package/src/api/cms/index.ts +218 -218
  76. package/src/api/cms/types.ts +379 -379
  77. package/src/api/constant.ts +6 -6
  78. package/src/api/dict/index.ts +44 -44
  79. package/src/api/dict/types.ts +49 -49
  80. package/src/api/dicts.ts +72 -72
  81. package/src/api/files/index.ts +163 -163
  82. package/src/api/files/types.ts +67 -67
  83. package/src/api/index.ts +11 -11
  84. package/src/api/myorgan/types.ts +42 -42
  85. package/src/api/region/index.ts +23 -23
  86. package/src/api/region/types.ts +36 -36
  87. package/src/api/storage/index.ts +62 -62
  88. package/src/api/storage/types.ts +54 -54
  89. package/src/api/types.ts +72 -72
  90. package/src/app.mpx +71 -71
  91. package/src/components/auth-user/jmash-logout.mpx +91 -91
  92. package/src/components/auth-user/jmash-update-user.mpx +386 -386
  93. package/src/components/auth-user/jmash-update-user.web.mpx +366 -366
  94. package/src/components/auth-user/jmash-user.mpx +359 -359
  95. package/src/components/cms/jmash-cms-acticle-list.mpx +182 -182
  96. package/src/components/cms/jmash-cms-article-item.mpx +241 -241
  97. package/src/components/cms/jmash-cms-article-view.mpx +131 -131
  98. package/src/components/cms/jmash-cms-article.mpx +68 -68
  99. package/src/components/cms/jmash-cms-like.mpx +151 -151
  100. package/src/components/common/jmash-avatar-edit.mpx +153 -153
  101. package/src/components/common/jmash-cascader-region.mpx +112 -112
  102. package/src/components/common/jmash-menu.mpx +129 -129
  103. package/src/components/common/jmash-none-data.mpx +82 -82
  104. package/src/components/common/jmash-pic-swiper.mpx +71 -71
  105. package/src/components/common/jmash-popup.mpx +137 -137
  106. package/src/components/common/jmash-search.mpx +126 -126
  107. package/src/components/common/jmash-single-btn.mpx +53 -53
  108. package/src/components/common/jmash-stepper.mpx +214 -214
  109. package/src/components/common/jmash-tab-bar.mpx +50 -50
  110. package/src/components/common/jmash-textarea.mpx +88 -88
  111. package/src/components/common/jmash-top-navigation.mpx +203 -203
  112. package/src/components/common/jmash-upload-picture.mpx +129 -126
  113. package/src/components/core/jmash-cms-protocol.mpx +66 -66
  114. package/src/components/core/jmash-login.ali.mpx +284 -284
  115. package/src/components/core/jmash-login.mpx +348 -348
  116. package/src/components/core/jmash-login.web.mpx +421 -421
  117. package/src/components/core/jmash-popup-login.ali.mpx +311 -311
  118. package/src/components/core/jmash-popup-login.mpx +415 -415
  119. package/src/components/core/jmash-popup-login.web.mpx +389 -389
  120. package/src/custom-tab-bar/index.mpx +10 -10
  121. package/src/global.d.ts +11 -11
  122. package/src/index.ts +71 -71
  123. package/src/packages/index.mpx +10 -10
  124. package/src/packages/pages/auth/cms-protocol.mpx +31 -31
  125. package/src/packages/pages/auth/login.mpx +59 -59
  126. package/src/packages/pages/auth/update-user.mpx +17 -17
  127. package/src/packages/pages/cms/cms-article-list.mpx +164 -164
  128. package/src/packages/pages/cms/cms-article.mpx +32 -32
  129. package/src/pages/basic-component.mpx +30 -30
  130. package/src/pages/half-home.mpx +58 -58
  131. package/src/pages/home.mpx +52 -52
  132. package/src/pages/home2.mpx +47 -47
  133. package/src/pages/index.mpx +13 -3
  134. package/src/pages/tabbar/home.mpx +77 -77
  135. package/src/pages/tabbar/my.mpx +80 -80
  136. package/src/store/user.ts +270 -270
  137. package/src/styles/index.scss +20 -20
  138. package/src/styles/vars.scss +27 -27
  139. package/src/utils/common.ts +179 -179
  140. package/src/utils/config.ts +35 -35
  141. package/src/utils/db.ts +100 -100
  142. package/src/utils/grpc.ts +21 -21
  143. package/src/utils/net.ts +18 -18
  144. package/src/utils/request.ts +134 -134
  145. package/static/ali/mini.project.json +4 -4
  146. package/static/dd/project.config.json +15 -15
  147. package/static/swan/project.swan.json +14 -14
  148. package/static/tt/project.config.json +11 -11
  149. package/static/wx/project.config.json +40 -40
  150. package/uno.config.js +9 -9
@@ -1,386 +1,386 @@
1
- <template>
2
- <!-- 我的页面 中个人信息编辑页面 -->
3
- <view class="my-information">
4
- <view class="main">
5
- <!-- 头像区域 -->
6
- <view class="main-profile" wx:if="{{ isUserAvatar }}">
7
- <view class="profile-left">头像</view>
8
- <view class="profile-right">
9
- <button class="avatar-wrapper" plain open-type="chooseAvatar" bind:chooseavatar@wx="onChooseAvatar"
10
- onChooseAvatar@ali="onChooseAvatar">
11
- <image class="avatar-img" src="{{ resourceUrl + '/components/gray_head2x.png' }}" mode="aspectFill"
12
- wx:if="{{ !userInfo.avatar }}" />
13
- <image class="avatar-img" src="{{ imageUrl + userInfo.avatar }}" mode="aspectFill" wx:else />
14
- <view class="avatar-badge">
15
- <text class="badge-icon">✎</text>
16
- </view>
17
- </button>
18
- </view>
19
- </view>
20
-
21
- <!-- 昵称 -->
22
- <view class="main-nickname" wx:if="{{ isUserNickName }}">
23
- <view class="nickname-left">昵称</view>
24
- <view class="nickname-right">
25
- <input wx:model="{{ userInfo.nickName }}" wx:model-prop="value" type="nickname" class="nickname-input"
26
- placeholder="请输入昵称" />
27
- </view>
28
- </view>
29
-
30
- <!-- 姓名 -->
31
- <view class="main-nickname" wx:if="{{ isUserRealName }}">
32
- <view class="nickname-left">姓名</view>
33
- <view class="nickname-right">
34
- <input wx:model="{{ userInfo.realName }}" wx:model-prop="value" type="text" class="nickname-input"
35
- placeholder="请输入姓名" />
36
- </view>
37
- </view>
38
-
39
- <!-- 手机号 -->
40
- <view class="main-phone" wx:if="{{ isUserMobilePhone }}">
41
- <view class="phone-left">手机号</view>
42
- <view class="phone-right">
43
- <view class="phone-number">{{ userInfo.mobilePhone }}</view>
44
- <!-- 微信 -->
45
- <button open-type="getPhoneNumber" class="phone-right-btn" bindgetphonenumber="getPhoneNumberWechat"
46
- wx:if="{{ isChangePhone && __mpx_mode__ === 'wx' }}">更换手机号</button>
47
- <!-- 支付宝 -->
48
- <button open-type="getAuthorize" scope="phoneNumber" class="phone-right-btn"
49
- wx:if="{{ isChangePhone && __mpx_mode__ === 'ali' }}" onGetAuthorize="getPhoneNumberAli"
50
- onError="onPhoneAuthFail">更换手机号</button>
51
- </view>
52
- </view>
53
- </view>
54
-
55
- <!-- 保存按钮 -->
56
- <view class="main-btn">
57
- <button class="main-btn-item" bindtap="handleUpdateUser">保存</button>
58
- </view>
59
- </view>
60
- </template>
61
-
62
- <script lang="ts">
63
- import mpx, { createComponent } from '@mpxjs/core'
64
- import { UpdateUserReq, UserInfo } from '../../api/auth/types'
65
- import { authApi } from '../../api/auth/index'
66
- import { fileApi } from '../../api/files/index';
67
- import { FileInfo } from '../../api/files/types';
68
- import { useUserStore } from '../../store/user';
69
-
70
- createComponent({
71
- properties: {
72
- // 是否显示用户头像
73
- isUserAvatar: {
74
- type: Boolean,
75
- value: true
76
- },
77
- // 是否显示昵称
78
- isUserNickName: {
79
- type: Boolean,
80
- value: true
81
- },
82
- // 是否显示姓名
83
- isUserRealName: {
84
- type: Boolean,
85
- value: true
86
- },
87
- // 是否显示手机号
88
- isUserMobilePhone: {
89
- type: Boolean,
90
- value: true
91
- },
92
- // 是否显示更换手机号
93
- isChangePhone: {
94
- type: Boolean,
95
- value: true
96
- }
97
- },
98
- data: {
99
- resourceUrl: getApp().globalData.config.resourceUrl + "/images",
100
- imageUrl: getApp().globalData.config.baseUrl + "/v1/file/path/",
101
- userInfo: {} as UserInfo,
102
- userStore: {} as any,
103
- },
104
- ready() {
105
- this.userStore = useUserStore();
106
- this.getUserInfo();
107
- },
108
- /**
109
- * 组件的方法列表
110
- */
111
- methods: {
112
- // 获取用户信息
113
- getUserInfo(cache: boolean = true) {
114
- console.log("getUserInfo");
115
- this.userStore.getUserInfo(cache).then((resp: UserInfo) => {
116
- this.userInfo = resp;
117
- });
118
- },
119
-
120
- // 获取微信头像
121
- onChooseAvatar(e: any) {
122
- console.log("onChooseAvatar", e);
123
- const { avatarUrl } = e.detail;
124
- fileApi.uploadFile(avatarUrl).then((res: FileInfo) => {
125
- console.log("uploadFile1", res);
126
- this.userInfo.avatar = res.fileSrc;
127
- });
128
- },
129
-
130
- // 更换手机号
131
- getPhoneNumberWechat(e: any) {
132
- console.log("getPhoneNumber", e);
133
- const config = getApp().globalData.config;
134
- if (e.detail.errMsg === "getPhoneNumber:ok") {
135
- // 授权成功后,调用rbac模块接口 已登陆状态小程序更换绑定手机号
136
- authApi.replaceBindphone({
137
- appId: config.appId,
138
- phoneCode: e.detail.code,
139
- componentAppid: config.componentAppid
140
- }).then((res) => {
141
- if (res.data) {
142
- this.getUserInfo(false);
143
- }
144
- })
145
- }
146
- },
147
- getPhoneNumberAli(e: any) {
148
- console.log("getPhoneNumber", e);
149
- const config = getApp().globalData.config;
150
- // 支付宝小程序获取手机号
151
- my.getPhoneNumber({
152
- success: (res: any) => {
153
- console.log("手机号授权", res);
154
- const { response } = res;
155
- authApi.replaceBindphone({
156
- appId: config.appId,
157
- phoneCode: response,
158
- componentAppid: config.componentAppid
159
- }).then((res) => {
160
- if (res.data) {
161
- this.getUserInfo(false);
162
- }
163
- })
164
- },
165
- fail: () => {
166
- mpx.showToast({
167
- title: "您已取消授权",
168
- icon: "none",
169
- duration: 2000,
170
- });
171
- }
172
- });
173
- },
174
- // 更新用户信息
175
- handleUpdateUser() {
176
- let updateReq: UpdateUserReq = { ...this.userInfo } as UpdateUserReq;
177
- updateReq.requestId = Math.random() * 10 + "";
178
- updateReq.updateMask = "nickName,avatar,realName";
179
- authApi.updateUserInfo(updateReq).then((res) => {
180
- // 保存成功后重新设置本地缓存信息,并跳转到我的页面
181
- if (res.statusCode === 200) {
182
- this.userStore.setUserInfo(res.data);
183
- mpx.navigateBack({
184
- delta: 1
185
- });
186
- };
187
- });
188
- },
189
- // 手机号授权失败回调
190
- onPhoneAuthFail() {
191
- mpx.showToast({
192
- title: "手机号授权失败",
193
- icon: "none",
194
- duration: 2000,
195
- });
196
- }
197
- }
198
- }
199
-
200
- )
201
- </script>
202
-
203
- <style lang="scss">
204
- @use "../../styles/index.scss" as *;
205
-
206
- // 颜色变量
207
- $primary: #07c160;
208
- $primary-dark: #06ad56;
209
- $text-1: #111111;
210
- $text-2: #555555;
211
- $text-3: #888888;
212
- $border: #e8e8e8;
213
- $bg-page: #f2f2f2;
214
- $bg-card: #ffffff;
215
-
216
- .my-information {
217
- background-color: $bg-page;
218
- width: 100%;
219
- min-height: 100vh;
220
- position: relative;
221
- padding: 30rpx 0;
222
-
223
- .main {
224
- background-color: $bg-card;
225
- margin: 0 30rpx;
226
- border-radius: 24rpx;
227
- overflow: hidden;
228
- box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
229
-
230
- .main-profile,
231
- .main-nickname,
232
- .main-phone {
233
- display: flex;
234
- justify-content: space-between;
235
- align-items: center;
236
- height: 120rpx;
237
- padding: 0 32rpx;
238
- border-bottom: 1rpx solid $border;
239
- transition: background-color 0.2s;
240
-
241
- &:last-child {
242
- border-bottom: none;
243
- }
244
-
245
- &:active {
246
- background-color: rgba(0, 0, 0, 0.02);
247
- }
248
-
249
- .profile-left,
250
- .nickname-left,
251
- .phone-left {
252
- font-size: 30rpx;
253
- color: $text-1;
254
- font-weight: 500;
255
- }
256
-
257
- .profile-right {
258
- .avatar-wrapper {
259
- position: relative;
260
- margin: 0;
261
- padding: 0;
262
- background: transparent;
263
- line-height: 1;
264
- border: 0;
265
-
266
- &::after {
267
- display: none;
268
- }
269
-
270
- .avatar-img {
271
- width: 88rpx;
272
- height: 88rpx;
273
- border-radius: 50%;
274
- border: 2rpx solid $border;
275
- display: block;
276
- }
277
-
278
- .avatar-badge {
279
- position: absolute;
280
- right: -4rpx;
281
- bottom: -4rpx;
282
- width: 36rpx;
283
- height: 36rpx;
284
- background: $primary;
285
- border-radius: 50%;
286
- border: 2rpx solid $bg-card;
287
- display: flex;
288
- align-items: center;
289
- justify-content: center;
290
-
291
- .badge-icon {
292
- font-size: 16rpx;
293
- color: #fff;
294
- }
295
- }
296
- }
297
- }
298
-
299
- .nickname-right,
300
- .phone-right {
301
- display: flex;
302
- justify-content: flex-end;
303
- align-items: center;
304
- flex: 1;
305
- margin-left: 30rpx;
306
- }
307
-
308
- .nickname-input {
309
- flex: 1;
310
- text-align: right;
311
- font-size: 30rpx;
312
- color: $text-1;
313
- background: transparent;
314
- border: none;
315
- outline: none;
316
- height: 80rpx;
317
- line-height: 80rpx;
318
- padding: 0;
319
-
320
- &::placeholder {
321
- color: $text-3;
322
- }
323
- }
324
-
325
- .phone-right {
326
- .phone-number {
327
- font-size: 30rpx;
328
- color: $text-1;
329
- font-weight: 500;
330
- }
331
-
332
- .phone-right-btn {
333
- background-color: #e6f7ff;
334
- border-radius: 24rpx;
335
- margin-left: 20rpx;
336
- border: none;
337
- font-size: 24rpx;
338
- color: $primary;
339
- padding: 12rpx 24rpx;
340
- height: auto;
341
- line-height: 1.4;
342
- }
343
- }
344
- }
345
-
346
- .main-phone {
347
- border-bottom: none;
348
- }
349
- }
350
-
351
- // 保存按钮样式
352
- .main-btn {
353
- display: flex;
354
- justify-content: center;
355
- align-items: center;
356
- padding: 60rpx 30rpx;
357
- }
358
-
359
- .main-btn-item {
360
- width: 100%;
361
- height: 88rpx;
362
- border-radius: 44rpx;
363
- font-size: 32rpx;
364
- font-weight: 600;
365
- letter-spacing: 2rpx;
366
- background-color: $primary;
367
- color: #fff;
368
- border: none;
369
- display: flex;
370
- align-items: center;
371
- justify-content: center;
372
- transition: background-color 0.2s;
373
- box-shadow: 0 4rpx 12rpx rgba(7, 193, 96, 0.3);
374
-
375
- &:active {
376
- background-color: $primary-dark;
377
- }
378
- }
379
- }
380
- </style>
381
-
382
- <script type="application/json">
383
- {
384
- "component": true
385
- }
386
- </script>
1
+ <template>
2
+ <!-- 我的页面 中个人信息编辑页面 -->
3
+ <view class="my-information">
4
+ <view class="main">
5
+ <!-- 头像区域 -->
6
+ <view class="main-profile" wx:if="{{ isUserAvatar }}">
7
+ <view class="profile-left">头像</view>
8
+ <view class="profile-right">
9
+ <button class="avatar-wrapper" plain open-type="chooseAvatar" bind:chooseavatar@wx="onChooseAvatar"
10
+ onChooseAvatar@ali="onChooseAvatar">
11
+ <image class="avatar-img" src="{{ resourceUrl + '/components/gray_head2x.png' }}" mode="aspectFill"
12
+ wx:if="{{ !userInfo.avatar }}" />
13
+ <image class="avatar-img" src="{{ imageUrl + userInfo.avatar }}" mode="aspectFill" wx:else />
14
+ <view class="avatar-badge">
15
+ <text class="badge-icon">✎</text>
16
+ </view>
17
+ </button>
18
+ </view>
19
+ </view>
20
+
21
+ <!-- 昵称 -->
22
+ <view class="main-nickname" wx:if="{{ isUserNickName }}">
23
+ <view class="nickname-left">昵称</view>
24
+ <view class="nickname-right">
25
+ <input wx:model="{{ userInfo.nickName }}" wx:model-prop="value" type="nickname" class="nickname-input"
26
+ placeholder="请输入昵称" />
27
+ </view>
28
+ </view>
29
+
30
+ <!-- 姓名 -->
31
+ <view class="main-nickname" wx:if="{{ isUserRealName }}">
32
+ <view class="nickname-left">姓名</view>
33
+ <view class="nickname-right">
34
+ <input wx:model="{{ userInfo.realName }}" wx:model-prop="value" type="text" class="nickname-input"
35
+ placeholder="请输入姓名" />
36
+ </view>
37
+ </view>
38
+
39
+ <!-- 手机号 -->
40
+ <view class="main-phone" wx:if="{{ isUserMobilePhone }}">
41
+ <view class="phone-left">手机号</view>
42
+ <view class="phone-right">
43
+ <view class="phone-number">{{ userInfo.mobilePhone }}</view>
44
+ <!-- 微信 -->
45
+ <button open-type="getPhoneNumber" class="phone-right-btn" bindgetphonenumber="getPhoneNumberWechat"
46
+ wx:if="{{ isChangePhone && __mpx_mode__ === 'wx' }}">更换手机号</button>
47
+ <!-- 支付宝 -->
48
+ <button open-type="getAuthorize" scope="phoneNumber" class="phone-right-btn"
49
+ wx:if="{{ isChangePhone && __mpx_mode__ === 'ali' }}" onGetAuthorize="getPhoneNumberAli"
50
+ onError="onPhoneAuthFail">更换手机号</button>
51
+ </view>
52
+ </view>
53
+ </view>
54
+
55
+ <!-- 保存按钮 -->
56
+ <view class="main-btn">
57
+ <button class="main-btn-item" bindtap="handleUpdateUser">保存</button>
58
+ </view>
59
+ </view>
60
+ </template>
61
+
62
+ <script lang="ts">
63
+ import mpx, { createComponent } from '@mpxjs/core'
64
+ import { UpdateUserReq, UserInfo } from '../../api/auth/types'
65
+ import { authApi } from '../../api/auth/index'
66
+ import { fileApi } from '../../api/files/index';
67
+ import { FileInfo } from '../../api/files/types';
68
+ import { useUserStore } from '../../store/user';
69
+
70
+ createComponent({
71
+ properties: {
72
+ // 是否显示用户头像
73
+ isUserAvatar: {
74
+ type: Boolean,
75
+ value: true
76
+ },
77
+ // 是否显示昵称
78
+ isUserNickName: {
79
+ type: Boolean,
80
+ value: true
81
+ },
82
+ // 是否显示姓名
83
+ isUserRealName: {
84
+ type: Boolean,
85
+ value: true
86
+ },
87
+ // 是否显示手机号
88
+ isUserMobilePhone: {
89
+ type: Boolean,
90
+ value: true
91
+ },
92
+ // 是否显示更换手机号
93
+ isChangePhone: {
94
+ type: Boolean,
95
+ value: true
96
+ }
97
+ },
98
+ data: {
99
+ resourceUrl: getApp().globalData.config.resourceUrl + "/images",
100
+ imageUrl: getApp().globalData.config.baseUrl + "/v1/file/path/",
101
+ userInfo: {} as UserInfo,
102
+ userStore: {} as any,
103
+ },
104
+ ready() {
105
+ this.userStore = useUserStore();
106
+ this.getUserInfo();
107
+ },
108
+ /**
109
+ * 组件的方法列表
110
+ */
111
+ methods: {
112
+ // 获取用户信息
113
+ getUserInfo(cache: boolean = true) {
114
+ console.log("getUserInfo");
115
+ this.userStore.getUserInfo(cache).then((resp: UserInfo) => {
116
+ this.userInfo = resp;
117
+ });
118
+ },
119
+
120
+ // 获取微信头像
121
+ onChooseAvatar(e: any) {
122
+ console.log("onChooseAvatar", e);
123
+ const { avatarUrl } = e.detail;
124
+ fileApi.uploadFile(avatarUrl).then((res: FileInfo) => {
125
+ console.log("uploadFile1", res);
126
+ this.userInfo.avatar = res.fileSrc;
127
+ });
128
+ },
129
+
130
+ // 更换手机号
131
+ getPhoneNumberWechat(e: any) {
132
+ console.log("getPhoneNumber", e);
133
+ const config = getApp().globalData.config;
134
+ if (e.detail.errMsg === "getPhoneNumber:ok") {
135
+ // 授权成功后,调用rbac模块接口 已登陆状态小程序更换绑定手机号
136
+ authApi.replaceBindphone({
137
+ appId: config.appId,
138
+ phoneCode: e.detail.code,
139
+ componentAppid: config.componentAppid
140
+ }).then((res) => {
141
+ if (res.data) {
142
+ this.getUserInfo(false);
143
+ }
144
+ })
145
+ }
146
+ },
147
+ getPhoneNumberAli(e: any) {
148
+ console.log("getPhoneNumber", e);
149
+ const config = getApp().globalData.config;
150
+ // 支付宝小程序获取手机号
151
+ my.getPhoneNumber({
152
+ success: (res: any) => {
153
+ console.log("手机号授权", res);
154
+ const { response } = res;
155
+ authApi.replaceBindphone({
156
+ appId: config.appId,
157
+ phoneCode: response,
158
+ componentAppid: config.componentAppid
159
+ }).then((res) => {
160
+ if (res.data) {
161
+ this.getUserInfo(false);
162
+ }
163
+ })
164
+ },
165
+ fail: () => {
166
+ mpx.showToast({
167
+ title: "您已取消授权",
168
+ icon: "none",
169
+ duration: 2000,
170
+ });
171
+ }
172
+ });
173
+ },
174
+ // 更新用户信息
175
+ handleUpdateUser() {
176
+ let updateReq: UpdateUserReq = { ...this.userInfo } as UpdateUserReq;
177
+ updateReq.requestId = Math.random() * 10 + "";
178
+ updateReq.updateMask = "nickName,avatar,realName";
179
+ authApi.updateUserInfo(updateReq).then((res) => {
180
+ // 保存成功后重新设置本地缓存信息,并跳转到我的页面
181
+ if (res.statusCode === 200) {
182
+ this.userStore.setUserInfo(res.data);
183
+ mpx.navigateBack({
184
+ delta: 1
185
+ });
186
+ };
187
+ });
188
+ },
189
+ // 手机号授权失败回调
190
+ onPhoneAuthFail() {
191
+ mpx.showToast({
192
+ title: "手机号授权失败",
193
+ icon: "none",
194
+ duration: 2000,
195
+ });
196
+ }
197
+ }
198
+ }
199
+
200
+ )
201
+ </script>
202
+
203
+ <style lang="scss">
204
+ @use "../../styles/index.scss" as *;
205
+
206
+ // 颜色变量
207
+ $primary: #07c160;
208
+ $primary-dark: #06ad56;
209
+ $text-1: #111111;
210
+ $text-2: #555555;
211
+ $text-3: #888888;
212
+ $border: #e8e8e8;
213
+ $bg-page: #f2f2f2;
214
+ $bg-card: #ffffff;
215
+
216
+ .my-information {
217
+ background-color: $bg-page;
218
+ width: 100%;
219
+ min-height: 100vh;
220
+ position: relative;
221
+ padding: 30rpx 0;
222
+
223
+ .main {
224
+ background-color: $bg-card;
225
+ margin: 0 30rpx;
226
+ border-radius: 24rpx;
227
+ overflow: hidden;
228
+ box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.05);
229
+
230
+ .main-profile,
231
+ .main-nickname,
232
+ .main-phone {
233
+ display: flex;
234
+ justify-content: space-between;
235
+ align-items: center;
236
+ height: 120rpx;
237
+ padding: 0 32rpx;
238
+ border-bottom: 1rpx solid $border;
239
+ transition: background-color 0.2s;
240
+
241
+ &:last-child {
242
+ border-bottom: none;
243
+ }
244
+
245
+ &:active {
246
+ background-color: rgba(0, 0, 0, 0.02);
247
+ }
248
+
249
+ .profile-left,
250
+ .nickname-left,
251
+ .phone-left {
252
+ font-size: 30rpx;
253
+ color: $text-1;
254
+ font-weight: 500;
255
+ }
256
+
257
+ .profile-right {
258
+ .avatar-wrapper {
259
+ position: relative;
260
+ margin: 0;
261
+ padding: 0;
262
+ background: transparent;
263
+ line-height: 1;
264
+ border: 0;
265
+
266
+ &::after {
267
+ display: none;
268
+ }
269
+
270
+ .avatar-img {
271
+ width: 88rpx;
272
+ height: 88rpx;
273
+ border-radius: 50%;
274
+ border: 2rpx solid $border;
275
+ display: block;
276
+ }
277
+
278
+ .avatar-badge {
279
+ position: absolute;
280
+ right: -4rpx;
281
+ bottom: -4rpx;
282
+ width: 36rpx;
283
+ height: 36rpx;
284
+ background: $primary;
285
+ border-radius: 50%;
286
+ border: 2rpx solid $bg-card;
287
+ display: flex;
288
+ align-items: center;
289
+ justify-content: center;
290
+
291
+ .badge-icon {
292
+ font-size: 16rpx;
293
+ color: #fff;
294
+ }
295
+ }
296
+ }
297
+ }
298
+
299
+ .nickname-right,
300
+ .phone-right {
301
+ display: flex;
302
+ justify-content: flex-end;
303
+ align-items: center;
304
+ flex: 1;
305
+ margin-left: 30rpx;
306
+ }
307
+
308
+ .nickname-input {
309
+ flex: 1;
310
+ text-align: right;
311
+ font-size: 30rpx;
312
+ color: $text-1;
313
+ background: transparent;
314
+ border: none;
315
+ outline: none;
316
+ height: 80rpx;
317
+ line-height: 80rpx;
318
+ padding: 0;
319
+
320
+ &::placeholder {
321
+ color: $text-3;
322
+ }
323
+ }
324
+
325
+ .phone-right {
326
+ .phone-number {
327
+ font-size: 30rpx;
328
+ color: $text-1;
329
+ font-weight: 500;
330
+ }
331
+
332
+ .phone-right-btn {
333
+ background-color: #e6f7ff;
334
+ border-radius: 24rpx;
335
+ margin-left: 20rpx;
336
+ border: none;
337
+ font-size: 24rpx;
338
+ color: $primary;
339
+ padding: 12rpx 24rpx;
340
+ height: auto;
341
+ line-height: 1.4;
342
+ }
343
+ }
344
+ }
345
+
346
+ .main-phone {
347
+ border-bottom: none;
348
+ }
349
+ }
350
+
351
+ // 保存按钮样式
352
+ .main-btn {
353
+ display: flex;
354
+ justify-content: center;
355
+ align-items: center;
356
+ padding: 60rpx 30rpx;
357
+ }
358
+
359
+ .main-btn-item {
360
+ width: 100%;
361
+ height: 88rpx;
362
+ border-radius: 44rpx;
363
+ font-size: 32rpx;
364
+ font-weight: 600;
365
+ letter-spacing: 2rpx;
366
+ background-color: $primary;
367
+ color: #fff;
368
+ border: none;
369
+ display: flex;
370
+ align-items: center;
371
+ justify-content: center;
372
+ transition: background-color 0.2s;
373
+ box-shadow: 0 4rpx 12rpx rgba(7, 193, 96, 0.3);
374
+
375
+ &:active {
376
+ background-color: $primary-dark;
377
+ }
378
+ }
379
+ }
380
+ </style>
381
+
382
+ <script type="application/json">
383
+ {
384
+ "component": true
385
+ }
386
+ </script>