@cloudbase/weda-ui 0.2.17 → 1.0.21
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 +3 -0
- package/package.json +6 -3
- package/src/configs/components/calendar.json +4 -1
- package/src/configs/components/chart/bar.json +19 -6
- package/src/configs/components/chart/line.json +19 -6
- package/src/configs/components/chart/pie.json +14 -4
- package/src/configs/components/chart/statisticsCard.json +61 -13
- package/src/configs/components/container.json +7 -2
- package/src/configs/components/dataView.json +21 -6
- package/src/configs/components/form/checkbox.json +97 -5
- package/src/configs/components/form/radio.json +96 -4
- package/src/configs/components/form/select.json +245 -11
- package/src/configs/components/graphicCard.json +84 -73
- package/src/configs/components/image.json +7 -2
- package/src/configs/components/link.json +19 -3
- package/src/configs/components/listView.json +63 -17
- package/src/configs/components/modal.json +37 -5
- package/src/configs/components/navLayout.json +87 -75
- package/src/configs/components/navigationBar.json +59 -0
- package/src/configs/components/richtextview.json +4 -1
- package/src/configs/components/scrollVeiw.json +74 -22
- package/src/configs/components/swiper.json +4 -1
- package/src/configs/components/tabs.json +51 -8
- package/src/configs/components/text.json +33 -25
- package/src/configs/components/wxOpenApi/phone.json +141 -0
- package/src/configs/components/wxOpenApi/phoneCode.json +121 -0
- package/src/configs/components/wxOpenApi/share.json +167 -0
- package/src/configs/components/wxOpenApi/userInfo.json +174 -0
- package/src/configs/index.js +11 -0
- package/src/mp/components/chart/bar/index.js +6 -2
- package/src/mp/components/chart/common/core/eChartBar.js +9 -8
- package/src/mp/components/chart/common/core/eChartBase.js +20 -16
- package/src/mp/components/chart/common/core/eChartLine.js +6 -5
- package/src/mp/components/chart/line/index.js +10 -6
- package/src/mp/components/chart/pie/index.js +6 -2
- package/src/mp/components/chart/statisticsCard/index.js +33 -6
- package/src/mp/components/dataView/index.json +1 -1
- package/src/mp/components/form/checkbox/index.js +41 -2
- package/src/mp/components/form/checkbox/index.wxml +1 -1
- package/src/mp/components/form/input/index.js +1 -1
- package/src/mp/components/form/location/index.js +43 -2
- package/src/mp/components/form/radio/index.js +34 -1
- package/src/mp/components/form/select/index.js +360 -40
- package/src/mp/components/form/select/index.wxml +17 -2
- package/src/mp/components/form/select/region/index.js +98 -0
- package/src/mp/components/form/uploader/index.js +39 -27
- package/src/mp/components/form/uploaderFile/index.js +10 -6
- package/src/mp/components/listView/index.js +33 -27
- package/src/mp/components/listView/index.wxml +1 -1
- package/src/mp/components/listView/index.wxss +5 -0
- package/src/mp/components/navigationBar/index.js +193 -0
- package/src/mp/components/navigationBar/index.json +6 -0
- package/src/mp/components/navigationBar/index.wxml +88 -0
- package/src/mp/components/navigationBar/index.wxss +1257 -0
- package/src/mp/components/tabs/index.js +7 -2
- package/src/mp/components/tabs/index.wxml +2 -1
- package/src/mp/components/text/index.js +0 -25
- package/src/mp/components/text/index.wxml +3 -3
- package/src/mp/components/wxOpenApi/phone/index.js +117 -0
- package/src/mp/components/{internals/listView → wxOpenApi/phone}/index.json +0 -0
- package/src/mp/components/wxOpenApi/phone/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phone/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.js +89 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.json +4 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/phoneCode/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/share/index.js +117 -0
- package/src/mp/components/wxOpenApi/share/index.json +4 -0
- package/src/mp/components/wxOpenApi/share/index.wxml +15 -0
- package/src/mp/components/wxOpenApi/share/index.wxss +22 -0
- package/src/mp/components/wxOpenApi/userInfo/index.js +88 -0
- package/src/mp/components/wxOpenApi/userInfo/index.json +4 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxml +14 -0
- package/src/mp/components/wxOpenApi/userInfo/index.wxss +22 -0
- package/src/mp/index.json +7 -2
- package/src/mp/style/weda-ui.wxss +2 -0
- package/src/mp/utils/destr.js +48 -0
- package/src/mp/utils/platform.js +10 -0
- package/src/mp/utils/tcb.js +44 -0
- package/src/web/components/button/index.css +8 -1
- package/src/web/components/button/index.tsx +3 -2
- package/src/web/components/chart/bar/index.tsx +40 -39
- package/src/web/components/chart/common/core/eChartBar.js +7 -6
- package/src/web/components/chart/common/core/eChartBase.ts +20 -16
- package/src/web/components/chart/common/core/eChartLine.js +8 -6
- package/src/web/components/chart/line/index.tsx +40 -39
- package/src/web/components/chart/statisticsCard/index.tsx +29 -8
- package/src/web/components/form/checkbox/index.tsx +55 -23
- package/src/web/components/form/radio/index.tsx +84 -53
- package/src/web/components/form/select/h5.tsx +388 -72
- package/src/web/components/form/select/index.css +10 -0
- package/src/web/components/form/select/index.tsx +404 -144
- package/src/web/components/form/select/region/index.ts +122 -31
- package/src/web/components/form/select/time.jsx +89 -0
- package/src/web/components/form/select/year.tsx +170 -0
- package/src/web/components/form/uploader/uploader.h5.tsx +9 -2
- package/src/web/components/form/uploader/uploader.pc.tsx +4 -4
- package/src/web/components/form/uploaderFile/uploadFile.h5.tsx +13 -7
- package/src/web/components/form/uploaderFile/uploadFile.pc.tsx +13 -5
- package/src/web/components/image/image.tsx +1 -1
- package/src/web/components/image/index.tsx +1 -1
- package/src/web/components/index.js +7 -0
- package/src/web/components/link/index.tsx +6 -3
- package/src/web/components/listView/index.css +4 -0
- package/src/web/components/listView/index.tsx +6 -1
- package/src/web/components/modal/index.tsx +3 -1
- package/src/web/components/navigationBar/chevron-right--double.svg +3 -0
- package/src/web/components/navigationBar/common.tsx +198 -0
- package/src/web/components/navigationBar/h5Menu.tsx +179 -0
- package/src/web/components/navigationBar/horizontalMenu.tsx +200 -0
- package/src/web/components/navigationBar/index.css +762 -0
- package/src/web/components/navigationBar/index.tsx +231 -0
- package/src/web/components/navigationBar/type.d.ts +111 -0
- package/src/web/components/navigationBar/verticalMenu.tsx +81 -0
- package/src/web/components/phone/index.css +0 -0
- package/src/web/components/phone/index.tsx +22 -0
- package/src/web/components/phoneCode/index.css +0 -0
- package/src/web/components/phoneCode/index.tsx +22 -0
- package/src/web/components/richTextView/index.tsx +3 -5
- package/src/web/components/share/index.css +0 -0
- package/src/web/components/share/index.tsx +38 -0
- package/src/web/components/tabs/index.tsx +2 -0
- package/src/web/components/tabs/tabs.h5.tsx +43 -33
- package/src/web/components/tabs/tabs.pc.tsx +23 -10
- package/src/web/components/text/index.tsx +6 -14
- package/src/web/components/userInfo/index.css +0 -0
- package/src/web/components/userInfo/index.tsx +30 -0
- package/src/web/utils/platform.js +9 -0
- package/src/web/utils/tcb.js +26 -0
- package/src/web/weda-ui.css +2 -0
- package/src/mp/components/internals/listView/arrow-right-line.svg +0 -3
- package/src/mp/components/internals/listView/index.js +0 -286
- package/src/mp/components/internals/listView/index.wxml +0 -40
- package/src/mp/components/internals/listView/index.wxss +0 -150
- package/src/mp/components/internals/listView/more-line.svg +0 -3
- package/src/web/components/form/select/region/cities.ts +0 -2410
- package/src/web/components/form/select/region/provinces.ts +0 -240
- package/src/web/components/form/select/region/regions.ts +0 -20645
|
@@ -40,30 +40,39 @@ Component({
|
|
|
40
40
|
cloudFile: [],
|
|
41
41
|
files: [],
|
|
42
42
|
urls: [],
|
|
43
|
+
singleFlag: false,
|
|
43
44
|
uploadFile: async function (files) {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
45
|
+
try {
|
|
46
|
+
// 文件上传的函数,返回一个promise
|
|
47
|
+
const uploadPath = 'weda-uploader';
|
|
48
|
+
const tcb = await getCloudInstance();
|
|
49
|
+
const uploadPromise = files.tempFilePaths.map(
|
|
50
|
+
async (tempFilePath, index) => {
|
|
51
|
+
var spark = new SparkMD5.ArrayBuffer();
|
|
52
|
+
spark.append(files.contents[index]);
|
|
53
|
+
var md5Path = spark.end(false);
|
|
54
|
+
const fileType = tempFilePath.split('.')[1];
|
|
55
|
+
const cloudPath = `${uploadPath}/${md5Path}-${Date.now()}.${fileType}`;
|
|
56
|
+
const uploadRes = await tcb.uploadFile({
|
|
57
|
+
cloudPath,
|
|
58
|
+
filePath: tempFilePath,
|
|
59
|
+
});
|
|
60
|
+
return { fileID: uploadRes.fileID };
|
|
61
|
+
}
|
|
62
|
+
);
|
|
63
|
+
const uploadFileList = await Promise.all(uploadPromise);
|
|
64
|
+
const cloudUrls = uploadFileList.map((file) => file.fileID);
|
|
65
|
+
// 这里返回的东西会在uploadSuccess回调函数中获取到
|
|
66
|
+
// https://github.com/wechat-miniprogram/weui-miniprogram/blob/a3630575910302e3b94e69fcef266d2b509de650/src/components/uploader/uploader.ts#L149
|
|
67
|
+
// 写死的从返回值的 .urls 获取展示用的url来用。一定要将tempFilePaths透传下去,否则会重新加载然后出现闪白
|
|
68
|
+
return { urls: files.tempFilePaths, cloudUrls };
|
|
69
|
+
} catch (e) {
|
|
70
|
+
wx.showToast({
|
|
71
|
+
title: `${e}` || '上传失败',
|
|
72
|
+
icon: 'none',
|
|
73
|
+
duration: 2000,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
67
76
|
},
|
|
68
77
|
},
|
|
69
78
|
methods: {
|
|
@@ -103,10 +112,13 @@ Component({
|
|
|
103
112
|
},
|
|
104
113
|
observers: {
|
|
105
114
|
defaultValue: async function (value) {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
115
|
+
//当单图片上传且默认值为空数组时,初次渲染更新value,以避免空串提交类型不匹配问题
|
|
116
|
+
if (Array.isArray(value) && !this.data.singleFlag) {
|
|
117
|
+
this.setData({
|
|
118
|
+
urls: value
|
|
119
|
+
});
|
|
120
|
+
this.data.singleFlag = true;
|
|
121
|
+
}
|
|
110
122
|
if (value) {
|
|
111
123
|
let httpFiles = [];
|
|
112
124
|
for (let f of value) {
|
|
@@ -60,6 +60,7 @@ Component({
|
|
|
60
60
|
urls: [],
|
|
61
61
|
cloudFile: [],
|
|
62
62
|
strogeUrls: [],
|
|
63
|
+
singleFlag: false
|
|
63
64
|
},
|
|
64
65
|
methods: {
|
|
65
66
|
// 批量上传文件前置事件
|
|
@@ -133,9 +134,8 @@ Component({
|
|
|
133
134
|
if (!this.handleBefore(files?.tempFiles)) return;
|
|
134
135
|
const uploadPath = 'weda-uploader';
|
|
135
136
|
const uploadPromise = files.tempFiles.map(async (tempFile) => {
|
|
136
|
-
const cloudPath = `${uploadPath}/${uuid().replaceAll('-', '')}-${
|
|
137
|
-
|
|
138
|
-
}`;
|
|
137
|
+
const cloudPath = `${uploadPath}/${uuid().replaceAll('-', '')}-${tempFile.name
|
|
138
|
+
}`;
|
|
139
139
|
tempFile.percent = '0';
|
|
140
140
|
tempFile.cloudPath = null;
|
|
141
141
|
tempFile.filePath = tempFile?.path || null;
|
|
@@ -257,9 +257,13 @@ Component({
|
|
|
257
257
|
},
|
|
258
258
|
observers: {
|
|
259
259
|
defaultValue: async function (value) {
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
260
|
+
//当单图片上传且默认值为空数组时,初次渲染更新value,以避免空串提交类型不匹配问题
|
|
261
|
+
if (Array.isArray(value) && !this.data.singleFlag) {
|
|
262
|
+
this.setData({
|
|
263
|
+
urls: value
|
|
264
|
+
});
|
|
265
|
+
this.data.singleFlag = true;
|
|
266
|
+
}
|
|
263
267
|
let httpFiles = [];
|
|
264
268
|
if (value && JSON.stringify(value) != '[]') {
|
|
265
269
|
for (let f of value) {
|
|
@@ -127,34 +127,40 @@ Component({
|
|
|
127
127
|
const whereEffected = [].concat(getWhereList(where));
|
|
128
128
|
whereEffected.length > 0 && (tcbParams['where'] = whereEffected);
|
|
129
129
|
// tcb结果和事件
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
total,
|
|
146
|
-
records,
|
|
147
|
-
loading: false,
|
|
148
|
-
isReLoad: false,
|
|
149
|
-
pageStr: `${total > 0 ? pageNo : 0}/${
|
|
150
|
-
Math.ceil(total / pageSize) || 0
|
|
151
|
-
}`,
|
|
152
|
-
},
|
|
153
|
-
() => {
|
|
154
|
-
this._handleEvents(data);
|
|
155
|
-
setTimeout(() => this._firstScreenLoadMore(), 150);
|
|
130
|
+
try {
|
|
131
|
+
const data = await callDataSource({
|
|
132
|
+
dataSourceName,
|
|
133
|
+
methodName,
|
|
134
|
+
params: tcbParams,
|
|
135
|
+
});
|
|
136
|
+
let records = data?.records || [];
|
|
137
|
+
let total = data?.total || 0;
|
|
138
|
+
if (
|
|
139
|
+
['loadMoreButton', 'bottomLoad'].includes(
|
|
140
|
+
this.properties.pagination
|
|
141
|
+
) &&
|
|
142
|
+
!isReLoad
|
|
143
|
+
) {
|
|
144
|
+
records = [...this.data.records, ...records]; // TODO 可能存在单次 setData 数据量过大引起小程序性能问题
|
|
156
145
|
}
|
|
157
|
-
|
|
146
|
+
this.setData(
|
|
147
|
+
{
|
|
148
|
+
total,
|
|
149
|
+
records,
|
|
150
|
+
loading: false,
|
|
151
|
+
isReLoad: false,
|
|
152
|
+
pageStr: `${total > 0 ? pageNo : 0}/${
|
|
153
|
+
Math.ceil(total / pageSize) || 0
|
|
154
|
+
}`,
|
|
155
|
+
},
|
|
156
|
+
() => {
|
|
157
|
+
this._handleEvents(data);
|
|
158
|
+
setTimeout(() => this._firstScreenLoadMore(), 150);
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
} catch (e) {
|
|
162
|
+
this.setData({ loading: false });
|
|
163
|
+
}
|
|
158
164
|
},
|
|
159
165
|
/**
|
|
160
166
|
* 下一页
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<slot></slot>
|
|
6
6
|
</view>
|
|
7
7
|
|
|
8
|
-
<view class="weda-list-view__more">
|
|
8
|
+
<view class="weda-list-view__more {{'weda-list-view__more-' + pagination}}">
|
|
9
9
|
<!-- 加载更多 -->
|
|
10
10
|
<block wx:if="{{pagination==='loadMoreButton' && pageSize * pageNo < total}}">
|
|
11
11
|
<view class="weda-list-view__more-text" bindtap="handleNext">加载更多</view>
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import destr from '../../utils/destr';
|
|
2
|
+
import { isUrl } from '../../utils/platform';
|
|
3
|
+
import { getAppCustomNav } from '../../utils/tcb';
|
|
4
|
+
|
|
5
|
+
Component({
|
|
6
|
+
properties: {
|
|
7
|
+
className: {
|
|
8
|
+
type: String,
|
|
9
|
+
value: '',
|
|
10
|
+
},
|
|
11
|
+
style: {
|
|
12
|
+
type: String,
|
|
13
|
+
value: '',
|
|
14
|
+
},
|
|
15
|
+
navigationbar: { type: Object, value: {} },
|
|
16
|
+
},
|
|
17
|
+
data: {
|
|
18
|
+
defaultLogoUrl:
|
|
19
|
+
'https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/43d3b2b7-445c-4858-8eb0-50ac5d5cc08e.svg',
|
|
20
|
+
visible: false,
|
|
21
|
+
selectedKey: 'index',
|
|
22
|
+
menuData: [],
|
|
23
|
+
navigationStyle: {
|
|
24
|
+
isHorizontal: false,
|
|
25
|
+
showMenuIcon: true,
|
|
26
|
+
fixedTop: true,
|
|
27
|
+
menuFontSize: 14,
|
|
28
|
+
menuBackgroundColor: '#fff',
|
|
29
|
+
menuColor: '#000',
|
|
30
|
+
menuHoverColor: '#f3f3f3',
|
|
31
|
+
showTitle: true,
|
|
32
|
+
title: '标题',
|
|
33
|
+
showLogo: true,
|
|
34
|
+
logoUrl:
|
|
35
|
+
'https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/43d3b2b7-445c-4858-8eb0-50ac5d5cc08e.svg ',
|
|
36
|
+
titleFontSize: '18',
|
|
37
|
+
titleColor: '#000',
|
|
38
|
+
logoWidth: '32',
|
|
39
|
+
logoHeight: '32',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
observers: {
|
|
43
|
+
navigationbar: function (navigationbar) {
|
|
44
|
+
this.getMenusByapi(navigationbar);
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
methods: {
|
|
48
|
+
getMenusByapi(navigationbar) {
|
|
49
|
+
getAppCustomNav()
|
|
50
|
+
.then((res) => {
|
|
51
|
+
const { Content } = res;
|
|
52
|
+
const navigationData = destr(Content);
|
|
53
|
+
if (navigationData?.navigationStyle) {
|
|
54
|
+
const {
|
|
55
|
+
menuData,
|
|
56
|
+
navigationStyle,
|
|
57
|
+
isMultiTerminal,
|
|
58
|
+
mobileMenuData,
|
|
59
|
+
} = navigationData;
|
|
60
|
+
let menus = isMultiTerminal ? mobileMenuData : menuData;
|
|
61
|
+
let selectedKey = this.defaultSelectedMenu(menus);
|
|
62
|
+
this.setData({
|
|
63
|
+
menuData: this.generateMenuData(
|
|
64
|
+
menus,
|
|
65
|
+
{ key: selectedKey },
|
|
66
|
+
true
|
|
67
|
+
),
|
|
68
|
+
navigationStyle,
|
|
69
|
+
selectedKey,
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
.catch((error) => {
|
|
74
|
+
console.log(error);
|
|
75
|
+
const { menuData, navigationStyle } = navigationbar;
|
|
76
|
+
let selectedKey = this.defaultSelectedMenu(menuData);
|
|
77
|
+
|
|
78
|
+
this.setData({
|
|
79
|
+
menuData: this.generateMenuData(
|
|
80
|
+
menuData,
|
|
81
|
+
{ key: selectedKey },
|
|
82
|
+
true
|
|
83
|
+
),
|
|
84
|
+
navigationStyle,
|
|
85
|
+
selectedKey,
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
},
|
|
89
|
+
generateMenuData(menuData, menuItem, init = false) {
|
|
90
|
+
let menus = JSON.parse(JSON.stringify(menuData));
|
|
91
|
+
return menus?.map((i) => {
|
|
92
|
+
let { iconUrl = 'td:view-module', children } = i;
|
|
93
|
+
let iconType = 'image';
|
|
94
|
+
let ticon = '';
|
|
95
|
+
if (!isUrl(iconUrl)) {
|
|
96
|
+
iconType = 'icon';
|
|
97
|
+
if (iconUrl.includes('td:')) {
|
|
98
|
+
iconType = 't-icon';
|
|
99
|
+
ticon = iconUrl?.replace('td:', '');
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (init) {
|
|
103
|
+
i.expand = this.hasSelectedMenu(i, menuItem.key);
|
|
104
|
+
} else if (i.key === menuItem.key) {
|
|
105
|
+
i.expand = menuItem.expand;
|
|
106
|
+
}
|
|
107
|
+
return {
|
|
108
|
+
...i,
|
|
109
|
+
iconType,
|
|
110
|
+
iconUrl,
|
|
111
|
+
ticon,
|
|
112
|
+
children: this.generateMenuData(children || [], menuItem, init),
|
|
113
|
+
};
|
|
114
|
+
});
|
|
115
|
+
},
|
|
116
|
+
showMenu() {
|
|
117
|
+
this.setData({ visible: !this.data.visible });
|
|
118
|
+
},
|
|
119
|
+
menuClick(itemInfo) {
|
|
120
|
+
const menu = itemInfo?.currentTarget?.dataset?.menu;
|
|
121
|
+
const { path, type, key, children, expand } = menu;
|
|
122
|
+
if (children.length) {
|
|
123
|
+
this.setData({
|
|
124
|
+
menuData: this.generateMenuData(this.data.menuData, {
|
|
125
|
+
...menu,
|
|
126
|
+
expand: !expand,
|
|
127
|
+
}),
|
|
128
|
+
});
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
if (type === 'route') {
|
|
132
|
+
let { app } = getApp();
|
|
133
|
+
app.navigateTo({
|
|
134
|
+
pageId: path?.replace('/', ''),
|
|
135
|
+
packageName: '',
|
|
136
|
+
mode: 'weDa',
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
},
|
|
140
|
+
hasSelectedMenu(menu, selectedkey) {
|
|
141
|
+
let opened = false;
|
|
142
|
+
if (menu.key === selectedkey) {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
menu?.children?.forEach((i) => {
|
|
146
|
+
if (i.key === selectedkey) {
|
|
147
|
+
opened = true;
|
|
148
|
+
}
|
|
149
|
+
if (i?.children?.length) {
|
|
150
|
+
opened = this.hasSelectedMenu(i, selectedkey);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
return opened;
|
|
154
|
+
},
|
|
155
|
+
findMenuItemByPath(menus, targetPath) {
|
|
156
|
+
const queue = [];
|
|
157
|
+
let targetNode = null;
|
|
158
|
+
menus.forEach((node) => queue.push(node));
|
|
159
|
+
|
|
160
|
+
while (queue.length) {
|
|
161
|
+
const node = queue.shift();
|
|
162
|
+
if (!node) return null;
|
|
163
|
+
|
|
164
|
+
if (node.path === targetPath) {
|
|
165
|
+
// 添加节点
|
|
166
|
+
targetNode = node;
|
|
167
|
+
break;
|
|
168
|
+
} else {
|
|
169
|
+
node.children?.forEach((node) => queue.push(node));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return targetNode;
|
|
174
|
+
},
|
|
175
|
+
defaultSelectedMenu(menu) {
|
|
176
|
+
try {
|
|
177
|
+
// eslint-disable-next-line no-undef
|
|
178
|
+
const pages = getCurrentPages();
|
|
179
|
+
const currentpage = pages[pages.length - 1];
|
|
180
|
+
let path = currentpage.route.split('/');
|
|
181
|
+
path = path[1];
|
|
182
|
+
let selectedKey = '';
|
|
183
|
+
const targetMenu = this.findMenuItemByPath(menu, `/${path}`);
|
|
184
|
+
if (targetMenu) {
|
|
185
|
+
selectedKey = targetMenu.key;
|
|
186
|
+
}
|
|
187
|
+
return selectedKey;
|
|
188
|
+
} catch (error) {
|
|
189
|
+
return '';
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
});
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
<view class="weda-menu weda-menu-mobile" style="display: {{menuData.length?'block':'none'}};">
|
|
2
|
+
<view class="weda-menu__wrapper" style="background:{{navigationStyle.menuBackgroundColor}}">
|
|
3
|
+
<view class="weda-menu__bar-main">
|
|
4
|
+
<view class="weda-menu__main-logo">
|
|
5
|
+
<image wx:if="{{navigationStyle.showLogo}}" class="weda-menu__main-icon" style="width:{{navigationStyle.logoWidth}};height:{{navigationStyle.logoHeight}};" src="{{navigationStyle.logoUrl||defaultLogoUrl}}"></image>
|
|
6
|
+
<text wx:if="{{navigationStyle.showTitle}}" style="font-size:{{navigationStyle.titleFontSize}};color:{{navigationStyle.titleColor}};line-height: 2px;">
|
|
7
|
+
{{navigationStyle.title}}
|
|
8
|
+
</text>
|
|
9
|
+
</view>
|
|
10
|
+
</view>
|
|
11
|
+
<view class="weda-menu__bar-extra">
|
|
12
|
+
<view wx:if="{{!visible}}" class=".weda-menu__bar-btn weda-icon t-icon t-icon-view-list" bindtap="showMenu" style="color:{{navigationStyle.titleColor}}"></view>
|
|
13
|
+
<view wx:else class="weda-menu__bar-btn--close weda-icon t-icon t-icon-close" bindtap="showMenu" style="color:{{navigationStyle.titleColor}}"></view>
|
|
14
|
+
</view>
|
|
15
|
+
</view>
|
|
16
|
+
<view class="menu-solt">
|
|
17
|
+
<slot></slot>
|
|
18
|
+
</view>
|
|
19
|
+
</view>
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
<view class="weda-menu-mobile__drawer" wx-if="{{visible}}">
|
|
23
|
+
|
|
24
|
+
<view class="weda-menu weda-menu-mobile">
|
|
25
|
+
<view class="weda-menu__wrapper" style="background:{{navigationStyle.menuBackgroundColor}}">
|
|
26
|
+
<view class="weda-menu__bar-main">
|
|
27
|
+
<view class="weda-menu__main-logo">
|
|
28
|
+
<image wx:if="{{navigationStyle.showLogo}}" class="weda-menu__main-icon" style="width:{{navigationStyle.logoWidth}};height:{{navigationStyle.logoHeight}};" src="{{navigationStyle.logoUrl||defaultLogoUrl}}"></image>
|
|
29
|
+
<text wx:if="{{navigationStyle.showTitle}}" style="font-size:{{navigationStyle.titleFontSize}};color:{{navigationStyle.titleColor}};line-height: 2px;">
|
|
30
|
+
{{navigationStyle.title}}
|
|
31
|
+
</text>
|
|
32
|
+
</view>
|
|
33
|
+
</view>
|
|
34
|
+
<view class="weda-menu__bar-extra">
|
|
35
|
+
<view wx:if="{{!visible}}" class=".weda-menu__bar-btn weda-icon t-icon t-icon-view-list" bindtap="showMenu" style="color:{{navigationStyle.titleColor}}"></view>
|
|
36
|
+
<view wx:else class="weda-menu__bar-btn--close weda-icon t-icon t-icon-close" bindtap="showMenu" style="color:{{navigationStyle.titleColor}}"></view>
|
|
37
|
+
</view>
|
|
38
|
+
</view>
|
|
39
|
+
</view>
|
|
40
|
+
<view class="weda-drawer-drawer__body">
|
|
41
|
+
<scroll-view class="weda-drawer-menu weda-menu__drawer-menu weda-drawer-menu--light" scroll-y >
|
|
42
|
+
<view class="weda-drawer-menu weda-menu__drawer-menu weda-drawer-menu--light" style="background:{{navigationStyle.menuBackgroundColor}}">
|
|
43
|
+
<view class="weda-drawer-menu__body">
|
|
44
|
+
<view class="weda-drawer-menu__list">
|
|
45
|
+
<block wx:for="{{menuData}}" wx:key="menuIndex" wx:for-item="menu">
|
|
46
|
+
<view class="{{menu.children ? 'weda-drawer-menu__submenu' : ''}} {{menu.expand?'expand':''}}" >
|
|
47
|
+
<view class="weda-drawer-menu__item" style="background-color:{{selectedKey===menu.key?navigationStyle.menuHoverColor:'unset'}};" bindtap="menuClick" data-menu="{{menu}}">
|
|
48
|
+
<view wx:if="{{navigationStyle.showMenuIcon && menu.iconType!=='image'}}" class="weda-grid-navigation__icon">
|
|
49
|
+
<view wx:if="{{menu.iconType === 't-icon'}}" class="weda-icon t-icon t-icon-{{menu.ticon}}" style="font-size:{{navigationStyle.menuFontSize}};color:{{navigationStyle.menuColor}}"></view>
|
|
50
|
+
<view wx:if="{{menu.iconType !== 't-icon'}}" class="weda-icon lcap-icon-padding lcap-icon lcap-icon-{{menu.iconUrl}}" style="font-size:{{navigationStyle.menuFontSize}};color:{{navigationStyle.menuColor}}">
|
|
51
|
+
</view>
|
|
52
|
+
</view>
|
|
53
|
+
<image wx:if="{{navigationStyle.showMenuIcon && menu.iconType==='image'}}" class="weda-drawer-menu__list-icon" src="{{menu.iconUrl}}" alt="icon"></image>
|
|
54
|
+
<view class="weda-drawer-menu__text" style="font-size:{{navigationStyle.menuFontSize}};color:{{navigationStyle.menuColor}}">{{menu.title}}</view>
|
|
55
|
+
<view wx-if="{{menu.children.length>0}}" class="weda-menu__bar-btn-expand lcap-icon lcap-icon-chevrondown"></view>
|
|
56
|
+
</view>
|
|
57
|
+
<view class="weda-drawer-menu__list">
|
|
58
|
+
<block wx-if="{{menu.children}}">
|
|
59
|
+
<block wx:for="{{menu.children}}" wx:key="secondIndex" wx:for-item="secondMenu">
|
|
60
|
+
<view class="{{secondMenu.children ? 'weda-drawer-menu__submenu weda-menu__submenu' : ''}} {{secondMenu.expand?'expand':''}}">
|
|
61
|
+
<view class="weda-drawer-menu__item" style="background-color:{{selectedKey===secondMenu.key?navigationStyle.menuHoverColor:'unset'}};" bindtap="menuClick" data-menu="{{secondMenu}}">
|
|
62
|
+
<view class="weda-drawer-menu__text" style="font-size:{{navigationStyle.menuFontSize}};color:{{navigationStyle.menuColor}}">{{secondMenu.title}}</view>
|
|
63
|
+
<view wx-if="{{secondMenu.children.length>0}}" class="weda-menu__bar-btn-expand lcap-icon lcap-icon-chevrondown"></view>
|
|
64
|
+
</view>
|
|
65
|
+
<view class="weda-drawer-menu__list">
|
|
66
|
+
<block wx-if="{{secondMenu.children}}">
|
|
67
|
+
<block wx:for="{{secondMenu.children}}" wx:key="thridIndex" wx:for-item="thridMenu">
|
|
68
|
+
<view class="">
|
|
69
|
+
<view class="weda-drawer-menu__item" style="background-color:{{selectedKey===thridMenu.key?navigationStyle.menuHoverColor:'unset'}};" bindtap="menuClick" data-menu="{{thridMenu}}">
|
|
70
|
+
<view class="weda-drawer-menu__text" style="font-size:{{navigationStyle.menuFontSize}};color:{{navigationStyle.menuColor}}">{{thridMenu.title}}</view>
|
|
71
|
+
</view>
|
|
72
|
+
</view>
|
|
73
|
+
</block>
|
|
74
|
+
</block>
|
|
75
|
+
</view>
|
|
76
|
+
</view>
|
|
77
|
+
</block>
|
|
78
|
+
</block>
|
|
79
|
+
</view>
|
|
80
|
+
</view>
|
|
81
|
+
</block>
|
|
82
|
+
</view>
|
|
83
|
+
</view>
|
|
84
|
+
</view>
|
|
85
|
+
</scroll-view>
|
|
86
|
+
</view>
|
|
87
|
+
|
|
88
|
+
</view>
|