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,421 +1,421 @@
1
- <template>
2
- <view class="login-container">
3
- <view class="login_box">
4
- <view class="avatar-section">
5
- <view class="avatar-wrapper">
6
- <image class="avatar-img" src="{{ avatar }}" />
7
- </view>
8
- <view class="avatar-tip">欢迎登录</view>
9
- </view>
10
-
11
- <view class="form-section">
12
- <view class="form-item">
13
- <view class="form-label">用户名</view>
14
- <input class="form-input" type="text" placeholder="请输入用户名" bind:input="onUsernameInput"
15
- value="{{ username }}" />
16
- </view>
17
-
18
- <view class="form-item">
19
- <view class="form-label">密码</view>
20
- <input class="form-input" type="password" placeholder="请输入密码" bind:input="onPasswordInput"
21
- value="{{ password }}" />
22
- </view>
23
- </view>
24
-
25
- <view class="agreement-section" wx:if="{{ showPrivacyPolicy }}">
26
- <checkbox-group bind:change="onAgreementChange">
27
- <label class="agreement-label">
28
- <checkbox value="agree" checked="{{ agreed }}" color="{{ checkedColor }}" />
29
- <text class="agreement-text">我已阅读并同意</text>
30
- </label>
31
- </checkbox-group>
32
- <view class="agreement-links">
33
- <text id="user" bind:tap="goPolicyInfo" class="agreement-link">《用户使用协议》</text>
34
- <text class="agreement-separator">和</text>
35
- <text id="privacy" bind:tap="goPolicyInfo" class="agreement-link">《隐私权政策》</text>
36
- </view>
37
- </view>
38
-
39
- <button class="login-btn" style="{{ loginStyle }}" bind:tap="onUsernameLogin">登录</button>
40
-
41
- <view class="bottom-actions">
42
- <text class="register-btn" bind:tap="onRegister">注册账号</text>
43
- </view>
44
- </view>
45
- </view>
46
- </template>
47
-
48
- <script lang="ts">
49
- import { useUserStore } from '../../store/user'
50
- import mpx, { createComponent, ref } from '@mpxjs/core'
51
-
52
- createComponent({
53
- options: {
54
- multipleSlots: true,
55
- },
56
- properties: {
57
- // 登录按钮样式
58
- loginStyle: {
59
- type: String,
60
- value:
61
- "width: 100%;background-color: #2563EB;color: #fff;font-size: 15px;",
62
- },
63
- // 单选框选中的颜色
64
- checkedColor: {
65
- type: String,
66
- value: "#0551ff",
67
- },
68
-
69
- // 协议样式
70
- agreementStyle: {
71
- type: String,
72
- value: "color: #0551ff",
73
- },
74
-
75
- //登录后跳转页面
76
- backurl: {
77
- type: String,
78
- value: "/pages/home",
79
- },
80
- // 登录后跳转方式 "redirectTo switchTab reLaunch navigateTo"
81
- linkType: {
82
- type: String,
83
- value: "redirectTo",
84
- },
85
- //遮罩层效果
86
- isShowModel: {
87
- type: Boolean,
88
- value: false,
89
- },
90
- // 是否显示隐私协议和政策
91
- showPrivacyPolicy: {
92
- type: Boolean,
93
- value: true
94
- }
95
- },
96
- setup(props) {
97
- let config = getApp().globalData.config || { resourceUrl: '', name: '应用' };
98
- let agreeStatus = ref(false);
99
- let nameValue = ref('');
100
- let avatarUrl = ref('');
101
- let isValidate = ref(false);
102
- let userStore = useUserStore();
103
- let avatar = ref(config.resourceUrl + "/images/components/gray_head2x.png");
104
- let username = ref('');
105
- let password = ref('');
106
- let agreed = ref(false);
107
- console.log(avatar);
108
- return {
109
- agreeStatus,
110
- nameValue,
111
- avatarUrl,
112
- isValidate,
113
- avatar,
114
- userStore,
115
- username,
116
- password,
117
- agreed
118
- };
119
- },
120
- methods: {
121
- // 协议勾选事件
122
- agreeChange() {
123
- this.agreeStatus = !this.agreeStatus;
124
- this.validate();
125
- },
126
- // 用户名输入
127
- onUsernameInput(e: any) {
128
- this.username = e.detail.value;
129
- },
130
- // 密码输入
131
- onPasswordInput(e: any) {
132
- this.password = e.detail.value;
133
- },
134
- // 协议勾选变化
135
- onAgreementChange(e: any) {
136
- this.agreed = e.detail.value.includes('agree');
137
- },
138
- // 用户名密码登录
139
- onUsernameLogin() {
140
- if (!this.username.trim()) {
141
- return mpx.showToast({ title: '请输入用户名', icon: 'none', duration: 2000 })
142
- }
143
- if (!this.password.trim()) {
144
- return mpx.showToast({ title: '请输入密码', icon: 'none', duration: 2000 })
145
- }
146
- if (!this.agreed && this.showPrivacyPolicy) {
147
- return mpx.showToast({ title: '请阅读并同意用户协议', icon: 'none', duration: 2000 })
148
- }
149
-
150
- mpx.showLoading({ title: '登录中...', mask: true })
151
- let that = this;
152
- this.userStore.webLogin(
153
- this.username.trim(),
154
- this.password.trim()
155
- ).then((res: any) => {
156
- mpx.hideLoading()
157
- if (res.status) {
158
- mpx.showToast({ title: '登录成功', icon: 'success', duration: 1500 })
159
- that.triggerEvent('loginSuccess', res.data)
160
- setTimeout(() => {
161
- that.doRedirect()
162
- }, 1500)
163
- } else {
164
- mpx.showToast({ title: res.message || '登录失败,请重试', icon: 'error', duration: 2000 })
165
- }
166
- }).catch((err: any) => {
167
- mpx.hideLoading()
168
- console.error('登录失败:', err)
169
- mpx.showToast({ title: '登录失败,请检查网络', icon: 'error', duration: 2000 })
170
- })
171
- },
172
- // 注册账号
173
- onRegister() {
174
- this.triggerEvent('toRegister')
175
- },
176
- // 跳转隐私协议
177
- goPolicyInfo(e: any) {
178
- const id = e.currentTarget.id
179
- this.triggerEvent("policy", id);
180
- mpx.navigateTo({
181
- url: '/jmash/pages/auth/cms-protocol?channelAlias=' + id
182
- });
183
- },
184
- // 验证
185
- validate() {
186
- if (!this.nameValue) {
187
- this.isValidate = false;
188
- return;
189
- }
190
- this.isValidate = true;
191
- },
192
- // 登录后跳转
193
- doRedirect() {
194
- const backurl = decodeURIComponent(this.backurl);
195
- if (this.linkType === "switchTab") {
196
- mpx.switchTab({ url: backurl });
197
- } else if (this.linkType === "navigateTo") {
198
- mpx.navigateTo({ url: backurl });
199
- } else if (this.linkType === "redirectTo") {
200
- mpx.redirectTo({ url: backurl });
201
- } else {
202
- mpx.reLaunch({ url: backurl });
203
- }
204
- },
205
- // 登录前验证
206
- onLogin() {
207
- console.log(this.agreeStatus);
208
- if (!this.agreeStatus && this.showPrivacyPolicy) {
209
- mpx.showModal({
210
- title: "提示",
211
- content: "您是否已阅读《用户使用协议》《隐私权政策》?",
212
- success: (res) => {
213
- if (res.confirm) {
214
- this.agreeStatus = true;
215
- }
216
- },
217
- });
218
- }
219
- if (!this.nameValue) {
220
- mpx.showToast({
221
- title: "请输入姓名",
222
- icon: "none",
223
- duration: 2000,
224
- });
225
- }
226
- },
227
- wxPhoneLogin(event: any) {
228
- let that = this;
229
- console.log(event);
230
- if (!this.agreeStatus && this.showPrivacyPolicy) {
231
- mpx.showModal({
232
- title: "提示",
233
- content: "您是否已阅读《用户使用协议》《隐私权政策》?",
234
- success(res) {
235
- if (res.confirm) {
236
- that.agreeStatus = true;
237
- }
238
- },
239
- });
240
- return;
241
- }
242
- if (!this.nameValue) {
243
- mpx.showToast({
244
- title: "请输入姓名",
245
- icon: "none",
246
- duration: 2000,
247
- });
248
- return;
249
- }
250
- if (event.detail.errMsg === "getPhoneNumber:ok") {
251
- console.log(event.detail.code);
252
- this.userStore.mpRegister(event.detail.code, this.nameValue).then((resp) => {
253
- if (resp.status === false) {
254
- mpx.showToast({
255
- title: resp.message ? resp.message : "登录失败联系管理员",
256
- icon: "none",
257
- duration: 2000,
258
- });
259
- return;
260
- }
261
- const backurl = decodeURIComponent(this.backurl);
262
- if (this.linkType === "switchTab") {
263
- mpx.switchTab({ url: backurl });
264
- } else if (this.linkType === "navigateTo") {
265
- mpx.navigateTo({ url: backurl });
266
- } else if (this.linkType === "redirectTo") {
267
- mpx.redirectTo({ url: backurl });
268
- } else {
269
- mpx.reLaunch({ url: backurl });
270
- }
271
- });
272
- } else {
273
- mpx.showToast({
274
- title: "您已取消授权",
275
- icon: "none",
276
- duration: 2000,
277
- });
278
- }
279
- }
280
- }
281
- })
282
- </script>
283
-
284
- <style lang="scss">
285
- @use "../../styles/index.scss" as *;
286
-
287
- $primary: #07c160;
288
- $primary-dark: #06ad56;
289
- $text-1: #111111;
290
- $text-2: #555555;
291
- $text-3: #888888;
292
- $border: #d0d0d0;
293
- $bg-page: #f2f2f2;
294
- $bg-card: #ffffff;
295
-
296
- .login_box {
297
- padding: 13% 3% 4%;
298
- display: flex;
299
- flex-direction: column;
300
- align-items: center;
301
-
302
- .login_btn {
303
- background-color: $blue-color;
304
- color: $white-color;
305
- padding: 16px 0;
306
- width: $width;
307
- font-size: $font-size;
308
- }
309
-
310
- .protocol_agree {
311
- color: $font-color-grey-opacity;
312
- font-size: $font-size;
313
- margin-top: 20px;
314
-
315
- text {
316
- color: $blue-color;
317
- }
318
- }
319
-
320
- .avatar-section {
321
- display: flex;
322
- flex-direction: column;
323
- align-items: center;
324
- margin-bottom: 32rpx;
325
-
326
- .avatar-wrapper {
327
- position: relative;
328
- margin: 0;
329
- padding: 0;
330
- background: none;
331
- border: none;
332
- line-height: 1;
333
-
334
- .avatar-img {
335
- width: 120rpx;
336
- height: 120rpx;
337
- border-radius: 50%;
338
- border: 4rpx solid $border;
339
- display: block;
340
- }
341
-
342
- .avatar-badge {
343
- position: absolute;
344
- right: 0;
345
- bottom: 0;
346
- width: 36rpx;
347
- height: 36rpx;
348
- background: $primary;
349
- border-radius: 50%;
350
- border: 3rpx solid $bg-card;
351
- display: flex;
352
- align-items: center;
353
- justify-content: center;
354
-
355
- .badge-icon {
356
- font-size: 16rpx;
357
- color: #fff;
358
- }
359
- }
360
- }
361
-
362
- .avatar-tip {
363
- margin-top: 16rpx;
364
- font-size: 20rpx;
365
- color: $text-3;
366
- }
367
- }
368
-
369
- .name-section {
370
- width: 100%;
371
- margin-bottom: 32rpx;
372
-
373
- .name-field {
374
- display: flex;
375
- align-items: center;
376
- background: $bg-page;
377
- border-radius: 20rpx;
378
- padding: 0 28rpx;
379
- height: 88rpx;
380
- border: 2rpx solid transparent;
381
- transition: border-color 0.25s, background-color 0.25s;
382
-
383
- .field-icon {
384
- font-size: 32rpx;
385
- margin-right: 16rpx;
386
- flex-shrink: 0;
387
- }
388
-
389
- .name-input {
390
- flex: 1;
391
- min-width: 0;
392
- font-size: 28rpx;
393
- color: $text-1;
394
- background: transparent;
395
- border: none;
396
- outline: none;
397
- height: 80rpx;
398
- line-height: 80rpx;
399
- padding: 0;
400
- }
401
-
402
- .name-input::placeholder {
403
- font-size: 28rpx;
404
- color: $text-3;
405
- }
406
- }
407
-
408
- .name-field:focus-within {
409
- border-color: $primary;
410
- background: $bg-card;
411
- }
412
- }
413
- }
414
- </style>
415
-
416
- <script type="application/json">
417
- {
418
- "component": true,
419
- "usingComponents": {}
420
- }
421
- </script>
1
+ <template>
2
+ <view class="login-container">
3
+ <view class="login_box">
4
+ <view class="avatar-section">
5
+ <view class="avatar-wrapper">
6
+ <image class="avatar-img" src="{{ avatar }}" />
7
+ </view>
8
+ <view class="avatar-tip">欢迎登录</view>
9
+ </view>
10
+
11
+ <view class="form-section">
12
+ <view class="form-item">
13
+ <view class="form-label">用户名</view>
14
+ <input class="form-input" type="text" placeholder="请输入用户名" bind:input="onUsernameInput"
15
+ value="{{ username }}" />
16
+ </view>
17
+
18
+ <view class="form-item">
19
+ <view class="form-label">密码</view>
20
+ <input class="form-input" type="password" placeholder="请输入密码" bind:input="onPasswordInput"
21
+ value="{{ password }}" />
22
+ </view>
23
+ </view>
24
+
25
+ <view class="agreement-section" wx:if="{{ showPrivacyPolicy }}">
26
+ <checkbox-group bind:change="onAgreementChange">
27
+ <label class="agreement-label">
28
+ <checkbox value="agree" checked="{{ agreed }}" color="{{ checkedColor }}" />
29
+ <text class="agreement-text">我已阅读并同意</text>
30
+ </label>
31
+ </checkbox-group>
32
+ <view class="agreement-links">
33
+ <text id="user" bind:tap="goPolicyInfo" class="agreement-link">《用户使用协议》</text>
34
+ <text class="agreement-separator">和</text>
35
+ <text id="privacy" bind:tap="goPolicyInfo" class="agreement-link">《隐私权政策》</text>
36
+ </view>
37
+ </view>
38
+
39
+ <button class="login-btn" style="{{ loginStyle }}" bind:tap="onUsernameLogin">登录</button>
40
+
41
+ <view class="bottom-actions">
42
+ <text class="register-btn" bind:tap="onRegister">注册账号</text>
43
+ </view>
44
+ </view>
45
+ </view>
46
+ </template>
47
+
48
+ <script lang="ts">
49
+ import { useUserStore } from '../../store/user'
50
+ import mpx, { createComponent, ref } from '@mpxjs/core'
51
+
52
+ createComponent({
53
+ options: {
54
+ multipleSlots: true,
55
+ },
56
+ properties: {
57
+ // 登录按钮样式
58
+ loginStyle: {
59
+ type: String,
60
+ value:
61
+ "width: 100%;background-color: #2563EB;color: #fff;font-size: 15px;",
62
+ },
63
+ // 单选框选中的颜色
64
+ checkedColor: {
65
+ type: String,
66
+ value: "#0551ff",
67
+ },
68
+
69
+ // 协议样式
70
+ agreementStyle: {
71
+ type: String,
72
+ value: "color: #0551ff",
73
+ },
74
+
75
+ //登录后跳转页面
76
+ backurl: {
77
+ type: String,
78
+ value: "/pages/home",
79
+ },
80
+ // 登录后跳转方式 "redirectTo switchTab reLaunch navigateTo"
81
+ linkType: {
82
+ type: String,
83
+ value: "redirectTo",
84
+ },
85
+ //遮罩层效果
86
+ isShowModel: {
87
+ type: Boolean,
88
+ value: false,
89
+ },
90
+ // 是否显示隐私协议和政策
91
+ showPrivacyPolicy: {
92
+ type: Boolean,
93
+ value: true
94
+ }
95
+ },
96
+ setup(props) {
97
+ let config = getApp().globalData.config || { resourceUrl: '', name: '应用' };
98
+ let agreeStatus = ref(false);
99
+ let nameValue = ref('');
100
+ let avatarUrl = ref('');
101
+ let isValidate = ref(false);
102
+ let userStore = useUserStore();
103
+ let avatar = ref(config.resourceUrl + "/images/components/gray_head2x.png");
104
+ let username = ref('');
105
+ let password = ref('');
106
+ let agreed = ref(false);
107
+ console.log(avatar);
108
+ return {
109
+ agreeStatus,
110
+ nameValue,
111
+ avatarUrl,
112
+ isValidate,
113
+ avatar,
114
+ userStore,
115
+ username,
116
+ password,
117
+ agreed
118
+ };
119
+ },
120
+ methods: {
121
+ // 协议勾选事件
122
+ agreeChange() {
123
+ this.agreeStatus = !this.agreeStatus;
124
+ this.validate();
125
+ },
126
+ // 用户名输入
127
+ onUsernameInput(e: any) {
128
+ this.username = e.detail.value;
129
+ },
130
+ // 密码输入
131
+ onPasswordInput(e: any) {
132
+ this.password = e.detail.value;
133
+ },
134
+ // 协议勾选变化
135
+ onAgreementChange(e: any) {
136
+ this.agreed = e.detail.value.includes('agree');
137
+ },
138
+ // 用户名密码登录
139
+ onUsernameLogin() {
140
+ if (!this.username.trim()) {
141
+ return mpx.showToast({ title: '请输入用户名', icon: 'none', duration: 2000 })
142
+ }
143
+ if (!this.password.trim()) {
144
+ return mpx.showToast({ title: '请输入密码', icon: 'none', duration: 2000 })
145
+ }
146
+ if (!this.agreed && this.showPrivacyPolicy) {
147
+ return mpx.showToast({ title: '请阅读并同意用户协议', icon: 'none', duration: 2000 })
148
+ }
149
+
150
+ mpx.showLoading({ title: '登录中...', mask: true })
151
+ let that = this;
152
+ this.userStore.webLogin(
153
+ this.username.trim(),
154
+ this.password.trim()
155
+ ).then((res: any) => {
156
+ mpx.hideLoading()
157
+ if (res.status) {
158
+ mpx.showToast({ title: '登录成功', icon: 'success', duration: 1500 })
159
+ that.triggerEvent('loginSuccess', res.data)
160
+ setTimeout(() => {
161
+ that.doRedirect()
162
+ }, 1500)
163
+ } else {
164
+ mpx.showToast({ title: res.message || '登录失败,请重试', icon: 'error', duration: 2000 })
165
+ }
166
+ }).catch((err: any) => {
167
+ mpx.hideLoading()
168
+ console.error('登录失败:', err)
169
+ mpx.showToast({ title: '登录失败,请检查网络', icon: 'error', duration: 2000 })
170
+ })
171
+ },
172
+ // 注册账号
173
+ onRegister() {
174
+ this.triggerEvent('toRegister')
175
+ },
176
+ // 跳转隐私协议
177
+ goPolicyInfo(e: any) {
178
+ const id = e.currentTarget.id
179
+ this.triggerEvent("policy", id);
180
+ mpx.navigateTo({
181
+ url: '/jmash/pages/auth/cms-protocol?channelAlias=' + id
182
+ });
183
+ },
184
+ // 验证
185
+ validate() {
186
+ if (!this.nameValue) {
187
+ this.isValidate = false;
188
+ return;
189
+ }
190
+ this.isValidate = true;
191
+ },
192
+ // 登录后跳转
193
+ doRedirect() {
194
+ const backurl = decodeURIComponent(this.backurl);
195
+ if (this.linkType === "switchTab") {
196
+ mpx.switchTab({ url: backurl });
197
+ } else if (this.linkType === "navigateTo") {
198
+ mpx.navigateTo({ url: backurl });
199
+ } else if (this.linkType === "redirectTo") {
200
+ mpx.redirectTo({ url: backurl });
201
+ } else {
202
+ mpx.reLaunch({ url: backurl });
203
+ }
204
+ },
205
+ // 登录前验证
206
+ onLogin() {
207
+ console.log(this.agreeStatus);
208
+ if (!this.agreeStatus && this.showPrivacyPolicy) {
209
+ mpx.showModal({
210
+ title: "提示",
211
+ content: "您是否已阅读《用户使用协议》《隐私权政策》?",
212
+ success: (res) => {
213
+ if (res.confirm) {
214
+ this.agreeStatus = true;
215
+ }
216
+ },
217
+ });
218
+ }
219
+ if (!this.nameValue) {
220
+ mpx.showToast({
221
+ title: "请输入姓名",
222
+ icon: "none",
223
+ duration: 2000,
224
+ });
225
+ }
226
+ },
227
+ wxPhoneLogin(event: any) {
228
+ let that = this;
229
+ console.log(event);
230
+ if (!this.agreeStatus && this.showPrivacyPolicy) {
231
+ mpx.showModal({
232
+ title: "提示",
233
+ content: "您是否已阅读《用户使用协议》《隐私权政策》?",
234
+ success(res) {
235
+ if (res.confirm) {
236
+ that.agreeStatus = true;
237
+ }
238
+ },
239
+ });
240
+ return;
241
+ }
242
+ if (!this.nameValue) {
243
+ mpx.showToast({
244
+ title: "请输入姓名",
245
+ icon: "none",
246
+ duration: 2000,
247
+ });
248
+ return;
249
+ }
250
+ if (event.detail.errMsg === "getPhoneNumber:ok") {
251
+ console.log(event.detail.code);
252
+ this.userStore.mpRegister(event.detail.code, this.nameValue).then((resp) => {
253
+ if (resp.status === false) {
254
+ mpx.showToast({
255
+ title: resp.message ? resp.message : "登录失败联系管理员",
256
+ icon: "none",
257
+ duration: 2000,
258
+ });
259
+ return;
260
+ }
261
+ const backurl = decodeURIComponent(this.backurl);
262
+ if (this.linkType === "switchTab") {
263
+ mpx.switchTab({ url: backurl });
264
+ } else if (this.linkType === "navigateTo") {
265
+ mpx.navigateTo({ url: backurl });
266
+ } else if (this.linkType === "redirectTo") {
267
+ mpx.redirectTo({ url: backurl });
268
+ } else {
269
+ mpx.reLaunch({ url: backurl });
270
+ }
271
+ });
272
+ } else {
273
+ mpx.showToast({
274
+ title: "您已取消授权",
275
+ icon: "none",
276
+ duration: 2000,
277
+ });
278
+ }
279
+ }
280
+ }
281
+ })
282
+ </script>
283
+
284
+ <style lang="scss">
285
+ @use "../../styles/index.scss" as *;
286
+
287
+ $primary: #07c160;
288
+ $primary-dark: #06ad56;
289
+ $text-1: #111111;
290
+ $text-2: #555555;
291
+ $text-3: #888888;
292
+ $border: #d0d0d0;
293
+ $bg-page: #f2f2f2;
294
+ $bg-card: #ffffff;
295
+
296
+ .login_box {
297
+ padding: 13% 3% 4%;
298
+ display: flex;
299
+ flex-direction: column;
300
+ align-items: center;
301
+
302
+ .login_btn {
303
+ background-color: $blue-color;
304
+ color: $white-color;
305
+ padding: 16px 0;
306
+ width: $width;
307
+ font-size: $font-size;
308
+ }
309
+
310
+ .protocol_agree {
311
+ color: $font-color-grey-opacity;
312
+ font-size: $font-size;
313
+ margin-top: 20px;
314
+
315
+ text {
316
+ color: $blue-color;
317
+ }
318
+ }
319
+
320
+ .avatar-section {
321
+ display: flex;
322
+ flex-direction: column;
323
+ align-items: center;
324
+ margin-bottom: 32rpx;
325
+
326
+ .avatar-wrapper {
327
+ position: relative;
328
+ margin: 0;
329
+ padding: 0;
330
+ background: none;
331
+ border: none;
332
+ line-height: 1;
333
+
334
+ .avatar-img {
335
+ width: 120rpx;
336
+ height: 120rpx;
337
+ border-radius: 50%;
338
+ border: 4rpx solid $border;
339
+ display: block;
340
+ }
341
+
342
+ .avatar-badge {
343
+ position: absolute;
344
+ right: 0;
345
+ bottom: 0;
346
+ width: 36rpx;
347
+ height: 36rpx;
348
+ background: $primary;
349
+ border-radius: 50%;
350
+ border: 3rpx solid $bg-card;
351
+ display: flex;
352
+ align-items: center;
353
+ justify-content: center;
354
+
355
+ .badge-icon {
356
+ font-size: 16rpx;
357
+ color: #fff;
358
+ }
359
+ }
360
+ }
361
+
362
+ .avatar-tip {
363
+ margin-top: 16rpx;
364
+ font-size: 20rpx;
365
+ color: $text-3;
366
+ }
367
+ }
368
+
369
+ .name-section {
370
+ width: 100%;
371
+ margin-bottom: 32rpx;
372
+
373
+ .name-field {
374
+ display: flex;
375
+ align-items: center;
376
+ background: $bg-page;
377
+ border-radius: 20rpx;
378
+ padding: 0 28rpx;
379
+ height: 88rpx;
380
+ border: 2rpx solid transparent;
381
+ transition: border-color 0.25s, background-color 0.25s;
382
+
383
+ .field-icon {
384
+ font-size: 32rpx;
385
+ margin-right: 16rpx;
386
+ flex-shrink: 0;
387
+ }
388
+
389
+ .name-input {
390
+ flex: 1;
391
+ min-width: 0;
392
+ font-size: 28rpx;
393
+ color: $text-1;
394
+ background: transparent;
395
+ border: none;
396
+ outline: none;
397
+ height: 80rpx;
398
+ line-height: 80rpx;
399
+ padding: 0;
400
+ }
401
+
402
+ .name-input::placeholder {
403
+ font-size: 28rpx;
404
+ color: $text-3;
405
+ }
406
+ }
407
+
408
+ .name-field:focus-within {
409
+ border-color: $primary;
410
+ background: $bg-card;
411
+ }
412
+ }
413
+ }
414
+ </style>
415
+
416
+ <script type="application/json">
417
+ {
418
+ "component": true,
419
+ "usingComponents": {}
420
+ }
421
+ </script>