jmash-core-mp 0.1.48 → 0.1.49

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 (197) 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 +35 -35
  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/{types/core.js → components/cms/cms-channel-list.mpx.d.ts} +1 -1
  43. package/lib/components/cms/jmash-cms-acticle-list.mpx.d.ts +1 -1
  44. package/lib/components/cms/jmash-cms-activity-item.mpx.d.ts +1 -1
  45. package/lib/components/cms/jmash-cms-activity-list.mpx.d.ts +1 -1
  46. package/lib/components/cms/jmash-cms-activity-page.mpx.d.ts +1 -0
  47. package/lib/components/cms/jmash-cms-article-item.mpx.d.ts +1 -1
  48. package/lib/components/cms/jmash-cms-article-list.mpx.d.ts +1 -1
  49. package/lib/components/cms/jmash-cms-article-view.mpx.d.ts +1 -1
  50. package/lib/components/cms/jmash-cms-article.mpx.d.ts +1 -1
  51. package/lib/components/cms/jmash-cms-like.mpx.d.ts +1 -1
  52. package/lib/components/cms/jmash-cms-location-list.mpx.d.ts +1 -1
  53. package/lib/components/cms/jmash-cms-location-page.mpx.d.ts +1 -0
  54. package/lib/components/cms/jmash-cms-location.mpx.d.ts +1 -1
  55. package/lib/components/cms/jmash-cms-product-item.mpx.d.ts +1 -1
  56. package/lib/components/cms/jmash-cms-product-list.mpx.d.ts +1 -1
  57. package/lib/components/common/jmash-none-data.mpx.d.ts +1 -0
  58. package/lib/components/common/jmash-search.mpx.d.ts +1 -1
  59. package/lib/components/common/jmash-top-navigation.mpx.d.ts +1 -0
  60. package/lib/components/core/jmash-login.mpx.d.ts +1 -1
  61. package/lib/components/organ/browser-organ-list.mpx.d.ts +1 -0
  62. package/lib/components/organ/my-organ-list.mpx.d.ts +1 -0
  63. package/lib/components/organ/organ-item.mpx.d.ts +1 -0
  64. package/lib/components/organ/organ-search.mpx.d.ts +1 -0
  65. package/lib/index.d.ts +24 -23
  66. package/lib/index.js +20 -18
  67. package/lib/packages/pages/auth/setting-page.mpx.d.ts +1 -1
  68. package/lib/packages/pages/cms/cms-activity-list.mpx.d.ts +1 -1
  69. package/lib/packages/pages/cms/cms-article-list.mpx.d.ts +1 -1
  70. package/lib/packages/pages/cms/cms-info.mpx.d.ts +1 -0
  71. package/lib/packages/pages/cms/cms-list.mpx.d.ts +1 -0
  72. package/lib/packages/pages/cms/cms-location-list.mpx.d.ts +1 -1
  73. package/lib/packages/pages/cms/cms-product-list.mpx.d.ts +1 -1
  74. package/lib/pages/organ-search.mpx.d.ts +1 -0
  75. package/lib/pages/organ.mpx.d.ts +1 -0
  76. package/lib/store/organ.d.ts +9 -0
  77. package/lib/store/organ.js +17 -0
  78. package/lib/store/user.d.ts +31 -31
  79. package/lib/store/user.js +226 -226
  80. package/lib/utils/common.d.ts +35 -35
  81. package/lib/utils/common.js +165 -165
  82. package/lib/utils/config.d.ts +5 -5
  83. package/lib/utils/config.js +30 -30
  84. package/lib/utils/db.d.ts +25 -21
  85. package/lib/utils/db.js +98 -84
  86. package/lib/utils/grpc.d.ts +5 -5
  87. package/lib/utils/grpc.js +20 -20
  88. package/lib/utils/net.d.ts +7 -7
  89. package/lib/utils/net.js +15 -15
  90. package/lib/utils/request.d.ts +2 -2
  91. package/lib/utils/request.js +114 -114
  92. package/mpx.config.js +27 -27
  93. package/package.json +1 -1
  94. package/postcss.config.js +11 -11
  95. package/project.config.json +24 -24
  96. package/project.private.config.json +13 -13
  97. package/public/index.html +15 -15
  98. package/src/api/auth/index.ts +227 -227
  99. package/src/api/auth/types.ts +166 -166
  100. package/src/api/cms/index.ts +218 -218
  101. package/src/api/cms/types.ts +385 -385
  102. package/src/api/constant.ts +8 -8
  103. package/src/api/dict/index.ts +68 -68
  104. package/src/api/dict/types.ts +73 -73
  105. package/src/api/dicts.ts +132 -132
  106. package/src/api/files/index.ts +162 -162
  107. package/src/api/files/types.ts +67 -67
  108. package/src/api/index.ts +15 -15
  109. package/src/api/myorgan/types.ts +42 -42
  110. package/src/api/region/index.ts +24 -24
  111. package/src/api/region/types.ts +36 -36
  112. package/src/api/storage/index.ts +62 -62
  113. package/src/api/storage/types.ts +65 -65
  114. package/src/api/types.ts +74 -74
  115. package/src/app.mpx +62 -60
  116. package/src/components/auth-user/jmash-logout.mpx +93 -93
  117. package/src/components/auth-user/jmash-update-user.mpx +387 -387
  118. package/src/components/auth-user/jmash-update-user.web.mpx +367 -367
  119. package/src/components/auth-user/jmash-user.mpx +310 -310
  120. package/src/components/cms/jmash-cms-activity-item.mpx +207 -207
  121. package/src/components/cms/jmash-cms-activity-list.mpx +357 -357
  122. package/src/components/cms/jmash-cms-article-item.mpx +221 -221
  123. package/src/components/cms/jmash-cms-article-list.mpx +248 -248
  124. package/src/components/cms/jmash-cms-article-view.mpx +131 -131
  125. package/src/components/cms/jmash-cms-article.mpx +231 -231
  126. package/src/components/cms/jmash-cms-like.mpx +151 -151
  127. package/src/components/cms/jmash-cms-location-list.mpx +286 -286
  128. package/src/components/cms/jmash-cms-location.mpx +256 -256
  129. package/src/components/cms/jmash-cms-product-item.mpx +185 -185
  130. package/src/components/cms/jmash-cms-product-list.mpx +230 -230
  131. package/src/components/common/jmash-avatar-edit.mpx +154 -154
  132. package/src/components/common/jmash-cascader-region.mpx +118 -118
  133. package/src/components/common/jmash-cell-group.mpx +201 -201
  134. package/src/components/common/jmash-code-interest-popup.mpx +223 -223
  135. package/src/components/common/jmash-form-cell.mpx +524 -524
  136. package/src/components/common/jmash-menu.mpx +129 -129
  137. package/src/components/common/jmash-none-data.mpx +95 -95
  138. package/src/components/common/jmash-pic-swiper.mpx +72 -72
  139. package/src/components/common/jmash-popup.mpx +138 -138
  140. package/src/components/common/jmash-search.mpx +126 -126
  141. package/src/components/common/jmash-single-btn.mpx +53 -53
  142. package/src/components/common/jmash-stepper.mpx +236 -236
  143. package/src/components/common/jmash-tab-bar.mpx +46 -46
  144. package/src/components/common/jmash-textarea.mpx +88 -88
  145. package/src/components/common/jmash-top-navigation.mpx +203 -203
  146. package/src/components/common/jmash-upload-picture.mpx +199 -199
  147. package/src/components/core/jmash-cms-protocol.mpx +72 -72
  148. package/src/components/core/jmash-login.ali.mpx +284 -284
  149. package/src/components/core/jmash-login.mpx +378 -378
  150. package/src/components/core/jmash-login.web.mpx +420 -420
  151. package/src/components/core/jmash-popup-login.ali.mpx +312 -312
  152. package/src/components/core/jmash-popup-login.mpx +416 -416
  153. package/src/components/core/jmash-popup-login.web.mpx +389 -389
  154. package/src/components/organ/browser-organ-list.mpx +62 -0
  155. package/src/components/organ/my-organ-list.mpx +62 -0
  156. package/src/components/organ/organ-item.mpx +122 -0
  157. package/src/components/organ/organ-search.mpx +148 -0
  158. package/src/custom-tab-bar/index.mpx +10 -10
  159. package/src/global.d.ts +11 -11
  160. package/src/index.ts +82 -80
  161. package/src/packages/index.mpx +15 -15
  162. package/src/packages/pages/auth/cms-protocol.mpx +35 -35
  163. package/src/packages/pages/auth/login.mpx +62 -62
  164. package/src/packages/pages/auth/setting-page.mpx +134 -134
  165. package/src/packages/pages/auth/update-user.mpx +17 -17
  166. package/src/packages/pages/cms/cms-activity-list.mpx +86 -86
  167. package/src/packages/pages/cms/cms-article-list.mpx +88 -88
  168. package/src/packages/pages/cms/cms-article.mpx +32 -32
  169. package/src/packages/pages/cms/cms-location-list.mpx +83 -83
  170. package/src/packages/pages/cms/cms-location.mpx +32 -32
  171. package/src/packages/pages/cms/cms-product-list.mpx +88 -88
  172. package/src/pages/basic-component.mpx +30 -30
  173. package/src/pages/half-home.mpx +58 -58
  174. package/src/pages/home.mpx +54 -54
  175. package/src/pages/home2.mpx +45 -45
  176. package/src/pages/index.mpx +43 -43
  177. package/src/pages/organ-search.mpx +60 -0
  178. package/src/pages/organ.mpx +104 -0
  179. package/src/pages/tabbar/home.mpx +92 -91
  180. package/src/pages/tabbar/my.mpx +79 -79
  181. package/src/store/organ.ts +26 -0
  182. package/src/store/user.ts +269 -269
  183. package/src/styles/index.scss +20 -20
  184. package/src/styles/vars.scss +27 -27
  185. package/src/utils/common.ts +178 -178
  186. package/src/utils/config.ts +36 -36
  187. package/src/utils/db.ts +116 -100
  188. package/src/utils/grpc.ts +21 -21
  189. package/src/utils/net.ts +18 -18
  190. package/src/utils/request.ts +126 -126
  191. package/static/ali/mini.project.json +4 -4
  192. package/static/dd/project.config.json +15 -15
  193. package/static/swan/project.swan.json +14 -14
  194. package/static/tt/project.config.json +11 -11
  195. package/static/wx/project.config.json +40 -40
  196. package/uno.config.js +9 -9
  197. package/lib/types/core.d.ts +0 -41
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();