xyvcard-wechat-auth 0.0.1 → 0.0.2

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 (72) hide show
  1. package/README.md +1 -1
  2. package/dist/api/auth/index.js +159 -1
  3. package/dist/api/auth/types.js +1 -1
  4. package/dist/api/dict/index.js +36 -1
  5. package/dist/api/dict/types.js +1 -1
  6. package/dist/api/dicts.js +53 -1
  7. package/dist/api/files/index.js +135 -1
  8. package/dist/api/files/types.js +1 -1
  9. package/dist/api/index.js +12 -1
  10. package/dist/api/myorgan/index.js +1 -1
  11. package/dist/api/myorgan/types.js +1 -1
  12. package/dist/api/types.d.ts +47 -0
  13. package/dist/api/types.js +9 -1
  14. package/dist/components/common/btn/footer-btn/index.js +34 -1
  15. package/dist/components/common/btn/footer-btn/index.wxml +1 -1
  16. package/dist/components/common/btn/footer-double-btn/index.js +67 -1
  17. package/dist/components/common/btn/footer-double-btn/index.wxml +4 -2
  18. package/dist/components/common/btn/footer-double-btn/index.wxss +1 -0
  19. package/dist/components/common/choose-avatar/index.js +82 -1
  20. package/dist/components/common/choose-avatar/index.wxss +1 -1
  21. package/dist/components/common/none-data/index.js +53 -1
  22. package/dist/components/common/none-data/index.wxml +2 -2
  23. package/dist/components/common/none-data/index.wxss +1 -1
  24. package/dist/components/common/popup/index.js +50 -1
  25. package/dist/components/common/popup/index.wxml +1 -1
  26. package/dist/components/common/popup/index.wxss +1 -1
  27. package/dist/components/common/search/index.d.ts +1 -0
  28. package/dist/components/common/search/index.js +55 -0
  29. package/dist/components/common/search/index.json +4 -0
  30. package/dist/components/common/search/index.wxml +7 -0
  31. package/dist/components/common/search/index.wxss +1 -0
  32. package/dist/components/common/top-navigation/index.d.ts +1 -0
  33. package/dist/components/common/top-navigation/index.js +49 -0
  34. package/dist/components/common/top-navigation/index.json +4 -0
  35. package/dist/components/common/top-navigation/index.wxml +6 -0
  36. package/dist/components/common/top-navigation/index.wxss +1 -0
  37. package/dist/components/jmash-half-login/index.d.ts +1 -0
  38. package/dist/components/jmash-half-login/index.js +105 -0
  39. package/dist/components/jmash-half-login/index.json +8 -0
  40. package/dist/components/jmash-half-login/index.wxml +46 -0
  41. package/dist/components/jmash-half-login/index.wxss +1 -0
  42. package/dist/components/jmash-login/index.d.ts +1 -0
  43. package/dist/components/jmash-login/index.js +99 -0
  44. package/dist/components/jmash-login/index.json +4 -0
  45. package/dist/components/jmash-login/index.wxml +16 -0
  46. package/dist/components/jmash-login/index.wxss +1 -0
  47. package/dist/constant.js +15 -1
  48. package/dist/index.d.ts +10 -2
  49. package/dist/index.js +23 -1
  50. package/dist/styles/{global.scss → index.scss} +11 -1
  51. package/dist/utils/auth.d.ts +3 -2
  52. package/dist/utils/auth.js +199 -1
  53. package/dist/utils/common.d.ts +16 -0
  54. package/dist/utils/common.js +112 -1
  55. package/dist/utils/config.d.ts +3 -1
  56. package/dist/utils/config.js +27 -1
  57. package/dist/utils/db.js +188 -1
  58. package/dist/utils/request.js +86 -1
  59. package/dist/utils/util.d.ts +9 -0
  60. package/dist/utils/util.js +88 -1
  61. package/package.json +4 -3
  62. package/xyvcard-wechat-auth-0.0.1.tgz +0 -0
  63. package/dist/app.d.ts +0 -0
  64. package/dist/app.js +0 -1
  65. package/dist/app.json +0 -24
  66. package/dist/app.wxss +0 -0
  67. package/dist/pages/index/index.d.ts +0 -0
  68. package/dist/pages/index/index.js +0 -1
  69. package/dist/pages/index/index.json +0 -7
  70. package/dist/pages/index/index.wxml +0 -4
  71. package/dist/pages/index/index.wxss +0 -0
  72. package/dist/sitemap.json +0 -7
