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
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<button bind:tap="onClick" class="auth-btn" style="{{ buttonStyle }}" disabled="{{ disabled }}">
|
|
3
|
-
{{ text }}
|
|
4
|
-
</button>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script lang="ts">
|
|
8
|
-
import { createComponent } from "@mpxjs/core";
|
|
9
|
-
|
|
10
|
-
createComponent({
|
|
11
|
-
properties: {
|
|
12
|
-
// 文本
|
|
13
|
-
text: {
|
|
14
|
-
type: String,
|
|
15
|
-
value: ""
|
|
16
|
-
},
|
|
17
|
-
// 禁用
|
|
18
|
-
disabled: {
|
|
19
|
-
type: Boolean,
|
|
20
|
-
value: false
|
|
21
|
-
},
|
|
22
|
-
// 按钮的样式(包括字体颜色,背景色等)
|
|
23
|
-
buttonStyle: {
|
|
24
|
-
type: String,
|
|
25
|
-
value: "background-color: #2563EB;color: #fff;"
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
methods: {
|
|
29
|
-
onClick() {
|
|
30
|
-
this.triggerEvent("click", null, {});
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
</script>
|
|
35
|
-
|
|
36
|
-
<style lang="scss">
|
|
37
|
-
@use "../../styles/index.scss" as *;
|
|
38
|
-
|
|
39
|
-
.auth-btn {
|
|
40
|
-
font-size: 32rpx;
|
|
41
|
-
width: $width !important;
|
|
42
|
-
|
|
43
|
-
&::after {
|
|
44
|
-
border: none;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
</style>
|
|
48
|
-
|
|
49
|
-
<script type="application/json">
|
|
50
|
-
{
|
|
51
|
-
"component": true,
|
|
52
|
-
"usingComponents": {}
|
|
53
|
-
}
|
|
1
|
+
<template>
|
|
2
|
+
<button bind:tap="onClick" class="auth-btn" style="{{ buttonStyle }}" disabled="{{ disabled }}">
|
|
3
|
+
{{ text }}
|
|
4
|
+
</button>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script lang="ts">
|
|
8
|
+
import { createComponent } from "@mpxjs/core";
|
|
9
|
+
|
|
10
|
+
createComponent({
|
|
11
|
+
properties: {
|
|
12
|
+
// 文本
|
|
13
|
+
text: {
|
|
14
|
+
type: String,
|
|
15
|
+
value: ""
|
|
16
|
+
},
|
|
17
|
+
// 禁用
|
|
18
|
+
disabled: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
value: false
|
|
21
|
+
},
|
|
22
|
+
// 按钮的样式(包括字体颜色,背景色等)
|
|
23
|
+
buttonStyle: {
|
|
24
|
+
type: String,
|
|
25
|
+
value: "background-color: #2563EB;color: #fff;"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
methods: {
|
|
29
|
+
onClick() {
|
|
30
|
+
this.triggerEvent("click", null, {});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
})
|
|
34
|
+
</script>
|
|
35
|
+
|
|
36
|
+
<style lang="scss">
|
|
37
|
+
@use "../../styles/index.scss" as *;
|
|
38
|
+
|
|
39
|
+
.auth-btn {
|
|
40
|
+
font-size: 32rpx;
|
|
41
|
+
width: $width !important;
|
|
42
|
+
|
|
43
|
+
&::after {
|
|
44
|
+
border: none;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
</style>
|
|
48
|
+
|
|
49
|
+
<script type="application/json">
|
|
50
|
+
{
|
|
51
|
+
"component": true,
|
|
52
|
+
"usingComponents": {}
|
|
53
|
+
}
|
|
54
54
|
</script>
|
|
@@ -1,214 +1,214 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<!-- 步进器-选择数量 -->
|
|
3
|
-
<view class="stepper">
|
|
4
|
-
<!-- 减少按钮 -->
|
|
5
|
-
<view class="stepper-btn {{ disabled || decDisabled ? 'disabled' : '' }}"
|
|
6
|
-
bind:tap="{{ disabled || decDisabled ? '' : 'handleDecrement' }}">
|
|
7
|
-
<text class="stepper-symbol">-</text>
|
|
8
|
-
</view>
|
|
9
|
-
|
|
10
|
-
<!-- 数量输入框 -->
|
|
11
|
-
<input class="stepper-input" type="number" value="{{ quantity + '' }}" disabled="{{ disabled }}"
|
|
12
|
-
bind:input="handleInput" />
|
|
13
|
-
|
|
14
|
-
<!-- 增加按钮 -->
|
|
15
|
-
<view class="stepper-btn {{ disabled || incDisabled ? 'disabled' : '' }}"
|
|
16
|
-
bind:tap="{{ disabled || incDisabled ? '' : 'handleIncrement' }}">
|
|
17
|
-
<text class="stepper-symbol">+</text>
|
|
18
|
-
</view>
|
|
19
|
-
</view>
|
|
20
|
-
</template>
|
|
21
|
-
|
|
22
|
-
<script lang="ts">
|
|
23
|
-
import { createComponent, ref } from "@mpxjs/core";
|
|
24
|
-
import { EventBase } from "../../api/types";
|
|
25
|
-
|
|
26
|
-
createComponent({
|
|
27
|
-
options: {
|
|
28
|
-
styleIsolation: "apply-shared"
|
|
29
|
-
},
|
|
30
|
-
properties: {
|
|
31
|
-
// 最大数(-1表示无限制)
|
|
32
|
-
maxNum: {
|
|
33
|
-
type: Number,
|
|
34
|
-
value: -1
|
|
35
|
-
},
|
|
36
|
-
// 最小数
|
|
37
|
-
minNum: {
|
|
38
|
-
type: Number,
|
|
39
|
-
value: 0
|
|
40
|
-
},
|
|
41
|
-
// 初始值
|
|
42
|
-
value: {
|
|
43
|
-
type: Number,
|
|
44
|
-
value: 1,
|
|
45
|
-
observer() {
|
|
46
|
-
this.quantity = this.value;
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
// 是否禁用按钮
|
|
50
|
-
disabled: {
|
|
51
|
-
type: Boolean,
|
|
52
|
-
value: false
|
|
53
|
-
},
|
|
54
|
-
// 步长
|
|
55
|
-
step: {
|
|
56
|
-
type: Number,
|
|
57
|
-
value: 1
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
setup() {
|
|
61
|
-
// 数量
|
|
62
|
-
let quantity = ref(1);
|
|
63
|
-
// 减少按钮是否禁用
|
|
64
|
-
let decDisabled = ref(false);
|
|
65
|
-
// 增加按钮是否禁用
|
|
66
|
-
let incDisabled = ref(false);
|
|
67
|
-
|
|
68
|
-
return { quantity, decDisabled, incDisabled }
|
|
69
|
-
},
|
|
70
|
-
lifetimes: {
|
|
71
|
-
ready() {
|
|
72
|
-
// 初始化数量
|
|
73
|
-
this.initQuantity();
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
methods: {
|
|
77
|
-
// 初始化数量,并设置按钮禁用状态
|
|
78
|
-
initQuantity() {
|
|
79
|
-
const initValue = this.value;
|
|
80
|
-
// 处理初始值无效的情况
|
|
81
|
-
if (initValue === null || initValue === undefined) {
|
|
82
|
-
this.quantity = 1;
|
|
83
|
-
this.decDisabled = false;
|
|
84
|
-
this.incDisabled = false;
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
// 确保初始值在 [minNum, maxNum] 范围内
|
|
88
|
-
if (initValue < this.minNum) {
|
|
89
|
-
this.quantity = this.minNum;
|
|
90
|
-
} else if (this.maxNum >= 0 && initValue > this.maxNum) {
|
|
91
|
-
this.quantity = this.maxNum;
|
|
92
|
-
} else {
|
|
93
|
-
this.quantity = initValue;
|
|
94
|
-
}
|
|
95
|
-
// 更新按钮禁用状态
|
|
96
|
-
this.updateButtonStatus();
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
// 更新按钮禁用状态
|
|
100
|
-
updateButtonStatus() {
|
|
101
|
-
// 减少按钮:当数量等于最小值时禁用
|
|
102
|
-
this.decDisabled = this.quantity <= this.minNum;
|
|
103
|
-
// 增加按钮:当数量等于最大值(且有限制)时禁用
|
|
104
|
-
this.incDisabled = this.maxNum >= 0 && this.quantity >= this.maxNum;
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
// 减少数量,并更新按钮状态
|
|
108
|
-
handleDecrement() {
|
|
109
|
-
// 已达到最小值,不执行减少操作
|
|
110
|
-
if (this.quantity <= this.minNum) {
|
|
111
|
-
this.decDisabled = true;
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
114
|
-
this.quantity -= this.step;
|
|
115
|
-
// 确保数量不小于最小值
|
|
116
|
-
if (this.quantity < this.minNum) {
|
|
117
|
-
this.quantity = this.minNum;
|
|
118
|
-
}
|
|
119
|
-
// 更新按钮禁用状态
|
|
120
|
-
this.updateButtonStatus();
|
|
121
|
-
this.triggerEvent("quantity", this.quantity);
|
|
122
|
-
},
|
|
123
|
-
|
|
124
|
-
// 增加数量,并更新按钮状态
|
|
125
|
-
handleIncrement() {
|
|
126
|
-
// 已达到最大值(且有限制),不执行增加操作
|
|
127
|
-
if (this.maxNum >= 0 && this.quantity >= this.maxNum) {
|
|
128
|
-
this.incDisabled = true;
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
this.quantity += this.step;
|
|
132
|
-
// 确保数量不超过最大值(如果有限制)
|
|
133
|
-
if (this.maxNum >= 0 && this.quantity > this.maxNum) {
|
|
134
|
-
this.quantity = this.maxNum;
|
|
135
|
-
}
|
|
136
|
-
// 更新按钮禁用状态
|
|
137
|
-
this.updateButtonStatus();
|
|
138
|
-
this.triggerEvent("quantity", this.quantity);
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
// 输入数量处理
|
|
142
|
-
handleInput(e: EventBase) {
|
|
143
|
-
// 将输入值转为数字,无效输入默认为 1
|
|
144
|
-
let value = parseInt(e.detail.value) || 1;
|
|
145
|
-
// 确保输入值在 [minNum, maxNum] 范围内
|
|
146
|
-
if (value < this.minNum) {
|
|
147
|
-
value = this.minNum;
|
|
148
|
-
} else if (this.maxNum >= 0 && value > this.maxNum) {
|
|
149
|
-
value = this.maxNum;
|
|
150
|
-
}
|
|
151
|
-
this.quantity = value;
|
|
152
|
-
// 更新按钮禁用状态
|
|
153
|
-
this.updateButtonStatus();
|
|
154
|
-
this.triggerEvent("quantity", this.quantity);
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
})
|
|
158
|
-
</script>
|
|
159
|
-
|
|
160
|
-
<style lang="scss">
|
|
161
|
-
.stepper {
|
|
162
|
-
display: inline-flex;
|
|
163
|
-
align-items: center;
|
|
164
|
-
gap: 2rpx;
|
|
165
|
-
border-radius: 8rpx;
|
|
166
|
-
overflow: hidden;
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// 步进器按钮
|
|
170
|
-
.stepper-btn {
|
|
171
|
-
width: 56rpx;
|
|
172
|
-
height: 56rpx;
|
|
173
|
-
display: flex;
|
|
174
|
-
align-items: center;
|
|
175
|
-
justify-content: center;
|
|
176
|
-
background-color: #f5f5f5;
|
|
177
|
-
user-select: none;
|
|
178
|
-
transition: opacity 0.2s;
|
|
179
|
-
|
|
180
|
-
&.disabled {
|
|
181
|
-
opacity: 0.5;
|
|
182
|
-
pointer-events: none;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// 步进器符号
|
|
186
|
-
.stepper-symbol {
|
|
187
|
-
display: flex;
|
|
188
|
-
align-items: center;
|
|
189
|
-
justify-content: center;
|
|
190
|
-
font-size: 28rpx;
|
|
191
|
-
color: #333;
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
// 数量输入框
|
|
196
|
-
.stepper-input {
|
|
197
|
-
width: 80rpx;
|
|
198
|
-
height: 56rpx;
|
|
199
|
-
text-align: center;
|
|
200
|
-
font-size: 28rpx;
|
|
201
|
-
color: #333;
|
|
202
|
-
background-color: #f5f5f5;
|
|
203
|
-
padding: 0;
|
|
204
|
-
margin: 0;
|
|
205
|
-
box-sizing: border-box;
|
|
206
|
-
}
|
|
207
|
-
</style>
|
|
208
|
-
|
|
209
|
-
<script type="application/json">
|
|
210
|
-
{
|
|
211
|
-
"component": true,
|
|
212
|
-
"usingComponents": {}
|
|
213
|
-
}
|
|
214
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<!-- 步进器-选择数量 -->
|
|
3
|
+
<view class="stepper">
|
|
4
|
+
<!-- 减少按钮 -->
|
|
5
|
+
<view class="stepper-btn {{ disabled || decDisabled ? 'disabled' : '' }}"
|
|
6
|
+
bind:tap="{{ disabled || decDisabled ? '' : 'handleDecrement' }}">
|
|
7
|
+
<text class="stepper-symbol">-</text>
|
|
8
|
+
</view>
|
|
9
|
+
|
|
10
|
+
<!-- 数量输入框 -->
|
|
11
|
+
<input class="stepper-input" type="number" value="{{ quantity + '' }}" disabled="{{ disabled }}"
|
|
12
|
+
bind:input="handleInput" />
|
|
13
|
+
|
|
14
|
+
<!-- 增加按钮 -->
|
|
15
|
+
<view class="stepper-btn {{ disabled || incDisabled ? 'disabled' : '' }}"
|
|
16
|
+
bind:tap="{{ disabled || incDisabled ? '' : 'handleIncrement' }}">
|
|
17
|
+
<text class="stepper-symbol">+</text>
|
|
18
|
+
</view>
|
|
19
|
+
</view>
|
|
20
|
+
</template>
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
import { createComponent, ref } from "@mpxjs/core";
|
|
24
|
+
import { EventBase } from "../../api/types";
|
|
25
|
+
|
|
26
|
+
createComponent({
|
|
27
|
+
options: {
|
|
28
|
+
styleIsolation: "apply-shared"
|
|
29
|
+
},
|
|
30
|
+
properties: {
|
|
31
|
+
// 最大数(-1表示无限制)
|
|
32
|
+
maxNum: {
|
|
33
|
+
type: Number,
|
|
34
|
+
value: -1
|
|
35
|
+
},
|
|
36
|
+
// 最小数
|
|
37
|
+
minNum: {
|
|
38
|
+
type: Number,
|
|
39
|
+
value: 0
|
|
40
|
+
},
|
|
41
|
+
// 初始值
|
|
42
|
+
value: {
|
|
43
|
+
type: Number,
|
|
44
|
+
value: 1,
|
|
45
|
+
observer() {
|
|
46
|
+
this.quantity = this.value;
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
// 是否禁用按钮
|
|
50
|
+
disabled: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
value: false
|
|
53
|
+
},
|
|
54
|
+
// 步长
|
|
55
|
+
step: {
|
|
56
|
+
type: Number,
|
|
57
|
+
value: 1
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
setup() {
|
|
61
|
+
// 数量
|
|
62
|
+
let quantity = ref(1);
|
|
63
|
+
// 减少按钮是否禁用
|
|
64
|
+
let decDisabled = ref(false);
|
|
65
|
+
// 增加按钮是否禁用
|
|
66
|
+
let incDisabled = ref(false);
|
|
67
|
+
|
|
68
|
+
return { quantity, decDisabled, incDisabled }
|
|
69
|
+
},
|
|
70
|
+
lifetimes: {
|
|
71
|
+
ready() {
|
|
72
|
+
// 初始化数量
|
|
73
|
+
this.initQuantity();
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
methods: {
|
|
77
|
+
// 初始化数量,并设置按钮禁用状态
|
|
78
|
+
initQuantity() {
|
|
79
|
+
const initValue = this.value;
|
|
80
|
+
// 处理初始值无效的情况
|
|
81
|
+
if (initValue === null || initValue === undefined) {
|
|
82
|
+
this.quantity = 1;
|
|
83
|
+
this.decDisabled = false;
|
|
84
|
+
this.incDisabled = false;
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// 确保初始值在 [minNum, maxNum] 范围内
|
|
88
|
+
if (initValue < this.minNum) {
|
|
89
|
+
this.quantity = this.minNum;
|
|
90
|
+
} else if (this.maxNum >= 0 && initValue > this.maxNum) {
|
|
91
|
+
this.quantity = this.maxNum;
|
|
92
|
+
} else {
|
|
93
|
+
this.quantity = initValue;
|
|
94
|
+
}
|
|
95
|
+
// 更新按钮禁用状态
|
|
96
|
+
this.updateButtonStatus();
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
// 更新按钮禁用状态
|
|
100
|
+
updateButtonStatus() {
|
|
101
|
+
// 减少按钮:当数量等于最小值时禁用
|
|
102
|
+
this.decDisabled = this.quantity <= this.minNum;
|
|
103
|
+
// 增加按钮:当数量等于最大值(且有限制)时禁用
|
|
104
|
+
this.incDisabled = this.maxNum >= 0 && this.quantity >= this.maxNum;
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
// 减少数量,并更新按钮状态
|
|
108
|
+
handleDecrement() {
|
|
109
|
+
// 已达到最小值,不执行减少操作
|
|
110
|
+
if (this.quantity <= this.minNum) {
|
|
111
|
+
this.decDisabled = true;
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
this.quantity -= this.step;
|
|
115
|
+
// 确保数量不小于最小值
|
|
116
|
+
if (this.quantity < this.minNum) {
|
|
117
|
+
this.quantity = this.minNum;
|
|
118
|
+
}
|
|
119
|
+
// 更新按钮禁用状态
|
|
120
|
+
this.updateButtonStatus();
|
|
121
|
+
this.triggerEvent("quantity", this.quantity);
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
// 增加数量,并更新按钮状态
|
|
125
|
+
handleIncrement() {
|
|
126
|
+
// 已达到最大值(且有限制),不执行增加操作
|
|
127
|
+
if (this.maxNum >= 0 && this.quantity >= this.maxNum) {
|
|
128
|
+
this.incDisabled = true;
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
this.quantity += this.step;
|
|
132
|
+
// 确保数量不超过最大值(如果有限制)
|
|
133
|
+
if (this.maxNum >= 0 && this.quantity > this.maxNum) {
|
|
134
|
+
this.quantity = this.maxNum;
|
|
135
|
+
}
|
|
136
|
+
// 更新按钮禁用状态
|
|
137
|
+
this.updateButtonStatus();
|
|
138
|
+
this.triggerEvent("quantity", this.quantity);
|
|
139
|
+
},
|
|
140
|
+
|
|
141
|
+
// 输入数量处理
|
|
142
|
+
handleInput(e: EventBase) {
|
|
143
|
+
// 将输入值转为数字,无效输入默认为 1
|
|
144
|
+
let value = parseInt(e.detail.value) || 1;
|
|
145
|
+
// 确保输入值在 [minNum, maxNum] 范围内
|
|
146
|
+
if (value < this.minNum) {
|
|
147
|
+
value = this.minNum;
|
|
148
|
+
} else if (this.maxNum >= 0 && value > this.maxNum) {
|
|
149
|
+
value = this.maxNum;
|
|
150
|
+
}
|
|
151
|
+
this.quantity = value;
|
|
152
|
+
// 更新按钮禁用状态
|
|
153
|
+
this.updateButtonStatus();
|
|
154
|
+
this.triggerEvent("quantity", this.quantity);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
})
|
|
158
|
+
</script>
|
|
159
|
+
|
|
160
|
+
<style lang="scss">
|
|
161
|
+
.stepper {
|
|
162
|
+
display: inline-flex;
|
|
163
|
+
align-items: center;
|
|
164
|
+
gap: 2rpx;
|
|
165
|
+
border-radius: 8rpx;
|
|
166
|
+
overflow: hidden;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// 步进器按钮
|
|
170
|
+
.stepper-btn {
|
|
171
|
+
width: 56rpx;
|
|
172
|
+
height: 56rpx;
|
|
173
|
+
display: flex;
|
|
174
|
+
align-items: center;
|
|
175
|
+
justify-content: center;
|
|
176
|
+
background-color: #f5f5f5;
|
|
177
|
+
user-select: none;
|
|
178
|
+
transition: opacity 0.2s;
|
|
179
|
+
|
|
180
|
+
&.disabled {
|
|
181
|
+
opacity: 0.5;
|
|
182
|
+
pointer-events: none;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// 步进器符号
|
|
186
|
+
.stepper-symbol {
|
|
187
|
+
display: flex;
|
|
188
|
+
align-items: center;
|
|
189
|
+
justify-content: center;
|
|
190
|
+
font-size: 28rpx;
|
|
191
|
+
color: #333;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// 数量输入框
|
|
196
|
+
.stepper-input {
|
|
197
|
+
width: 80rpx;
|
|
198
|
+
height: 56rpx;
|
|
199
|
+
text-align: center;
|
|
200
|
+
font-size: 28rpx;
|
|
201
|
+
color: #333;
|
|
202
|
+
background-color: #f5f5f5;
|
|
203
|
+
padding: 0;
|
|
204
|
+
margin: 0;
|
|
205
|
+
box-sizing: border-box;
|
|
206
|
+
}
|
|
207
|
+
</style>
|
|
208
|
+
|
|
209
|
+
<script type="application/json">
|
|
210
|
+
{
|
|
211
|
+
"component": true,
|
|
212
|
+
"usingComponents": {}
|
|
213
|
+
}
|
|
214
|
+
</script>
|
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<cube-tab-bar wx:model="{{ selectedLabelDefault }}" wx:model-prop="value" tabs="{{ tabs }}"
|
|
3
|
-
bindclick="clickHandler">
|
|
4
|
-
</cube-tab-bar>
|
|
5
|
-
</template>
|
|
6
|
-
|
|
7
|
-
<script>
|
|
8
|
-
import mpx, { createComponent } from '@mpxjs/core'
|
|
9
|
-
createComponent({
|
|
10
|
-
data: {
|
|
11
|
-
selectedLabelDefault: 'Home',
|
|
12
|
-
tabs: [{
|
|
13
|
-
label: '首页',
|
|
14
|
-
value: 'Home',
|
|
15
|
-
pagePath: '/pages/tabbar/home',
|
|
16
|
-
icon: 'home'
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
label: '我的',
|
|
20
|
-
value: 'My',
|
|
21
|
-
pagePath: '/pages/tabbar/my',
|
|
22
|
-
icon: 'user'
|
|
23
|
-
},]
|
|
24
|
-
},
|
|
25
|
-
methods: {
|
|
26
|
-
clickHandler(tab) {
|
|
27
|
-
// console.log('tab was clicked', tab)
|
|
28
|
-
const target = this.tabs.find(item => item.value === tab.detail.value)
|
|
29
|
-
if (target) {
|
|
30
|
-
mpx.switchTab({
|
|
31
|
-
url: target.pagePath
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
activeTab(value) {
|
|
36
|
-
// console.log('activeTab set value:', value)
|
|
37
|
-
this.selectedLabelDefault = value;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
</script>
|
|
42
|
-
<script type="application/json">
|
|
43
|
-
{
|
|
44
|
-
"usingComponents": {
|
|
45
|
-
"cube-tab-bar": "@mpxjs/mpx-cube-ui/lib/components/tab-bar/index.mpx",
|
|
46
|
-
// "cube-tab": "@mpxjs/mpx-cube-ui/lib/components/tab-bar/tab.mpx",
|
|
47
|
-
// "cube-icon": "@mpxjs/mpx-cube-ui/lib/components/icon/index.mpx"
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
</script>
|
|
1
|
+
<template>
|
|
2
|
+
<cube-tab-bar wx:model="{{ selectedLabelDefault }}" wx:model-prop="value" tabs="{{ tabs }}"
|
|
3
|
+
bindclick="clickHandler">
|
|
4
|
+
</cube-tab-bar>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script>
|
|
8
|
+
import mpx, { createComponent } from '@mpxjs/core'
|
|
9
|
+
createComponent({
|
|
10
|
+
data: {
|
|
11
|
+
selectedLabelDefault: 'Home',
|
|
12
|
+
tabs: [{
|
|
13
|
+
label: '首页',
|
|
14
|
+
value: 'Home',
|
|
15
|
+
pagePath: '/pages/tabbar/home',
|
|
16
|
+
icon: 'home'
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: '我的',
|
|
20
|
+
value: 'My',
|
|
21
|
+
pagePath: '/pages/tabbar/my',
|
|
22
|
+
icon: 'user'
|
|
23
|
+
},]
|
|
24
|
+
},
|
|
25
|
+
methods: {
|
|
26
|
+
clickHandler(tab) {
|
|
27
|
+
// console.log('tab was clicked', tab)
|
|
28
|
+
const target = this.tabs.find(item => item.value === tab.detail.value)
|
|
29
|
+
if (target) {
|
|
30
|
+
mpx.switchTab({
|
|
31
|
+
url: target.pagePath
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
activeTab(value) {
|
|
36
|
+
// console.log('activeTab set value:', value)
|
|
37
|
+
this.selectedLabelDefault = value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
</script>
|
|
42
|
+
<script type="application/json">
|
|
43
|
+
{
|
|
44
|
+
"usingComponents": {
|
|
45
|
+
"cube-tab-bar": "@mpxjs/mpx-cube-ui/lib/components/tab-bar/index.mpx",
|
|
46
|
+
// "cube-tab": "@mpxjs/mpx-cube-ui/lib/components/tab-bar/tab.mpx",
|
|
47
|
+
// "cube-icon": "@mpxjs/mpx-cube-ui/lib/components/icon/index.mpx"
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
</script>
|