jmash-core-mp 0.1.43 → 0.1.45

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 (173) 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 +201 -201
  12. package/lib/api/cms/types.js +1 -1
  13. package/lib/api/constant.d.ts +6 -6
  14. package/lib/api/constant.js +8 -8
  15. package/lib/api/dict/index.d.ts +24 -24
  16. package/lib/api/dict/index.js +51 -51
  17. package/lib/api/dict/types.d.ts +40 -40
  18. package/lib/api/dict/types.js +1 -1
  19. package/lib/api/dicts.d.ts +32 -32
  20. package/lib/api/dicts.js +118 -118
  21. package/lib/api/files/index.d.ts +25 -25
  22. package/lib/api/files/index.js +134 -134
  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 +5 -5
  26. package/lib/api/index.js +8 -8
  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 +20 -20
  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 +43 -43
  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/{common/jmash-stepper.mpx.d.ts → cms/jmash-cms-acticle-list.mpx.d.ts} +1 -1
  43. package/lib/components/cms/jmash-cms-activity-item.mpx.d.ts +1 -1
  44. package/lib/components/cms/jmash-cms-activity-list.mpx.d.ts +1 -1
  45. package/lib/components/cms/jmash-cms-article-item.mpx.d.ts +1 -1
  46. package/lib/components/cms/jmash-cms-article-list.mpx.d.ts +1 -1
  47. package/lib/components/cms/jmash-cms-article-view.mpx.d.ts +1 -1
  48. package/lib/components/cms/jmash-cms-article.mpx.d.ts +1 -1
  49. package/lib/components/cms/jmash-cms-like.mpx.d.ts +1 -1
  50. package/lib/components/cms/jmash-cms-location-list.mpx.d.ts +1 -1
  51. package/lib/components/cms/jmash-cms-location.mpx.d.ts +1 -1
  52. package/lib/components/cms/jmash-cms-product-item.mpx.d.ts +1 -1
  53. package/lib/components/cms/jmash-cms-product-list.mpx.d.ts +1 -1
  54. package/lib/components/common/jmash-search.mpx.d.ts +1 -1
  55. package/lib/components/core/jmash-login.mpx.d.ts +1 -1
  56. package/lib/index.d.ts +23 -23
  57. package/lib/index.js +18 -18
  58. package/lib/packages/pages/cms/cms-activity-list.mpx.d.ts +1 -1
  59. package/lib/packages/pages/cms/cms-article-list.mpx.d.ts +1 -1
  60. package/lib/packages/pages/cms/cms-location-list.mpx.d.ts +1 -1
  61. package/lib/packages/pages/cms/cms-product-list.mpx.d.ts +1 -1
  62. package/lib/store/user.d.ts +31 -31
  63. package/lib/store/user.js +226 -226
  64. package/lib/types/core.d.ts +41 -0
  65. package/lib/types/core.js +1 -0
  66. package/lib/utils/common.d.ts +35 -35
  67. package/lib/utils/common.js +165 -165
  68. package/lib/utils/config.d.ts +5 -5
  69. package/lib/utils/config.js +30 -30
  70. package/lib/utils/db.d.ts +21 -21
  71. package/lib/utils/db.js +84 -84
  72. package/lib/utils/grpc.d.ts +5 -5
  73. package/lib/utils/grpc.js +20 -20
  74. package/lib/utils/net.d.ts +7 -7
  75. package/lib/utils/net.js +15 -15
  76. package/lib/utils/request.d.ts +2 -2
  77. package/lib/utils/request.js +114 -114
  78. package/mpx.config.js +27 -27
  79. package/package.json +1 -1
  80. package/postcss.config.js +11 -11
  81. package/project.config.json +24 -24
  82. package/project.private.config.json +13 -13
  83. package/public/index.html +15 -15
  84. package/src/api/auth/index.ts +227 -227
  85. package/src/api/auth/types.ts +166 -166
  86. package/src/api/cms/index.ts +218 -218
  87. package/src/api/cms/types.ts +385 -385
  88. package/src/api/constant.ts +8 -8
  89. package/src/api/dict/index.ts +62 -62
  90. package/src/api/dict/types.ts +73 -73
  91. package/src/api/dicts.ts +132 -132
  92. package/src/api/files/index.ts +162 -162
  93. package/src/api/files/types.ts +67 -67
  94. package/src/api/index.ts +15 -15
  95. package/src/api/myorgan/types.ts +42 -42
  96. package/src/api/region/index.ts +24 -24
  97. package/src/api/region/types.ts +36 -36
  98. package/src/api/storage/index.ts +62 -62
  99. package/src/api/storage/types.ts +54 -54
  100. package/src/api/types.ts +74 -74
  101. package/src/app.mpx +60 -60
  102. package/src/components/auth-user/jmash-logout.mpx +93 -93
  103. package/src/components/auth-user/jmash-update-user.mpx +387 -386
  104. package/src/components/auth-user/jmash-update-user.web.mpx +367 -366
  105. package/src/components/auth-user/jmash-user.mpx +310 -310
  106. package/src/components/cms/jmash-cms-activity-item.mpx +207 -207
  107. package/src/components/cms/jmash-cms-activity-list.mpx +357 -357
  108. package/src/components/cms/jmash-cms-article-item.mpx +221 -220
  109. package/src/components/cms/jmash-cms-article-list.mpx +248 -247
  110. package/src/components/cms/jmash-cms-article-view.mpx +131 -131
  111. package/src/components/cms/jmash-cms-article.mpx +231 -231
  112. package/src/components/cms/jmash-cms-like.mpx +151 -151
  113. package/src/components/cms/jmash-cms-location-list.mpx +286 -285
  114. package/src/components/cms/jmash-cms-location.mpx +256 -256
  115. package/src/components/cms/jmash-cms-product-item.mpx +185 -184
  116. package/src/components/cms/jmash-cms-product-list.mpx +230 -229
  117. package/src/components/common/jmash-avatar-edit.mpx +154 -154
  118. package/src/components/common/jmash-cascader-region.mpx +118 -118
  119. package/src/components/common/jmash-form-cell.mpx +524 -0
  120. package/src/components/common/jmash-menu.mpx +129 -129
  121. package/src/components/common/jmash-none-data.mpx +95 -95
  122. package/src/components/common/jmash-pic-swiper.mpx +72 -72
  123. package/src/components/common/jmash-popup.mpx +138 -132
  124. package/src/components/common/jmash-search.mpx +126 -126
  125. package/src/components/common/jmash-single-btn.mpx +53 -53
  126. package/src/components/common/jmash-stepper.mpx +236 -236
  127. package/src/components/common/jmash-swipe-cell.mpx +153 -0
  128. package/src/components/common/jmash-tab-bar.mpx +46 -46
  129. package/src/components/common/jmash-textarea.mpx +88 -88
  130. package/src/components/common/jmash-top-navigation.mpx +203 -203
  131. package/src/components/common/jmash-upload-picture.mpx +199 -180
  132. package/src/components/core/jmash-cms-protocol.mpx +72 -72
  133. package/src/components/core/jmash-login.ali.mpx +284 -284
  134. package/src/components/core/jmash-login.mpx +378 -377
  135. package/src/components/core/jmash-login.web.mpx +420 -420
  136. package/src/components/core/jmash-popup-login.ali.mpx +312 -312
  137. package/src/components/core/jmash-popup-login.mpx +416 -415
  138. package/src/components/core/jmash-popup-login.web.mpx +389 -389
  139. package/src/custom-tab-bar/index.mpx +10 -10
  140. package/src/global.d.ts +11 -11
  141. package/src/index.ts +80 -80
  142. package/src/packages/index.mpx +14 -14
  143. package/src/packages/pages/auth/cms-protocol.mpx +35 -35
  144. package/src/packages/pages/auth/login.mpx +62 -62
  145. package/src/packages/pages/auth/update-user.mpx +17 -17
  146. package/src/packages/pages/cms/cms-activity-list.mpx +86 -86
  147. package/src/packages/pages/cms/cms-article-list.mpx +88 -88
  148. package/src/packages/pages/cms/cms-article.mpx +32 -32
  149. package/src/packages/pages/cms/cms-location-list.mpx +83 -83
  150. package/src/packages/pages/cms/cms-location.mpx +32 -32
  151. package/src/packages/pages/cms/cms-product-list.mpx +88 -88
  152. package/src/pages/basic-component.mpx +30 -30
  153. package/src/pages/half-home.mpx +58 -58
  154. package/src/pages/home.mpx +54 -54
  155. package/src/pages/home2.mpx +45 -45
  156. package/src/pages/index.mpx +43 -43
  157. package/src/pages/tabbar/home.mpx +91 -91
  158. package/src/pages/tabbar/my.mpx +79 -79
  159. package/src/store/user.ts +269 -269
  160. package/src/styles/index.scss +20 -20
  161. package/src/styles/vars.scss +27 -27
  162. package/src/utils/common.ts +178 -178
  163. package/src/utils/config.ts +36 -36
  164. package/src/utils/db.ts +100 -100
  165. package/src/utils/grpc.ts +21 -21
  166. package/src/utils/net.ts +18 -18
  167. package/src/utils/request.ts +126 -126
  168. package/static/ali/mini.project.json +4 -4
  169. package/static/dd/project.config.json +15 -15
  170. package/static/swan/project.swan.json +14 -14
  171. package/static/tt/project.config.json +11 -11
  172. package/static/wx/project.config.json +40 -40
  173. package/uno.config.js +9 -9
