xyvcard-wechat-auth 0.0.17 → 0.0.19

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 (62) hide show
  1. package/dist/api/auth/index.js +1 -159
  2. package/dist/api/auth/types.js +1 -1
  3. package/dist/api/dict/index.js +1 -36
  4. package/dist/api/dict/types.js +1 -1
  5. package/dist/api/dicts.js +1 -53
  6. package/dist/api/files/index.js +1 -135
  7. package/dist/api/files/types.js +1 -1
  8. package/dist/api/index.js +1 -12
  9. package/dist/api/myorgan/index.js +1 -1
  10. package/dist/api/myorgan/types.js +1 -1
  11. package/dist/api/types.js +1 -9
  12. package/dist/app.d.ts +0 -0
  13. package/dist/app.js +1 -0
  14. package/dist/app.json +27 -0
  15. package/dist/app.wxss +0 -0
  16. package/dist/components/auth-user/jmash-update-user/index.js +1 -133
  17. package/dist/components/auth-user/jmash-user/index.js +1 -34
  18. package/dist/components/common/auth-avatar/avatar-edit/index.js +1 -82
  19. package/dist/components/common/auth-btn/double-btn/index.js +1 -67
  20. package/dist/components/common/auth-btn/single-btn/index.js +1 -34
  21. package/dist/components/common/auth-none-data/none-data-image/index.js +1 -53
  22. package/dist/components/common/auth-popup/index.js +1 -50
  23. package/dist/components/common/auth-search/index.js +1 -60
  24. package/dist/components/common/auth-top-navigation/index.js +1 -49
  25. package/dist/components/jmash-half-login/index.js +1 -105
  26. package/dist/components/jmash-login/index.js +1 -113
  27. package/dist/constant.js +1 -15
  28. package/dist/index.js +1 -35
  29. package/dist/pages/auth/login/index.d.ts +1 -0
  30. package/dist/pages/auth/login/index.js +1 -0
  31. package/dist/pages/auth/login/index.json +5 -0
  32. package/dist/pages/auth/login/index.wxml +6 -0
  33. package/dist/pages/auth/login/index.wxss +1 -0
  34. package/dist/pages/demo/index.d.ts +0 -0
  35. package/dist/pages/demo/index.js +1 -0
  36. package/dist/pages/demo/index.json +14 -0
  37. package/dist/pages/demo/index.wxml +11 -0
  38. package/dist/pages/demo/index.wxss +0 -0
  39. package/dist/pages/half-home/index.d.ts +1 -0
  40. package/dist/pages/half-home/index.js +1 -0
  41. package/dist/pages/half-home/index.json +5 -0
  42. package/dist/pages/half-home/index.wxml +5 -0
  43. package/dist/pages/half-home/index.wxss +0 -0
  44. package/dist/pages/home/index.d.ts +1 -0
  45. package/dist/pages/home/index.js +1 -0
  46. package/dist/pages/home/index.json +3 -0
  47. package/dist/pages/home/index.wxml +2 -0
  48. package/dist/pages/home/index.wxss +0 -0
  49. package/dist/pages/index/index.d.ts +1 -0
  50. package/dist/pages/index/index.js +1 -0
  51. package/dist/pages/index/index.json +4 -0
  52. package/dist/pages/index/index.wxml +8 -0
  53. package/dist/pages/index/index.wxss +0 -0
  54. package/dist/sitemap.json +7 -0
  55. package/dist/utils/auth.js +1 -212
  56. package/dist/utils/common.d.ts +1 -1
  57. package/dist/utils/common.js +1 -112
  58. package/dist/utils/config.js +1 -29
  59. package/dist/utils/db.js +1 -188
  60. package/dist/utils/request.js +1 -86
  61. package/dist/utils/util.js +1 -88
  62. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,35 +1 @@
