jmash-core-mp 0.1.61 → 0.1.62

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