package/.editorconfig CHANGED
@@ -1,9 +1,9 @@
1
- root = true
2
-
3
- [*]
4
- charset = utf-8
5
- indent_style = space
6
- indent_size = 2
7
- end_of_line = lf
8
- insert_final_newline = true
9
- trim_trailing_whitespace = true
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = space
6
+ indent_size = 2
7
+ end_of_line = lf
8
+ insert_final_newline = true
9
+ trim_trailing_whitespace = true
package/README.md CHANGED
@@ -1,60 +1,60 @@
1
- # jmash-core-mp
2
-
3
- 采用 MPX 构建的 Jmash 高性能跨端小程序。
4
- https://mpxjs.cn/
5
-
6
- ## Project setup
7
-
8
- ```javascript
9
- // 开发构建,默认输出微信小程序
10
- npm run serve
11
-
12
- // 开发构建,跨平台输出支付宝小程序
13
- npm run serve:ali
14
-
15
- // 开发构建,跨平台输出 Web
16
- npm run serve:web
17
-
18
- // 开发构建,跨平台输出其他平台小程序target = swan|tt|qq|jd|ks
19
- npm run serve -- --targets={target}
20
-
21
- // 开发构建,同时输出多平台产物
22
- npm run serve -- --targets=wx,ali,web
23
-
24
- // 生产构建,默认输出微信小程序
25
- npm run build
26
-
27
- // 生产构建,跨平台输出
28
- npm run build:ali
29
- npm run build:web
30
- npm run build -- --targets=wx,ali,web
31
- ```
32
-
33
- # ALi 小程序
34
-
35
- 登录
36
- minidev login
37
-
38
- 调试开发
39
- minidev dev
40
-
41
- 本地 IP 调试
42
- minidev dev --host 192.168.1.154
43
-
44
- 真机调试
45
- minidev remote-debug -a 2021006137629651
46
-
47
- Web 端调试
48
- minidev dev
49
- web -a 2021006137629651
50
- 真机预览
51
- minidev preview -a 2021006137629651
52
-
53
- # pnpm publish --no-git-checks
54
-
55
- 官方镜像
56
- npm config set registry https://registry.npmjs.org/
57
- 国内镜像
58
- npm config set registry https://registry.npmmirror.com/
59
- 代理镜像
60
- npm config set registry https://npm.crenjoy.com/
1
+ # jmash-core-mp
2
+
3
+ 采用 MPX 构建的 Jmash 高性能跨端小程序。
4
+ https://mpxjs.cn/
5
+
6
+ ## Project setup
7
+
8
+ ```javascript
9
+ // 开发构建,默认输出微信小程序
10
+ npm run serve
11
+
12
+ // 开发构建,跨平台输出支付宝小程序
13
+ npm run serve:ali
14
+
15
+ // 开发构建,跨平台输出 Web
16
+ npm run serve:web
17
+
18
+ // 开发构建,跨平台输出其他平台小程序target = swan|tt|qq|jd|ks
19
+ npm run serve -- --targets={target}
20
+
21
+ // 开发构建,同时输出多平台产物
22
+ npm run serve -- --targets=wx,ali,web
23
+
24
+ // 生产构建,默认输出微信小程序
25
+ npm run build
26
+
27
+ // 生产构建,跨平台输出
28
+ npm run build:ali
29
+ npm run build:web
30
+ npm run build -- --targets=wx,ali,web
31
+ ```
32
+
33
+ # ALi 小程序
34
+
35
+ 登录
36
+ minidev login
37
+
38
+ 调试开发
39
+ minidev dev
40
+
41
+ 本地 IP 调试
42
+ minidev dev --host 192.168.1.154
43
+
44
+ 真机调试
45
+ minidev remote-debug -a 2021006137629651
46
+
47
+ Web 端调试
48
+ minidev dev
49
+ web -a 2021006137629651
50
+ 真机预览
51
+ minidev preview -a 2021006137629651
52
+
53
+ # pnpm publish --no-git-checks
54
+
55
+ 官方镜像
56
+ npm config set registry https://registry.npmjs.org/
57
+ 国内镜像
58
+ npm config set registry https://registry.npmmirror.com/
59
+ 代理镜像
60
+ npm config set registry https://npm.crenjoy.com/
package/babel.config.json CHANGED
@@ -1,34 +1,34 @@
1
- {
2
- "presets": [
3
- [
4
- "@babel/preset-env",
5
- {
6
- "modules": false,
7
- "shippedProposals": true
8
- }
9
- ],
10
- ],
11
- "plugins": [
12
- [
13
- "@babel/transform-runtime",
14
- {
15
- "corejs": 3,
16
- "version": "^7.10.4"
17
- }
18
- ],
19
- "@mpxjs/babel-plugin-inject-page-events",
20
- ],
21
- "sourceType": "unambiguous",
22
- "env": {
23
- "test": {
24
- "presets": [
25
- [
26
- "@babel/env",
27
- {
28
- "shippedProposals": true
29
- }
30
- ]
31
- ]
32
- }
33
- }
34
- }
1
+ {
2
+ "presets": [
3
+ [
4
+ "@babel/preset-env",
5
+ {
6
+ "modules": false,
7
+ "shippedProposals": true
8
+ }
9
+ ],
10
+ ],
11
+ "plugins": [
12
+ [
13
+ "@babel/transform-runtime",
14
+ {
15
+ "corejs": 3,
16
+ "version": "^7.10.4"
17
+ }
18
+ ],
19
+ "@mpxjs/babel-plugin-inject-page-events",
20
+ ],
21
+ "sourceType": "unambiguous",
22
+ "env": {
23
+ "test": {
24
+ "presets": [
25
+ [
26
+ "@babel/env",
27
+ {
28
+ "shippedProposals": true
29
+ }
30
+ ]
31
+ ]
32
+ }
33
+ }
34
+ }
package/eslint.config.mjs CHANGED
@@ -1,7 +1,7 @@
1
- import { mpxConfig } from '@mpxjs/eslint-config'
2
- export default mpxConfig(
3
- {
4
- mpx: true,
5
- typescript: true
6
- }
7
- )
1
+ import { mpxConfig } from '@mpxjs/eslint-config'
2
+ export default mpxConfig(
3
+ {
4
+ mpx: true,
5
+ typescript: true
6
+ }
7
+ )
@@ -1,21 +1,21 @@
1
- import { ResponseData } from "../../api/types";
2
- import type { LoginReq, LoginRes, RolesPerms, WebLoginReq, TokenModel, PhoneRegisterReq, PhoneReplaceReq, UpdateUserReq, UserInfoReq, UserInfo } from "./types";
3
- declare class AuthApi {
4
- mpLogin(data: LoginReq): Promise<ResponseData<LoginRes>>;
5
- mpPhoneRegister(data: PhoneRegisterReq): Promise<ResponseData<LoginRes>>;
6
- replaceBindphone(data: PhoneReplaceReq): Promise<ResponseData<string>>;
7
- webLogin(data: WebLoginReq): Promise<ResponseData<TokenModel>>;
8
- refreshToken(): Promise<ResponseData<TokenModel>>;
9
- userInfo(): Promise<ResponseData<UserInfo>>;
10
- userRolesPerms(): Promise<ResponseData<RolesPerms>>;
11
- allowRunAsUser(): Promise<ResponseData<any[]>>;
12
- runAsUser(userId: string): Promise<ResponseData<any>>;
13
- updateUser(data: any): Promise<ResponseData<any>>;
14
- updatePwd(encodeOldPwd: string, encodeNewPwd: string): Promise<ResponseData<any>>;
15
- deptTree(deptId?: string, tenant?: string): Promise<ResponseData<any[]>>;
16
- jobTree(jobId?: string, tenant?: string): Promise<ResponseData<any[]>>;
17
- updateUserInfo(data: UpdateUserReq): Promise<ResponseData<UserInfo>>;
18
- findUserInfo(data: UserInfoReq): Promise<ResponseData<UserInfo>>;
19
- }
20
- export declare const authApi: AuthApi;
21
- export {};
1
+ import { ResponseData } from "../../api/types";
2
+ import type { LoginReq, LoginRes, RolesPerms, WebLoginReq, TokenModel, PhoneRegisterReq, PhoneReplaceReq, UpdateUserReq, UserInfoReq, UserInfo } from "./types";
3
+ declare class AuthApi {
4
+ mpLogin(data: LoginReq): Promise<ResponseData<LoginRes>>;
5
+ mpPhoneRegister(data: PhoneRegisterReq): Promise<ResponseData<LoginRes>>;
6
+ replaceBindphone(data: PhoneReplaceReq): Promise<ResponseData<string>>;
7
+ webLogin(data: WebLoginReq): Promise<ResponseData<TokenModel>>;
8
+ refreshToken(): Promise<ResponseData<TokenModel>>;
9
+ userInfo(): Promise<ResponseData<UserInfo>>;
10
+ userRolesPerms(): Promise<ResponseData<RolesPerms>>;
11
+ allowRunAsUser(): Promise<ResponseData<any[]>>;
12
+ runAsUser(userId: string): Promise<ResponseData<any>>;
13
+ updateUser(data: any): Promise<ResponseData<any>>;
14
+ updatePwd(encodeOldPwd: string, encodeNewPwd: string): Promise<ResponseData<any>>;
15
+ deptTree(deptId?: string, tenant?: string): Promise<ResponseData<any[]>>;
16
+ jobTree(jobId?: string, tenant?: string): Promise<ResponseData<any[]>>;
17
+ updateUserInfo(data: UpdateUserReq): Promise<ResponseData<UserInfo>>;
18
+ findUserInfo(data: UserInfoReq): Promise<ResponseData<UserInfo>>;
19
+ }
20
+ export declare const authApi: AuthApi;
21
+ export {};
@@ -1,199 +1,199 @@
1
- import { OpensType } from "./types";
2
- import { db } from "../../utils/db";
3
- import { grpc } from "../../utils/grpc";
4
- import mpx from "@mpxjs/core";
5
- class AuthApi {
6
- // 小程序静默登录
7
- mpLogin(data) {
8
- if (__mpx_mode__ === "wx") {
9
- data.opensType = OpensType.wechat;
10
- }
11
- if (__mpx_mode__ === "ali") {
12
- data.opensType = OpensType.ali_pay;
13
- }
14
- const config = getApp().globalData.config;
15
- return mpx.xfetch.fetch({
16
- url: "/v1/front/rbac/miniapp_login/" + config.tenant,
17
- method: "POST",
18
- data,
19
- header: {
20
- "content-type": "application/json",
21
- Authorization: false,
22
- },
23
- });
24
- }
25
- // 手机号注册登录
26
- mpPhoneRegister(data) {
27
- if (__mpx_mode__ === "wx") {
28
- data.opensType = OpensType.wechat;
29
- }
30
- if (__mpx_mode__ === "ali") {
31
- data.opensType = OpensType.ali_pay;
32
- }
33
- const config = getApp().globalData.config;
34
- return mpx.xfetch.fetch({
35
- url: "/v1/front/rbac/miniapp_phonenumber/" + config.tenant,
36
- method: "POST",
37
- data: data,
38
- header: {
39
- Authorization: false,
40
- },
41
- });
42
- }
43
- // 已登陆状态小程序更换绑定手机号
44
- replaceBindphone(data) {
45
- const config = getApp().globalData.config;
46
- data.tenant = config.tenant;
47
- if (__mpx_mode__ === "wx") {
48
- data.opensType = OpensType.wechat;
49
- }
50
- if (__mpx_mode__ === "ali") {
51
- data.opensType = OpensType.ali_pay;
52
- }
53
- grpc.clearEmpty(data);
54
- return mpx.xfetch.fetch({
55
- url: "/v1/front/rbac/miniapp_bindphone",
56
- method: "POST",
57
- data: data,
58
- });
59
- }
60
- //web登录.
61
- webLogin(data) {
62
- const config = getApp().globalData.config;
63
- data.tenant = config.tenant;
64
- data.directoryId = "user";
65
- data.clientId = config.appId ? config.appId : "h5";
66
- data.captchaId = "1";
67
- data.captchaCode = "1";
68
- return mpx.xfetch.fetch({
69
- url: "/v1/rbac/auth/login",
70
- method: "POST",
71
- data: data,
72
- header: {
73
- Authorization: false,
74
- },
75
- });
76
- }
77
- // 刷新token
78
- refreshToken() {
79
- const config = getApp().globalData.config;
80
- return mpx.xfetch.fetch({
81
- url: "/v1/front/rbac/auth/refresh_token",
82
- method: "POST",
83
- data: {
84
- refreshToken: db.getRefreshToken(),
85
- tenant: config.tenant,
86
- clientId: config.appId,
87
- },
88
- header: { "content-type": "application/json" },
89
- });
90
- }
91
- // 获取当前会话用户
92
- userInfo() {
93
- const config = getApp().globalData.config;
94
- return mpx.xfetch.fetch({
95
- url: "/v1/rbac/auth/user?tenant=" + config.tenant,
96
- method: "GET",
97
- });
98
- }
99
- // 当前用户角色权限
100
- userRolesPerms() {
101
- const config = getApp().globalData.config;
102
- return mpx.xfetch.fetch({
103
- url: "/v1/rbac/auth/roles_perms?tenant=" + config.tenant,
104
- method: "GET",
105
- });
106
- }
107
- // 允许切换身份的用户列表
108
- allowRunAsUser() {
109
- const config = getApp().globalData.config;
110
- return mpx.xfetch.fetch({
111
- url: "/v1/rbac/auth/allow_run_as_user?tenant=" + config.tenant,
112
- method: "GET",
113
- });
114
- }
115
- // 运行某种身份
116
- runAsUser(userId) {
117
- const config = getApp().globalData.config;
118
- const data = {
119
- tenant: config.tenant,
120
- userId: userId,
121
- };
122
- return mpx.xfetch.fetch({
123
- url: "/v1/rbac/auth/run_as",
124
- method: "POST",
125
- data: data,
126
- });
127
- }
128
- // 更新用户
129
- updateUser(data) {
130
- return mpx.xfetch.fetch({
131
- url: "/v1/rbac/auth/user",
132
- method: "PATCH",
133
- data: data,
134
- });
135
- }
136
- // 修改密码
137
- updatePwd(encodeOldPwd, encodeNewPwd) {
138
- const data = {
139
- tenant: db.getUserTenant(),
140
- encodeOldPwd: encodeOldPwd,
141
- encodeNewPwd: encodeNewPwd,
142
- };
143
- return mpx.xfetch.fetch({
144
- url: "/v1/rbac/auth/change_pwd",
145
- method: "PATCH",
146
- data: data,
147
- });
148
- }
149
- // 部门Tree
150
- deptTree(deptId, tenant) {
151
- const config = getApp().globalData.config;
152
- const query = {
153
- tenant: tenant ? tenant : config.tenant,
154
- excludeId: deptId,
155
- };
156
- return mpx.xfetch.fetch({
157
- url: "/v1/rbac/dept/treelist",
158
- method: "GET",
159
- data: query,
160
- });
161
- }
162
- // 职务Tree
163
- jobTree(jobId, tenant) {
164
- const config = getApp().globalData.config;
165
- const query = {
166
- tenant: tenant ? tenant : config.tenant,
167
- roleType: "job",
168
- hasRoleType: true,
169
- excludeId: jobId,
170
- };
171
- return mpx.xfetch.fetch({
172
- url: "/v1/rbac/role/treelist",
173
- method: "GET",
174
- data: query,
175
- });
176
- }
177
- // 修改个人信息
178
- updateUserInfo(data) {
179
- const config = getApp().globalData.config;
180
- data.tenant = config.tenant;
181
- grpc.clearEmpty(data);
182
- return mpx.xfetch.fetch({
183
- url: "/v1/rbac/auth/user",
184
- method: "PATCH",
185
- data: data,
186
- });
187
- }
188
- // 获取当前会话用户的信息
189
- findUserInfo(data) {
190
- const config = getApp().globalData.config;
191
- data.tenant = config.tenant;
192
- return mpx.xfetch.fetch({
193
- url: "/v1/front/rbac/auth/user",
194
- method: "GET",
195
- data,
196
- });
197
- }
198
- }
199
- export const authApi = new AuthApi();
1
+ import { OpensType } from "./types";
2
+ import { db } from "../../utils/db";
3
+ import { grpc } from "../../utils/grpc";
4
+ import mpx from "@mpxjs/core";
5
+ class AuthApi {
6
+ // 小程序静默登录
7
+ mpLogin(data) {
8
+ if (__mpx_mode__ === "wx") {
9
+ data.opensType = OpensType.wechat;
10
+ }
11
+ if (__mpx_mode__ === "ali") {
12
+ data.opensType = OpensType.ali_pay;
13
+ }
14
+ const config = getApp().globalData.config;
15
+ return mpx.xfetch.fetch({
16
+ url: "/v1/front/rbac/miniapp_login/" + config.tenant,
17
+ method: "POST",
18
+ data,
19
+ header: {
20
+ "content-type": "application/json",
21
+ Authorization: false,
22
+ },
23
+ });
24
+ }
25
+ // 手机号注册登录
26
+ mpPhoneRegister(data) {
27
+ if (__mpx_mode__ === "wx") {
28
+ data.opensType = OpensType.wechat;
29
+ }
30
+ if (__mpx_mode__ === "ali") {
31
+ data.opensType = OpensType.ali_pay;
32
+ }
33
+ const config = getApp().globalData.config;
34
+ return mpx.xfetch.fetch({
35
+ url: "/v1/front/rbac/miniapp_phonenumber/" + config.tenant,
36
+ method: "POST",
37
+ data: data,
38
+ header: {
39
+ Authorization: false,
40
+ },
41
+ });
42
+ }
43
+ // 已登陆状态小程序更换绑定手机号
44
+ replaceBindphone(data) {
45
+ const config = getApp().globalData.config;
46
+ data.tenant = config.tenant;
47
+ if (__mpx_mode__ === "wx") {
48
+ data.opensType = OpensType.wechat;
49
+ }
50
+ if (__mpx_mode__ === "ali") {
51
+ data.opensType = OpensType.ali_pay;
52
+ }
53
+ grpc.clearEmpty(data);
54
+ return mpx.xfetch.fetch({
55
+ url: "/v1/front/rbac/miniapp_bindphone",
56
+ method: "POST",
57
+ data: data,
58
+ });
59
+ }
60
+ //web登录.
61
+ webLogin(data) {
62
+ const config = getApp().globalData.config;
63
+ data.tenant = config.tenant;
64
+ data.directoryId = "user";
65
+ data.clientId = config.appId ? config.appId : "h5";
66
+ data.captchaId = "1";
67
+ data.captchaCode = "1";
68
+ return mpx.xfetch.fetch({
69
+ url: "/v1/rbac/auth/login",
70
+ method: "POST",
71
+ data: data,
72
+ header: {
73
+ Authorization: false,
74
+ },
75
+ });
76
+ }
77
+ // 刷新token
78
+ refreshToken() {
79
+ const config = getApp().globalData.config;
80
+ return mpx.xfetch.fetch({
81
+ url: "/v1/front/rbac/auth/refresh_token",
82
+ method: "POST",
83
+ data: {
84
+ refreshToken: db.getRefreshToken(),
85
+ tenant: config.tenant,
86
+ clientId: config.appId,
87
+ },
88
+ header: { "content-type": "application/json" },
89
+ });
90
+ }
91
+ // 获取当前会话用户
92
+ userInfo() {
93
+ const config = getApp().globalData.config;
94
+ return mpx.xfetch.fetch({
95
+ url: "/v1/rbac/auth/user?tenant=" + config.tenant,
96
+ method: "GET",
97
+ });
98
+ }
99
+ // 当前用户角色权限
100
+ userRolesPerms() {
101
+ const config = getApp().globalData.config;
102
+ return mpx.xfetch.fetch({
103
+ url: "/v1/rbac/auth/roles_perms?tenant=" + config.tenant,
104
+ method: "GET",
105
+ });
106
+ }
107
+ // 允许切换身份的用户列表
108
+ allowRunAsUser() {
109
+ const config = getApp().globalData.config;
110
+ return mpx.xfetch.fetch({
111
+ url: "/v1/rbac/auth/allow_run_as_user?tenant=" + config.tenant,
112
+ method: "GET",
113
+ });
114
+ }
115
+ // 运行某种身份
116
+ runAsUser(userId) {
117
+ const config = getApp().globalData.config;
118
+ const data = {
119
+ tenant: config.tenant,
120
+ userId: userId,
121
+ };
122
+ return mpx.xfetch.fetch({
123
+ url: "/v1/rbac/auth/run_as",
124
+ method: "POST",
125
+ data: data,
126
+ });
127
+ }
128
+ // 更新用户
129
+ updateUser(data) {
130
+ return mpx.xfetch.fetch({
131
+ url: "/v1/rbac/auth/user",
132
+ method: "PATCH",
133
+ data: data,
134
+ });
135
+ }
136
+ // 修改密码
137
+ updatePwd(encodeOldPwd, encodeNewPwd) {
138
+ const data = {
139
+ tenant: db.getUserTenant(),
140
+ encodeOldPwd: encodeOldPwd,
141
+ encodeNewPwd: encodeNewPwd,
142
+ };
143
+ return mpx.xfetch.fetch({
144
+ url: "/v1/rbac/auth/change_pwd",
145
+ method: "PATCH",
146
+ data: data,
147
+ });
148
+ }
149
+ // 部门Tree
150
+ deptTree(deptId, tenant) {
151
+ const config = getApp().globalData.config;
152
+ const query = {
153
+ tenant: tenant ? tenant : config.tenant,
154
+ excludeId: deptId,
155
+ };
156
+ return mpx.xfetch.fetch({
157
+ url: "/v1/rbac/dept/treelist",
158
+ method: "GET",
159
+ data: query,
160
+ });
161
+ }
162
+ // 职务Tree
163
+ jobTree(jobId, tenant) {
164
+ const config = getApp().globalData.config;
165
+ const query = {
166
+ tenant: tenant ? tenant : config.tenant,
167
+ roleType: "job",
168
+ hasRoleType: true,
169
+ excludeId: jobId,
170
+ };
171
+ return mpx.xfetch.fetch({
172
+ url: "/v1/rbac/role/treelist",
173
+ method: "GET",
174
+ data: query,
175
+ });
176
+ }
177
+ // 修改个人信息
178
+ updateUserInfo(data) {
179
+ const config = getApp().globalData.config;
180
+ data.tenant = config.tenant;
181
+ grpc.clearEmpty(data);
182
+ return mpx.xfetch.fetch({
183
+ url: "/v1/rbac/auth/user",
184
+ method: "PATCH",
185
+ data: data,
186
+ });
187
+ }
188
+ // 获取当前会话用户的信息
189
+ findUserInfo(data) {
190
+ const config = getApp().globalData.config;
191
+ data.tenant = config.tenant;
192
+ return mpx.xfetch.fetch({
193
+ url: "/v1/front/rbac/auth/user",
194
+ method: "GET",
195
+ data,
196
+ });
197
+ }
198
+ }
199
+ export const authApi = new AuthApi();