jmash-core-mp 0.1.0 → 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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmash-core-mp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "private": false,
5
5
  "dependencies": {
6
6
  "@mpxjs/api-proxy": "^2.10.19",
package/src/app.mpx CHANGED
@@ -14,6 +14,10 @@ createApp({
14
14
  config: config
15
15
  }
16
16
  })
17
+ // 只有运行时才能调用
18
+ const accountInfo = mpx.getAccountInfoSync();
19
+ // 微信
20
+ config.appId = accountInfo.miniProgram.appId;
17
21
  </script>
18
22
 
19
23
  <style></style>
@@ -28,6 +28,7 @@
28
28
  import mpx, { createComponent, ref, onShow } from '@mpxjs/core'
29
29
  import { db } from '../../utils/db';
30
30
  import { authApi } from '../../api/auth/index';
31
+ import { auth } from "../../utils/auth.ts";
31
32
 
32
33
  createComponent({
33
34
  properties: {
@@ -35,6 +36,14 @@ createComponent({
35
36
  type: String,
36
37
  value: ''
37
38
  },
39
+ backurl: {
40
+ type: String,
41
+ value: '/pages/home'
42
+ },
43
+ tabbar: {
44
+ type: String,
45
+ value: 'false'
46
+ }
38
47
  },
39
48
  setup(props, context) {
40
49
  let config = getApp().globalData.config;
@@ -42,21 +51,28 @@ createComponent({
42
51
  let baseUrl = ref(config.baseUrl);
43
52
  let token = ref('');
44
53
  let userInfo = ref({});
45
-
46
- onShow(() => {
54
+ let refreshFunc = () => {
47
55
  token.value = db.getToken();
48
56
  authApi.userInfo().then((resp) => {
49
57
  userInfo.value = resp.data;
50
58
  })
51
- })
59
+ };
60
+ onShow(refreshFunc);
52
61
  console.log(resourceUrl);
53
- return { resourceUrl, baseUrl, token, userInfo };
62
+ return { resourceUrl, baseUrl, token, userInfo, refreshFunc };
54
63
  },
55
64
  methods: {
56
65
  handleLogin() {
57
- mpx.navigateTo({
58
- url: '/jmash/pages/auth/login'
59
- })
66
+ //检查登录并跳转登录
67
+ auth.loginOnlyAC().then(() => {
68
+ //登录成功,加载业务
69
+ console.log("静默登录成功");
70
+ this.refreshFunc();
71
+ }).catch(() => {
72
+ mpx.navigateTo({
73
+ url: '/jmash/pages/auth/login' + "?backurl=" + encodeURIComponent(this.properties.backurl) + "&tabbar=" + this.properties.tabbar
74
+ })
75
+ });
60
76
  },
61
77
  handleUpdateUser() {
62
78
  mpx.navigateTo({
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <jmash-login tabbar="{{ tabbar }}" backurl="{{ backurl }}">
2
+ <jmash-login linkType="{{ linkType }}" backurl="{{ backurl }}">
3
3
  <image mode="widthFix" src="{{ resourceUrl }}/images/login_bg.png" class="index_bj" slot="before">
4
4
  <image mode="widthFix" src="{{ resourceUrl }}/images/logo.png" class="login_logo"></image>
5
5
  </image>
@@ -11,13 +11,23 @@
11
11
  import { createPage, ref } from '@mpxjs/core'
12
12
 
13
13
  createPage({
14
+ properties: {
15
+ tabbar: {
16
+ type: String,
17
+ value: 'false'
18
+ },
19
+ backurl: {
20
+ type: String,
21
+ value: '/pages/home'
22
+ }
23
+ },
14
24
  setup(props) {
15
25
  let resourceUrl = ref(getApp().globalData.config.resourceUrl);
16
26
  let appName = ref(getApp().globalData.config.name);
17
- let tabbar = ref(props.tabbar === 'true');
18
- let backurl = ref(props.backurl || '');
19
- console.log(appName);
20
- return { resourceUrl, appName, tabbar, backurl };
27
+ let linkType = ref(props.tabbar === 'true' ? "switchTab" : "redirectTo");
28
+ let backurl = ref(props.backurl);
29
+ console.log(appName, linkType, backurl);
30
+ return { resourceUrl, appName, linkType, backurl };
21
31
  }
22
32
  })
23
33
  </script>
@@ -6,17 +6,20 @@
6
6
 
7
7
  <script>
8
8
  import { createPage } from '@mpxjs/core'
9
- import { db } from '../utils/db'
10
9
  import mpx from '@mpxjs/core'
10
+ import { auth } from "../utils/auth.ts";
11
11
 
12
12
  createPage({
13
13
  setup() {
14
- // 无法退回,检查登录状态
15
- if (!db.getToken()) {
14
+ //检查登录并跳转登录
15
+ auth.loginOnlyAC().then(() => {
16
+ //登录成功,加载业务
17
+ console.log("静默登录成功");
18
+ }).catch(() => {
16
19
  mpx.navigateTo({
17
20
  url: '/jmash/pages/auth/login'
18
21
  })
19
- }
22
+ });
20
23
  return {}
21
24
  }
22
25
  })
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <view class="basic-component-page">
3
- <jmash-user></jmash-user>
3
+ <jmash-user tabbar="true" backurl="/pages/tabbar/my"></jmash-user>
4
4
  <text>{{ title }}</text>
5
5
  </view>
6
6
  </template>
@@ -3,7 +3,7 @@ import { AppConfig } from "../types/core";
3
3
  const config: AppConfig = {
4
4
  name: "Jmash Core MPX",
5
5
  dev: true,
6
- testNewUser: true,
6
+ testNewUser: false,
7
7
  tenant: "xyvcard",
8
8
  baseUrl: "https://mm.sooyie.cn",
9
9
  resourceUrl: "https://mm.sooyie.cn/v1/file/path/wxapp",
@@ -17,7 +17,7 @@ const config: AppConfig = {
17
17
 
18
18
  if (__mpx_mode__ === "wx") {
19
19
  // 微信
20
- config.appId = "wx2a8b3d689b8959eb";
20
+ config.appId = "wx2a8b3d689b8959eb1";
21
21
  } else if (__mpx_mode__ === "ali") {
22
22
  // 支付宝
23
23
  config.appId = "2016102700684542";