xyvcard-wechat-auth 0.0.24 → 0.0.27

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.
@@ -12,7 +12,7 @@ declare class AuthApiImpl {
12
12
  updateUser(data: any): Promise<ResponseData<any>>;
13
13
  updatePwd(encodeOldPwd: string, encodeNewPwd: string): Promise<ResponseData<any>>;
14
14
  deptTree(deptId?: string): Promise<ResponseData<any>>;
15
- jobTree(): Promise<ResponseData<any>>;
15
+ jobTree(jobId?: string): Promise<ResponseData<any>>;
16
16
  updateUserInfo(data: UpdateUserReq): Promise<ResponseData<UserInfo>>;
17
17
  replaceBindphone(data: PhoneNumberReq): Promise<ResponseData<boolean>>;
18
18
  findUserInfo(data: UserInfoReq): Promise<ResponseData<UserInfo>>;
@@ -111,11 +111,12 @@ class AuthApiImpl {
111
111
  });
112
112
  }
113
113
  // 职务Tree
114
- jobTree() {
114
+ jobTree(jobId) {
115
115
  const query = {
116
116
  tenant: db.getUserTenant(),
117
117
  roleType: "job",
118
- hasRoleType: true
118
+ hasRoleType: true,
119
+ excludeId: jobId
119
120
  };
120
121
  return request({
121
122
  url: "/v1/rbac/role/treelist",
@@ -56,3 +56,14 @@ export interface UpdateUserReq {
56
56
  export interface UserInfoReq {
57
57
  tenant?: string;
58
58
  }
59
+ export interface RoleModel {
60
+ roleId?: string;
61
+ roleName?: string;
62
+ roleType?: string;
63
+ }
64
+ export interface DeptModel {
65
+ deptId?: string;
66
+ deptName?: string;
67
+ deptType?: string;
68
+ parentId?: string;
69
+ }
@@ -1 +1 @@
1
- .auth-mask-box{position:fixed;left:0;top:0;bottom:0;right:0;width:100%;background-color:rgba(0,0,0,.5);z-index:99999}.auth-mask-popup{position:fixed;bottom:0;left:0;padding:0 30rpx env(safe-area-inset-bottom);box-sizing:border-box;z-index:99999}.auth-mask-popup .popup-title{color:#333;font-size:28rpx;padding:40rpx 20rpx 20rpx;font-weight:bold;display:flex;align-items:center;justify-content:space-between}.auth-mask-popup .popup-title .close-icon{width:40rpx;height:40rpx}
1
+ .auth-mask-box{position:fixed;left:0;top:0;bottom:0;right:0;width:100%;background-color:rgba(0,0,0,.5);z-index:99999}.auth-mask-popup{position:fixed;bottom:0;left:0;width:92%;padding:0 30rpx env(safe-area-inset-bottom);box-sizing:border-box;z-index:99999}.auth-mask-popup .popup-title{color:#333;font-size:28rpx;padding:20px 10px 10px;font-weight:bold;display:flex;align-items:center;justify-content:space-between}.auth-mask-popup .popup-title .close-icon{width:40rpx;height:40rpx}
@@ -31,7 +31,7 @@ Component({
31
31
  // 登录后跳转方式 "redirectTo switchTab reLaunch navigateTo"
32
32
  linkType: {
33
33
  type: String,
34
- value: ""
34
+ value: "redirectTo"
35
35
  },
36
36
  //遮罩层效果
37
37
  isShowModel: {
@@ -76,7 +76,6 @@ Component({
76
76
  if (event.detail.errMsg === "getPhoneNumber:ok") {
77
77
  console.log(event.detail.code);
78
78
  auth.phoneCodeLogin(event.detail.code).then((resp) => {
79
- console.log(resp);
80
79
  if (resp.status == false) {
81
80
  wx.showToast({
82
81
  title: resp.message ? resp.message : "登录失败联系管理员",
@@ -85,22 +84,15 @@ Component({
85
84
  });
86
85
  return;
87
86
  }
87
+ const backurl = decodeURIComponent(this.properties.backurl);
88
88
  if (this.properties.linkType === "switchTab") {
89
- wx.switchTab({
90
- url: this.properties.backurl
91
- });
89
+ wx.switchTab({ url: backurl });
92
90
  } else if (this.properties.linkType === "navigateTo") {
93
- wx.navigateTo({
94
- url: this.properties.backurl
95
- });
91
+ wx.navigateTo({ url: backurl });
96
92
  } else if (this.properties.linkType === "reLaunch") {
97
- wx.reLaunch({
98
- url: this.properties.backurl
99
- });
93
+ wx.reLaunch({ url: backurl });
100
94
  } else {
101
- wx.redirectTo({
102
- url: this.properties.backurl
103
- });
95
+ wx.redirectTo({ url: backurl });
104
96
  }
105
97
  });
106
98
  } else {
package/dist/index.d.ts CHANGED
@@ -9,7 +9,7 @@ export type { RequestData, ResponseData, RequestHeader, CustomEvent } from "./ap
9
9
  export { Dict } from "./api/index";
10
10
  export { EntryDict, EnumDict } from "./api/dicts";
11
11
  export { authApi } from "./api/auth/index";
12
- export type { LoginReq, LoginRes, PhoneNumberReq, RefreshTokenReq, TokenRes, RolesPerms, UserInfo, UpdateUserReq, UserInfoReq } from "./api/auth/types";
12
+ export type { LoginReq, LoginRes, PhoneNumberReq, RefreshTokenReq, TokenRes, RolesPerms, UserInfo, UpdateUserReq, UserInfoReq, RoleModel, DeptModel } from "./api/auth/types";
13
13
  export { dictApi } from "./api/dict/index";
14
14
  export type { Entry, DictEntryModel, DictEntryReq } from "./api/dict/types";
15
15
  export { fileApi } from "./api/files/index";
@@ -29,13 +29,11 @@ class Auth {
29
29
  resolve(true);
30
30
  return;
31
31
  }
32
+ let toUrl = loginurl + "?tabbar=" + (tabbar ? "true" : "false");
33
+ toUrl += "&backurl=" + encodeURIComponent(backurl);
32
34
  if (config.dev && config.testNewUser) {
33
35
  reject(false);
34
- let toUrl = loginurl + "?tabbar=" + (tabbar ? "true" : "false");
35
- toUrl += "&backurl=" + backurl;
36
- wx.navigateTo({
37
- url: toUrl
38
- });
36
+ wx.navigateTo({ url: toUrl });
39
37
  return;
40
38
  }
41
39
  this.silentLogin().then((res) => {
@@ -43,11 +41,7 @@ class Auth {
43
41
  resolve(true);
44
42
  } else {
45
43
  reject(false);
46
- let toUrl = loginurl + "?tabbar=" + (tabbar ? "true" : "false");
47
- toUrl += "&backurl=" + backurl;
48
- wx.navigateTo({
49
- url: toUrl
50
- });
44
+ wx.navigateTo({ url: toUrl });
51
45
  }
52
46
  });
53
47
  });
@@ -131,20 +125,18 @@ class Auth {
131
125
  appId: config.appId,
132
126
  nickName,
133
127
  componentAppid: config.componentAppid
134
- }).then(
135
- (resp) => {
136
- console.log("phoneCodeLogin-res", resp);
137
- if (resp.code === 200 && resp.data.status === true) {
138
- db.loginStorage(resp.data);
139
- console.log("login success");
140
- this.getRolePerm().then(() => {
141
- resolve(resp.data);
142
- });
143
- } else {
144
- reject(resp.message);
145
- }
128
+ }).then((resp) => {
129
+ console.log("phoneCodeLogin-res", resp);
130
+ if (resp.code === 200 && resp.data.status === true) {
131
+ db.loginStorage(resp.data);
132
+ console.log("login success");
133
+ this.getRolePerm().then(() => {
134
+ resolve(resp.data);
135
+ });
136
+ } else {
137
+ reject(resp.message);
146
138
  }
147
- );
139
+ });
148
140
  }
149
141
  },
150
142
  fail: (fail) => {
@@ -157,7 +149,10 @@ class Auth {
157
149
  // 获取角色
158
150
  getRolePerm(cache = true) {
159
151
  return new Promise((resolve, reject) => {
160
- let rolesPerms = { roleCodes: db.getRoleCodes(), permCodes: db.getPermCodes() };
152
+ let rolesPerms = {
153
+ roleCodes: db.getRoleCodes(),
154
+ permCodes: db.getPermCodes()
155
+ };
161
156
  if (cache && (Object.keys(rolesPerms.roleCodes).length > 0 || Object.keys(rolesPerms.permCodes).length > 0)) {
162
157
  resolve(rolesPerms);
163
158
  return;
@@ -2,8 +2,8 @@ const https = "https://";
2
2
  const host = "gh.sooyie.cn";
3
3
  const agentUrl = "/v1/file/path/wxapp";
4
4
  const config = {
5
- dev: true,
6
- testNewUser: true,
5
+ dev: false,
6
+ testNewUser: false,
7
7
  name: "Jmash框架",
8
8
  baseUrl: https + host,
9
9
  // 接口域名
@@ -1,5 +1,4 @@
1
1
  import { RequestData, ResponseData, RequestHeader } from "../api/types";
2
- declare const request: (options?: RequestData<any>, tenant?: string) => Promise<ResponseData<any>>;
3
- declare const sendRequest: (options: RequestData<any>, header: RequestHeader) => Promise<ResponseData<any>>;
4
- declare function clearEmpty(params: any): any;
5
- export { request, sendRequest, clearEmpty };
2
+ export declare const request: (options?: RequestData<any>, tenant?: string) => Promise<ResponseData<any>>;
3
+ export declare const sendRequest: (options: RequestData<any>, header: RequestHeader) => Promise<ResponseData<any>>;
4
+ export declare function clearEmpty(params: any): any;
@@ -24,7 +24,7 @@ const request = async (options = {}, tenant = "") => {
24
24
  try {
25
25
  let header = {
26
26
  "content-type": "application/json",
27
- "Authorization": db.getBearerToken(),
27
+ Authorization: db.getBearerToken(),
28
28
  "Grpc-Metadata-Tenant": tenant
29
29
  };
30
30
  const response = await sendRequest(options, header);
@@ -67,15 +67,14 @@ const sendRequest = (options, header) => {
67
67
  };
68
68
  function clearEmpty(params) {
69
69
  for (const key in params) {
70
- if (typeof params[key] === "object") {
71
- clearEmpty(params[key]);
72
- }
73
- if (typeof params[key] === "object" && Object.keys(params[key]).length === 0) {
74
- delete params[key];
75
- }
76
- if (params[key] === "") {
77
- delete params[key];
70
+ if (params[key] !== null && typeof params[key] === "object") {
71
+ if (Object.keys(params[key]).length === 0) {
72
+ delete params[key];
73
+ } else {
74
+ clearEmpty(params[key]);
75
+ }
78
76
  }
77
+ if ([void 0, null, ""].includes(params[key])) delete params[key];
79
78
  }
80
79
  return params;
81
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xyvcard-wechat-auth",
3
- "version": "0.0.24",
3
+ "version": "0.0.27",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",