@@ -1 +1,86 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./config.js"),t=require("./db.js"),r=require("./auth.js");let o=!1,s=null;const a=(t,r)=>new Promise((o,s)=>{var a;wx.request({url:e.config.baseUrl+t.url,method:t.method,data:t.data,header:r,responseType:null!=(a=t.responseType)?a:"text",success(e){200===e.statusCode?o({code:e.statusCode,message:e.errMsg,data:e.data}):401===e.statusCode?wx.clearStorage():o({code:e.statusCode,message:e.errMsg,data:e.data})},fail(e){s(e)}})});exports.clearEmpty=function e(t){for(const r in t)"object"==typeof t[r]&&e(t[r]),"object"==typeof t[r]&&0===Object.keys(t[r]).length&&delete t[r],""===t[r]&&delete t[r];return t},exports.request=(...e)=>{return n=null,c=[...e],u=function*(e={},n=""){t.db.isTokenExpire()&&(o?yield s:(o=!0,s||(s=new Promise((e,t)=>{r.auth.refreshToken().then(()=>e(!0)).catch(e=>{wx.clearStorage(),t(e)})})),yield s,o=!1));try{let r={"content-type":"application/json",Authorization:t.db.getBearerToken(),"Grpc-Metadata-Tenant":n};return yield a(e,r)}catch(c){return Promise.reject(c)}},new Promise((e,t)=>{var r=e=>{try{s(u.next(e))}catch(r){t(r)}},o=e=>{try{s(u.throw(e))}catch(r){t(r)}},s=t=>t.done?e(t.value):Promise.resolve(t.value).then(r,o);s((u=u.apply(n,c)).next())});var n,c,u},exports.sendRequest=a,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
1
+ import { config } from "./config.js";
2
+ import { db } from "./db.js";
3
+ import { auth } from "./auth.js";
4
+ let isRefreshing = false;
5
+ let refreshPromise = null;
6
+ const request = async (options = {}, tenant = "") => {
7
+ if (db.isTokenExpire()) {
8
+ if (!isRefreshing) {
9
+ isRefreshing = true;
10
+ if (!refreshPromise) {
11
+ refreshPromise = new Promise((resolve, reject) => {
12
+ auth.refreshToken().then(() => resolve(true)).catch((err) => {
13
+ wx.clearStorage();
14
+ reject(err);
15
+ });
16
+ });
17
+ }
18
+ await refreshPromise;
19
+ isRefreshing = false;
20
+ } else {
21
+ await refreshPromise;
22
+ }
23
+ }
24
+ try {
25
+ let header = {
26
+ "content-type": "application/json",
27
+ "Authorization": db.getBearerToken(),
28
+ "Grpc-Metadata-Tenant": tenant
29
+ };
30
+ const response = await sendRequest(options, header);
31
+ return response;
32
+ } catch (error) {
33
+ return Promise.reject(error);
34
+ }
35
+ };
36
+ const sendRequest = (options, header) => {
37
+ return new Promise((resolve, reject) => {
38
+ wx.request({
39
+ url: config.baseUrl + options.url,
40
+ method: options.method,
41
+ data: options.data,
42
+ header,
43
+ responseType: options.responseType ? "text" : options.responseType,
44
+ success(response) {
45
+ if (response.statusCode === 200) {
46
+ resolve({
47
+ code: response.statusCode,
48
+ message: response.errMsg,
49
+ data: response.data
50
+ });
51
+ } else if (response.statusCode === 401) {
52
+ console.log("token过期....");
53
+ wx.clearStorage();
54
+ } else {
55
+ resolve({
56
+ code: response.statusCode,
57
+ message: response.errMsg,
58
+ data: response.data
59
+ });
60
+ }
61
+ },
62
+ fail(error) {
63
+ reject(error);
64
+ }
65
+ });
66
+ });
67
+ };
68
+ function clearEmpty(params) {
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];
78
+ }
79
+ }
80
+ return params;
81
+ }
82
+ export {
83
+ clearEmpty,
84
+ request,
85
+ sendRequest
86
+ };
@@ -1 +1,10 @@
1
+ /**
2
+ * 格式化日期时间字符串,格式化后的日期时间字符串2024-05-16
3
+ * @param dateTimeString 转换前的字符串2024-05-16T00:00:00.000Z
4
+ * @param format 转换格式
5
+ */
6
+ export declare const formatDateTime: (dateTimeString: string, format?: any) => string;
1
7
  export declare const formatTime: (date: Date) => string;
