jmash-core-mp 0.1.73 → 0.1.74
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/lib/packages/pages/share/scan.mpx.d.ts +1 -0
- package/lib/utils/share.d.ts +1 -0
- package/lib/utils/share.js +42 -0
- package/package.json +1 -1
- package/src/packages/index.mpx +1 -0
- package/src/packages/pages/share/scan.mpx +104 -0
- package/src/pages/tabbar/home.mpx +15 -0
- package/src/utils/share.ts +39 -0
- package/static/wx/project.config.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/utils/share.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
declare class ShareUtil {
|
|
2
2
|
getCurrentPage(): string;
|
|
3
3
|
getCurrentQuery(): string;
|
|
4
|
+
shareLoad(options: Record<string, string>): Promise<boolean>;
|
|
4
5
|
shareUserPath(pagePath: string, query: string): string;
|
|
5
6
|
shareUserQuery(query: string): string;
|
|
6
7
|
shareUserLoad(options: Record<string, string>): Promise<boolean>;
|
package/lib/utils/share.js
CHANGED
|
@@ -29,6 +29,47 @@ class ShareUtil {
|
|
|
29
29
|
.map((key) => `${key}=${options[key]}`)
|
|
30
30
|
.join("&");
|
|
31
31
|
}
|
|
32
|
+
// 分享加载
|
|
33
|
+
shareLoad(options) {
|
|
34
|
+
//推荐人
|
|
35
|
+
const userStore = useUserStore();
|
|
36
|
+
console.log("推荐人:", options.referee);
|
|
37
|
+
if (options.referee) {
|
|
38
|
+
userStore.setReferee(options.referee);
|
|
39
|
+
}
|
|
40
|
+
const shopStore = useShopStore();
|
|
41
|
+
//门店ID
|
|
42
|
+
if (options.branchId && options.organTenant) {
|
|
43
|
+
console.log("门店ID", options.branchId, options.organTenant);
|
|
44
|
+
return shopApi
|
|
45
|
+
.findShopBranchById(options.organTenant, options.branchId)
|
|
46
|
+
.then((res) => {
|
|
47
|
+
return shopStore.switchBranch(res.data).then(() => {
|
|
48
|
+
return userStore.loginOnlyAC();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
else if (options.shopId) {
|
|
53
|
+
//商城ID
|
|
54
|
+
console.log("商城ID", options.shopId);
|
|
55
|
+
return shopApi.findShopInfoById(options.shopId).then((res) => {
|
|
56
|
+
return shopStore.switchShop(res.data).then(() => {
|
|
57
|
+
return userStore.loginOnlyAC();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
else if (options.organTenant) {
|
|
62
|
+
//组织Token
|
|
63
|
+
const organStore = useOrganStore();
|
|
64
|
+
console.log("组织Token", options.organTenant);
|
|
65
|
+
return organStore.setOrganTenant(options.organTenant).then(() => {
|
|
66
|
+
//静默登录
|
|
67
|
+
return userStore.loginOnlyAC();
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
//静默登录
|
|
71
|
+
return userStore.loginOnlyAC();
|
|
72
|
+
}
|
|
32
73
|
// 分享用户页给好友
|
|
33
74
|
shareUserPath(pagePath, query) {
|
|
34
75
|
const userStore = useUserStore();
|
|
@@ -45,6 +86,7 @@ class ShareUtil {
|
|
|
45
86
|
shareUserLoad(options) {
|
|
46
87
|
//推荐人
|
|
47
88
|
const userStore = useUserStore();
|
|
89
|
+
console.log("推荐人:", options.referee);
|
|
48
90
|
if (options.referee) {
|
|
49
91
|
userStore.setReferee(options.referee);
|
|
50
92
|
}
|
package/package.json
CHANGED
package/src/packages/index.mpx
CHANGED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 分享公共页面 -->
|
|
3
|
+
<image wx:if="{{ resourceUrl }}" class="img" src="{{ resourceUrl + '/images/mall/img-1.png' }}" mode="widthFix" />
|
|
4
|
+
</template>
|
|
5
|
+
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import mpx, { createPage, onLoad } from "@mpxjs/core";
|
|
8
|
+
import { useUserStore } from "../../../store/user";
|
|
9
|
+
import { share } from "../../../utils/share";
|
|
10
|
+
|
|
11
|
+
createPage({
|
|
12
|
+
setup() {
|
|
13
|
+
const config = getApp().globalData.config;
|
|
14
|
+
// 资源路径
|
|
15
|
+
let resourceUrl = config.resourceUrl;
|
|
16
|
+
// 用户状态管理
|
|
17
|
+
const userStore = useUserStore();
|
|
18
|
+
/**
|
|
19
|
+
* 生命周期函数--监听页面加载
|
|
20
|
+
*/
|
|
21
|
+
onLoad(async (options) => {
|
|
22
|
+
// 判断是否登录-静默登录
|
|
23
|
+
userStore.loginOnlyAC().then(() => {
|
|
24
|
+
// 处理页面参数
|
|
25
|
+
if (options.q) {
|
|
26
|
+
const q = decodeURIComponent(options.q);
|
|
27
|
+
if (q.includes("share?")) {
|
|
28
|
+
const params = _URIParams(q);
|
|
29
|
+
onRedirectTo(params, _ReturnParams(params));
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
onRedirectTo(options, _ReturnParams(options));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// 跳转页面
|
|
38
|
+
function onRedirectTo(options: any, query: string) {
|
|
39
|
+
console.log("action--->页面路径 ==> ", options.action, options.tab);
|
|
40
|
+
console.log("query--->页面参数 ==> ", query);
|
|
41
|
+
// mpx.reLaunch({ url: `${options.action}${query}` });
|
|
42
|
+
if (options.action && options.tab) {
|
|
43
|
+
share.shareLoad(options).then(() => {
|
|
44
|
+
console.log("TabBar ", options.action);
|
|
45
|
+
mpx.switchTab({ url: options.action });
|
|
46
|
+
});
|
|
47
|
+
} else {
|
|
48
|
+
mpx.navigateTo({ url: `${options.action}${query}` });
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
// 拼接参数
|
|
53
|
+
function _ReturnParams(options: any): string {
|
|
54
|
+
let query = Object.keys(options)
|
|
55
|
+
.filter((key) => key !== "action")
|
|
56
|
+
.filter((key) => key !== "tab")
|
|
57
|
+
.map((key) => key + "=" + options[key])
|
|
58
|
+
.join("&");
|
|
59
|
+
return query ? `?${query}` : "";
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
// 提取地址参数
|
|
63
|
+
function _URIParams(q: string): object {
|
|
64
|
+
const obj: { [key: string]: string } = {};
|
|
65
|
+
q.substring(q.indexOf("?") + 1, q.length)
|
|
66
|
+
.split("&")
|
|
67
|
+
.forEach((item) => {
|
|
68
|
+
obj[item.split("=")[0]] = item.split("=")[1];
|
|
69
|
+
});
|
|
70
|
+
return obj;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
resourceUrl,
|
|
75
|
+
userStore,
|
|
76
|
+
onRedirectTo,
|
|
77
|
+
_ReturnParams,
|
|
78
|
+
_URIParams,
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
})
|
|
82
|
+
</script>
|
|
83
|
+
|
|
84
|
+
<style lang="scss">
|
|
85
|
+
page {
|
|
86
|
+
background-image: linear-gradient(to bottom, #ffdbdb, #fffbfb, #fff7f7);
|
|
87
|
+
display: flex;
|
|
88
|
+
justify-content: center;
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
align-items: center;
|
|
91
|
+
height: 100%;
|
|
92
|
+
|
|
93
|
+
.img {
|
|
94
|
+
width: 291px;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
</style>
|
|
98
|
+
|
|
99
|
+
<script type="application/json">
|
|
100
|
+
{
|
|
101
|
+
"usingComponents": {},
|
|
102
|
+
"navigationStyle": "custom"
|
|
103
|
+
}
|
|
104
|
+
</script>
|
|
@@ -31,6 +31,21 @@ createPage({
|
|
|
31
31
|
{
|
|
32
32
|
key: 'cms-article-list', title: '文章列表', icon: '📝', iconBg: '#409eff', path: '/jmash/pages/cms/cms-article-list'
|
|
33
33
|
},
|
|
34
|
+
{
|
|
35
|
+
key: 'share-scan', title: '扫码Tab首页', icon: '📝', iconBg: '#409eff', path: '/jmash/pages/share/scan?action=/pages/tabbar/home&tab=1'
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
key: 'share-scan', title: '扫码Tab组织', icon: '📝', iconBg: '#409eff', path: '/jmash/pages/share/scan?action=/pages/tabbar/organ&tab=1&organTenant=a904d3a75b21499b8c62c95c6c2ea664@e97'
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
key: 'share-scan', title: '扫码Tab电商', icon: '📝', iconBg: '#409eff', path: '/jmash/pages/share/scan?action=/pages/tabbar/mall&tab=1&shopId=f78f767c-f52d-4bf1-964d-5a11f4c81c75'
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
key: 'share-scan', title: '扫码Tab门店', icon: '📝', iconBg: '#409eff', path: '/jmash/pages/share/scan?action=/pages/tabbar/mall&tab=1&organTenant=092c3844a7b2445888ed7e63338d98c7@e97&branchId=267703a8-f960-4125-9319-693ddfb1ea7a'
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
key: 'share-scan', title: '扫码首页', icon: '📝', iconBg: '#409eff', path: '/jmash/pages/share/scan?action=/pages/index'
|
|
48
|
+
},
|
|
34
49
|
]
|
|
35
50
|
}
|
|
36
51
|
]
|
package/src/utils/share.ts
CHANGED
|
@@ -30,6 +30,45 @@ class ShareUtil {
|
|
|
30
30
|
.map((key) => `${key}=${options[key]}`)
|
|
31
31
|
.join("&");
|
|
32
32
|
}
|
|
33
|
+
// 分享加载
|
|
34
|
+
shareLoad(options: Record<string, string>): Promise<boolean> {
|
|
35
|
+
//推荐人
|
|
36
|
+
const userStore = useUserStore();
|
|
37
|
+
console.log("推荐人:", options.referee);
|
|
38
|
+
if (options.referee) {
|
|
39
|
+
userStore.setReferee(options.referee);
|
|
40
|
+
}
|
|
41
|
+
const shopStore = useShopStore();
|
|
42
|
+
//门店ID
|
|
43
|
+
if (options.branchId && options.organTenant) {
|
|
44
|
+
console.log("门店ID", options.branchId, options.organTenant);
|
|
45
|
+
return shopApi
|
|
46
|
+
.findShopBranchById(options.organTenant, options.branchId)
|
|
47
|
+
.then((res) => {
|
|
48
|
+
return shopStore.switchBranch(res.data).then(() => {
|
|
49
|
+
return userStore.loginOnlyAC();
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
} else if (options.shopId) {
|
|
53
|
+
//商城ID
|
|
54
|
+
console.log("商城ID", options.shopId);
|
|
55
|
+
return shopApi.findShopInfoById(options.shopId).then((res) => {
|
|
56
|
+
return shopStore.switchShop(res.data).then(() => {
|
|
57
|
+
return userStore.loginOnlyAC();
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
} else if (options.organTenant) {
|
|
61
|
+
//组织Token
|
|
62
|
+
const organStore = useOrganStore();
|
|
63
|
+
console.log("组织Token", options.organTenant);
|
|
64
|
+
return organStore.setOrganTenant(options.organTenant).then(() => {
|
|
65
|
+
//静默登录
|
|
66
|
+
return userStore.loginOnlyAC();
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
//静默登录
|
|
70
|
+
return userStore.loginOnlyAC();
|
|
71
|
+
}
|
|
33
72
|
|
|
34
73
|
// 分享用户页给好友
|
|
35
74
|
shareUserPath(pagePath: string, query: string): string {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"setting": {
|
|
3
3
|
"newFeature": true,
|
|
4
4
|
"urlCheck": true,
|
|
5
|
-
"es6":
|
|
5
|
+
"es6": true,
|
|
6
6
|
"postcss": true,
|
|
7
7
|
"minified": false,
|
|
8
8
|
"checkSiteMap": false,
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"compileWorklet": false,
|
|
11
11
|
"uglifyFileName": false,
|
|
12
12
|
"uploadWithSourceMap": true,
|
|
13
|
-
"enhance":
|
|
13
|
+
"enhance": true,
|
|
14
14
|
"packNpmManually": false,
|
|
15
15
|
"packNpmRelationList": [],
|
|
16
16
|
"minifyWXSS": true,
|