@zfqh/uniapp 0.1.1
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.
- package/CHANGELOG.md +16 -0
- package/LICENSE +21 -0
- package/README.md +39 -0
- package/docs/api/apis/core.md +189 -0
- package/docs/api/apis/index.md +82 -0
- package/docs/api/apis/request.md +369 -0
- package/docs/api/configs/api.md +32 -0
- package/docs/api/configs/app.md +43 -0
- package/docs/api/configs/brand.md +43 -0
- package/docs/api/configs/cdn.md +35 -0
- package/docs/api/configs/color.md +144 -0
- package/docs/api/configs/env.md +120 -0
- package/docs/api/configs/index.md +394 -0
- package/docs/api/configs/link.md +33 -0
- package/docs/api/configs/log.md +27 -0
- package/docs/api/configs/mp.md +34 -0
- package/docs/api/configs/navigate.md +27 -0
- package/docs/api/configs/page.md +32 -0
- package/docs/api/configs/path.md +27 -0
- package/docs/api/configs/storage.md +24 -0
- package/docs/api/configs/tabbar.md +29 -0
- package/docs/api/configs/toast.md +35 -0
- package/docs/api/configs/update.md +25 -0
- package/docs/api/configs/upload.md +45 -0
- package/docs/api/configs/ver.md +32 -0
- package/docs/api/configs/web.md +28 -0
- package/docs/api/hooks/index.md +182 -0
- package/docs/api/hooks/useI18n.md +27 -0
- package/docs/api/hooks/useOverlay.md +37 -0
- package/docs/api/hooks/usePopup.md +35 -0
- package/docs/api/hooks/useVersion.md +23 -0
- package/docs/api/index.md +269 -0
- package/docs/api/mixins/app.md +29 -0
- package/docs/api/mixins/badge.md +23 -0
- package/docs/api/mixins/debounce.md +32 -0
- package/docs/api/mixins/deep.md +29 -0
- package/docs/api/mixins/index.md +23 -0
- package/docs/api/mixins/login.md +22 -0
- package/docs/api/mixins/model.md +26 -0
- package/docs/api/mixins/redirect.md +26 -0
- package/docs/api/mixins/share.md +29 -0
- package/docs/api/mixins/show.md +27 -0
- package/docs/api/mixins/webview.md +27 -0
- package/docs/api/modules/app.md +30 -0
- package/docs/api/modules/dict.md +28 -0
- package/docs/api/modules/im.md +22 -0
- package/docs/api/modules/index.md +44 -0
- package/docs/api/modules/launch.md +26 -0
- package/docs/api/modules/location.md +25 -0
- package/docs/api/modules/login.md +35 -0
- package/docs/api/modules/network.md +26 -0
- package/docs/api/modules/system.md +29 -0
- package/docs/api/utils/audio.md +84 -0
- package/docs/api/utils/consts.md +201 -0
- package/docs/api/utils/cos.md +269 -0
- package/docs/api/utils/debounce.md +89 -0
- package/docs/api/utils/file.md +78 -0
- package/docs/api/utils/index.md +547 -0
- package/docs/api/utils/locale.md +32 -0
- package/docs/api/utils/message.md +81 -0
- package/docs/api/utils/navigate.md +267 -0
- package/docs/api/utils/pages.md +205 -0
- package/docs/api/utils/permission.md +28 -0
- package/docs/api/utils/permit.md +62 -0
- package/docs/api/utils/query.md +89 -0
- package/docs/api/utils/request.md +34 -0
- package/docs/api/utils/storage.md +145 -0
- package/docs/api/utils/subscribe.md +77 -0
- package/docs/api/utils/throttle.md +101 -0
- package/docs/api/utils/toast.md +164 -0
- package/docs/api/utils/uni.md +28 -0
- package/docs/api/utils/update.md +165 -0
- package/docs/components/g-back-button.md +76 -0
- package/docs/components/g-checkbox-list.md +101 -0
- package/docs/components/g-container.md +93 -0
- package/docs/components/g-data-list.md +106 -0
- package/docs/components/g-dot-text.md +79 -0
- package/docs/components/g-env.md +75 -0
- package/docs/components/g-float.md +83 -0
- package/docs/components/g-grid-image.md +91 -0
- package/docs/components/g-grid-swiper.md +99 -0
- package/docs/components/g-icon.md +106 -0
- package/docs/components/g-mask.md +82 -0
- package/docs/components/g-money.md +90 -0
- package/docs/components/g-more.md +78 -0
- package/docs/components/g-page-container.md +170 -0
- package/docs/components/g-permission-popup.md +117 -0
- package/docs/components/g-polyline-chat.md +102 -0
- package/docs/components/g-polyline-view.md +67 -0
- package/docs/components/g-popup.md +144 -0
- package/docs/components/g-refresh-view.md +118 -0
- package/docs/components/g-render-image.md +83 -0
- package/docs/components/g-search.md +120 -0
- package/docs/components/g-share-photo.md +77 -0
- package/docs/components/g-share-view.md +83 -0
- package/docs/components/g-share-weixin.md +81 -0
- package/docs/components/g-skeleton-view.md +71 -0
- package/docs/components/g-skeleton.md +64 -0
- package/docs/components/g-tag-editor.md +134 -0
- package/docs/components/g-timer.md +72 -0
- package/docs/components/g-trtc-room.md +116 -0
- package/docs/components/g-trtc-tui.md +84 -0
- package/docs/components/g-trtc.md +124 -0
- package/docs/components/g-upload.md +117 -0
- package/docs/components/g-waterfall.md +84 -0
- package/docs/components/index.md +109 -0
- package/docs/components/styles/base-styles.md +367 -0
- package/docs/components/styles/global-vars.md +150 -0
- package/docs/components/usage.md +112 -0
- package/docs/faq/index.md +78 -0
- package/docs/guide/getting-started.md +195 -0
- package/docs/guide/project-frame.md +297 -0
- package/docs/index.md +80 -0
- package/lib/apis/core.d.ts +12 -0
- package/lib/apis/core.js +13 -0
- package/lib/apis/index.d.ts +2 -0
- package/lib/apis/index.js +2 -0
- package/lib/apis/request.d.ts +4 -0
- package/lib/apis/request.js +27 -0
- package/lib/components/g-back-button/g-back-button.vue +141 -0
- package/lib/components/g-checkbox-list/g-checkbox-list.vue +156 -0
- package/lib/components/g-container/g-container.vue +159 -0
- package/lib/components/g-data-list/g-data-list.vue +192 -0
- package/lib/components/g-dot-text/g-dot-text.vue +114 -0
- package/lib/components/g-env/g-env.vue +123 -0
- package/lib/components/g-float/g-float.vue +131 -0
- package/lib/components/g-grid-image/g-grid-image.vue +84 -0
- package/lib/components/g-grid-swiper/g-grid-swiper.vue +224 -0
- package/lib/components/g-icon/g-icon.vue +72 -0
- package/lib/components/g-mask/g-mask.vue +126 -0
- package/lib/components/g-money/g-money.vue +174 -0
- package/lib/components/g-more/g-more.vue +68 -0
- package/lib/components/g-page-container/g-page-container.vue +470 -0
- package/lib/components/g-permission-popup/g-permission-popup.vue +80 -0
- package/lib/components/g-polyline-chat/g-polyline-chat.vue +255 -0
- package/lib/components/g-polyline-view/g-polyline-view.vue +104 -0
- package/lib/components/g-popup/g-popup.vue +449 -0
- package/lib/components/g-refresh-view/g-refresh-view.vue +213 -0
- package/lib/components/g-render-image/g-render-image.vue +222 -0
- package/lib/components/g-search/g-search.vue +274 -0
- package/lib/components/g-share-photo/g-share-photo.vue +75 -0
- package/lib/components/g-share-view/g-share-view.vue +157 -0
- package/lib/components/g-share-weixin/g-share-weixin.vue +106 -0
- package/lib/components/g-skeleton/g-skeleton.vue +55 -0
- package/lib/components/g-skeleton-view/g-skeleton-view.vue +78 -0
- package/lib/components/g-tag-editor/g-tag-editor.vue +482 -0
- package/lib/components/g-timer/g-timer.vue +61 -0
- package/lib/components/g-trtc/g-trtc.vue +347 -0
- package/lib/components/g-trtc-room/g-trtc-room.vue +524 -0
- package/lib/components/g-trtc-room/iconfont.scss +59 -0
- package/lib/components/g-trtc-tui/g-trtc-tui.vue +245 -0
- package/lib/components/g-upload/g-upload.vue +294 -0
- package/lib/components/g-waterfall/g-waterfall.vue +101 -0
- package/lib/configs/api.d.ts +7 -0
- package/lib/configs/api.js +6 -0
- package/lib/configs/app.d.ts +26 -0
- package/lib/configs/app.js +50 -0
- package/lib/configs/brand.d.ts +22 -0
- package/lib/configs/brand.js +26 -0
- package/lib/configs/cdn.d.ts +13 -0
- package/lib/configs/cdn.js +12 -0
- package/lib/configs/color.d.ts +62 -0
- package/lib/configs/color.js +66 -0
- package/lib/configs/env.d.ts +37 -0
- package/lib/configs/env.js +71 -0
- package/lib/configs/index.d.ts +170 -0
- package/lib/configs/index.js +82 -0
- package/lib/configs/link.d.ts +11 -0
- package/lib/configs/link.js +3 -0
- package/lib/configs/log.d.ts +9 -0
- package/lib/configs/log.js +8 -0
- package/lib/configs/mp.d.ts +15 -0
- package/lib/configs/mp.js +9 -0
- package/lib/configs/navigate.d.ts +17 -0
- package/lib/configs/navigate.js +5 -0
- package/lib/configs/page.d.ts +18 -0
- package/lib/configs/page.js +14 -0
- package/lib/configs/path.d.ts +11 -0
- package/lib/configs/path.js +10 -0
- package/lib/configs/storage.d.ts +7 -0
- package/lib/configs/storage.js +6 -0
- package/lib/configs/tabbar.d.ts +7 -0
- package/lib/configs/tabbar.js +6 -0
- package/lib/configs/toast.d.ts +18 -0
- package/lib/configs/toast.js +29 -0
- package/lib/configs/update.d.ts +45 -0
- package/lib/configs/update.js +6 -0
- package/lib/configs/upload.d.ts +30 -0
- package/lib/configs/upload.js +7 -0
- package/lib/configs/ver.d.ts +8 -0
- package/lib/configs/ver.js +28 -0
- package/lib/configs/web.d.ts +5 -0
- package/lib/configs/web.js +2 -0
- package/lib/hooks/index.d.ts +4 -0
- package/lib/hooks/index.js +4 -0
- package/lib/hooks/useI18n.d.ts +2 -0
- package/lib/hooks/useI18n.js +19 -0
- package/lib/hooks/useOverlay.d.ts +1 -0
- package/lib/hooks/useOverlay.js +17 -0
- package/lib/hooks/usePopup.d.ts +1 -0
- package/lib/hooks/usePopup.js +14 -0
- package/lib/hooks/useVersion.d.ts +6 -0
- package/lib/hooks/useVersion.js +21 -0
- package/lib/index.d.ts +26 -0
- package/lib/index.js +33 -0
- package/lib/mixins/app.d.ts +14 -0
- package/lib/mixins/app.js +105 -0
- package/lib/mixins/badge.d.ts +24 -0
- package/lib/mixins/badge.js +44 -0
- package/lib/mixins/debounce.d.ts +6 -0
- package/lib/mixins/debounce.js +11 -0
- package/lib/mixins/deep.d.ts +6 -0
- package/lib/mixins/deep.js +8 -0
- package/lib/mixins/index.d.ts +8 -0
- package/lib/mixins/index.js +8 -0
- package/lib/mixins/login.d.ts +4 -0
- package/lib/mixins/login.js +25 -0
- package/lib/mixins/model.d.ts +22 -0
- package/lib/mixins/model.js +29 -0
- package/lib/mixins/redirect.d.ts +8 -0
- package/lib/mixins/redirect.js +94 -0
- package/lib/mixins/share.d.ts +15 -0
- package/lib/mixins/share.js +55 -0
- package/lib/mixins/show.d.ts +9 -0
- package/lib/mixins/show.js +16 -0
- package/lib/mixins/webview.d.ts +26 -0
- package/lib/mixins/webview.js +225 -0
- package/lib/modules/app.d.ts +5 -0
- package/lib/modules/app.js +19 -0
- package/lib/modules/dict.d.ts +8 -0
- package/lib/modules/dict.js +43 -0
- package/lib/modules/im.d.ts +6 -0
- package/lib/modules/im.js +105 -0
- package/lib/modules/index.d.ts +8 -0
- package/lib/modules/index.js +8 -0
- package/lib/modules/launch.d.ts +5 -0
- package/lib/modules/launch.js +32 -0
- package/lib/modules/location.d.ts +5 -0
- package/lib/modules/location.js +57 -0
- package/lib/modules/login.d.ts +5 -0
- package/lib/modules/login.js +72 -0
- package/lib/modules/network.d.ts +5 -0
- package/lib/modules/network.js +39 -0
- package/lib/modules/system.d.ts +5 -0
- package/lib/modules/system.js +65 -0
- package/lib/styles/animate-vue.scss +3 -0
- package/lib/styles/animate.scss +27 -0
- package/lib/styles/bg-vue.scss +21 -0
- package/lib/styles/bg.scss +93 -0
- package/lib/styles/border.scss +218 -0
- package/lib/styles/flex-nvue.scss +64 -0
- package/lib/styles/flex-vue.scss +75 -0
- package/lib/styles/font.scss +59 -0
- package/lib/styles/index.scss +25 -0
- package/lib/styles/layout-nvue.scss +24 -0
- package/lib/styles/layout-vue.scss +30 -0
- package/lib/styles/layout.scss +76 -0
- package/lib/styles/opacity.scss +10 -0
- package/lib/styles/reset-vue.scss +46 -0
- package/lib/styles/shadow.scss +12 -0
- package/lib/styles/sizing-vue.scss +21 -0
- package/lib/styles/sizing.scss +21 -0
- package/lib/styles/spacing.scss +234 -0
- package/lib/styles/text-nvue.scss +21 -0
- package/lib/styles/text-vue.scss +70 -0
- package/lib/styles/text.scss +122 -0
- package/lib/styles/var.module.scss +29 -0
- package/lib/utils/audio.d.ts +14 -0
- package/lib/utils/audio.js +43 -0
- package/lib/utils/consts.d.ts +30 -0
- package/lib/utils/consts.js +52 -0
- package/lib/utils/cos.d.ts +15 -0
- package/lib/utils/cos.js +140 -0
- package/lib/utils/debounce.d.ts +2 -0
- package/lib/utils/debounce.js +30 -0
- package/lib/utils/file.d.ts +28 -0
- package/lib/utils/file.js +292 -0
- package/lib/utils/index.d.ts +166 -0
- package/lib/utils/index.js +485 -0
- package/lib/utils/locale.d.ts +6 -0
- package/lib/utils/locale.js +19 -0
- package/lib/utils/message.d.ts +9 -0
- package/lib/utils/message.js +63 -0
- package/lib/utils/navigate.d.ts +27 -0
- package/lib/utils/navigate.js +183 -0
- package/lib/utils/pages.d.ts +21 -0
- package/lib/utils/pages.js +79 -0
- package/lib/utils/permission.d.ts +16 -0
- package/lib/utils/permission.js +291 -0
- package/lib/utils/permit.d.ts +30 -0
- package/lib/utils/permit.js +181 -0
- package/lib/utils/query.d.ts +13 -0
- package/lib/utils/query.js +14 -0
- package/lib/utils/request.d.ts +8 -0
- package/lib/utils/request.js +126 -0
- package/lib/utils/storage.d.ts +53 -0
- package/lib/utils/storage.js +145 -0
- package/lib/utils/subscribe.d.ts +7 -0
- package/lib/utils/subscribe.js +94 -0
- package/lib/utils/throttle.d.ts +2 -0
- package/lib/utils/throttle.js +32 -0
- package/lib/utils/toast.d.ts +17 -0
- package/lib/utils/toast.js +66 -0
- package/lib/utils/uni.d.ts +1 -0
- package/lib/utils/uni.js +147 -0
- package/lib/utils/update.d.ts +9 -0
- package/lib/utils/update.js +376 -0
- package/package.json +49 -0
- package/types/index.d.ts +25 -0
- package/types/virtual.d.ts +1 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as app } from './app';
|
|
2
|
+
export { default as badge } from './badge';
|
|
3
|
+
export { default as deep } from './deep';
|
|
4
|
+
export { default as login } from './login';
|
|
5
|
+
export { default as redirect } from './redirect';
|
|
6
|
+
export { default as share } from './share';
|
|
7
|
+
export { default as webview } from './webview';
|
|
8
|
+
export { default as model } from './model';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { default as app } from './app';
|
|
2
|
+
export { default as badge } from './badge';
|
|
3
|
+
export { default as deep } from './deep';
|
|
4
|
+
export { default as login } from './login';
|
|
5
|
+
export { default as redirect } from './redirect';
|
|
6
|
+
export { default as share } from './share';
|
|
7
|
+
export { default as webview } from './webview';
|
|
8
|
+
export { default as model } from './model';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import page from '../configs/page';
|
|
2
|
+
import { inPages } from '../utils/pages';
|
|
3
|
+
import navigate from '../utils/navigate';
|
|
4
|
+
// #ifdef H5
|
|
5
|
+
import { IS_WEBVIEW_ENV } from '../utils/consts';
|
|
6
|
+
// #endif
|
|
7
|
+
export default {
|
|
8
|
+
onShow() {
|
|
9
|
+
if (this.$options.mpType === 'app') {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
if (uni.showAppFromBackground) {
|
|
13
|
+
// #ifdef H5
|
|
14
|
+
// 防止登录后,返回webview页面再次跳转登录页面
|
|
15
|
+
if (IS_WEBVIEW_ENV && this.$store.state.login?.info?.token == null) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
// #endif
|
|
19
|
+
const { route } = getCurrentPages().pop() || {};
|
|
20
|
+
if (!this.$store.getters.isLogin && !!route && inPages(page.needLoginPages, `/${route}`)) {
|
|
21
|
+
navigate({ url: '', needLogin: true });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare const _default: (prop: {
|
|
2
|
+
type: any;
|
|
3
|
+
default: any;
|
|
4
|
+
}) => {
|
|
5
|
+
props: {
|
|
6
|
+
value: {
|
|
7
|
+
type: any;
|
|
8
|
+
default: any;
|
|
9
|
+
};
|
|
10
|
+
modelValue: {
|
|
11
|
+
type: any;
|
|
12
|
+
default: any;
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
computed: {
|
|
16
|
+
value(): any;
|
|
17
|
+
};
|
|
18
|
+
methods: {
|
|
19
|
+
updateModel(value: any): void;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default (prop) => {
|
|
2
|
+
return {
|
|
3
|
+
props: {
|
|
4
|
+
// #ifndef VUE3
|
|
5
|
+
value: prop,
|
|
6
|
+
// #endif
|
|
7
|
+
// #ifdef VUE3
|
|
8
|
+
modelValue: prop,
|
|
9
|
+
// #endif
|
|
10
|
+
},
|
|
11
|
+
// #ifdef VUE3
|
|
12
|
+
computed: {
|
|
13
|
+
value() {
|
|
14
|
+
return this.modelValue;
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
// #endif
|
|
18
|
+
methods: {
|
|
19
|
+
updateModel(value) {
|
|
20
|
+
// #ifndef VUE3
|
|
21
|
+
this.$emit('input', value);
|
|
22
|
+
// #endif
|
|
23
|
+
// #ifdef VUE3
|
|
24
|
+
this.$emit('update:modelValue', value);
|
|
25
|
+
// #endif
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
};
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { parse } from 'qs';
|
|
2
|
+
import navigate from '../utils/navigate';
|
|
3
|
+
import { TYPES } from '../utils/message';
|
|
4
|
+
import { inPages } from '../utils/pages';
|
|
5
|
+
import page from '../configs/page';
|
|
6
|
+
import path from '../configs/path';
|
|
7
|
+
import { IS_WEBVIEW_ENV } from '../utils/consts';
|
|
8
|
+
export default {
|
|
9
|
+
onLoad({ __referrer, __navigate }) {
|
|
10
|
+
if (__referrer) {
|
|
11
|
+
// 由登录拦截器跳转本页面,记录来源
|
|
12
|
+
path['referrer'] = decodeURIComponent(__referrer);
|
|
13
|
+
}
|
|
14
|
+
else if (__navigate) {
|
|
15
|
+
// 登录成功,跳回来源页面后,若需要重定向,则跳转
|
|
16
|
+
navigate(__navigate.startsWith('/') ? __navigate : decodeURIComponent(__navigate), __navigate ? 'navigateTo' : 'redirectTo');
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
onShow() {
|
|
20
|
+
// App.vue不执行
|
|
21
|
+
if (this.$options.mpType === 'app') {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const routes = getCurrentPages();
|
|
25
|
+
const current = `/${routes.pop()?.route}`;
|
|
26
|
+
if (!this.$store.getters.isLogin) {
|
|
27
|
+
// #ifdef H5
|
|
28
|
+
// 防止登录后,返回webview页面再次跳转登录页面
|
|
29
|
+
if (IS_WEBVIEW_ENV) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
// #endif
|
|
33
|
+
// 检测页面是否跳转登录
|
|
34
|
+
if (inPages(page.needLoginPages, current)) {
|
|
35
|
+
navigate({ url: '', needLogin: true });
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
// 禁止跳转
|
|
40
|
+
if (inPages(page.notRedirectPages, current)) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const url = path['referrer'];
|
|
44
|
+
if (url) {
|
|
45
|
+
path['referrer'] = '';
|
|
46
|
+
const isCurrent = url.startsWith(current);
|
|
47
|
+
if (this.webview) {
|
|
48
|
+
// 需要设置为false,否则webview.ts onShow也会执行
|
|
49
|
+
this.changed = false;
|
|
50
|
+
// 登录后,跳回的页面是webview页面,则需要重新加载该页面
|
|
51
|
+
// #ifdef MP
|
|
52
|
+
if (inPages(page.tabBarPages, current)) {
|
|
53
|
+
// tabbar页面刷新页面
|
|
54
|
+
const [, path] = url.split('?');
|
|
55
|
+
const { url: _url } = parse(path, { decoder: (str) => str });
|
|
56
|
+
this.params.url = _url;
|
|
57
|
+
this.initUrl();
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
// 非tabbar页面,重新打开页面
|
|
61
|
+
uni[routes.length >= 2 ? 'redirectTo' : 'reLaunch']({
|
|
62
|
+
url,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
// #endif
|
|
66
|
+
// #ifndef MP
|
|
67
|
+
const { token = '' } = this.loginInfo;
|
|
68
|
+
const [, path] = url.split('?');
|
|
69
|
+
const { url: _url } = parse(path, { decoder: (str) => str });
|
|
70
|
+
this.postMessage({
|
|
71
|
+
type: TYPES.LOGIN,
|
|
72
|
+
payload: {
|
|
73
|
+
token,
|
|
74
|
+
referrer: decodeURIComponent(_url),
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
// #endif
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
if (isCurrent) {
|
|
81
|
+
const [, __navigate] = url.split('__navigate=');
|
|
82
|
+
if (__navigate) {
|
|
83
|
+
// 跳回其他页面,则判断参数是否需要重定向
|
|
84
|
+
navigate(__navigate.startsWith('/') ? __navigate : decodeURIComponent(__navigate));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
// 登录后返回其他页面,比如reLaunch到首页,则重新跳转到原页面
|
|
89
|
+
navigate(url);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
computed: {
|
|
3
|
+
mergeShareData(): any;
|
|
4
|
+
};
|
|
5
|
+
watch: {
|
|
6
|
+
shareData(): void;
|
|
7
|
+
};
|
|
8
|
+
methods: {
|
|
9
|
+
sendShareDataMessage(): void;
|
|
10
|
+
};
|
|
11
|
+
onShow(): void;
|
|
12
|
+
onShareAppMessage(): any;
|
|
13
|
+
onShareTimeline(): any;
|
|
14
|
+
};
|
|
15
|
+
export default _default;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { TYPES } from '../utils/message';
|
|
2
|
+
import { postMessage } from '../utils/index';
|
|
3
|
+
import { IS_WEBVIEW_ENV } from '../utils/consts';
|
|
4
|
+
export default {
|
|
5
|
+
computed: {
|
|
6
|
+
mergeShareData() {
|
|
7
|
+
const { route, options } = getCurrentPages().pop();
|
|
8
|
+
return {
|
|
9
|
+
path: `/${route}${uni.$uv.queryParams(options)}`,
|
|
10
|
+
content: '',
|
|
11
|
+
// #ifdef H5
|
|
12
|
+
title: document.title,
|
|
13
|
+
// #endif
|
|
14
|
+
...this.shareData,
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
// #ifdef H5
|
|
19
|
+
watch: {
|
|
20
|
+
shareData() {
|
|
21
|
+
this.sendShareDataMessage();
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
methods: {
|
|
25
|
+
sendShareDataMessage() {
|
|
26
|
+
if (IS_WEBVIEW_ENV) {
|
|
27
|
+
try {
|
|
28
|
+
postMessage({
|
|
29
|
+
type: TYPES.SHARE_PAGE,
|
|
30
|
+
payload: this.mergeShareData,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
catch (e) { }
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
uni.showShareMenu(this.mergeShareData);
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
onShow() {
|
|
41
|
+
if (this.$options.mpType === 'app') {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
this.sendShareDataMessage();
|
|
45
|
+
},
|
|
46
|
+
// #endif
|
|
47
|
+
// #ifdef MP
|
|
48
|
+
onShareAppMessage() {
|
|
49
|
+
return this.mergeShareData;
|
|
50
|
+
},
|
|
51
|
+
onShareTimeline() {
|
|
52
|
+
return this.mergeShareData;
|
|
53
|
+
},
|
|
54
|
+
// #endif
|
|
55
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
data(): {
|
|
3
|
+
shareData: {};
|
|
4
|
+
params: {};
|
|
5
|
+
url: string;
|
|
6
|
+
changed: boolean;
|
|
7
|
+
webview: boolean;
|
|
8
|
+
};
|
|
9
|
+
computed: {
|
|
10
|
+
loginInfo(): any;
|
|
11
|
+
queryInfo(): any;
|
|
12
|
+
appInfo(): any;
|
|
13
|
+
queryString(): string;
|
|
14
|
+
};
|
|
15
|
+
watch: {
|
|
16
|
+
queryString(): void;
|
|
17
|
+
};
|
|
18
|
+
methods: {
|
|
19
|
+
onMessage(e: any): Promise<void>;
|
|
20
|
+
postMessage(data: any): void;
|
|
21
|
+
initUrl(): void;
|
|
22
|
+
};
|
|
23
|
+
onLoad(params: any): void;
|
|
24
|
+
onShow(): void;
|
|
25
|
+
};
|
|
26
|
+
export default _default;
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import Url from 'url-parse';
|
|
2
|
+
import { stringify } from 'qs';
|
|
3
|
+
import { TYPES } from '../utils/message';
|
|
4
|
+
import system from '../modules/system';
|
|
5
|
+
import { PLATFORM_CODE, IS_WEBVIEW_ENV } from '../utils/consts';
|
|
6
|
+
import { requestPermission } from '../utils/permit';
|
|
7
|
+
import web from '../configs/web';
|
|
8
|
+
import link from '../configs/link';
|
|
9
|
+
import path from '../configs/path';
|
|
10
|
+
import { base64ToPath } from '../utils/file';
|
|
11
|
+
export default {
|
|
12
|
+
data() {
|
|
13
|
+
return {
|
|
14
|
+
shareData: {},
|
|
15
|
+
params: {},
|
|
16
|
+
url: '',
|
|
17
|
+
changed: true,
|
|
18
|
+
webview: true,
|
|
19
|
+
};
|
|
20
|
+
},
|
|
21
|
+
computed: {
|
|
22
|
+
loginInfo() {
|
|
23
|
+
return this.$store.state.login?.info || {};
|
|
24
|
+
},
|
|
25
|
+
queryInfo() {
|
|
26
|
+
return this.$store.state.query?.info || {};
|
|
27
|
+
},
|
|
28
|
+
appInfo() {
|
|
29
|
+
return this.$store.state.app?.info || {};
|
|
30
|
+
},
|
|
31
|
+
queryString() {
|
|
32
|
+
const { loginInfo, queryInfo, appInfo } = this;
|
|
33
|
+
const query = {
|
|
34
|
+
...queryInfo,
|
|
35
|
+
token: loginInfo.token || '',
|
|
36
|
+
brand: appInfo.brand?.code || '',
|
|
37
|
+
app: appInfo.app?.code || '',
|
|
38
|
+
platform: PLATFORM_CODE,
|
|
39
|
+
};
|
|
40
|
+
if (query.primary) {
|
|
41
|
+
if (String(query.primary).startsWith('#')) {
|
|
42
|
+
query.primary = encodeURIComponent(query.primary);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return stringify(query, { encode: false });
|
|
46
|
+
},
|
|
47
|
+
},
|
|
48
|
+
watch: {
|
|
49
|
+
queryString() {
|
|
50
|
+
this.changed = 'changed';
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
methods: {
|
|
54
|
+
async onMessage(e) {
|
|
55
|
+
try {
|
|
56
|
+
const { type, payload } = e.detail.data.pop();
|
|
57
|
+
switch (type) {
|
|
58
|
+
case TYPES.SAVE_IMAGE: {
|
|
59
|
+
const { data } = payload;
|
|
60
|
+
await requestPermission('storage');
|
|
61
|
+
const path = await base64ToPath(data);
|
|
62
|
+
uni.saveImageToPhotosAlbum({
|
|
63
|
+
filePath: path,
|
|
64
|
+
success() {
|
|
65
|
+
uni.showToast({
|
|
66
|
+
title: '已保存到相册',
|
|
67
|
+
position: 'bottom',
|
|
68
|
+
});
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
case TYPES.CHNAGE_TITLE: {
|
|
74
|
+
const { title } = payload;
|
|
75
|
+
uni.setNavigationBarTitle({
|
|
76
|
+
title,
|
|
77
|
+
});
|
|
78
|
+
break;
|
|
79
|
+
}
|
|
80
|
+
case TYPES.SHARE_PAGE: {
|
|
81
|
+
if (!payload.path) {
|
|
82
|
+
uni.share(payload);
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
const { path, ...shareRest } = payload;
|
|
86
|
+
const { route } = getCurrentPages().pop();
|
|
87
|
+
const params = { ...this.params };
|
|
88
|
+
delete params.url;
|
|
89
|
+
this.shareData = {
|
|
90
|
+
...shareRest,
|
|
91
|
+
path: `/${route}${uni.$uv.queryParams({ url: encodeURIComponent(path), ...params })}`,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
break;
|
|
95
|
+
}
|
|
96
|
+
case TYPES.GET_LOCATION:
|
|
97
|
+
case TYPES.OPEN_LOCATION: {
|
|
98
|
+
const type = TYPES.GET_LOCATION || TYPES.OPEN_LOCATION;
|
|
99
|
+
const success = (e) => {
|
|
100
|
+
this.postMessage({
|
|
101
|
+
type,
|
|
102
|
+
payload: {
|
|
103
|
+
success: e,
|
|
104
|
+
},
|
|
105
|
+
});
|
|
106
|
+
};
|
|
107
|
+
const fail = (e) => {
|
|
108
|
+
this.postMessage({
|
|
109
|
+
type,
|
|
110
|
+
payload: {
|
|
111
|
+
fail: e,
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
|
+
try {
|
|
116
|
+
await requestPermission('location');
|
|
117
|
+
uni.getLocation({
|
|
118
|
+
...payload,
|
|
119
|
+
success,
|
|
120
|
+
fail,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
catch (e) {
|
|
124
|
+
fail(e);
|
|
125
|
+
}
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
catch (e) { }
|
|
131
|
+
},
|
|
132
|
+
postMessage(data) {
|
|
133
|
+
try {
|
|
134
|
+
if (!this.__webView) {
|
|
135
|
+
// #ifdef H5
|
|
136
|
+
this.__webView = document.querySelector('iframe')?.contentWindow;
|
|
137
|
+
this.__postMessage = (data) => {
|
|
138
|
+
this.__webView.postMessage({ type: 'WEBVIEW_MESSAGE', data }, '*');
|
|
139
|
+
};
|
|
140
|
+
// #endif
|
|
141
|
+
// #ifdef APP-PLUS
|
|
142
|
+
this.__webView = this.$scope.$getAppWebview().children()[0];
|
|
143
|
+
this.__postMessage = (data) => {
|
|
144
|
+
this.__webView.evalJS(`window.onmessage({ data: { type: 'WEBVIEW_MESSAGE', data: ${JSON.stringify(data)} } })`);
|
|
145
|
+
};
|
|
146
|
+
// #endif
|
|
147
|
+
}
|
|
148
|
+
this.__postMessage(data);
|
|
149
|
+
}
|
|
150
|
+
catch (e) { }
|
|
151
|
+
},
|
|
152
|
+
initUrl() {
|
|
153
|
+
const params = this.params;
|
|
154
|
+
if (params.url) {
|
|
155
|
+
params.url = decodeURIComponent(params.url);
|
|
156
|
+
}
|
|
157
|
+
const { type, app: _app, url: _url, ...rest } = params;
|
|
158
|
+
let url = _url;
|
|
159
|
+
let title = rest.title;
|
|
160
|
+
let src = '';
|
|
161
|
+
const queryString = `?${stringify({ _: Date.now(), safeBottom: system.state.info.safeAreaInsets.bottom, ...rest }, { encode: false })}&${this.queryString}`;
|
|
162
|
+
if (_app && web[_app]) {
|
|
163
|
+
const sep = /\.html$/i.test(web[_app]) ? '' : '/';
|
|
164
|
+
src = `${web[_app]}${sep}${queryString}#${url}`;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
if (link && link[type]) {
|
|
168
|
+
const { url: _url, title: _title } = link[type];
|
|
169
|
+
if (_url) {
|
|
170
|
+
url = _url;
|
|
171
|
+
}
|
|
172
|
+
if (_title) {
|
|
173
|
+
title = _title;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (url && /^https?:/.test(url)) {
|
|
177
|
+
const { origin, query, pathname, hash } = new Url(url);
|
|
178
|
+
const q = `${queryString}${query.replace(/^\?/, '&')}`;
|
|
179
|
+
src = `${origin}${pathname}${q}${hash}`;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
if (title) {
|
|
183
|
+
uni.setNavigationBarTitle({
|
|
184
|
+
title,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
this.url = src;
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
onLoad(params) {
|
|
191
|
+
this.params = {
|
|
192
|
+
...this.params,
|
|
193
|
+
...params,
|
|
194
|
+
};
|
|
195
|
+
this._params = {
|
|
196
|
+
...this.params,
|
|
197
|
+
};
|
|
198
|
+
},
|
|
199
|
+
onShow() {
|
|
200
|
+
if (this.$options.mpType === 'app') {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
this.$nextTick(() => {
|
|
204
|
+
if (this.changed === true || (this.changed === 'changed' && !path['referrer'])) {
|
|
205
|
+
this.params = {
|
|
206
|
+
...this._params,
|
|
207
|
+
};
|
|
208
|
+
this.initUrl();
|
|
209
|
+
this.changed = false;
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
// #ifdef H5
|
|
213
|
+
if (!IS_WEBVIEW_ENV) {
|
|
214
|
+
window.onmessage = (e) => {
|
|
215
|
+
try {
|
|
216
|
+
if (e.data.type === 'WEBVIEW_APP_MESSAGE') {
|
|
217
|
+
this.onMessage({ detail: { data: [e.data.data] } });
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch (e) { }
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
// #endif
|
|
224
|
+
},
|
|
225
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import config from '../configs';
|
|
2
|
+
function getDefaultState() {
|
|
3
|
+
const appInfo = { app: config.app, brand: config.brand };
|
|
4
|
+
return {
|
|
5
|
+
info: appInfo,
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
const store = {
|
|
9
|
+
state: getDefaultState(),
|
|
10
|
+
mutations: {
|
|
11
|
+
setAppInfo(state, data) {
|
|
12
|
+
state.info = {
|
|
13
|
+
...state.info,
|
|
14
|
+
...data,
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
export default store;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function getDefaultState() {
|
|
2
|
+
return {
|
|
3
|
+
info: {},
|
|
4
|
+
};
|
|
5
|
+
}
|
|
6
|
+
const store = {
|
|
7
|
+
state: getDefaultState(),
|
|
8
|
+
mutations: {
|
|
9
|
+
setDictInfo(state, data) {
|
|
10
|
+
state.info = { ...state.info, ...data };
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
actions: {
|
|
14
|
+
async getDictInfo({ commit, state }, options = {}) {
|
|
15
|
+
try {
|
|
16
|
+
const { name, cache } = options;
|
|
17
|
+
if (name && (!cache || (cache && !state.info[name]))) {
|
|
18
|
+
const e = await store.request({ name });
|
|
19
|
+
const enums = {};
|
|
20
|
+
const values = [];
|
|
21
|
+
const labels = [];
|
|
22
|
+
const options = e.data.map(({ label, value }) => {
|
|
23
|
+
values.push(value);
|
|
24
|
+
labels.push(label);
|
|
25
|
+
enums[label] = value;
|
|
26
|
+
enums[value] = label;
|
|
27
|
+
return { label, value };
|
|
28
|
+
});
|
|
29
|
+
commit('setDictInfo', {
|
|
30
|
+
[name]: {
|
|
31
|
+
options,
|
|
32
|
+
values,
|
|
33
|
+
labels,
|
|
34
|
+
enums,
|
|
35
|
+
},
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (e) { }
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
export default store;
|