jmash-core-mp 0.1.72 → 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.
@@ -0,0 +1 @@
1
+ export {};
@@ -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>;
@@ -29,22 +29,64 @@ 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();
35
- const referee = userStore.userInfo?.userId || "";
76
+ const referee = userStore.userInfo?.userId.replace(/-/g, "") || "";
36
77
  return `${pagePath}?referee=${referee}&${query}`;
37
78
  }
38
79
  // 分享用户页到朋友圈
39
80
  shareUserQuery(query) {
40
81
  const userStore = useUserStore();
41
- const referee = userStore.userInfo?.userId || "";
82
+ const referee = userStore.userInfo?.userId.replace(/-/g, "") || "";
42
83
  return `referee=${referee}&${query}`;
43
84
  }
44
85
  // 分享用户页加载
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
  }
@@ -54,7 +96,7 @@ class ShareUtil {
54
96
  // 分享组织页给好友
55
97
  shareOrganPath(pagePath, query) {
56
98
  const userStore = useUserStore();
57
- const referee = userStore.userInfo?.userId || "";
99
+ const referee = userStore.userInfo?.userId.replace(/-/g, "") || "";
58
100
  const organStore = useOrganStore();
59
101
  const organTenant = organStore.organTenant || "";
60
102
  return `${pagePath}?referee=${referee}&organTenant=${organTenant}&${query}`;
@@ -62,7 +104,7 @@ class ShareUtil {
62
104
  // 分享组织页给朋友圈
63
105
  shareOrganQuery(query) {
64
106
  const userStore = useUserStore();
65
- const referee = userStore.userInfo?.userId || "";
107
+ const referee = userStore.userInfo?.userId.replace(/-/g, "") || "";
66
108
  const organStore = useOrganStore();
67
109
  const organTenant = organStore.organTenant || "";
68
110
  return `referee=${referee}&organTenant=${organTenant}&${query}`;
@@ -89,7 +131,7 @@ class ShareUtil {
89
131
  // 分享电商页给好友
90
132
  shareMallPath(pagePath, query) {
91
133
  const userStore = useUserStore();
92
- const referee = userStore.userInfo?.userId || "";
134
+ const referee = userStore.userInfo?.userId.replace(/-/g, "") || "";
93
135
  const shopStore = useShopStore();
94
136
  if (shopStore.isShop) {
95
137
  const shopId = shopStore.shopInfo?.shopId || "";
@@ -105,7 +147,7 @@ class ShareUtil {
105
147
  // 分享电商页给朋友圈
106
148
  shareMallQuery(query) {
107
149
  const userStore = useUserStore();
108
- const referee = userStore.userInfo?.userId || "";
150
+ const referee = userStore.userInfo?.userId.replace(/-/g, "") || "";
109
151
  const shopStore = useShopStore();
110
152
  if (shopStore.isShop) {
111
153
  const shopId = shopStore.shopInfo?.shopId || "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmash-core-mp",
3
- "version": "0.1.72",
3
+ "version": "0.1.74",
4
4
  "private": false,
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -11,6 +11,7 @@
11
11
  "./pages/cms/cms-location",
12
12
  "./pages/cms/cms-activity-list",
13
13
  "./pages/cms/cms-product-list",
14
+ "./pages/share/scan",
14
15
  ]
15
16
  }
16
17
  </script>
@@ -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
  ]
@@ -30,23 +30,63 @@ 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 {
36
75
  const userStore = useUserStore();
37
- const referee = userStore.userInfo?.userId || "";
76
+ const referee = userStore.userInfo?.userId.replace(/-/g, "") || "";
38
77
  return `${pagePath}?referee=${referee}&${query}`;
39
78
  }
40
79
  // 分享用户页到朋友圈
41
80
  shareUserQuery(query: string): string {
42
81
  const userStore = useUserStore();
43
- const referee = userStore.userInfo?.userId || "";
82
+ const referee = userStore.userInfo?.userId.replace(/-/g, "") || "";
44
83
  return `referee=${referee}&${query}`;
45
84
  }
46
85
  // 分享用户页加载
47
86
  shareUserLoad(options: Record<string, string>): Promise<boolean> {
48
87
  //推荐人
49
88
  const userStore = useUserStore();
89
+ console.log("推荐人:", options.referee);
50
90
  if (options.referee) {
51
91
  userStore.setReferee(options.referee);
52
92
  }
@@ -56,7 +96,7 @@ class ShareUtil {
56
96
  // 分享组织页给好友
57
97
  shareOrganPath(pagePath: string, query: string): string {
58
98
  const userStore = useUserStore();
59
- const referee = userStore.userInfo?.userId || "";
99
+ const referee = userStore.userInfo?.userId.replace(/-/g, "") || "";
60
100
  const organStore = useOrganStore();
61
101
  const organTenant = organStore.organTenant || "";
62
102
  return `${pagePath}?referee=${referee}&organTenant=${organTenant}&${query}`;
@@ -64,7 +104,7 @@ class ShareUtil {
64
104
  // 分享组织页给朋友圈
65
105
  shareOrganQuery(query: string): string {
66
106
  const userStore = useUserStore();
67
- const referee = userStore.userInfo?.userId || "";
107
+ const referee = userStore.userInfo?.userId.replace(/-/g, "") || "";
68
108
  const organStore = useOrganStore();
69
109
  const organTenant = organStore.organTenant || "";
70
110
  return `referee=${referee}&organTenant=${organTenant}&${query}`;
@@ -92,7 +132,7 @@ class ShareUtil {
92
132
  // 分享电商页给好友
93
133
  shareMallPath(pagePath: string, query: string): string {
94
134
  const userStore = useUserStore();
95
- const referee = userStore.userInfo?.userId || "";
135
+ const referee = userStore.userInfo?.userId.replace(/-/g, "") || "";
96
136
  const shopStore = useShopStore();
97
137
  if (shopStore.isShop) {
98
138
  const shopId = shopStore.shopInfo?.shopId || "";
@@ -107,7 +147,7 @@ class ShareUtil {
107
147
  // 分享电商页给朋友圈
108
148
  shareMallQuery(query: string): string {
109
149
  const userStore = useUserStore();
110
- const referee = userStore.userInfo?.userId || "";
150
+ const referee = userStore.userInfo?.userId.replace(/-/g, "") || "";
111
151
  const shopStore = useShopStore();
112
152
  if (shopStore.isShop) {
113
153
  const shopId = shopStore.shopInfo?.shopId || "";
@@ -2,7 +2,7 @@
2
2
  "setting": {
3
3
  "newFeature": true,
4
4
  "urlCheck": true,
5
- "es6": false,
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": false,
13
+ "enhance": true,
14
14
  "packNpmManually": false,
15
15
  "packNpmRelationList": [],
16
16
  "minifyWXSS": true,