1
- import { clearEmpty, request, sendRequest } from "./utils/request.js";
2
- import { config, initconfig } from "./utils/config.js";
3
- import { auth } from "./utils/auth.js";
4
- import { db } from "./utils/db.js";
5
- import { convertToISOString, formatDateTime, getHeight, kbToMb, validateRequired, validateRules } from "./utils/common.js";
6
- import { splitOrganTenant, splitVcardTenant, splitVcardTenantReturn } from "./utils/util.js";
7
- import { Dict } from "./api/index.js";
8
- import { EntryDict, EnumDict } from "./api/dicts.js";
9
- import { authApi } from "./api/auth/index.js";
10
- import { dictApi } from "./api/dict/index.js";
11
- import { fileApi } from "./api/files/index.js";
12
- export {
13
- Dict,
14
- EntryDict,
15
- EnumDict,
16
- auth,
17
- authApi,
18
- clearEmpty,
19
- config,
20
- convertToISOString,
21
- db,
22
- dictApi,
23
- fileApi,
24
- formatDateTime,
25
- getHeight,
26
- initconfig,
27
- kbToMb,
28
- request,
29
- sendRequest,
30
- splitOrganTenant,
31
- splitVcardTenant,
32
- splitVcardTenantReturn,
33
- validateRequired,
34
- validateRules
35
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./utils/request.js"),t=require("./utils/config.js"),i=require("./utils/auth.js"),r=require("./utils/db.js"),s=require("./utils/common.js"),o=require("./utils/util.js"),p=require("./api/index.js"),n=require("./api/dicts.js"),u=require("./api/auth/index.js"),a=require("./api/dict/index.js"),c=require("./api/files/index.js");exports.clearEmpty=e.clearEmpty,exports.request=e.request,exports.sendRequest=e.sendRequest,exports.config=t.config,exports.initconfig=t.initconfig,exports.auth=i.auth,exports.db=r.db,exports.convertToISOString=s.convertToISOString,exports.formatDateTime=s.formatDateTime,exports.getHeight=s.getHeight,exports.kbToMb=s.kbToMb,exports.validateRequired=s.validateRequired,exports.validateRules=s.validateRules,exports.splitOrganTenant=o.splitOrganTenant,exports.splitVcardTenant=o.splitVcardTenant,exports.splitVcardTenantReturn=o.splitVcardTenantReturn,exports.Dict=p.Dict,exports.EntryDict=n.EntryDict,exports.EnumDict=n.EnumDict,exports.authApi=u.authApi,exports.dictApi=a.dictApi,exports.fileApi=c.fileApi,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ "use strict";const e=require("../../../utils/config.js");Page({data:{resourceUrl:e.config.resourceUrl,backurl:"/pages/home/index",tabbar:!1},onLoad(e){this.data.tabbar="true"===e.tabbar,this.data.backurl=e.backurl},onReady(){},onShow(){},onHide(){},onUnload(){},onPullDownRefresh(){},onReachBottom(){},onShareAppMessage(){}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
@@ -0,0 +1,5 @@
1
+ {
2
+ "usingComponents": {
3
+ "jmash-login": "/components/jmash-login/index"
4
+ }
5
+ }
@@ -0,0 +1,6 @@
1
+ <jmash-login tabbar="{{ tabbar }}" backurl="{{ backurl }}">
2
+ <image mode="widthFix" src="{{ resourceUrl }}/images/login_bg.png" class="index_bj" slot="before">
3
+ <image mode="widthFix" src="{{ resourceUrl }}/images/logo.png" class="login_logo"></image>
4
+ </image>
5
+ <view class="tips_box" slot="after">温馨提示:{{config.name}}手机号授权登录。</view>
6
+ </jmash-login>
@@ -0,0 +1 @@
1
+ .login_logo{width:250px;margin-top:-500px}.index_bj{width:100%;text-align:center}.tips_box{color:#2563eb;font-size:12px;margin-top:40%}
File without changes
@@ -0,0 +1 @@
1
+ "use strict";Page({data:{},onLoad(){},onReady(){},onShow(){},onHide(){},onUnload(){},onPullDownRefresh(){},onReachBottom(){},onShareAppMessage(){},toBack(){wx.navigateBack()}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(o){exports[o]=module.exports[o]});
@@ -0,0 +1,14 @@
1
+ {
2
+ "usingComponents": {
3
+ "auth-single-btn": "/components/common/auth-btn/single-btn/index",
4
+ "auth-double-btn": "/components/common/auth-btn/double-btn/index",
5
+ "auth-avatar-edit": "/components/common/auth-avatar/avatar-edit/index",
6
+ "auth-search": "/components/common/auth-search/index",
7
+ "auth-top-navigation": "/components/common/auth-top-navigation/index",
8
+ "auth-popup": "/components/common/auth-popup/index",
9
+ "auth-none-data-image": "/components/common/auth-none-data/none-data-image/index",
10
+ "jmash-update-user": "/components/auth-user/jmash-update-user/index",
11
+ "jmash-user": "/components/auth-user/jmash-user/index"
12
+ },
13
+ "navigationStyle": "custom"
14
+ }
@@ -0,0 +1,11 @@
1
+ <!--pages/test/index.wxml-->
2
+
3
+ <auth-top-navigation title="首页" bind:eventBackTo="toBack"></auth-top-navigation>
4
+ <view style="width: 100%;">
5
+ <text>自定义顶部导航</text>
6
+ <auth-search placeholder="" disabled="{{ true }}" bind:handleSearch="" bind:click=""></auth-search>
7
+ <text>查询</text>
8
+ <text>底部按钮</text>
9
+ <auth-double-btn leftText="取消" rightText="保存" leftBgColor="#2563EB" leftColor="#fff" btnRadius="15px"></auth-double-btn>
10
+ </view>
11
+ <jmash-user />
File without changes
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ "use strict";const o=require("../../utils/auth.js");Page({data:{isLoginPopup:!1},onLoad(){o.auth.loginOnlyAC().then(()=>{}).catch(()=>{this.setData({isLoginPopup:!0})})},onReady(){},onShow(){},onHide(){},onUnload(){},onPullDownRefresh(){},onReachBottom(){},onShareAppMessage(){},onLoginClose(o){this.setData({isLoginPopup:o.detail})},loginSuccess(){}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(o){exports[o]=module.exports[o]});
@@ -0,0 +1,5 @@
1
+ {
2
+ "usingComponents": {
3
+ "jmash-half-login":"/components/jmash-half-login/index"
4
+ }
5
+ }
@@ -0,0 +1,5 @@
1
+ <!--pages/hsp-home/index.wxml-->
2
+ <text>主页(半屏登录)</text>
3
+
4
+ <!-- 授权登录弹出层 -->
5
+ <jmash-half-login show="{{ isLoginPopup }}" bind:close="onLoginClose" bind:status="loginSuccess"></jmash-half-login>
File without changes
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ "use strict";const e=require("../../utils/auth.js");Page({data:{},onLoad(){e.auth.loginAC("/page/home/index",!1).then(()=>{})},onReady(){},onShow(){},onHide(){},onUnload(){},onPullDownRefresh(){},onReachBottom(){},onShareAppMessage(){}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
@@ -0,0 +1,3 @@
1
+ {
2
+ "usingComponents": {}
3
+ }
@@ -0,0 +1,2 @@
1
+ <!--pages/home/index.wxml-->
2
+ <text>主页(全屏登录)</text>
File without changes
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ "use strict";const e=require("../../utils/auth.js");Page({data:{},onLoad(){},onReady(){},onShow(){},onHide(){},onUnload(){},onPullDownRefresh(){},onReachBottom(){},onShareAppMessage(){},toHomePage(){wx.navigateTo({url:"/pages/home/index"})},toHalfHomePage(){wx.navigateTo({url:"/pages/half-home/index"})},toCompTestPage(){wx.navigateTo({url:"/pages/demo/index"})},loginOut(){e.auth.loginOut()}}),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
@@ -0,0 +1,4 @@
1
+ {
2
+ "usingComponents": {
3
+ }
4
+ }
@@ -0,0 +1,8 @@
1
+
2
+ <view class="page-body">
3
+ <button type="default" bind:tap="toHomePage">主页(全屏登录)</button>
4
+ <button type="default" bind:tap="toHalfHomePage">主页(半屏登录)</button>
5
+ <button type="default" bind:tap="toCompTestPage">组件演示</button>
6
+ <button type="default" bind:tap="loginOut">退出</button>
7
+ </view>
8
+
File without changes
@@ -0,0 +1,7 @@
1
+ {
2
+ "desc": "关于本文件的更多信息,请参考文档 https://developers.weixin.qq.com/miniprogram/dev/framework/sitemap.html",
3
+ "rules": [{
4
+ "action": "allow",
5
+ "page": "*"
6
+ }]
7
+ }
@@ -1,212 +1 @@
1
- import { config } from "./config.js";
2
- import { db } from "./db.js";
3
- import { authApi } from "../api/auth/index.js";
4
- class Auth {
5
- /** 登录检查 */
6
- loginOnlyAC() {
7
- return new Promise((resolve, reject) => {
8
- if (this.checkLogin()) {
9
- resolve(true);
10
- return;
11
- }
12
- if (config.dev && config.testNewUser) {
13
- reject(false);
14
- return;
15
- }
16
- this.silentLogin().then((res) => {
17
- if (res.status) {
18
- resolve(true);
19
- } else {
20
- reject(false);
21
- }
22
- });
23
- });
24
- }
25
- /** 登录检查并跳转登录 */
26
- loginAC(backurl, tabbar, loginurl = "/pages/auth/login/index") {
27
- return new Promise((resolve, reject) => {
28
- if (this.checkLogin()) {
29
- resolve(true);
30
- return;
31
- }
32
- if (config.dev && config.testNewUser) {
33
- reject(false);
34
- let toUrl = loginurl + "?tabbar=" + (tabbar ? "true" : "false");
35
- toUrl += "&backurl=" + backurl;
36
- wx.navigateTo({
37
- url: toUrl
38
- });
39
- return;
40
- }
41
- this.silentLogin().then((res) => {
42
- if (res.status) {
43
- resolve(true);
44
- } else {
45
- reject(false);
46
- let toUrl = loginurl + "?tabbar=" + (tabbar ? "true" : "false");
47
- toUrl += "&backurl=" + backurl;
48
- wx.navigateTo({
49
- url: toUrl
50
- });
51
- }
52
- });
53
- });
54
- }
55
- /** 检查登录是否有效? */
56
- checkLogin() {
57
- if (db.getToken() && !db.isTokenExpire()) {
58
- return true;
59
- }
60
- return false;
61
- }
62
- // 判断是否存在有效用户.
63
- async hasUser() {
64
- const isLoggedIn = auth.checkLogin();
65
- if (!isLoggedIn) {
66
- return auth.silentLogin().then((res) => {
67
- console.log("静默登录--------", res);
68
- if (!res.status) {
69
- return false;
70
- }
71
- return true;
72
- }).catch((err) => {
73
- console.error("Silent login failed:", err);
74
- return false;
75
- });
76
- } else {
77
- return Promise.resolve(true);
78
- }
79
- }
80
- // 检查角色
81
- checkRole(role) {
82
- const roleCodes = db.getRoleCodes();
83
- return roleCodes.length > 0 && roleCodes.indexOf(role) !== -1;
84
- }
85
- /** 静默登录 */
86
- silentLogin() {
87
- return new Promise((resolve, reject) => {
88
- try {
89
- wx.login({
90
- success: (res) => {
91
- if (res.code) {
92
- authApi.miniappLogin({
93
- loginCode: res.code,
94
- appId: config.appId,
95
- componentAppid: config.componentAppid
96
- }).then((response) => {
97
- if (response.code === 200 && response.data.status === true) {
98
- db.loginStorage(response.data);
99
- console.log("login success");
100
- this.getUserInfo(false);
101
- this.getRolePerm(false).then(() => {
102
- resolve(response.data);
103
- });
104
- } else if (response.code === 200) {
105
- resolve(response.data);
106
- } else {
107
- reject(response.message);
108
- }
109
- });
110
- }
111
- },
112
- fail: (fail) => {
113
- console.log("登录失败2", fail.errMsg);
114
- reject(fail.errMsg);
115
- }
116
- });
117
- } catch (error) {
118
- console.log("silentLogin静默登录抛出异常");
119
- }
120
- });
121
- }
122
- // 手机号code 注册登录
123
- phoneCodeLogin(phoneCode, nickName = "") {
124
- return new Promise((resolve, reject) => {
125
- wx.login({
126
- success: (res) => {
127
- if (res.code) {
128
- authApi.miniappPhoneNumber({
129
- phoneCode,
130
- loginCode: res.code,
131
- appId: config.appId,
132
- nickName,
133
- 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
- }
146
- }
147
- );
148
- }
149
- },
150
- fail: (fail) => {
151
- console.log("登录失败3", fail.errMsg);
152
- reject(fail.errMsg);
153
- }
154
- });
155
- });
156
- }
157
- // 获取角色
158
- getRolePerm(cache = true) {
159
- return new Promise((resolve, reject) => {
160
- let rolesPerms = { roleCodes: db.getRoleCodes(), permCodes: db.getPermCodes() };
161
- if (cache && (Object.keys(rolesPerms.roleCodes).length > 0 || Object.keys(rolesPerms.permCodes).length > 0)) {
162
- resolve(rolesPerms);
163
- return;
164
- }
165
- authApi.userRolesPerms().then((response) => {
166
- db.rolesPermsStorage(response.data);
167
- resolve(response.data);
168
- }).catch(() => {
169
- reject("获取角色权限错误!");
170
- });
171
- });
172
- }
173
- // 获取用户信息
174
- getUserInfo(cache = true) {
175
- return new Promise((resolve, reject) => {
176
- let userInfo = db.getUserInfo();
177
- if (cache && Object.keys(userInfo).length > 0) {
178
- resolve(userInfo);
179
- return;
180
- }
181
- authApi.userInfo().then((resp) => {
182
- db.userInfoStorage(resp.data);
183
- resolve(resp.data);
184
- }).catch(() => {
185
- reject("获取角色权限错误!");
186
- });
187
- });
188
- }
189
- // 刷新Token.
190
- refreshToken() {
191
- return new Promise((resolve, reject) => {
192
- authApi.refreshToken({
193
- tenant: config.tenant,
194
- refreshToken: db.getRefreshToken(),
195
- clientId: config.appId
196
- }).then((response) => {
197
- db.tokenStorage(response.data);
198
- resolve(true);
199
- }).catch((error) => {
200
- reject(error);
201
- });
202
- });
203
- }
204
- // 登出
205
- loginOut() {
206
- db.clearStorage();
207
- }
208
- }
209
- const auth = new Auth();
210
- export {
211
- auth
212
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./config.js"),t=require("./db.js"),o=require("../api/auth/index.js");const n=new class r{loginOnlyAC(){return new Promise((t,o)=>{this.checkLogin()?t(!0):e.config.dev&&e.config.testNewUser?o(!1):this.silentLogin().then(e=>{e.status?t(!0):o(!1)})})}loginAC(t,o,n="/pages/auth/login/index"){return new Promise((r,s)=>{if(this.checkLogin())r(!0);else{if(e.config.dev&&e.config.testNewUser){s(!1);let e=n+"?tabbar="+(o?"true":"false");return e+="&backurl="+t,void wx.navigateTo({url:e})}this.silentLogin().then(e=>{if(e.status)r(!0);else{s(!1);let e=n+"?tabbar="+(o?"true":"false");e+="&backurl="+t,wx.navigateTo({url:e})}})}})}checkLogin(){return!(!t.db.getToken()||t.db.isTokenExpire())}hasUser(){return e=this,t=null,o=function*(){return n.checkLogin()?Promise.resolve(!0):n.silentLogin().then(e=>!!e.status).catch(e=>!1)},new Promise((n,r)=>{var s=e=>{try{a(o.next(e))}catch(t){r(t)}},i=e=>{try{a(o.throw(e))}catch(t){r(t)}},a=e=>e.done?n(e.value):Promise.resolve(e.value).then(s,i);a((o=o.apply(e,t)).next())});var e,t,o}checkRole(e){const o=t.db.getRoleCodes();return o.length>0&&-1!==o.indexOf(e)}silentLogin(){return new Promise((n,r)=>{try{wx.login({success:s=>{s.code&&o.authApi.miniappLogin({loginCode:s.code,appId:e.config.appId,componentAppid:e.config.componentAppid}).then(e=>{200===e.code&&!0===e.data.status?(t.db.loginStorage(e.data),this.getUserInfo(!1),this.getRolePerm(!1).then(()=>{n(e.data)})):200===e.code?n(e.data):r(e.message)})},fail:e=>{r(e.errMsg)}})}catch(s){}})}phoneCodeLogin(n,r=""){return new Promise((s,i)=>{wx.login({success:a=>{a.code&&o.authApi.miniappPhoneNumber({phoneCode:n,loginCode:a.code,appId:e.config.appId,nickName:r,componentAppid:e.config.componentAppid}).then(e=>{200===e.code&&!0===e.data.status?(t.db.loginStorage(e.data),this.getRolePerm().then(()=>{s(e.data)})):i(e.message)})},fail:e=>{i(e.errMsg)}})})}getRolePerm(e=!0){return new Promise((n,r)=>{let s={roleCodes:t.db.getRoleCodes(),permCodes:t.db.getPermCodes()};e&&(Object.keys(s.roleCodes).length>0||Object.keys(s.permCodes).length>0)?n(s):o.authApi.userRolesPerms().then(e=>{t.db.rolesPermsStorage(e.data),n(e.data)}).catch(()=>{r("获取角色权限错误!")})})}getUserInfo(e=!0){return new Promise((n,r)=>{let s=t.db.getUserInfo();e&&Object.keys(s).length>0?n(s):o.authApi.userInfo().then(e=>{t.db.userInfoStorage(e.data),n(e.data)}).catch(()=>{r("获取角色权限错误!")})})}refreshToken(){return new Promise((n,r)=>{o.authApi.refreshToken({tenant:e.config.tenant,refreshToken:t.db.getRefreshToken(),clientId:e.config.appId}).then(e=>{t.db.tokenStorage(e.data),n(!0)}).catch(e=>{r(e)})})}loginOut(){t.db.clearStorage()}};exports.auth=n,"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});
@@ -10,7 +10,7 @@ export declare const validateRules: (value: string, message: string, rules: any)
10
10
  * @param {string} value 需要校验的值
11
11
  * @param {string} message 错误提示信息
12
12
  */
13
- export declare const validateRequired: (value: string, message: string) => boolean;
13
+ export declare const validateRequired: (value: string | number, message: string) => boolean;
14
14
  /**
15
15
  * 格式化日期时间字符串
16
16
  * @param dateTimeString 日期时间字符串
@@ -1,112 +1 @@
1
- const validateRules = (value, message, rules) => {
2
- if (value && !rules.test(value)) {
3
- wx.showToast({
4
- title: message,
5
- icon: "none",
6
- duration: 2e3
7
- });
8
- return false;
9
- }
10
- return true;
11
- };
12
- const validateRequired = (value, message) => {
13
- console.log(value, message);
14
- if (!value || value.trim() == "") {
15
- wx.showToast({
16
- title: message,
17
- icon: "none",
18
- duration: 2e3
19
- });
20
- return false;
21
- }
22
- return true;
23
- };
24
- const formatDateTime = (dateTimeString, format) => {
25
- var date = new Date(dateTimeString);
26
- if (isNaN(date.getTime())) {
27
- return "";
28
- }
29
- var year = date.getFullYear();
30
- var month = ("0" + (date.getMonth() + 1)).slice(-2);
31
- var day = ("0" + date.getDate()).slice(-2);
32
- var hours = ("0" + date.getHours()).slice(-2);
33
- var minutes = ("0" + date.getMinutes()).slice(-2);
34
- var seconds = ("0" + date.getSeconds()).slice(-2);
35
- if (format === "YYYY-MM-DD HH:mm:ss") {
36
- return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
37
- }
38
- if (format === "YYYY-MM-DD HH:mm") {
39
- return year + "-" + month + "-" + day + " " + hours + ":" + minutes;
40
- }
41
- if (format === "YYYY-MM-DD") {
42
- return year + "-" + month + "-" + day;
43
- }
44
- return "";
45
- };
46
- const kbToMb = (kb, decimalPlaces = 2) => {
47
- return parseFloat((kb / 1024 / 1024).toFixed(decimalPlaces));
48
- };
49
- const convertToISOString = (dateString) => {
50
- const date = new Date(dateString);
51
- return date.toISOString();
52
- };
53
- const getHeight = () => {
54
- let navigationPaddingHeight = 0;
55
- let topHeight = 0;
56
- let bottomHeight = 0;
57
- let MenuButtonRight = 0;
58
- let MenuButtonLeft = 0;
59
- let MenuButtonTop = 0;
60
- let MenuButtonBottom = 0;
61
- let MenuButtonWidth = 0;
62
- let MenuButtonHeight = 0;
63
- let MenuButtonBounding = 0;
64
- let screenWidth = 0;
65
- let screenHeight = 0;
66
- try {
67
- MenuButtonHeight = wx.getMenuButtonBoundingClientRect().height ? wx.getMenuButtonBoundingClientRect().height : 0;
68
- navigationPaddingHeight = wx.getWindowInfo().statusBarHeight + 7 ? wx.getWindowInfo().statusBarHeight + 7 : 0;
69
- topHeight = MenuButtonHeight + navigationPaddingHeight;
70
- bottomHeight = wx.getWindowInfo().screenHeight - wx.getWindowInfo().safeArea.bottom ? wx.getWindowInfo().screenHeight - wx.getWindowInfo().safeArea.bottom : 0;
71
- MenuButtonRight = wx.getMenuButtonBoundingClientRect().right;
72
- MenuButtonLeft = wx.getMenuButtonBoundingClientRect().left;
73
- MenuButtonTop = wx.getMenuButtonBoundingClientRect().top;
74
- MenuButtonBottom = wx.getMenuButtonBoundingClientRect().bottom;
75
- MenuButtonWidth = wx.getMenuButtonBoundingClientRect().width;
76
- MenuButtonBounding = wx.getWindowInfo().statusBarHeight;
77
- screenWidth = wx.getWindowInfo().screenWidth;
78
- screenHeight = wx.getWindowInfo().screenHeight;
79
- } catch (error) {
80
- console.log("getHeight", error);
81
- }
82
- function computeHeightFn(height, stackingHeight) {
83
- return height !== 0 ? height : height + stackingHeight;
84
- }
85
- function addition(height, addHeight) {
86
- return height + addHeight;
87
- }
88
- return {
89
- navigationPaddingHeight,
90
- topHeight,
91
- bottomHeight,
92
- MenuButtonRight,
93
- MenuButtonLeft,
94
- MenuButtonTop,
95
- MenuButtonBottom,
96
- MenuButtonWidth,
97
- MenuButtonHeight,
98
- MenuButtonBounding,
99
- screenWidth,
100
- screenHeight,
101
- computeHeightFn,
102
- addition
103
- };
104
- };
105
- export {
106
- convertToISOString,
107
- formatDateTime,
108
- getHeight,
109
- kbToMb,
110
- validateRequired,
111
- validateRules
112
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});exports.convertToISOString=t=>new Date(t).toISOString(),exports.formatDateTime=(t,e)=>{var n=new Date(t);if(isNaN(n.getTime()))return"";var o=n.getFullYear(),i=("0"+(n.getMonth()+1)).slice(-2),u=("0"+n.getDate()).slice(-2),g=("0"+n.getHours()).slice(-2),r=("0"+n.getMinutes()).slice(-2),s=("0"+n.getSeconds()).slice(-2);return"YYYY-MM-DD HH:mm:ss"===e?o+"-"+i+"-"+u+" "+g+":"+r+":"+s:"YYYY-MM-DD HH:mm"===e?o+"-"+i+"-"+u+" "+g+":"+r:"YYYY-MM-DD"===e?o+"-"+i+"-"+u:""},exports.getHeight=()=>{let t=0,e=0,n=0,o=0,i=0,u=0,g=0,r=0,s=0,d=0,a=0,c=0;try{s=wx.getMenuButtonBoundingClientRect().height?wx.getMenuButtonBoundingClientRect().height:0,t=wx.getWindowInfo().statusBarHeight+7?wx.getWindowInfo().statusBarHeight+7:0,e=s+t,n=wx.getWindowInfo().screenHeight-wx.getWindowInfo().safeArea.bottom?wx.getWindowInfo().screenHeight-wx.getWindowInfo().safeArea.bottom:0,o=wx.getMenuButtonBoundingClientRect().right,i=wx.getMenuButtonBoundingClientRect().left,u=wx.getMenuButtonBoundingClientRect().top,g=wx.getMenuButtonBoundingClientRect().bottom,r=wx.getMenuButtonBoundingClientRect().width,d=wx.getWindowInfo().statusBarHeight,a=wx.getWindowInfo().screenWidth,c=wx.getWindowInfo().screenHeight}catch(w){}return{navigationPaddingHeight:t,topHeight:e,bottomHeight:n,MenuButtonRight:o,MenuButtonLeft:i,MenuButtonTop:u,MenuButtonBottom:g,MenuButtonWidth:r,MenuButtonHeight:s,MenuButtonBounding:d,screenWidth:a,screenHeight:c,computeHeightFn:function(t,e){return 0!==t?t:t+e},addition:function(t,e){return t+e}}},exports.kbToMb=(t,e=2)=>parseFloat((t/1024/1024).toFixed(e)),exports.validateRequired=(t,e)=>{const n="number"==typeof t?String(t):t;return!(!n||""==n.trim())||(wx.showToast({title:e,icon:"none",duration:2e3}),!1)},exports.validateRules=(t,e,n)=>!(t&&!n.test(t))||(wx.showToast({title:e,icon:"none",duration:2e3}),!1),"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(t){exports[t]=module.exports[t]});
@@ -1,29 +1 @@
1
- const https = "https://";
2
- const host = "gh.sooyie.cn";
3
- const agentUrl = "/v1/file/path/wxapp";
4
- const config = {
5
- dev: true,
6
- testNewUser: true,
7
- name: "Jmash框架",
8
- baseUrl: https + host,
9
- // 接口域名
10
- resourceUrl: https + host + agentUrl,
11
- // 资源域名
12
- // 测试版本
13
- appId: wx.getAccountInfoSync().miniProgram.appId,
14
- // 小程序appid 查看详情里面id wxf201f46341e0adf6
15
- tenant: "xyvcard",
16
- // 登录租户
17
- componentAppid: "wxe1b784ea80c01f40",
18
- // 测试版·微信第三方平台,ext.json extAppid
19
- // componentAppid: "wx8a77494240acd868", // 正式版·微信第三方平台,ext.json extAppid
20
- siteId: "552416fb-5dc8-46b8-8a35-bc26b1a09be1"
21
- // 站点id
22
- };
23
- const initconfig = (appConfig) => {
24
- Object.assign(config, appConfig);
25
- };
26
- export {
27
- config,
28
- initconfig
29
- };
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="https://",t="gh.sooyie.cn",o={dev:!0,testNewUser:!0,name:"Jmash框架",baseUrl:e+t,resourceUrl:e+t+"/v1/file/path/wxapp",appId:wx.getAccountInfoSync().miniProgram.appId,tenant:"xyvcard",componentAppid:"wxe1b784ea80c01f40",siteId:"552416fb-5dc8-46b8-8a35-bc26b1a09be1"};exports.config=o,exports.initconfig=e=>{Object.assign(o,e)},"object"==typeof exports&&"undefined"!=typeof module&&Object.keys(module.exports).forEach(function(e){exports[e]=module.exports[e]});