@power-xa/m-ui 0.0.6 → 0.0.8
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 +37 -17
- package/dist/ActionSheet/index.js +5 -3
- package/dist/Breadcrumb/index.js +4 -2
- package/dist/Calendar/Date/index.d.ts +8 -0
- package/dist/Calendar/Date/index.js +246 -0
- package/dist/Calendar/Date/index.less +146 -0
- package/dist/Calendar/Month/index.d.ts +7 -0
- package/dist/Calendar/Month/index.js +199 -0
- package/dist/Calendar/Month/index.less +96 -0
- package/dist/Calendar/Week/index.d.ts +7 -0
- package/dist/Calendar/Week/index.js +200 -0
- package/dist/Calendar/Week/index.less +96 -0
- package/dist/Calendar/index.d.ts +10 -0
- package/dist/Calendar/index.js +9 -0
- package/dist/ConfigProvider/index.d.ts +1 -0
- package/dist/Drawer/index.d.ts +1 -0
- package/dist/Drawer/index.js +38 -20
- package/dist/Drawer/index.less +2 -1
- package/dist/Filter/index.d.ts +3 -0
- package/dist/Filter/index.js +8 -6
- package/dist/ProForm/Controls/Cascader/index.d.ts +28 -0
- package/dist/ProForm/Controls/Cascader/index.js +159 -0
- package/dist/ProForm/Controls/Cascader/index.less +106 -0
- package/dist/ProForm/Controls/Date/index.d.ts +6 -1
- package/dist/ProForm/Controls/Date/index.js +12 -4
- package/dist/ProForm/Controls/Date/index.less +18 -0
- package/dist/ProForm/Controls/List/index.d.ts +2 -8
- package/dist/ProForm/Controls/List/index.js +17 -9
- package/dist/ProForm/Controls/List/index.less +0 -0
- package/dist/ProForm/Controls/Select/index.d.ts +50 -1
- package/dist/ProForm/Controls/Select/index.js +289 -211
- package/dist/ProForm/Controls/Select/index.less +29 -0
- package/dist/ProForm/Controls/Stepper/index.d.ts +10 -0
- package/dist/ProForm/Controls/Stepper/index.js +72 -0
- package/dist/ProForm/Controls/Stepper/index.less +31 -0
- package/dist/ProForm/Controls/Switch/index.d.ts +5 -0
- package/dist/ProForm/Controls/Switch/index.js +21 -0
- package/dist/ProForm/Controls/Switch/index.less +3 -0
- package/dist/ProForm/Controls/Text/index.d.ts +9 -2
- package/dist/ProForm/Controls/Text/index.js +12 -12
- package/dist/ProForm/Controls/Text/index.less +0 -0
- package/dist/ProForm/Controls/TextArea/index.d.ts +6 -1
- package/dist/ProForm/Controls/TextArea/index.js +10 -11
- package/dist/ProForm/Controls/Upload/index.d.ts +32 -9
- package/dist/ProForm/Controls/Upload/index.js +14 -6
- package/dist/ProForm/Controls/Upload/index.less +0 -0
- package/dist/ProForm/Field/index.d.ts +27 -4
- package/dist/ProForm/Field/index.js +12 -13
- package/dist/ProForm/Field/index.less +0 -4
- package/dist/ProForm/Form/index.d.ts +41 -6
- package/dist/ProForm/Form/index.js +294 -172
- package/dist/ProForm/Form/index.less +0 -0
- package/dist/ProForm/Group/index.d.ts +22 -3
- package/dist/ProForm/Group/index.js +8 -30
- package/dist/ProForm/Group/index.less +0 -0
- package/dist/ProForm/index.d.ts +4 -4
- package/dist/ProForm/index.js +5 -5
- package/dist/ProList/index.d.ts +8 -2
- package/dist/ProList/index.js +6 -4
- package/dist/Tabbar/index.d.ts +4 -2
- package/dist/Tabbar/index.js +14 -5
- package/dist/Tabs/index.d.ts +8 -5
- package/dist/Tabs/index.js +6 -6
- package/dist/Tabs/index.less +4 -1
- package/dist/UserView/index.d.ts +15 -0
- package/dist/UserView/index.js +62 -0
- package/dist/UserView/index.less +41 -0
- package/dist/ValidMobilePopup/index.d.ts +9 -0
- package/dist/ValidMobilePopup/index.js +147 -0
- package/dist/ValidMobilePopup/index.less +58 -0
- package/dist/hooks/index.d.ts +22 -0
- package/dist/hooks/index.js +51 -0
- package/dist/index.d.ts +17 -2
- package/dist/index.js +9 -1
- package/dist/services/CommonController/index.d.ts +5 -0
- package/dist/services/CommonController/index.js +21 -0
- package/dist/services/CommonController/typings.d.ts +0 -0
- package/dist/services/index.d.ts +2 -1
- package/dist/services/index.js +2 -1
- package/package.json +6 -3
- package/dist/ProForm/typings.d.ts +0 -164
- package/dist/RefreshList/index.d.ts +0 -17
- package/dist/RefreshList/index.js +0 -43
- package/dist/RefreshList/index.less +0 -19
- package/dist/assets/fonts/PingFangSC-Light.ttf +0 -0
- package/dist/assets/fonts/PingFangSC-Medium.ttf +0 -0
- package/dist/assets/fonts/PingFangSC-Regular.ttf +0 -0
package/dist/ProForm/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ProForm from "./Form";
|
|
2
2
|
import ProFormGroup from "./Group";
|
|
3
3
|
import ProFormField from "./Field";
|
|
4
|
-
type ProFormType = typeof
|
|
4
|
+
type ProFormType = typeof ProForm & {
|
|
5
5
|
Group: typeof ProFormGroup;
|
|
6
6
|
Field: typeof ProFormField;
|
|
7
7
|
};
|
|
8
|
-
declare const
|
|
9
|
-
export default
|
|
8
|
+
declare const ProFormSource: ProFormType;
|
|
9
|
+
export default ProFormSource;
|
package/dist/ProForm/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
1
|
+
import ProForm from "./Form";
|
|
2
2
|
import ProFormGroup from "./Group";
|
|
3
3
|
import ProFormField from "./Field";
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export default
|
|
4
|
+
var ProFormSource = ProForm;
|
|
5
|
+
ProFormSource.Group = ProFormGroup;
|
|
6
|
+
ProFormSource.Field = ProFormField;
|
|
7
|
+
export default ProFormSource;
|
package/dist/ProList/index.d.ts
CHANGED
|
@@ -6,6 +6,12 @@ type MetaProps = {
|
|
|
6
6
|
[key: string]: any;
|
|
7
7
|
}, index: number) => string | ReactNode;
|
|
8
8
|
};
|
|
9
|
+
export type ProListInstance = {
|
|
10
|
+
onRefresh: () => void;
|
|
11
|
+
setFilterParams: (p: {
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
}) => void;
|
|
14
|
+
};
|
|
9
15
|
export type ProListProps = {
|
|
10
16
|
scrollable?: boolean;
|
|
11
17
|
dataSources?: {
|
|
@@ -77,5 +83,5 @@ export type ProListProps = {
|
|
|
77
83
|
[key: string]: any;
|
|
78
84
|
}, index: number, dom: ReactNode) => ReactNode;
|
|
79
85
|
};
|
|
80
|
-
declare const
|
|
81
|
-
export default
|
|
86
|
+
declare const ProList: React.ForwardRefExoticComponent<ProListProps & React.RefAttributes<ProListInstance>>;
|
|
87
|
+
export default ProList;
|
package/dist/ProList/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import { useDebounceEffect } from "ahooks";
|
|
|
18
18
|
import { useConfig } from "../ConfigProvider";
|
|
19
19
|
import { FileController } from "../services";
|
|
20
20
|
import "./index.less";
|
|
21
|
-
var ProList = function
|
|
21
|
+
var ProList = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
22
22
|
var _ref$scrollable = _ref.scrollable,
|
|
23
23
|
scrollable = _ref$scrollable === void 0 ? true : _ref$scrollable,
|
|
24
24
|
dataSources = _ref.dataSources,
|
|
@@ -94,7 +94,9 @@ var ProList = function ProList(_ref, ref) {
|
|
|
94
94
|
if ("{}" === JSON.stringify(p)) {
|
|
95
95
|
_setFilterParams(params || {});
|
|
96
96
|
} else {
|
|
97
|
-
_setFilterParams(_objectSpread(_objectSpread({},
|
|
97
|
+
_setFilterParams(_objectSpread(_objectSpread(_objectSpread({}, params), p), {}, {
|
|
98
|
+
size: size
|
|
99
|
+
}));
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
102
|
};
|
|
@@ -392,5 +394,5 @@ var ProList = function ProList(_ref, ref) {
|
|
|
392
394
|
},
|
|
393
395
|
className: "p-pro-list-container ".concat(className)
|
|
394
396
|
}, renderContent());
|
|
395
|
-
};
|
|
396
|
-
export default
|
|
397
|
+
});
|
|
398
|
+
export default ProList;
|
package/dist/Tabbar/index.d.ts
CHANGED
|
@@ -6,8 +6,10 @@ type TabItemProps = {
|
|
|
6
6
|
key: string;
|
|
7
7
|
children: ReactNode;
|
|
8
8
|
};
|
|
9
|
-
type
|
|
9
|
+
type ProTabbarProps = {
|
|
10
10
|
items: TabItemProps[];
|
|
11
|
+
activeKey?: string;
|
|
12
|
+
onChange?: (key: string) => void;
|
|
11
13
|
};
|
|
12
|
-
declare const Tabbar: FC<
|
|
14
|
+
declare const Tabbar: FC<ProTabbarProps>;
|
|
13
15
|
export default Tabbar;
|
package/dist/Tabbar/index.js
CHANGED
|
@@ -19,7 +19,9 @@ import { getWindowInfo } from "@tarojs/taro";
|
|
|
19
19
|
import { Text, View } from "@tarojs/components";
|
|
20
20
|
import "./index.less";
|
|
21
21
|
var Tabbar = function Tabbar(_ref) {
|
|
22
|
-
var items = _ref.items
|
|
22
|
+
var items = _ref.items,
|
|
23
|
+
activeKey = _ref.activeKey,
|
|
24
|
+
onChange = _ref.onChange;
|
|
23
25
|
var _getWindowInfo = getWindowInfo(),
|
|
24
26
|
safeArea = _getWindowInfo.safeArea;
|
|
25
27
|
var _ref2 = safeArea,
|
|
@@ -33,12 +35,16 @@ var Tabbar = function Tabbar(_ref) {
|
|
|
33
35
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
34
36
|
tabbarList = _useState4[0],
|
|
35
37
|
setTabbarList = _useState4[1];
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
if (activeKey && tab && tab !== activeKey) onChange === null || onChange === void 0 || onChange(tab);
|
|
40
|
+
}, [tab, activeKey]);
|
|
36
41
|
useEffect(function () {
|
|
37
42
|
if (items.length) {
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
var _tab = activeKey || items[0].key;
|
|
44
|
+
setTab(_tab);
|
|
45
|
+
setTabbarList(items.map(function (item) {
|
|
40
46
|
return _objectSpread(_objectSpread({}, item), {}, {
|
|
41
|
-
init:
|
|
47
|
+
init: item.key === _tab ? true : false
|
|
42
48
|
});
|
|
43
49
|
}));
|
|
44
50
|
}
|
|
@@ -46,13 +52,16 @@ var Tabbar = function Tabbar(_ref) {
|
|
|
46
52
|
return /*#__PURE__*/React.createElement(View, {
|
|
47
53
|
className: "p-tabbar-page-container"
|
|
48
54
|
}, tabbarList.map(function (item) {
|
|
55
|
+
var _items$find;
|
|
49
56
|
return item.init && /*#__PURE__*/React.createElement(View, {
|
|
50
57
|
key: 'content-' + item.key,
|
|
51
58
|
style: {
|
|
52
59
|
display: tab === item.key ? "block" : "none"
|
|
53
60
|
},
|
|
54
61
|
className: "p-tabbar-page-content"
|
|
55
|
-
},
|
|
62
|
+
}, (_items$find = items.find(function (i) {
|
|
63
|
+
return i.key === item.key;
|
|
64
|
+
})) === null || _items$find === void 0 ? void 0 : _items$find.children);
|
|
56
65
|
}), /*#__PURE__*/React.createElement(View, {
|
|
57
66
|
className: "p-tabbar-page-footer",
|
|
58
67
|
style: {
|
package/dist/Tabs/index.d.ts
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import React, { ReactNode } from "react";
|
|
2
2
|
import "./index.less";
|
|
3
|
-
type
|
|
3
|
+
export type ProTabsInstance = {
|
|
4
|
+
onRefresh: (keys: string[]) => void;
|
|
5
|
+
};
|
|
6
|
+
export type ProTabItemProps = {
|
|
4
7
|
label: string;
|
|
5
8
|
icon?: string;
|
|
6
9
|
key: string;
|
|
7
10
|
children?: ReactNode;
|
|
8
11
|
init?: boolean;
|
|
9
12
|
};
|
|
10
|
-
type
|
|
11
|
-
items:
|
|
13
|
+
export type ProTabsProps = {
|
|
14
|
+
items: ProTabItemProps[];
|
|
12
15
|
onChange?: (current: string) => void;
|
|
13
16
|
activeKey?: string;
|
|
14
17
|
extra?: {
|
|
@@ -22,5 +25,5 @@ type TabsProps = {
|
|
|
22
25
|
isCardList?: boolean;
|
|
23
26
|
centered?: boolean;
|
|
24
27
|
};
|
|
25
|
-
declare const
|
|
26
|
-
export default
|
|
28
|
+
declare const Tabs: React.ForwardRefExoticComponent<ProTabsProps & React.RefAttributes<ProTabsInstance>>;
|
|
29
|
+
export default Tabs;
|
package/dist/Tabs/index.js
CHANGED
|
@@ -18,8 +18,8 @@ import React, { useCallback, useEffect, useState, cloneElement, isValidElement,
|
|
|
18
18
|
import { ScrollView, Swiper, SwiperItem, Text, View } from "@tarojs/components";
|
|
19
19
|
import { createSelectorQuery } from "@tarojs/taro";
|
|
20
20
|
import "./index.less";
|
|
21
|
-
var Tabs = function
|
|
22
|
-
var _items$,
|
|
21
|
+
var Tabs = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
22
|
+
var _items$, _items$find2;
|
|
23
23
|
var items = _ref.items,
|
|
24
24
|
onChange = _ref.onChange,
|
|
25
25
|
activeKey = _ref.activeKey,
|
|
@@ -199,8 +199,8 @@ var Tabs = function Tabs(_ref, ref) {
|
|
|
199
199
|
id: "swiper-tab-content",
|
|
200
200
|
className: "swiper-tab-content-view"
|
|
201
201
|
}, renderSwiperTabContent(item)));
|
|
202
|
-
})) : (
|
|
202
|
+
})) : (_items$find2 = items.find(function (item) {
|
|
203
203
|
return item.key === selectKey;
|
|
204
|
-
})) === null ||
|
|
205
|
-
};
|
|
206
|
-
export default
|
|
204
|
+
})) === null || _items$find2 === void 0 ? void 0 : _items$find2.children));
|
|
205
|
+
});
|
|
206
|
+
export default Tabs;
|
package/dist/Tabs/index.less
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import "./index.less";
|
|
3
|
+
type UserViewProps = {
|
|
4
|
+
id?: string;
|
|
5
|
+
companyUserId?: string;
|
|
6
|
+
memberId?: string;
|
|
7
|
+
userName?: string;
|
|
8
|
+
description?: ReactNode;
|
|
9
|
+
format?: boolean;
|
|
10
|
+
extra?: {
|
|
11
|
+
onEdit?: (() => void) | undefined | false;
|
|
12
|
+
} | ReactNode;
|
|
13
|
+
};
|
|
14
|
+
declare const UserView: FC<UserViewProps>;
|
|
15
|
+
export default UserView;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
2
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
4
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
5
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
6
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
7
|
+
import React, { isValidElement, useCallback, useEffect, useState } from "react";
|
|
8
|
+
import { Image, Text, View } from "@tarojs/components";
|
|
9
|
+
import { Button, getSimplifyDay } from "./..";
|
|
10
|
+
import { useConfig } from "../ConfigProvider";
|
|
11
|
+
import { FileController } from "../services";
|
|
12
|
+
import "./index.less";
|
|
13
|
+
var UserView = function UserView(_ref) {
|
|
14
|
+
var id = _ref.id,
|
|
15
|
+
companyUserId = _ref.companyUserId,
|
|
16
|
+
memberId = _ref.memberId,
|
|
17
|
+
userName = _ref.userName,
|
|
18
|
+
description = _ref.description,
|
|
19
|
+
_ref$format = _ref.format,
|
|
20
|
+
format = _ref$format === void 0 ? true : _ref$format,
|
|
21
|
+
extra = _ref.extra;
|
|
22
|
+
var _useConfig = useConfig(),
|
|
23
|
+
src = _useConfig.src;
|
|
24
|
+
var _useState = useState(""),
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
avatar = _useState2[0],
|
|
27
|
+
setAvatar = _useState2[1];
|
|
28
|
+
useEffect(function () {
|
|
29
|
+
if (id || memberId || companyUserId) {
|
|
30
|
+
getAvatar();
|
|
31
|
+
}
|
|
32
|
+
}, [id, memberId, companyUserId]);
|
|
33
|
+
var getAvatar = useCallback(function () {
|
|
34
|
+
var _request;
|
|
35
|
+
var request = null;
|
|
36
|
+
if (id) request = FileController.getUserAvatar;
|
|
37
|
+
if (companyUserId) request = FileController.getCompanyUserAvatar;
|
|
38
|
+
if (memberId) request = FileController.getProjectMemberAvatar;
|
|
39
|
+
(_request = request) === null || _request === void 0 || _request({
|
|
40
|
+
ids: [id || companyUserId || memberId]
|
|
41
|
+
}).then(function (result) {
|
|
42
|
+
if (result.code === 200) setAvatar(result.data[0] || (src === null || src === void 0 ? void 0 : src.resource) + "/images/default/avatar.svg");
|
|
43
|
+
});
|
|
44
|
+
}, [id, companyUserId, memberId]);
|
|
45
|
+
return /*#__PURE__*/React.createElement(View, {
|
|
46
|
+
className: "p-user-view-container",
|
|
47
|
+
key: id || memberId || companyUserId
|
|
48
|
+
}, /*#__PURE__*/React.createElement(Image, {
|
|
49
|
+
src: avatar,
|
|
50
|
+
className: "avatar"
|
|
51
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
52
|
+
className: "text-content"
|
|
53
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
54
|
+
className: "text"
|
|
55
|
+
}, userName), typeof description === "string" ? /*#__PURE__*/React.createElement(Text, {
|
|
56
|
+
className: "sub-text"
|
|
57
|
+
}, format ? getSimplifyDay(description) : description) : description), /*#__PURE__*/isValidElement(extra) ? extra : extra.onEdit && /*#__PURE__*/React.createElement(Button, {
|
|
58
|
+
onTap: extra.onEdit,
|
|
59
|
+
round: true
|
|
60
|
+
}, "\u7F16\u8F91"));
|
|
61
|
+
};
|
|
62
|
+
export default UserView;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
@import "@power-xa/m-ui/dist/assets/less/mixins.less";
|
|
2
|
+
|
|
3
|
+
.p-user-view-container {
|
|
4
|
+
padding: 14px 24px 14px 34px;
|
|
5
|
+
box-sizing: border-box;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: space-between;
|
|
9
|
+
gap: 20px;
|
|
10
|
+
|
|
11
|
+
.avatar {
|
|
12
|
+
width: 70px;
|
|
13
|
+
height: 70px;
|
|
14
|
+
border-radius: 12px;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
.text-content {
|
|
18
|
+
display: flex;
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
gap: 8px;
|
|
21
|
+
flex: 1;
|
|
22
|
+
|
|
23
|
+
.text {
|
|
24
|
+
.font(24, #333437)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.sub-text {
|
|
28
|
+
.font(20, #999)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.p-button {
|
|
33
|
+
padding: 12px 28px;
|
|
34
|
+
background: #F5F6F7;
|
|
35
|
+
border: none;
|
|
36
|
+
|
|
37
|
+
.text {
|
|
38
|
+
.font(24, #333437)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC, ReactNode } from "react";
|
|
2
|
+
import "./index.less";
|
|
3
|
+
type ValidMobilePopupProps = {
|
|
4
|
+
mobile: string;
|
|
5
|
+
children: ReactNode;
|
|
6
|
+
onOk: (code: string) => void;
|
|
7
|
+
};
|
|
8
|
+
declare const ValidMobilePopup: FC<ValidMobilePopupProps>;
|
|
9
|
+
export default ValidMobilePopup;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
+
import React, { Fragment, useCallback, useEffect, useState } from "react";
|
|
14
|
+
import { showToast } from "@tarojs/taro";
|
|
15
|
+
import { Text, View } from "@tarojs/components";
|
|
16
|
+
import { Button, Popup, ProForm, ProFormText } from "./..";
|
|
17
|
+
import { useCountDown } from "ahooks";
|
|
18
|
+
import { CommonController } from "../services";
|
|
19
|
+
import "./index.less";
|
|
20
|
+
var ValidMobilePopup = function ValidMobilePopup(_ref) {
|
|
21
|
+
var children = _ref.children,
|
|
22
|
+
mobile = _ref.mobile,
|
|
23
|
+
onOk = _ref.onOk;
|
|
24
|
+
var _useState = useState(false),
|
|
25
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
26
|
+
open = _useState2[0],
|
|
27
|
+
setOpen = _useState2[1];
|
|
28
|
+
var _useState3 = useState({
|
|
29
|
+
mobile: mobile
|
|
30
|
+
}),
|
|
31
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
32
|
+
form = _useState4[0],
|
|
33
|
+
setForm = _useState4[1];
|
|
34
|
+
useEffect(function () {
|
|
35
|
+
if (open) setForm({
|
|
36
|
+
mobile: mobile,
|
|
37
|
+
code: ""
|
|
38
|
+
});
|
|
39
|
+
}, [open]);
|
|
40
|
+
|
|
41
|
+
// 获取验证码
|
|
42
|
+
var _useState5 = useState(),
|
|
43
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
44
|
+
targetDate = _useState6[0],
|
|
45
|
+
setTargetDate = _useState6[1];
|
|
46
|
+
var _useCountDown = useCountDown({
|
|
47
|
+
targetDate: targetDate,
|
|
48
|
+
onEnd: function onEnd() {
|
|
49
|
+
setTargetDate(undefined);
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
_useCountDown2 = _slicedToArray(_useCountDown, 1),
|
|
53
|
+
countDown = _useCountDown2[0];
|
|
54
|
+
var getCode = useCallback(function () {
|
|
55
|
+
if (!!targetDate) return false;
|
|
56
|
+
if (!form.mobile) return showToast({
|
|
57
|
+
title: "请输入手机号",
|
|
58
|
+
icon: "none"
|
|
59
|
+
});
|
|
60
|
+
if (!/^1[3456789]\d{9}$/.test(form.mobile)) return showToast({
|
|
61
|
+
title: "请输入正确的手机号",
|
|
62
|
+
icon: "none"
|
|
63
|
+
});
|
|
64
|
+
setTargetDate(Date.now() + 60000);
|
|
65
|
+
CommonController.sendCode(form.mobile);
|
|
66
|
+
}, [form]);
|
|
67
|
+
var validMobileCode = useCallback(function () {
|
|
68
|
+
if (!form.mobile) return showToast({
|
|
69
|
+
title: "请输入手机号",
|
|
70
|
+
icon: "none"
|
|
71
|
+
});
|
|
72
|
+
if (!form.code) return showToast({
|
|
73
|
+
title: "请输入验证码",
|
|
74
|
+
icon: "none"
|
|
75
|
+
});
|
|
76
|
+
CommonController.validMobileCode(form).then(function (result) {
|
|
77
|
+
if (result.code === 200) {
|
|
78
|
+
if (result.data) {
|
|
79
|
+
onOk(form.code);
|
|
80
|
+
setOpen(false);
|
|
81
|
+
} else {
|
|
82
|
+
showToast({
|
|
83
|
+
title: "验证码错误,请重新输入",
|
|
84
|
+
icon: "none"
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
;
|
|
89
|
+
});
|
|
90
|
+
}, [form]);
|
|
91
|
+
return /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(View, {
|
|
92
|
+
onTap: function onTap() {
|
|
93
|
+
return setOpen(true);
|
|
94
|
+
}
|
|
95
|
+
}, children), /*#__PURE__*/React.createElement(Popup, {
|
|
96
|
+
open: open,
|
|
97
|
+
onOpenChange: function onOpenChange() {
|
|
98
|
+
return setOpen(false);
|
|
99
|
+
},
|
|
100
|
+
header: {
|
|
101
|
+
title: "身份验证"
|
|
102
|
+
},
|
|
103
|
+
rootClassName: "p-vaild-mobile-popup-container",
|
|
104
|
+
height: 40
|
|
105
|
+
}, function (_ref2) {
|
|
106
|
+
var onOpenChange = _ref2.onOpenChange;
|
|
107
|
+
return /*#__PURE__*/React.createElement(ProForm, {
|
|
108
|
+
footer: {
|
|
109
|
+
children: /*#__PURE__*/React.createElement(Button, {
|
|
110
|
+
color: "primary",
|
|
111
|
+
round: true,
|
|
112
|
+
onTap: validMobileCode,
|
|
113
|
+
block: true
|
|
114
|
+
}, "\u4E0B\u4E00\u6B65")
|
|
115
|
+
}
|
|
116
|
+
}, /*#__PURE__*/React.createElement(ProFormText, {
|
|
117
|
+
inputType: "number",
|
|
118
|
+
maxLength: 11,
|
|
119
|
+
placeholder: "\u8BF7\u8F93\u5165\u624B\u673A\u53F7\u7801",
|
|
120
|
+
value: form.mobile,
|
|
121
|
+
onChange: function onChange(value) {
|
|
122
|
+
return setForm(_objectSpread(_objectSpread({}, form), {}, {
|
|
123
|
+
mobile: value
|
|
124
|
+
}));
|
|
125
|
+
},
|
|
126
|
+
disabled: true
|
|
127
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
128
|
+
className: "code-form"
|
|
129
|
+
}, /*#__PURE__*/React.createElement(ProFormText, {
|
|
130
|
+
inputType: "number",
|
|
131
|
+
maxLength: 6,
|
|
132
|
+
placeholder: "\u8BF7\u8F93\u5165\u9A8C\u8BC1\u7801",
|
|
133
|
+
value: form.code,
|
|
134
|
+
onChange: function onChange(value) {
|
|
135
|
+
return setForm(_objectSpread(_objectSpread({}, form), {}, {
|
|
136
|
+
code: value
|
|
137
|
+
}));
|
|
138
|
+
}
|
|
139
|
+
}), /*#__PURE__*/React.createElement(View, {
|
|
140
|
+
className: "get-code-button ".concat(!!targetDate ? "disabled" : ""),
|
|
141
|
+
onTap: getCode
|
|
142
|
+
}, /*#__PURE__*/React.createElement(Text, {
|
|
143
|
+
className: "get-code-text"
|
|
144
|
+
}, !targetDate ? "\u83B7\u53D6\u9A8C\u8BC1\u7801" : "".concat(Math.round(countDown / 1000), "s")))));
|
|
145
|
+
}));
|
|
146
|
+
};
|
|
147
|
+
export default ValidMobilePopup;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
@import "@power-xa/m-ui/dist/assets/less/mixins.less";
|
|
2
|
+
|
|
3
|
+
.p-vaild-mobile-popup-container {
|
|
4
|
+
.p-pro-form-scroll-view-content {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: column;
|
|
7
|
+
gap: 32px;
|
|
8
|
+
|
|
9
|
+
.p-pro-form-item {
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 36px 32px;
|
|
12
|
+
border-radius: 32px;
|
|
13
|
+
border-bottom: none;
|
|
14
|
+
|
|
15
|
+
.p-pro-form-item-input,
|
|
16
|
+
.p-pro-form-item-placeholder,
|
|
17
|
+
.p-pro-form-item-control-disabled {
|
|
18
|
+
text-align: left;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.code-form {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
border-bottom: none;
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
gap: 24px;
|
|
28
|
+
background: #fff;
|
|
29
|
+
border-radius: 32px;
|
|
30
|
+
padding-right: 32px;
|
|
31
|
+
|
|
32
|
+
.p-pro-form-item {
|
|
33
|
+
border-bottom: none;
|
|
34
|
+
flex: 1;
|
|
35
|
+
width: 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.get-code-button {
|
|
39
|
+
display: flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
|
|
42
|
+
.get-code-text {
|
|
43
|
+
.font(28);
|
|
44
|
+
|
|
45
|
+
&.disabled {
|
|
46
|
+
.font(28, #999)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&.disabled {
|
|
51
|
+
.get-code-text {
|
|
52
|
+
.font(28, #999)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const usePageParams: (key: string, callback: (params: {
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
}) => void) => void;
|
|
4
|
+
type DelayGoBackParams = {
|
|
5
|
+
title?: string;
|
|
6
|
+
refresh?: () => void;
|
|
7
|
+
returnPage?: boolean;
|
|
8
|
+
delta?: number;
|
|
9
|
+
callback?: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare const useDelayGoBack: (params?: DelayGoBackParams) => void;
|
|
12
|
+
type navigateToParams = {
|
|
13
|
+
url: string;
|
|
14
|
+
event?: {
|
|
15
|
+
name: string;
|
|
16
|
+
params?: {
|
|
17
|
+
[key: string]: any;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export declare const useNavigateTo: (params: navigateToParams) => void;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { getCurrentPages, showToast, navigateBack, navigateTo } from "@tarojs/taro";
|
|
2
|
+
export var usePageParams = function usePageParams(key, callback) {
|
|
3
|
+
var _eventChannel$once;
|
|
4
|
+
var pages = getCurrentPages();
|
|
5
|
+
var current = pages[pages.length - 1];
|
|
6
|
+
var eventChannel = current.getOpenerEventChannel();
|
|
7
|
+
(_eventChannel$once = eventChannel.once) === null || _eventChannel$once === void 0 || _eventChannel$once.call(eventChannel, key, callback);
|
|
8
|
+
};
|
|
9
|
+
export var useDelayGoBack = function useDelayGoBack() {
|
|
10
|
+
var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
|
|
11
|
+
returnPage: true,
|
|
12
|
+
delta: 1
|
|
13
|
+
};
|
|
14
|
+
var title = params.title,
|
|
15
|
+
refresh = params.refresh,
|
|
16
|
+
_params$returnPage = params.returnPage,
|
|
17
|
+
returnPage = _params$returnPage === void 0 ? true : _params$returnPage,
|
|
18
|
+
_params$delta = params.delta,
|
|
19
|
+
delta = _params$delta === void 0 ? 1 : _params$delta,
|
|
20
|
+
callback = params.callback;
|
|
21
|
+
if (title) showToast({
|
|
22
|
+
title: title,
|
|
23
|
+
icon: "none"
|
|
24
|
+
});
|
|
25
|
+
if (returnPage) {
|
|
26
|
+
var time = setTimeout(function () {
|
|
27
|
+
refresh === null || refresh === void 0 || refresh();
|
|
28
|
+
callback === null || callback === void 0 || callback();
|
|
29
|
+
navigateBack({
|
|
30
|
+
delta: delta
|
|
31
|
+
});
|
|
32
|
+
clearTimeout(time);
|
|
33
|
+
}, 200);
|
|
34
|
+
} else {
|
|
35
|
+
refresh === null || refresh === void 0 || refresh();
|
|
36
|
+
callback === null || callback === void 0 || callback();
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export var useNavigateTo = function useNavigateTo(params) {
|
|
40
|
+
var url = params.url,
|
|
41
|
+
event = params.event;
|
|
42
|
+
var toParams = {
|
|
43
|
+
url: url
|
|
44
|
+
};
|
|
45
|
+
if (event) {
|
|
46
|
+
toParams.success = function (result) {
|
|
47
|
+
return result.eventChannel.emit(event.name, event.params);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
navigateTo(toParams);
|
|
51
|
+
};
|