jmash-core-mp 0.1.21 → 0.1.22
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/.editorconfig +9 -9
- package/README.md +60 -60
- package/babel.config.json +34 -34
- package/eslint.config.mjs +7 -7
- package/lib/api/auth/index.d.ts +21 -21
- package/lib/api/auth/index.js +199 -199
- package/lib/api/auth/types.d.ts +86 -86
- package/lib/api/auth/types.js +9 -9
- package/lib/api/cms/index.d.ts +20 -20
- package/lib/api/cms/index.js +161 -161
- package/lib/api/cms/types.d.ts +200 -200
- package/lib/api/cms/types.js +1 -1
- package/lib/api/constant.d.ts +5 -5
- package/lib/api/constant.js +6 -6
- package/lib/api/dict/index.d.ts +18 -18
- package/lib/api/dict/index.js +34 -34
- package/lib/api/dict/types.d.ts +28 -28
- package/lib/api/dict/types.js +1 -1
- package/lib/api/dicts.d.ts +18 -18
- package/lib/api/dicts.js +67 -67
- package/lib/api/files/index.d.ts +25 -25
- package/lib/api/files/index.js +135 -135
- package/lib/api/files/types.d.ts +38 -38
- package/lib/api/files/types.js +1 -1
- package/lib/api/index.d.ts +4 -4
- package/lib/api/index.js +6 -6
- package/lib/api/myorgan/types.d.ts +22 -22
- package/lib/api/myorgan/types.js +1 -1
- package/lib/api/region/index.d.ts +7 -7
- package/lib/api/region/index.js +19 -19
- package/lib/api/region/types.d.ts +19 -19
- package/lib/api/region/types.js +1 -1
- package/lib/api/storage/index.d.ts +10 -10
- package/lib/api/storage/index.js +43 -43
- package/lib/api/storage/types.d.ts +28 -28
- package/lib/api/storage/types.js +1 -1
- package/lib/api/types.d.ts +42 -42
- package/lib/api/types.js +1 -1
- package/lib/app.mpx.d.ts +1 -1
- package/lib/components/auth-user/jmash-update-user.mpx.d.ts +1 -1
- package/lib/components/auth-user/jmash-user.mpx.d.ts +1 -1
- package/lib/components/cms/jmash-cms-acticle-list.mpx.d.ts +1 -1
- package/lib/components/cms/jmash-cms-article-item.mpx.d.ts +1 -1
- package/lib/components/cms/jmash-cms-article-view.mpx.d.ts +1 -0
- package/lib/components/cms/jmash-cms-article.mpx.d.ts +1 -1
- package/lib/components/cms/jmash-cms-like.mpx.d.ts +1 -1
- package/lib/components/common/jmash-upload-picture.mpx.d.ts +1 -0
- package/lib/components/core/jmash-login.mpx.d.ts +1 -0
- package/lib/index.d.ts +21 -21
- package/lib/index.js +14 -14
- package/lib/packages/pages/cms/cms-article-list.mpx.d.ts +1 -1
- package/lib/pages/index.mpx.d.ts +1 -0
- package/lib/store/user.d.ts +31 -31
- package/lib/store/user.js +227 -227
- package/lib/utils/common.d.ts +35 -35
- package/lib/utils/common.js +166 -166
- package/lib/utils/config.d.ts +5 -5
- package/lib/utils/config.js +29 -29
- package/lib/utils/db.d.ts +21 -21
- package/lib/utils/db.js +84 -84
- package/lib/utils/grpc.d.ts +5 -5
- package/lib/utils/grpc.js +20 -20
- package/lib/utils/net.d.ts +7 -7
- package/lib/utils/net.js +15 -15
- package/lib/utils/request.d.ts +2 -2
- package/lib/utils/request.js +123 -123
- package/mpx.config.js +27 -27
- package/package.json +1 -1
- package/postcss.config.js +11 -11
- package/project.config.json +24 -24
- package/project.private.config.json +13 -13
- package/public/index.html +15 -15
- package/src/api/auth/index.ts +227 -227
- package/src/api/auth/types.ts +166 -166
- package/src/api/cms/index.ts +218 -218
- package/src/api/cms/types.ts +379 -379
- package/src/api/constant.ts +6 -6
- package/src/api/dict/index.ts +44 -44
- package/src/api/dict/types.ts +49 -49
- package/src/api/dicts.ts +72 -72
- package/src/api/files/index.ts +163 -163
- package/src/api/files/types.ts +67 -67
- package/src/api/index.ts +11 -11
- package/src/api/myorgan/types.ts +42 -42
- package/src/api/region/index.ts +23 -23
- package/src/api/region/types.ts +36 -36
- package/src/api/storage/index.ts +62 -62
- package/src/api/storage/types.ts +54 -54
- package/src/api/types.ts +72 -72
- package/src/app.mpx +71 -71
- package/src/components/auth-user/jmash-logout.mpx +91 -91
- package/src/components/auth-user/jmash-update-user.mpx +386 -386
- package/src/components/auth-user/jmash-update-user.web.mpx +366 -366
- package/src/components/auth-user/jmash-user.mpx +359 -359
- package/src/components/cms/jmash-cms-acticle-list.mpx +182 -182
- package/src/components/cms/jmash-cms-article-item.mpx +241 -241
- package/src/components/cms/jmash-cms-article-view.mpx +131 -131
- package/src/components/cms/jmash-cms-article.mpx +68 -68
- package/src/components/cms/jmash-cms-like.mpx +151 -151
- package/src/components/common/jmash-avatar-edit.mpx +153 -153
- package/src/components/common/jmash-cascader-region.mpx +112 -112
- package/src/components/common/jmash-menu.mpx +129 -129
- package/src/components/common/jmash-none-data.mpx +82 -82
- package/src/components/common/jmash-pic-swiper.mpx +71 -71
- package/src/components/common/jmash-popup.mpx +137 -137
- package/src/components/common/jmash-search.mpx +126 -126
- package/src/components/common/jmash-single-btn.mpx +53 -53
- package/src/components/common/jmash-stepper.mpx +214 -214
- package/src/components/common/jmash-tab-bar.mpx +50 -50
- package/src/components/common/jmash-textarea.mpx +88 -88
- package/src/components/common/jmash-top-navigation.mpx +203 -203
- package/src/components/common/jmash-upload-picture.mpx +129 -126
- package/src/components/core/jmash-cms-protocol.mpx +66 -66
- package/src/components/core/jmash-login.ali.mpx +284 -284
- package/src/components/core/jmash-login.mpx +348 -348
- package/src/components/core/jmash-login.web.mpx +421 -421
- package/src/components/core/jmash-popup-login.ali.mpx +311 -311
- package/src/components/core/jmash-popup-login.mpx +415 -415
- package/src/components/core/jmash-popup-login.web.mpx +389 -389
- package/src/custom-tab-bar/index.mpx +10 -10
- package/src/global.d.ts +11 -11
- package/src/index.ts +71 -71
- package/src/packages/index.mpx +10 -10
- package/src/packages/pages/auth/cms-protocol.mpx +31 -31
- package/src/packages/pages/auth/login.mpx +59 -59
- package/src/packages/pages/auth/update-user.mpx +17 -17
- package/src/packages/pages/cms/cms-article-list.mpx +164 -164
- package/src/packages/pages/cms/cms-article.mpx +32 -32
- package/src/pages/basic-component.mpx +30 -30
- package/src/pages/half-home.mpx +58 -58
- package/src/pages/home.mpx +52 -52
- package/src/pages/home2.mpx +47 -47
- package/src/pages/index.mpx +13 -3
- package/src/pages/tabbar/home.mpx +77 -77
- package/src/pages/tabbar/my.mpx +80 -80
- package/src/store/user.ts +270 -270
- package/src/styles/index.scss +20 -20
- package/src/styles/vars.scss +27 -27
- package/src/utils/common.ts +179 -179
- package/src/utils/config.ts +35 -35
- package/src/utils/db.ts +100 -100
- package/src/utils/grpc.ts +21 -21
- package/src/utils/net.ts +18 -18
- package/src/utils/request.ts +134 -134
- package/static/ali/mini.project.json +4 -4
- package/static/dd/project.config.json +15 -15
- package/static/swan/project.swan.json +14 -14
- package/static/tt/project.config.json +11 -11
- package/static/wx/project.config.json +40 -40
- package/uno.config.js +9 -9
package/src/api/types.ts
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
export type ResponseData<
|
|
2
|
-
T extends string | WechatMiniprogram.IAnyObject | ArrayBuffer =
|
|
3
|
-
| string
|
|
4
|
-
| WechatMiniprogram.IAnyObject
|
|
5
|
-
| ArrayBuffer
|
|
6
|
-
> = WechatMiniprogram.RequestSuccessCallbackResult<T>;
|
|
7
|
-
|
|
8
|
-
export interface AppConfig {
|
|
9
|
-
//租户
|
|
10
|
-
tenant: string;
|
|
11
|
-
// 名称
|
|
12
|
-
name: string;
|
|
13
|
-
//请求地址
|
|
14
|
-
baseUrl: string;
|
|
15
|
-
//静态资源地址
|
|
16
|
-
resourceUrl: string;
|
|
17
|
-
// 小程序appid
|
|
18
|
-
appId: string;
|
|
19
|
-
// 三方平台id
|
|
20
|
-
componentAppid: string;
|
|
21
|
-
// 微信公众号APP_ID
|
|
22
|
-
wechatComponentAppId: string;
|
|
23
|
-
// 微信三方授权appId
|
|
24
|
-
wechatAppId: string;
|
|
25
|
-
// 微信公众号Biz
|
|
26
|
-
wechatBiz: string;
|
|
27
|
-
//站点ID.
|
|
28
|
-
siteId: string;
|
|
29
|
-
//是否开发环境.
|
|
30
|
-
dev: boolean;
|
|
31
|
-
//是否测试新用户.
|
|
32
|
-
testNewUser: boolean;
|
|
33
|
-
// 其他配置项
|
|
34
|
-
[key: string]: any;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// 校验
|
|
38
|
-
export interface ValidateData {
|
|
39
|
-
// 是否校验通过
|
|
40
|
-
validate: boolean;
|
|
41
|
-
// 校验失败提示信息.
|
|
42
|
-
message: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// 事件基础
|
|
46
|
-
export interface EventBase {
|
|
47
|
-
// 在触摸事件中使用,表示触摸点的状态
|
|
48
|
-
changedTouches?: any;
|
|
49
|
-
// 事件绑定的元素
|
|
50
|
-
currentTarget: EventTarget;
|
|
51
|
-
// 指向触发事件的目标节点
|
|
52
|
-
target?: EventTarget;
|
|
53
|
-
// 事件的类型,指示事件的具体类型,如 click, input, blur
|
|
54
|
-
type?: string;
|
|
55
|
-
detail?: any;
|
|
56
|
-
touches: any;
|
|
57
|
-
}
|
|
58
|
-
// 事件绑定的元素
|
|
59
|
-
export interface EventTarget {
|
|
60
|
-
dataset: any;
|
|
61
|
-
id: string | number;
|
|
62
|
-
offsetLeft?: number;
|
|
63
|
-
offsetTop?: number;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// canvas返回的数据
|
|
67
|
-
export interface CanvasResponse {
|
|
68
|
-
width?: number;
|
|
69
|
-
height?: number;
|
|
70
|
-
nodeCanvasType?: string;
|
|
71
|
-
node: any;
|
|
72
|
-
}
|
|
1
|
+
export type ResponseData<
|
|
2
|
+
T extends string | WechatMiniprogram.IAnyObject | ArrayBuffer =
|
|
3
|
+
| string
|
|
4
|
+
| WechatMiniprogram.IAnyObject
|
|
5
|
+
| ArrayBuffer
|
|
6
|
+
> = WechatMiniprogram.RequestSuccessCallbackResult<T>;
|
|
7
|
+
|
|
8
|
+
export interface AppConfig {
|
|
9
|
+
//租户
|
|
10
|
+
tenant: string;
|
|
11
|
+
// 名称
|
|
12
|
+
name: string;
|
|
13
|
+
//请求地址
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
//静态资源地址
|
|
16
|
+
resourceUrl: string;
|
|
17
|
+
// 小程序appid
|
|
18
|
+
appId: string;
|
|
19
|
+
// 三方平台id
|
|
20
|
+
componentAppid: string;
|
|
21
|
+
// 微信公众号APP_ID
|
|
22
|
+
wechatComponentAppId: string;
|
|
23
|
+
// 微信三方授权appId
|
|
24
|
+
wechatAppId: string;
|
|
25
|
+
// 微信公众号Biz
|
|
26
|
+
wechatBiz: string;
|
|
27
|
+
//站点ID.
|
|
28
|
+
siteId: string;
|
|
29
|
+
//是否开发环境.
|
|
30
|
+
dev: boolean;
|
|
31
|
+
//是否测试新用户.
|
|
32
|
+
testNewUser: boolean;
|
|
33
|
+
// 其他配置项
|
|
34
|
+
[key: string]: any;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// 校验
|
|
38
|
+
export interface ValidateData {
|
|
39
|
+
// 是否校验通过
|
|
40
|
+
validate: boolean;
|
|
41
|
+
// 校验失败提示信息.
|
|
42
|
+
message: string;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 事件基础
|
|
46
|
+
export interface EventBase {
|
|
47
|
+
// 在触摸事件中使用,表示触摸点的状态
|
|
48
|
+
changedTouches?: any;
|
|
49
|
+
// 事件绑定的元素
|
|
50
|
+
currentTarget: EventTarget;
|
|
51
|
+
// 指向触发事件的目标节点
|
|
52
|
+
target?: EventTarget;
|
|
53
|
+
// 事件的类型,指示事件的具体类型,如 click, input, blur
|
|
54
|
+
type?: string;
|
|
55
|
+
detail?: any;
|
|
56
|
+
touches: any;
|
|
57
|
+
}
|
|
58
|
+
// 事件绑定的元素
|
|
59
|
+
export interface EventTarget {
|
|
60
|
+
dataset: any;
|
|
61
|
+
id: string | number;
|
|
62
|
+
offsetLeft?: number;
|
|
63
|
+
offsetTop?: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// canvas返回的数据
|
|
67
|
+
export interface CanvasResponse {
|
|
68
|
+
width?: number;
|
|
69
|
+
height?: number;
|
|
70
|
+
nodeCanvasType?: string;
|
|
71
|
+
node: any;
|
|
72
|
+
}
|
package/src/app.mpx
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import mpx, { createApp } from '@mpxjs/core';
|
|
3
|
-
//api代理
|
|
4
|
-
import apiProxy from '@mpxjs/api-proxy';
|
|
5
|
-
mpx.use(apiProxy, { usePromise: true })
|
|
6
|
-
//状态管理
|
|
7
|
-
import { createPinia } from '@mpxjs/pinia';
|
|
8
|
-
createPinia();
|
|
9
|
-
//网络请求和App配置
|
|
10
|
-
import { mpxFetch, config, initConfig } from "./index";
|
|
11
|
-
mpx.use(mpxFetch);
|
|
12
|
-
|
|
13
|
-
createApp({
|
|
14
|
-
onLaunch(options) {
|
|
15
|
-
initConfig(config, "dev");
|
|
16
|
-
console.log("config", config);
|
|
17
|
-
},
|
|
18
|
-
globalData: {
|
|
19
|
-
config: config
|
|
20
|
-
}
|
|
21
|
-
})
|
|
22
|
-
</script>
|
|
23
|
-
|
|
24
|
-
<style></style>
|
|
25
|
-
|
|
26
|
-
<script type="application/json">
|
|
27
|
-
{
|
|
28
|
-
"pages": [
|
|
29
|
-
"./pages/index",
|
|
30
|
-
"./pages/home",
|
|
31
|
-
"./pages/home2",
|
|
32
|
-
"./pages/half-home",
|
|
33
|
-
"./pages/basic-component",
|
|
34
|
-
"./pages/tabbar/home",
|
|
35
|
-
"./pages/tabbar/my",
|
|
36
|
-
],
|
|
37
|
-
"packages": [
|
|
38
|
-
"./packages/index?root=jmash"
|
|
39
|
-
],
|
|
40
|
-
"tabBar": {
|
|
41
|
-
"custom": true,
|
|
42
|
-
"color": "#86909C",
|
|
43
|
-
"selectedColor": "#EA4C3B",
|
|
44
|
-
"list": [
|
|
45
|
-
{
|
|
46
|
-
"pagePath": "pages/tabbar/home",
|
|
47
|
-
"text": "首页",
|
|
48
|
-
"activeIcon": "",
|
|
49
|
-
"icon": ""
|
|
50
|
-
},
|
|
51
|
-
{
|
|
52
|
-
"pagePath": "pages/tabbar/my",
|
|
53
|
-
"text": "我的",
|
|
54
|
-
"activeIcon": "",
|
|
55
|
-
"icon": ""
|
|
56
|
-
}
|
|
57
|
-
]
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
</script>
|
|
61
|
-
|
|
62
|
-
<!--也可以通过以下形式用js输出json,便于书写注释和使用条件编译-->
|
|
63
|
-
|
|
64
|
-
<!--<script name="json">-->
|
|
65
|
-
<!-- // 可以写注释,通过defs注入的常量做一些判断之类的操作-->
|
|
66
|
-
<!-- module.exports = {-->
|
|
67
|
-
<!-- pages: [-->
|
|
68
|
-
<!-- './pages/index'-->
|
|
69
|
-
<!-- ]-->
|
|
70
|
-
<!-- }-->
|
|
71
|
-
<!--</script>-->
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import mpx, { createApp } from '@mpxjs/core';
|
|
3
|
+
//api代理
|
|
4
|
+
import apiProxy from '@mpxjs/api-proxy';
|
|
5
|
+
mpx.use(apiProxy, { usePromise: true })
|
|
6
|
+
//状态管理
|
|
7
|
+
import { createPinia } from '@mpxjs/pinia';
|
|
8
|
+
createPinia();
|
|
9
|
+
//网络请求和App配置
|
|
10
|
+
import { mpxFetch, config, initConfig } from "./index";
|
|
11
|
+
mpx.use(mpxFetch);
|
|
12
|
+
|
|
13
|
+
createApp({
|
|
14
|
+
onLaunch(options) {
|
|
15
|
+
initConfig(config, "dev");
|
|
16
|
+
console.log("config", config);
|
|
17
|
+
},
|
|
18
|
+
globalData: {
|
|
19
|
+
config: config
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
</script>
|
|
23
|
+
|
|
24
|
+
<style></style>
|
|
25
|
+
|
|
26
|
+
<script type="application/json">
|
|
27
|
+
{
|
|
28
|
+
"pages": [
|
|
29
|
+
"./pages/index",
|
|
30
|
+
"./pages/home",
|
|
31
|
+
"./pages/home2",
|
|
32
|
+
"./pages/half-home",
|
|
33
|
+
"./pages/basic-component",
|
|
34
|
+
"./pages/tabbar/home",
|
|
35
|
+
"./pages/tabbar/my",
|
|
36
|
+
],
|
|
37
|
+
"packages": [
|
|
38
|
+
"./packages/index?root=jmash"
|
|
39
|
+
],
|
|
40
|
+
"tabBar": {
|
|
41
|
+
"custom": true,
|
|
42
|
+
"color": "#86909C",
|
|
43
|
+
"selectedColor": "#EA4C3B",
|
|
44
|
+
"list": [
|
|
45
|
+
{
|
|
46
|
+
"pagePath": "pages/tabbar/home",
|
|
47
|
+
"text": "首页",
|
|
48
|
+
"activeIcon": "",
|
|
49
|
+
"icon": ""
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"pagePath": "pages/tabbar/my",
|
|
53
|
+
"text": "我的",
|
|
54
|
+
"activeIcon": "",
|
|
55
|
+
"icon": ""
|
|
56
|
+
}
|
|
57
|
+
]
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<!--也可以通过以下形式用js输出json,便于书写注释和使用条件编译-->
|
|
63
|
+
|
|
64
|
+
<!--<script name="json">-->
|
|
65
|
+
<!-- // 可以写注释,通过defs注入的常量做一些判断之类的操作-->
|
|
66
|
+
<!-- module.exports = {-->
|
|
67
|
+
<!-- pages: [-->
|
|
68
|
+
<!-- './pages/index'-->
|
|
69
|
+
<!-- ]-->
|
|
70
|
+
<!-- }-->
|
|
71
|
+
<!--</script>-->
|
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<view class="logout-section">
|
|
3
|
-
<!-- 登录状态才显示退出按钮 -->
|
|
4
|
-
<button class="logout-btn" bind:tap="handleLogout" wx:if="{{ isLogin }}">退出登录</button>
|
|
5
|
-
<text class="version-text">当前版本 V{{ version }}</text>
|
|
6
|
-
</view>
|
|
7
|
-
</template>
|
|
8
|
-
|
|
9
|
-
<script>
|
|
10
|
-
import mpx, { createComponent, computed } from '@mpxjs/core'
|
|
11
|
-
import { useUserStore } from '../../store/user'
|
|
12
|
-
|
|
13
|
-
createComponent({
|
|
14
|
-
properties: {
|
|
15
|
-
// 自定义版本号,默认读配置
|
|
16
|
-
version: {
|
|
17
|
-
type: String,
|
|
18
|
-
value: '1.0.0'
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
setup() {
|
|
22
|
-
let userStore = useUserStore();
|
|
23
|
-
const isLogin = computed(() => userStore.accessToken !== '');
|
|
24
|
-
return {
|
|
25
|
-
isLogin, userStore
|
|
26
|
-
};
|
|
27
|
-
},
|
|
28
|
-
methods: {
|
|
29
|
-
// 退出登录逻辑
|
|
30
|
-
handleLogout() {
|
|
31
|
-
mpx.showModal({
|
|
32
|
-
title: '提示',
|
|
33
|
-
content: '确定要退出登录吗?',
|
|
34
|
-
success: (res) => {
|
|
35
|
-
if (res.confirm) {
|
|
36
|
-
this.userStore.logout() // 调用退出接口
|
|
37
|
-
mpx.showToast({ title: '已退出登录', icon: 'success' })
|
|
38
|
-
// 通知父组件退出成功
|
|
39
|
-
this.triggerEvent('logoutSuccess');
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
</script>
|
|
47
|
-
|
|
48
|
-
<style lang="scss">
|
|
49
|
-
$primary: #07c160;
|
|
50
|
-
$text-3: #999999;
|
|
51
|
-
|
|
52
|
-
.logout-section {
|
|
53
|
-
padding: 40rpx 16rpx 80rpx; // 底部留空适配tabbar
|
|
54
|
-
display: flex;
|
|
55
|
-
flex-direction: column;
|
|
56
|
-
align-items: center;
|
|
57
|
-
|
|
58
|
-
.logout-btn {
|
|
59
|
-
width: 300rpx;
|
|
60
|
-
height: 72rpx;
|
|
61
|
-
border-radius: 36rpx;
|
|
62
|
-
border: 2rpx solid #ff4d4f;
|
|
63
|
-
background: #fff;
|
|
64
|
-
color: #ff4d4f;
|
|
65
|
-
font-size: 28rpx;
|
|
66
|
-
font-weight: 500;
|
|
67
|
-
display: flex;
|
|
68
|
-
align-items: center;
|
|
69
|
-
justify-content: center;
|
|
70
|
-
margin-bottom: 24rpx;
|
|
71
|
-
transition: all 0.2s;
|
|
72
|
-
|
|
73
|
-
&:active {
|
|
74
|
-
background: #fff1f0;
|
|
75
|
-
transform: scale(0.98);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.version-text {
|
|
80
|
-
font-size: 24rpx;
|
|
81
|
-
color: $text-3;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
</style>
|
|
85
|
-
|
|
86
|
-
<script type="application/json">
|
|
87
|
-
{
|
|
88
|
-
"component": true,
|
|
89
|
-
"usingComponents": {}
|
|
90
|
-
}
|
|
91
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<view class="logout-section">
|
|
3
|
+
<!-- 登录状态才显示退出按钮 -->
|
|
4
|
+
<button class="logout-btn" bind:tap="handleLogout" wx:if="{{ isLogin }}">退出登录</button>
|
|
5
|
+
<text class="version-text">当前版本 V{{ version }}</text>
|
|
6
|
+
</view>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script>
|
|
10
|
+
import mpx, { createComponent, computed } from '@mpxjs/core'
|
|
11
|
+
import { useUserStore } from '../../store/user'
|
|
12
|
+
|
|
13
|
+
createComponent({
|
|
14
|
+
properties: {
|
|
15
|
+
// 自定义版本号,默认读配置
|
|
16
|
+
version: {
|
|
17
|
+
type: String,
|
|
18
|
+
value: '1.0.0'
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
setup() {
|
|
22
|
+
let userStore = useUserStore();
|
|
23
|
+
const isLogin = computed(() => userStore.accessToken !== '');
|
|
24
|
+
return {
|
|
25
|
+
isLogin, userStore
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
methods: {
|
|
29
|
+
// 退出登录逻辑
|
|
30
|
+
handleLogout() {
|
|
31
|
+
mpx.showModal({
|
|
32
|
+
title: '提示',
|
|
33
|
+
content: '确定要退出登录吗?',
|
|
34
|
+
success: (res) => {
|
|
35
|
+
if (res.confirm) {
|
|
36
|
+
this.userStore.logout() // 调用退出接口
|
|
37
|
+
mpx.showToast({ title: '已退出登录', icon: 'success' })
|
|
38
|
+
// 通知父组件退出成功
|
|
39
|
+
this.triggerEvent('logoutSuccess');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
</script>
|
|
47
|
+
|
|
48
|
+
<style lang="scss">
|
|
49
|
+
$primary: #07c160;
|
|
50
|
+
$text-3: #999999;
|
|
51
|
+
|
|
52
|
+
.logout-section {
|
|
53
|
+
padding: 40rpx 16rpx 80rpx; // 底部留空适配tabbar
|
|
54
|
+
display: flex;
|
|
55
|
+
flex-direction: column;
|
|
56
|
+
align-items: center;
|
|
57
|
+
|
|
58
|
+
.logout-btn {
|
|
59
|
+
width: 300rpx;
|
|
60
|
+
height: 72rpx;
|
|
61
|
+
border-radius: 36rpx;
|
|
62
|
+
border: 2rpx solid #ff4d4f;
|
|
63
|
+
background: #fff;
|
|
64
|
+
color: #ff4d4f;
|
|
65
|
+
font-size: 28rpx;
|
|
66
|
+
font-weight: 500;
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
justify-content: center;
|
|
70
|
+
margin-bottom: 24rpx;
|
|
71
|
+
transition: all 0.2s;
|
|
72
|
+
|
|
73
|
+
&:active {
|
|
74
|
+
background: #fff1f0;
|
|
75
|
+
transform: scale(0.98);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.version-text {
|
|
80
|
+
font-size: 24rpx;
|
|
81
|
+
color: $text-3;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
</style>
|
|
85
|
+
|
|
86
|
+
<script type="application/json">
|
|
87
|
+
{
|
|
88
|
+
"component": true,
|
|
89
|
+
"usingComponents": {}
|
|
90
|
+
}
|
|
91
|
+
</script>
|