8
+ export declare function splitOrganTenant(organ: any): any;
9
+ export declare function splitVcardTenant(vcard: any): any;
10
+ export declare function splitVcardTenantReturn(vcardId: string, vcardTenant: string): string;
@@ -1 +1,88 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=e=>{const t=e.toString();return t[1]?t:"0"+t};exports.formatTime=t=>{const o=t.getFullYear(),r=t.getMonth()+1,n=t.getDate(),s=t.getHours(),u=t.getMinutes(),p=t.getSeconds();return[o,r,n].map(e).join("/")+" "+[s,u,p].map(e).join(":")},"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
1
+ const formatDateTime = (dateTimeString, format) => {
2
+ var date = new Date(dateTimeString);
3
+ var year = date.getFullYear();
4
+ var month = ("0" + (date.getMonth() + 1)).slice(-2);
5
+ var day = ("0" + date.getDate()).slice(-2);
6
+ var hours = ("0" + date.getHours()).slice(-2);
7
+ var minutes = ("0" + date.getMinutes()).slice(-2);
8
+ var seconds = ("0" + date.getSeconds()).slice(-2);
9
+ if (format === "YYYY-MM-DD HH:mm:ss") {
10
+ return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
11
+ }
12
+ if (format === "YYYY-MM-DD HH:mm") {
13
+ return year + "-" + month + "-" + day + " " + hours + ":" + minutes;
14
+ }
15
+ if (format === "YYYY-MM-DD") {
16
+ return year + "-" + month + "-" + day;
17
+ }
18
+ if (format === "YYYY-MM") {
19
+ return year + "-" + month;
20
+ }
21
+ if (format === "YYYY年MM月DD日") {
22
+ return year + "年" + month + "月" + day + "日";
23
+ }
24
+ if (format === "YYYY年MM月DD日 HH:mm") {
25
+ return year + "年" + month + "月" + day + "日 " + hours + ":" + minutes;
26
+ }
27
+ if (format === "YYYY年MM月DD日 HH:mm:ss") {
28
+ return year + "年" + month + "月" + day + "日 " + hours + ":" + minutes + ":" + seconds;
29
+ }
30
+ if (format === "YYYY年MM月DD日 HH时mm分") {
31
+ return year + "年" + month + "月" + day + "日 " + hours + "时" + minutes + "分";
32
+ }
33
+ if (format === "MM.DD") {
34
+ return month + "." + day;
35
+ }
36
+ if (format === "MM/DD") {
37
+ return month + "/" + day;
38
+ }
39
+ if (format === "MM月DD日") {
40
+ return month + "月" + day + "日";
41
+ }
42
+ if (format === "MM月DD日 HH:mm") {
43
+ return month + "月" + day + "日 " + hours + ":" + minutes;
44
+ }
45
+ return "";
46
+ };
47
+ const formatTime = (date) => {
48
+ const year = date.getFullYear();
49
+ const month = date.getMonth() + 1;
50
+ const day = date.getDate();
51
+ const hour = date.getHours();
52
+ const minute = date.getMinutes();
53
+ const second = date.getSeconds();
54
+ return [year, month, day].map(formatNumber).join("/") + " " + [hour, minute, second].map(formatNumber).join(":");
55
+ };
56
+ const formatNumber = (n) => {
57
+ const s = n.toString();
58
+ return s[1] ? s : "0" + s;
59
+ };
60
+ function splitOrganTenant(organ) {
61
+ let tenant = organ.organTenant;
62
+ if (organ.orgId) {
63
+ tenant = organ.organTenant.split("@")[1];
64
+ }
65
+ return tenant;
66
+ }
67
+ function splitVcardTenant(vcard) {
68
+ let tenant = vcard.organTenant;
69
+ if (vcard.orgId) {
70
+ tenant = vcard.organTenant.split("@")[1];
71
+ }
72
+ return tenant;
73
+ }
74
+ function splitVcardTenantReturn(vcardId, vcardTenant) {
75
+ const isOrganVcard = (vcardTenant == null ? void 0 : vcardTenant.indexOf("@e")) > -1 ? true : false;
76
+ console.log("是否是组织名片", isOrganVcard);
77
+ if (isOrganVcard) {
78
+ vcardTenant = vcardId.split("@")[1] ? vcardId.split("@")[1] : vcardTenant;
79
+ }
80
+ return vcardTenant;
81
+ }
82
+ export {
83
+ formatDateTime,
84
+ formatTime,
85
+ splitOrganTenant,
86
+ splitVcardTenant,
87
+ splitVcardTenantReturn
88
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xyvcard-wechat-auth",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -9,10 +9,11 @@
9
9
  "author": "",
10
10
  "license": "",
11
11
  "dependencies": {
12
- "miniprogram-api-typings": "^4.0.7"
12
+ "miniprogram-api-typings": "^4.1.0",
13
+ "@vant/weapp": "^1.11.7"
13
14
  },
14
15
  "devDependencies": {
15
- "xyvcard-mini-wechat": "^0.0.3",
16
+ "xyvcard-wechat-build": "^0.0.2",
16
17
  "typescript": "^5.8.3"
17
18
  },
18
19
  "scripts": {
Binary file
package/dist/app.d.ts DELETED
File without changes
package/dist/app.js DELETED
@@ -1 +0,0 @@
1
- "use strict";App({globalData:{},onLaunch(){(wx.getStorageSync("logs")||[]).unshift(Date.now()),wx.login({success:e=>{}})}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
package/dist/app.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "pages": [
3
- "pages/index/index"
4
- ],
5
- "window": {
6
- "navigationBarTextStyle": "black",
7
- "navigationBarTitleText": "",
8
- "navigationBarBackgroundColor": "#fff"
9
- },
10
- "style": "v2",
11
- "rendererOptions": {
12
- "skyline": {
13
- "defaultDisplayBlock": true,
14
- "defaultContentBox": true,
15
- "tagNameStyleIsolation": "legacy",
16
- "disableABTest": true,
17
- "sdkVersionBegin": "3.0.0",
18
- "sdkVersionEnd": "15.255.255"
19
- }
20
- },
21
- "componentFramework": "glass-easel",
22
- "sitemapLocation": "sitemap.json",
23
- "lazyCodeLoading": "requiredComponents"
24
- }
package/dist/app.wxss DELETED
File without changes
File without changes
@@ -1 +0,0 @@
1
- "use strict";Page({data:{},onLoad(){},onReady(){},onShow(){},onHide(){},onUnload(){},onPullDownRefresh(){},onReachBottom(){},onShareAppMessage(){}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(o){exports[o]=module.exports[o]});
@@ -1,7 +0,0 @@
1
- {
2
- "usingComponents": {
3
- "footer-btn": "/components/common/btn/footer-btn/index",
4
- "footer-double-btn": "/components/common/btn/footer-double-btn/index",
5
- "choose-avatar": "/components/common/choose-avatar/index"
6
- }
7
- }
@@ -1,4 +0,0 @@
1
- <view style="width: 100%;">
2
- <footer-btn text="保存" btnBgColor="#2563EB" fontColor="#fff"></footer-btn>
3
- </view>
4
- <choose-avatar></choose-avatar>
File without changes
package/dist/sitemap.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
3
- "rules": [{
4
- "action": "allow",
5
- "page": "*"
6
- }]
7
- }