maooo-skyline-ui-system 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/README.md +157 -0
- package/miniprogram_dist/button/button.js +43 -0
- package/miniprogram_dist/button/button.json +5 -0
- package/miniprogram_dist/button/button.wxml +12 -0
- package/miniprogram_dist/button/button.wxs +23 -0
- package/miniprogram_dist/button/button.wxss +133 -0
- package/miniprogram_dist/calendar/calendar.js +549 -0
- package/miniprogram_dist/calendar/calendar.json +8 -0
- package/miniprogram_dist/calendar/calendar.wxml +79 -0
- package/miniprogram_dist/calendar/calendar.wxss +265 -0
- package/miniprogram_dist/card/card.js +22 -0
- package/miniprogram_dist/card/card.json +5 -0
- package/miniprogram_dist/card/card.wxml +9 -0
- package/miniprogram_dist/card/card.wxss +34 -0
- package/miniprogram_dist/countdown/countdown.js +213 -0
- package/miniprogram_dist/countdown/countdown.json +3 -0
- package/miniprogram_dist/countdown/countdown.wxml +9 -0
- package/miniprogram_dist/countdown/countdown.wxss +33 -0
- package/miniprogram_dist/form/form.js +12 -0
- package/miniprogram_dist/form/form.json +5 -0
- package/miniprogram_dist/form/form.wxml +12 -0
- package/miniprogram_dist/form/form.wxss +35 -0
- package/miniprogram_dist/form-group/form-group.js +53 -0
- package/miniprogram_dist/form-group/form-group.json +5 -0
- package/miniprogram_dist/form-group/form-group.wxml +11 -0
- package/miniprogram_dist/form-group/form-group.wxss +50 -0
- package/miniprogram_dist/form-input/form-input.js +48 -0
- package/miniprogram_dist/form-input/form-input.json +8 -0
- package/miniprogram_dist/form-input/form-input.wxml +28 -0
- package/miniprogram_dist/form-input/form-input.wxss +3 -0
- package/miniprogram_dist/form-textarea/form-textarea.js +34 -0
- package/miniprogram_dist/form-textarea/form-textarea.json +8 -0
- package/miniprogram_dist/form-textarea/form-textarea.wxml +20 -0
- package/miniprogram_dist/form-textarea/form-textarea.wxss +3 -0
- package/miniprogram_dist/icon/_iconfont/iconfont.js +63 -0
- package/miniprogram_dist/icon/_iconfont/iconfont.json +4 -0
- package/miniprogram_dist/icon/_iconfont/iconfont.wxml +8 -0
- package/miniprogram_dist/icon/_iconfont/iconfont.wxss +3 -0
- package/miniprogram_dist/icon/icon.js +41 -0
- package/miniprogram_dist/icon/icon.json +7 -0
- package/miniprogram_dist/icon/icon.wxml +3 -0
- package/miniprogram_dist/icon/icon.wxss +13 -0
- package/miniprogram_dist/image-cropper/image-cropper.js +703 -0
- package/miniprogram_dist/image-cropper/image-cropper.json +3 -0
- package/miniprogram_dist/image-cropper/image-cropper.wxml +58 -0
- package/miniprogram_dist/image-cropper/image-cropper.wxss +195 -0
- package/miniprogram_dist/index.js +4 -0
- package/miniprogram_dist/input/input.js +119 -0
- package/miniprogram_dist/input/input.json +7 -0
- package/miniprogram_dist/input/input.wxml +38 -0
- package/miniprogram_dist/input/input.wxss +52 -0
- package/miniprogram_dist/media-upload/media-upload.js +1108 -0
- package/miniprogram_dist/media-upload/media-upload.json +7 -0
- package/miniprogram_dist/media-upload/media-upload.wxml +98 -0
- package/miniprogram_dist/media-upload/media-upload.wxss +149 -0
- package/miniprogram_dist/navbar/navbar.js +191 -0
- package/miniprogram_dist/navbar/navbar.json +6 -0
- package/miniprogram_dist/navbar/navbar.wxml +25 -0
- package/miniprogram_dist/navbar/navbar.wxss +60 -0
- package/miniprogram_dist/notify/notify.js +342 -0
- package/miniprogram_dist/notify/notify.json +5 -0
- package/miniprogram_dist/notify/notify.wxml +27 -0
- package/miniprogram_dist/notify/notify.wxss +246 -0
- package/miniprogram_dist/notify/service.js +69 -0
- package/miniprogram_dist/oss-upload/oss-upload.js +505 -0
- package/miniprogram_dist/oss-upload/oss-upload.json +6 -0
- package/miniprogram_dist/oss-upload/oss-upload.wxml +20 -0
- package/miniprogram_dist/oss-upload/oss-upload.wxss +5 -0
- package/miniprogram_dist/popup/popup.js +36 -0
- package/miniprogram_dist/popup/popup.json +5 -0
- package/miniprogram_dist/popup/popup.wxml +14 -0
- package/miniprogram_dist/popup/popup.wxss +138 -0
- package/miniprogram_dist/popup-page/popup-page.js +341 -0
- package/miniprogram_dist/popup-page/popup-page.json +8 -0
- package/miniprogram_dist/popup-page/popup-page.wxml +65 -0
- package/miniprogram_dist/popup-page/popup-page.wxss +92 -0
- package/miniprogram_dist/progress/progress.js +161 -0
- package/miniprogram_dist/progress/progress.json +5 -0
- package/miniprogram_dist/progress/progress.wxml +16 -0
- package/miniprogram_dist/progress/progress.wxss +81 -0
- package/miniprogram_dist/rate/rate.js +127 -0
- package/miniprogram_dist/rate/rate.json +5 -0
- package/miniprogram_dist/rate/rate.wxml +32 -0
- package/miniprogram_dist/rate/rate.wxs +21 -0
- package/miniprogram_dist/rate/rate.wxss +126 -0
- package/miniprogram_dist/stepper/stepper.js +153 -0
- package/miniprogram_dist/stepper/stepper.json +5 -0
- package/miniprogram_dist/stepper/stepper.wxml +19 -0
- package/miniprogram_dist/stepper/stepper.wxss +66 -0
- package/miniprogram_dist/switch/switch.js +29 -0
- package/miniprogram_dist/switch/switch.json +3 -0
- package/miniprogram_dist/switch/switch.wxml +10 -0
- package/miniprogram_dist/switch/switch.wxss +71 -0
- package/miniprogram_dist/textarea/textarea.js +83 -0
- package/miniprogram_dist/textarea/textarea.json +5 -0
- package/miniprogram_dist/textarea/textarea.wxml +14 -0
- package/miniprogram_dist/textarea/textarea.wxss +33 -0
- package/miniprogram_dist/theme/theme.wxss +64 -0
- package/miniprogram_dist/toast/toast.js +51 -0
- package/miniprogram_dist/toast/toast.json +5 -0
- package/miniprogram_dist/toast/toast.wxml +13 -0
- package/miniprogram_dist/toast/toast.wxss +143 -0
- package/miniprogram_dist/upload/upload.js +276 -0
- package/miniprogram_dist/upload/upload.json +3 -0
- package/miniprogram_dist/upload/upload.wxml +36 -0
- package/miniprogram_dist/upload/upload.wxss +136 -0
- package/miniprogram_dist/utils/class.js +37 -0
- package/miniprogram_dist/utils/device.js +67 -0
- package/miniprogram_dist/utils/dom.js +51 -0
- package/miniprogram_dist/utils/event.js +28 -0
- package/miniprogram_dist/utils/form.js +39 -0
- package/miniprogram_dist/utils/function.js +63 -0
- package/miniprogram_dist/utils/index.js +21 -0
- package/miniprogram_dist/utils/props.js +51 -0
- package/miniprogram_dist/utils/style.js +52 -0
- package/miniprogram_dist/utils/theme.js +30 -0
- package/package.json +31 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
<view class="mo-media-upload {{customClass}}">
|
|
2
|
+
<mo-upload
|
|
3
|
+
file-list="{{displayFileList}}"
|
|
4
|
+
max-count="{{maxCount}}"
|
|
5
|
+
accept="{{accept}}"
|
|
6
|
+
source-type="{{sourceType}}"
|
|
7
|
+
size-type="{{sizeType}}"
|
|
8
|
+
disabled="{{disabled}}"
|
|
9
|
+
deletable="{{deletable}}"
|
|
10
|
+
preview="{{false}}"
|
|
11
|
+
image-radius="{{imageRadius}}"
|
|
12
|
+
auto-append="{{false}}"
|
|
13
|
+
bind:choose="handleChoose"
|
|
14
|
+
bind:delete="handleDelete"
|
|
15
|
+
bind:preview="handlePreview"
|
|
16
|
+
bind:error="handleUploadError"
|
|
17
|
+
>
|
|
18
|
+
<slot></slot>
|
|
19
|
+
</mo-upload>
|
|
20
|
+
|
|
21
|
+
<view wx:if="{{showPreview}}" class="mo-media-upload__preview" catchtouchmove="handlePreviewTouchMove">
|
|
22
|
+
<view class="mo-media-upload__preview-header" style="{{previewHeaderStyle}}">
|
|
23
|
+
<view class="mo-media-upload__preview-close" bindtap="handleClosePreview">
|
|
24
|
+
<text class="mo-media-upload__preview-close-text">×</text>
|
|
25
|
+
</view>
|
|
26
|
+
<text class="mo-media-upload__preview-title">{{previewTitle}}</text>
|
|
27
|
+
<view class="mo-media-upload__preview-placeholder"></view>
|
|
28
|
+
</view>
|
|
29
|
+
|
|
30
|
+
<view class="mo-media-upload__preview-body">
|
|
31
|
+
<image
|
|
32
|
+
wx:if="{{!previewFile._isVideo}}"
|
|
33
|
+
class="mo-media-upload__preview-media"
|
|
34
|
+
mode="aspectFit"
|
|
35
|
+
src="{{previewFile._previewUrl}}"
|
|
36
|
+
/>
|
|
37
|
+
<video
|
|
38
|
+
wx:else
|
|
39
|
+
class="mo-media-upload__preview-media"
|
|
40
|
+
src="{{previewFile._previewUrl}}"
|
|
41
|
+
poster="{{previewFile._poster}}"
|
|
42
|
+
controls="{{true}}"
|
|
43
|
+
show-center-play-btn="{{true}}"
|
|
44
|
+
object-fit="contain"
|
|
45
|
+
></video>
|
|
46
|
+
</view>
|
|
47
|
+
|
|
48
|
+
<view class="mo-media-upload__preview-footer">
|
|
49
|
+
<view
|
|
50
|
+
class="mo-media-upload__preview-button {{previewFile.isMain ? 'is-disabled' : ''}}"
|
|
51
|
+
data-id="{{previewFile.id}}"
|
|
52
|
+
bindtap="handleSetMain"
|
|
53
|
+
>
|
|
54
|
+
<text>{{previewFile.isMain ? '已是主图' : '设置主图'}}</text>
|
|
55
|
+
</view>
|
|
56
|
+
<view
|
|
57
|
+
wx:if="{{previewFile._isVideo && enableVideoCover}}"
|
|
58
|
+
class="mo-media-upload__preview-button"
|
|
59
|
+
data-id="{{previewFile.id}}"
|
|
60
|
+
bindtap="handleOpenCoverPanel"
|
|
61
|
+
>
|
|
62
|
+
<text>更换封面</text>
|
|
63
|
+
</view>
|
|
64
|
+
</view>
|
|
65
|
+
</view>
|
|
66
|
+
|
|
67
|
+
<view wx:if="{{showCoverPanel}}" class="mo-media-upload__cover-panel">
|
|
68
|
+
<view class="mo-media-upload__cover-head">
|
|
69
|
+
<text class="mo-media-upload__cover-title">选择视频封面</text>
|
|
70
|
+
<view class="mo-media-upload__cover-close" bindtap="handleCloseCoverPanel">
|
|
71
|
+
<text>取消</text>
|
|
72
|
+
</view>
|
|
73
|
+
</view>
|
|
74
|
+
<view class="mo-media-upload__cover-list">
|
|
75
|
+
<view
|
|
76
|
+
wx:for="{{coverCandidates}}"
|
|
77
|
+
wx:key="url"
|
|
78
|
+
class="mo-media-upload__cover-item {{item.rowEnd ? 'is-row-end' : ''}}"
|
|
79
|
+
data-url="{{item.url}}"
|
|
80
|
+
bindtap="handleSelectCoverCandidate"
|
|
81
|
+
>
|
|
82
|
+
<image class="mo-media-upload__cover-image" src="{{item.url}}" mode="aspectFill" />
|
|
83
|
+
</view>
|
|
84
|
+
</view>
|
|
85
|
+
</view>
|
|
86
|
+
|
|
87
|
+
<mo-image-cropper
|
|
88
|
+
show="{{showCropper}}"
|
|
89
|
+
src="{{cropSrc}}"
|
|
90
|
+
file-list="{{cropFileList}}"
|
|
91
|
+
aspect-ratio="{{cropAspectRatio}}"
|
|
92
|
+
output-width="{{cropOutputWidth}}"
|
|
93
|
+
z-index="{{1001}}"
|
|
94
|
+
bind:confirm="handleCropConfirm"
|
|
95
|
+
bind:cancel="handleCropCancel"
|
|
96
|
+
bind:error="handleCropError"
|
|
97
|
+
/>
|
|
98
|
+
</view>
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
.mo-media-upload {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
width: 100%;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.mo-media-upload__preview {
|
|
8
|
+
position: fixed;
|
|
9
|
+
top: 0;
|
|
10
|
+
right: 0;
|
|
11
|
+
bottom: 0;
|
|
12
|
+
left: 0;
|
|
13
|
+
z-index: 1000;
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
background-color: #202124;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.mo-media-upload__preview-header {
|
|
20
|
+
display: flex;
|
|
21
|
+
align-items: center;
|
|
22
|
+
justify-content: space-between;
|
|
23
|
+
box-sizing: border-box;
|
|
24
|
+
flex-shrink: 0;
|
|
25
|
+
padding-right: 32rpx;
|
|
26
|
+
padding-left: 32rpx;
|
|
27
|
+
background-color: #202124;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.mo-media-upload__preview-close,
|
|
31
|
+
.mo-media-upload__preview-placeholder {
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: center;
|
|
34
|
+
justify-content: center;
|
|
35
|
+
width: 72rpx;
|
|
36
|
+
height: 72rpx;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.mo-media-upload__preview-close-text {
|
|
40
|
+
color: #ffffff;
|
|
41
|
+
font-size: 72rpx;
|
|
42
|
+
font-weight: 300;
|
|
43
|
+
line-height: 72rpx;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.mo-media-upload__preview-title {
|
|
47
|
+
color: #ffffff;
|
|
48
|
+
font-size: 36rpx;
|
|
49
|
+
font-weight: 600;
|
|
50
|
+
line-height: 52rpx;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.mo-media-upload__preview-body {
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
justify-content: center;
|
|
57
|
+
flex: 1;
|
|
58
|
+
min-height: 0;
|
|
59
|
+
background-color: var(--mo-color-text-primary, #111111);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.mo-media-upload__preview-media {
|
|
63
|
+
width: 100%;
|
|
64
|
+
height: 100%;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.mo-media-upload__preview-footer {
|
|
68
|
+
display: flex;
|
|
69
|
+
align-items: center;
|
|
70
|
+
justify-content: center;
|
|
71
|
+
flex-shrink: 0;
|
|
72
|
+
min-height: 172rpx;
|
|
73
|
+
padding: 28rpx 32rpx 48rpx;
|
|
74
|
+
background-color: #202124;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
.mo-media-upload__preview-button {
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
justify-content: center;
|
|
81
|
+
min-width: 220rpx;
|
|
82
|
+
height: 72rpx;
|
|
83
|
+
margin-right: 24rpx;
|
|
84
|
+
margin-left: 24rpx;
|
|
85
|
+
padding-right: 32rpx;
|
|
86
|
+
padding-left: 32rpx;
|
|
87
|
+
border: 2rpx solid rgba(255, 255, 255, 0.9);
|
|
88
|
+
border-radius: var(--mo-radius-md, 12rpx);
|
|
89
|
+
color: #ffffff;
|
|
90
|
+
font-size: 30rpx;
|
|
91
|
+
line-height: 42rpx;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.mo-media-upload__preview-button.is-disabled {
|
|
95
|
+
opacity: 0.48;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
.mo-media-upload__cover-panel {
|
|
99
|
+
display: flex;
|
|
100
|
+
flex-direction: column;
|
|
101
|
+
margin-top: 24rpx;
|
|
102
|
+
padding: 24rpx;
|
|
103
|
+
border-radius: var(--mo-radius-md, 12rpx);
|
|
104
|
+
background-color: var(--mo-color-background-surface, #FFFFFF);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.mo-media-upload__cover-head {
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
justify-content: space-between;
|
|
111
|
+
margin-bottom: 20rpx;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.mo-media-upload__cover-title {
|
|
115
|
+
color: var(--mo-color-text-primary, #111111);
|
|
116
|
+
font-size: 28rpx;
|
|
117
|
+
font-weight: 600;
|
|
118
|
+
line-height: 40rpx;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.mo-media-upload__cover-close {
|
|
122
|
+
color: var(--mo-color-text-secondary, #6b7280);
|
|
123
|
+
font-size: 24rpx;
|
|
124
|
+
line-height: 34rpx;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.mo-media-upload__cover-list {
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-wrap: wrap;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.mo-media-upload__cover-item {
|
|
133
|
+
width: 31%;
|
|
134
|
+
height: 150rpx;
|
|
135
|
+
margin-right: 3.5%;
|
|
136
|
+
margin-bottom: 18rpx;
|
|
137
|
+
border-radius: var(--mo-radius-md, 12rpx);
|
|
138
|
+
overflow: hidden;
|
|
139
|
+
background-color: var(--mo-color-background-muted, #F2F2F2);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
.mo-media-upload__cover-item.is-row-end {
|
|
143
|
+
margin-right: 0;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
.mo-media-upload__cover-image {
|
|
147
|
+
width: 100%;
|
|
148
|
+
height: 100%;
|
|
149
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
const {
|
|
2
|
+
getMenuButtonRect,
|
|
3
|
+
getWindowInfo,
|
|
4
|
+
isAndroid
|
|
5
|
+
} = require("../utils/device");
|
|
6
|
+
|
|
7
|
+
function getFallbackContentHeight() {
|
|
8
|
+
return isAndroid() ? 48 : 44;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function normalizeMenuButton(menuButton, windowInfo, statusBarHeight, contentHeight) {
|
|
12
|
+
if (menuButton && Number.isFinite(menuButton.top) && Number.isFinite(menuButton.height)) {
|
|
13
|
+
return menuButton;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const top = statusBarHeight;
|
|
17
|
+
const width = 87;
|
|
18
|
+
const right = 8;
|
|
19
|
+
const windowWidth = windowInfo.windowWidth || 375;
|
|
20
|
+
|
|
21
|
+
return {
|
|
22
|
+
top,
|
|
23
|
+
left: windowWidth - width - right,
|
|
24
|
+
right: windowWidth - right,
|
|
25
|
+
bottom: top + contentHeight,
|
|
26
|
+
width,
|
|
27
|
+
height: contentHeight
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function getNavbarMetrics() {
|
|
32
|
+
const windowInfo = getWindowInfo();
|
|
33
|
+
const statusBarHeight = windowInfo.statusBarHeight || 0;
|
|
34
|
+
const fallbackContentHeight = getFallbackContentHeight();
|
|
35
|
+
const menuButton = normalizeMenuButton(getMenuButtonRect(), windowInfo, statusBarHeight, fallbackContentHeight);
|
|
36
|
+
const topGap = Math.max(0, menuButton.top - statusBarHeight);
|
|
37
|
+
const contentHeight = menuButton.height + topGap * 2 || fallbackContentHeight;
|
|
38
|
+
const height = statusBarHeight + contentHeight;
|
|
39
|
+
const windowWidth = windowInfo.windowWidth || 375;
|
|
40
|
+
const menuRightWidth = Math.max(88, windowWidth - menuButton.left);
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
height,
|
|
44
|
+
placeholderHeight: height,
|
|
45
|
+
statusBarHeight,
|
|
46
|
+
contentHeight,
|
|
47
|
+
menuButton,
|
|
48
|
+
menuRightWidth
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function normalizeNumber(value, fallback) {
|
|
53
|
+
const numberValue = Number(value);
|
|
54
|
+
return Number.isFinite(numberValue) ? numberValue : fallback;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Component({
|
|
58
|
+
options: {
|
|
59
|
+
multipleSlots: true
|
|
60
|
+
},
|
|
61
|
+
properties: {
|
|
62
|
+
title: {
|
|
63
|
+
type: String,
|
|
64
|
+
value: ""
|
|
65
|
+
},
|
|
66
|
+
background: {
|
|
67
|
+
type: String,
|
|
68
|
+
value: "var(--mo-color-background-surface, #FFFFFF)",
|
|
69
|
+
observer: "syncStyles"
|
|
70
|
+
},
|
|
71
|
+
color: {
|
|
72
|
+
type: String,
|
|
73
|
+
value: "var(--mo-color-text-primary, #111111)"
|
|
74
|
+
},
|
|
75
|
+
fixed: {
|
|
76
|
+
type: Boolean,
|
|
77
|
+
value: true,
|
|
78
|
+
observer: "syncStyles"
|
|
79
|
+
},
|
|
80
|
+
placeholder: {
|
|
81
|
+
type: Boolean,
|
|
82
|
+
value: true,
|
|
83
|
+
observer: "syncStyles"
|
|
84
|
+
},
|
|
85
|
+
showBack: {
|
|
86
|
+
type: Boolean,
|
|
87
|
+
value: true
|
|
88
|
+
},
|
|
89
|
+
autoBack: {
|
|
90
|
+
type: Boolean,
|
|
91
|
+
value: true
|
|
92
|
+
},
|
|
93
|
+
homeUrl: {
|
|
94
|
+
type: String,
|
|
95
|
+
value: "/pages/index/index"
|
|
96
|
+
},
|
|
97
|
+
zIndex: {
|
|
98
|
+
type: Number,
|
|
99
|
+
value: 99,
|
|
100
|
+
observer: "syncStyles"
|
|
101
|
+
},
|
|
102
|
+
customClass: {
|
|
103
|
+
type: String,
|
|
104
|
+
value: ""
|
|
105
|
+
}
|
|
106
|
+
},
|
|
107
|
+
data: {
|
|
108
|
+
height: 0,
|
|
109
|
+
iconColor: "#111111",
|
|
110
|
+
placeholderStyle: "",
|
|
111
|
+
rootStyle: "",
|
|
112
|
+
innerStyle: "",
|
|
113
|
+
sideStyle: ""
|
|
114
|
+
},
|
|
115
|
+
lifetimes: {
|
|
116
|
+
attached() {
|
|
117
|
+
this.syncStyles();
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
methods: {
|
|
121
|
+
syncStyles() {
|
|
122
|
+
const metrics = getNavbarMetrics();
|
|
123
|
+
const zIndex = normalizeNumber(this.data.zIndex, 99);
|
|
124
|
+
const rootStyle = [
|
|
125
|
+
`height: ${metrics.height + 6}px`,
|
|
126
|
+
`background-color: ${this.data.background}`,
|
|
127
|
+
`z-index: ${zIndex}`
|
|
128
|
+
].join("; ");
|
|
129
|
+
const innerStyle = [
|
|
130
|
+
`padding-top: ${metrics.statusBarHeight}px`,
|
|
131
|
+
`height: ${metrics.height}px`
|
|
132
|
+
].join("; ");
|
|
133
|
+
const sideStyle = `width: ${metrics.menuRightWidth}px`;
|
|
134
|
+
|
|
135
|
+
this.setData(
|
|
136
|
+
{
|
|
137
|
+
height: metrics.height,
|
|
138
|
+
placeholderStyle: `height: ${metrics.placeholderHeight}px`,
|
|
139
|
+
rootStyle,
|
|
140
|
+
innerStyle,
|
|
141
|
+
sideStyle
|
|
142
|
+
},
|
|
143
|
+
() => {
|
|
144
|
+
this.triggerEvent("height", metrics);
|
|
145
|
+
}
|
|
146
|
+
);
|
|
147
|
+
},
|
|
148
|
+
getPageStackLength() {
|
|
149
|
+
if (typeof getCurrentPages !== "function") return 1;
|
|
150
|
+
return getCurrentPages().length;
|
|
151
|
+
},
|
|
152
|
+
handleLeftClick() {
|
|
153
|
+
const pageStackLength = this.getPageStackLength();
|
|
154
|
+
const shouldBack = pageStackLength > 1;
|
|
155
|
+
|
|
156
|
+
this.triggerEvent("click", {
|
|
157
|
+
type: shouldBack ? "back" : "home",
|
|
158
|
+
pageStackLength
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
if (shouldBack) {
|
|
162
|
+
this.triggerEvent("back", {
|
|
163
|
+
pageStackLength
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
if (this.data.autoBack) {
|
|
167
|
+
wx.navigateBack({
|
|
168
|
+
delta: 1
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
this.triggerEvent("home", {
|
|
175
|
+
pageStackLength,
|
|
176
|
+
url: this.data.homeUrl
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
if (this.data.autoBack) {
|
|
180
|
+
wx.switchTab({
|
|
181
|
+
url: this.data.homeUrl,
|
|
182
|
+
fail: () => {
|
|
183
|
+
wx.reLaunch({
|
|
184
|
+
url: this.data.homeUrl
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
});
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<view wx:if="{{placeholder && fixed}}" class="mo-navbar__placeholder" style="{{placeholderStyle}}"></view>
|
|
2
|
+
<view
|
|
3
|
+
class="mo-navbar {{fixed ? 'is-fixed' : ''}} {{customClass}}"
|
|
4
|
+
style="{{rootStyle}}"
|
|
5
|
+
>
|
|
6
|
+
<view class="mo-navbar__inner" style="{{innerStyle}}">
|
|
7
|
+
<view
|
|
8
|
+
class="mo-navbar__side mo-navbar__side--left"
|
|
9
|
+
style="{{sideStyle}}"
|
|
10
|
+
bindtap="handleLeftClick"
|
|
11
|
+
>
|
|
12
|
+
<mo-icon wx:if="{{showBack}}" name="arrow-left" size="{{40}}" color="{{iconColor}}" />
|
|
13
|
+
<slot name="left"></slot>
|
|
14
|
+
</view>
|
|
15
|
+
|
|
16
|
+
<view class="mo-navbar__title">
|
|
17
|
+
<text wx:if="{{title}}" class="mo-navbar__title-text" style="color: {{color}};">{{title}}</text>
|
|
18
|
+
<slot name="title"></slot>
|
|
19
|
+
</view>
|
|
20
|
+
|
|
21
|
+
<view class="mo-navbar__side mo-navbar__side--right" style="{{sideStyle}}">
|
|
22
|
+
<slot name="right"></slot>
|
|
23
|
+
</view>
|
|
24
|
+
</view>
|
|
25
|
+
</view>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
.mo-navbar {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
width: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.mo-navbar.is-fixed {
|
|
7
|
+
position: fixed;
|
|
8
|
+
top: 0;
|
|
9
|
+
right: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.mo-navbar__placeholder {
|
|
14
|
+
width: 100%;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.mo-navbar__inner {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
box-sizing: border-box;
|
|
21
|
+
width: 100%;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.mo-navbar__side {
|
|
25
|
+
display: flex;
|
|
26
|
+
align-items: center;
|
|
27
|
+
box-sizing: border-box;
|
|
28
|
+
height: 100%;
|
|
29
|
+
min-width: 0;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.mo-navbar__side--left {
|
|
33
|
+
justify-content: flex-start;
|
|
34
|
+
padding-left: 24rpx;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.mo-navbar__side--right {
|
|
38
|
+
justify-content: flex-end;
|
|
39
|
+
padding-right: 24rpx;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.mo-navbar__title {
|
|
43
|
+
display: flex;
|
|
44
|
+
align-items: center;
|
|
45
|
+
justify-content: center;
|
|
46
|
+
flex: 1;
|
|
47
|
+
min-width: 0;
|
|
48
|
+
height: 100%;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.mo-navbar__title-text {
|
|
52
|
+
max-width: 100%;
|
|
53
|
+
font-size: 34rpx;
|
|
54
|
+
font-weight: 600;
|
|
55
|
+
line-height: 48rpx;
|
|
56
|
+
text-align: center;
|
|
57
|
+
white-space: nowrap;
|
|
58
|
+
text-overflow: ellipsis;
|
|
59
|
+
overflow: hidden;
|
|
60
|
+
}
|