@cloudbase/weda-ui 3.1.0 → 3.1.3
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/dist/asset-manifest.json +17 -0
- package/dist/configs/actions/showModal.json +48 -0
- package/dist/configs/actions/showToast.json +41 -0
- package/dist/configs/components/auth.json +16 -0
- package/dist/configs/components/button.json +239 -0
- package/dist/configs/components/calendar.json +81 -0
- package/dist/configs/components/carousel.json +292 -0
- package/dist/configs/components/chart/bar.json +721 -0
- package/dist/configs/components/chart/line.json +674 -0
- package/dist/configs/components/chart/pie.json +494 -0
- package/dist/configs/components/chart/statisticsCard.json +376 -0
- package/dist/configs/components/container.json +50 -0
- package/dist/configs/components/dataView.json +239 -0
- package/dist/configs/components/drawer.json +115 -0
- package/dist/configs/components/form/checkbox.json +178 -0
- package/dist/configs/components/form/form.json +45 -0
- package/dist/configs/components/form/input.json +154 -0
- package/dist/configs/components/form/location.json +216 -0
- package/dist/configs/components/form/radio.json +203 -0
- package/dist/configs/components/form/richText.json +125 -0
- package/dist/configs/components/form/select.json +430 -0
- package/dist/configs/components/form/switch.json +58 -0
- package/dist/configs/components/form/textarea.json +116 -0
- package/dist/configs/components/form/tips.json +34 -0
- package/dist/configs/components/form/uploader.json +171 -0
- package/dist/configs/components/form/uploaderFile.json +158 -0
- package/dist/configs/components/graphicCard.json +413 -0
- package/dist/configs/components/image.json +187 -0
- package/dist/configs/components/link.json +79 -0
- package/dist/configs/components/listView.json +370 -0
- package/dist/configs/components/lottery.json +163 -0
- package/dist/configs/components/modal.json +72 -0
- package/dist/configs/components/navLayout.json +368 -0
- package/dist/configs/components/navigationBar.json +62 -0
- package/dist/configs/components/richtextview.json +26 -0
- package/dist/configs/components/scrollVeiw.json +253 -0
- package/dist/configs/components/slot.json +17 -0
- package/dist/configs/components/swiper.json +90 -0
- package/dist/configs/components/tabs.json +121 -0
- package/dist/configs/components/text.json +95 -0
- package/dist/configs/components/wedaVideo.json +89 -0
- package/dist/configs/components/wxOpenApi/phone.json +127 -0
- package/dist/configs/components/wxOpenApi/phoneCode.json +109 -0
- package/dist/configs/components/wxOpenApi/share.json +157 -0
- package/dist/configs/components/wxOpenApi/userInfo.json +156 -0
- package/dist/configs/index.d.ts +97 -0
- package/dist/configs/index.js +105 -0
- package/dist/docs/common/format.d.ts +13 -0
- package/dist/docs/common/format.js +103 -0
- package/dist/docs/common/tableView.d.ts +30 -0
- package/dist/docs/common/tableView.js +159 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.html +88 -0
- package/dist/index.js +3 -0
- package/dist/setupTests.d.ts +1 -0
- package/dist/setupTests.js +14 -0
- package/dist/static/js/bundle.js +963 -0
- package/dist/static/js/bundle.js.map +1 -0
- package/dist/static/js/main.chunk.js +8841 -0
- package/dist/static/js/main.chunk.js.map +1 -0
- package/dist/static/js/vendors~main.chunk.js +247885 -0
- package/dist/static/js/vendors~main.chunk.js.map +1 -0
- package/dist/static/media/ef6fa527e24e354765d806b826b41391.fa67580a.svg +627 -0
- package/dist/web/actions/index.d.ts +2 -0
- package/dist/web/actions/index.js +2 -0
- package/dist/web/actions/showModal/index.d.ts +3 -0
- package/dist/web/actions/showModal/index.js +66 -0
- package/dist/web/actions/showToast/index.d.ts +1 -0
- package/dist/web/actions/showToast/index.js +3 -0
- package/dist/web/components/auth/index.d.ts +10 -0
- package/dist/web/components/auth/index.js +37 -0
- package/dist/web/components/button/index.css +27 -0
- package/dist/web/components/button/index.d.ts +32 -0
- package/dist/web/components/button/index.js +48 -0
- package/dist/web/components/calendar/index.css +416 -0
- package/dist/web/components/calendar/index.d.ts +19 -0
- package/dist/web/components/calendar/index.js +181 -0
- package/dist/web/components/calendar/util.d.ts +13 -0
- package/dist/web/components/calendar/util.js +74 -0
- package/dist/web/components/carousel/index.css +119 -0
- package/dist/web/components/carousel/index.d.ts +41 -0
- package/dist/web/components/carousel/index.js +240 -0
- package/dist/web/components/chart/bar/index.d.ts +41 -0
- package/dist/web/components/chart/bar/index.js +56 -0
- package/dist/web/components/chart/common/config/bar.d.ts +48 -0
- package/dist/web/components/chart/common/config/bar.js +49 -0
- package/dist/web/components/chart/common/config/global.d.ts +13 -0
- package/dist/web/components/chart/common/config/global.js +16 -0
- package/dist/web/components/chart/common/config/line.d.ts +46 -0
- package/dist/web/components/chart/common/config/line.js +49 -0
- package/dist/web/components/chart/common/config/pie.d.ts +29 -0
- package/dist/web/components/chart/common/config/pie.js +36 -0
- package/dist/web/components/chart/common/core/eChartBar.d.ts +68 -0
- package/dist/web/components/chart/common/core/eChartBar.js +196 -0
- package/dist/web/components/chart/common/core/eChartBase.d.ts +128 -0
- package/dist/web/components/chart/common/core/eChartBase.js +346 -0
- package/dist/web/components/chart/common/core/eChartLine.d.ts +62 -0
- package/dist/web/components/chart/common/core/eChartLine.js +168 -0
- package/dist/web/components/chart/common/core/eChartPie.d.ts +50 -0
- package/dist/web/components/chart/common/core/eChartPie.js +132 -0
- package/dist/web/components/chart/common/core/type.d.ts +35 -0
- package/dist/web/components/chart/common/core/type.js +9 -0
- package/dist/web/components/chart/common/echarts.d.ts +2 -0
- package/dist/web/components/chart/common/echarts.js +24 -0
- package/dist/web/components/chart/common/useChart.d.ts +8 -0
- package/dist/web/components/chart/common/useChart.js +60 -0
- package/dist/web/components/chart/line/index.d.ts +39 -0
- package/dist/web/components/chart/line/index.js +53 -0
- package/dist/web/components/chart/pie/index.d.ts +27 -0
- package/dist/web/components/chart/pie/index.js +40 -0
- package/dist/web/components/chart/statisticsCard/index.css +63 -0
- package/dist/web/components/chart/statisticsCard/index.d.ts +85 -0
- package/dist/web/components/chart/statisticsCard/index.js +203 -0
- package/dist/web/components/chart/statisticsCard/interface.d.ts +13 -0
- package/dist/web/components/chart/statisticsCard/interface.js +1 -0
- package/dist/web/components/container/index.d.ts +6 -0
- package/dist/web/components/container/index.js +6 -0
- package/dist/web/components/dataView/index.d.ts +6 -0
- package/dist/web/components/dataView/index.js +8 -0
- package/dist/web/components/dataView/interface.d.ts +5 -0
- package/dist/web/components/dataView/interface.js +1 -0
- package/dist/web/components/drawer/index.d.ts +13 -0
- package/dist/web/components/drawer/index.js +12 -0
- package/dist/web/components/form/checkbox/index.d.ts +13 -0
- package/dist/web/components/form/checkbox/index.js +167 -0
- package/dist/web/components/form/enumSelect/MultipleSelect.d.ts +78 -0
- package/dist/web/components/form/enumSelect/MultipleSelect.js +52 -0
- package/dist/web/components/form/enumSelect/NormalSelect.d.ts +83 -0
- package/dist/web/components/form/enumSelect/NormalSelect.js +52 -0
- package/dist/web/components/form/enumSelect/SelectContainer.d.ts +16 -0
- package/dist/web/components/form/enumSelect/SelectContainer.js +30 -0
- package/dist/web/components/form/enumSelect/index.d.ts +82 -0
- package/dist/web/components/form/enumSelect/index.js +6 -0
- package/dist/web/components/form/enumSelect/props/defaultProps.d.ts +34 -0
- package/dist/web/components/form/enumSelect/props/defaultProps.js +40 -0
- package/dist/web/components/form/enumSelect/props/propsTypes.d.ts +39 -0
- package/dist/web/components/form/enumSelect/props/propsTypes.js +47 -0
- package/dist/web/components/form/form/index.css +9 -0
- package/dist/web/components/form/form/index.d.ts +13 -0
- package/dist/web/components/form/form/index.js +31 -0
- package/dist/web/components/form/formcell/index.css +85 -0
- package/dist/web/components/form/formcell/index.d.ts +8 -0
- package/dist/web/components/form/formcell/index.js +40 -0
- package/dist/web/components/form/input/index.css +40 -0
- package/dist/web/components/form/input/index.d.ts +14 -0
- package/dist/web/components/form/input/index.js +86 -0
- package/dist/web/components/form/location/common/mapChoose.css +477 -0
- package/dist/web/components/form/location/common/mapChoose.d.ts +15 -0
- package/dist/web/components/form/location/common/mapChoose.js +435 -0
- package/dist/web/components/form/location/common/mapView.d.ts +19 -0
- package/dist/web/components/form/location/common/mapView.js +170 -0
- package/dist/web/components/form/location/common/propsConfig.d.ts +59 -0
- package/dist/web/components/form/location/common/propsConfig.js +50 -0
- package/dist/web/components/form/location/common/selectModal.css +45 -0
- package/dist/web/components/form/location/common/selectModal.d.ts +21 -0
- package/dist/web/components/form/location/common/selectModal.js +44 -0
- package/dist/web/components/form/location/common/useLocationInfo.d.ts +36 -0
- package/dist/web/components/form/location/common/useLocationInfo.js +104 -0
- package/dist/web/components/form/location/components/LocationH5/index.css +100 -0
- package/dist/web/components/form/location/components/LocationH5/location.h5.d.ts +8 -0
- package/dist/web/components/form/location/components/LocationH5/location.h5.js +323 -0
- package/dist/web/components/form/location/components/LocationPC/Header.d.ts +12 -0
- package/dist/web/components/form/location/components/LocationPC/Header.js +43 -0
- package/dist/web/components/form/location/components/LocationPC/index.css +40 -0
- package/dist/web/components/form/location/components/LocationPC/location.PC.d.ts +8 -0
- package/dist/web/components/form/location/components/LocationPC/location.PC.js +224 -0
- package/dist/web/components/form/location/constants.d.ts +2 -0
- package/dist/web/components/form/location/constants.js +3 -0
- package/dist/web/components/form/location/index.css +13 -0
- package/dist/web/components/form/location/index.d.ts +1 -0
- package/dist/web/components/form/location/index.js +17 -0
- package/dist/web/components/form/radio/index.css +12 -0
- package/dist/web/components/form/radio/index.d.ts +11 -0
- package/dist/web/components/form/radio/index.js +115 -0
- package/dist/web/components/form/renderDecorator.d.ts +6 -0
- package/dist/web/components/form/renderDecorator.js +20 -0
- package/dist/web/components/form/select/h5.d.ts +16 -0
- package/dist/web/components/form/select/h5.js +504 -0
- package/dist/web/components/form/select/index.css +27 -0
- package/dist/web/components/form/select/index.d.ts +65 -0
- package/dist/web/components/form/select/index.js +301 -0
- package/dist/web/components/form/select/region/index.d.ts +6 -0
- package/dist/web/components/form/select/region/index.js +147 -0
- package/dist/web/components/form/select/time.d.ts +9 -0
- package/dist/web/components/form/select/time.js +146 -0
- package/dist/web/components/form/select/year.d.ts +7 -0
- package/dist/web/components/form/select/year.js +72 -0
- package/dist/web/components/form/switch/index.d.ts +6 -0
- package/dist/web/components/form/switch/index.js +57 -0
- package/dist/web/components/form/textarea/index.css +11 -0
- package/dist/web/components/form/textarea/index.d.ts +12 -0
- package/dist/web/components/form/textarea/index.js +66 -0
- package/dist/web/components/form/tips/index.css +4 -0
- package/dist/web/components/form/tips/index.d.ts +8 -0
- package/dist/web/components/form/tips/index.js +17 -0
- package/dist/web/components/form/uploader/index.css +118 -0
- package/dist/web/components/form/uploader/index.d.ts +3 -0
- package/dist/web/components/form/uploader/index.js +42 -0
- package/dist/web/components/form/uploader/uploader.h5.d.ts +19 -0
- package/dist/web/components/form/uploader/uploader.h5.js +201 -0
- package/dist/web/components/form/uploader/uploader.pc.d.ts +29 -0
- package/dist/web/components/form/uploader/uploader.pc.js +182 -0
- package/dist/web/components/form/uploaderFile/index.css +422 -0
- package/dist/web/components/form/uploaderFile/index.d.ts +4 -0
- package/dist/web/components/form/uploaderFile/index.js +19 -0
- package/dist/web/components/form/uploaderFile/uploadFile.h5.d.ts +23 -0
- package/dist/web/components/form/uploaderFile/uploadFile.h5.js +315 -0
- package/dist/web/components/form/uploaderFile/uploadFile.pc.d.ts +24 -0
- package/dist/web/components/form/uploaderFile/uploadFile.pc.js +290 -0
- package/dist/web/components/graphicCard/index.css +159 -0
- package/dist/web/components/graphicCard/index.d.ts +31 -0
- package/dist/web/components/graphicCard/index.js +166 -0
- package/dist/web/components/image/image.d.ts +9 -0
- package/dist/web/components/image/image.js +119 -0
- package/dist/web/components/image/index.css +54 -0
- package/dist/web/components/image/index.d.ts +13 -0
- package/dist/web/components/image/index.js +91 -0
- package/dist/web/components/index.d.ts +47 -0
- package/dist/web/components/index.js +94 -0
- package/dist/web/components/link/index.css +8 -0
- package/dist/web/components/link/index.d.ts +24 -0
- package/dist/web/components/link/index.js +71 -0
- package/dist/web/components/listView/index.css +143 -0
- package/dist/web/components/listView/index.d.ts +7 -0
- package/dist/web/components/listView/index.js +262 -0
- package/dist/web/components/listView/interface.d.ts +122 -0
- package/dist/web/components/listView/interface.js +1 -0
- package/dist/web/components/lottery/index.css +359 -0
- package/dist/web/components/lottery/index.d.ts +22 -0
- package/dist/web/components/lottery/index.js +390 -0
- package/dist/web/components/lottery/lotteryUtil.d.ts +23 -0
- package/dist/web/components/lottery/lotteryUtil.js +180 -0
- package/dist/web/components/modal/h5.css +53 -0
- package/dist/web/components/modal/index.d.ts +17 -0
- package/dist/web/components/modal/index.js +11 -0
- package/dist/web/components/modal/modal.h5.d.ts +4 -0
- package/dist/web/components/modal/modal.h5.js +46 -0
- package/dist/web/components/modal/modal.pc.d.ts +3 -0
- package/dist/web/components/modal/modal.pc.js +31 -0
- package/dist/web/components/navLayout/index.css +332 -0
- package/dist/web/components/navLayout/index.d.ts +46 -0
- package/dist/web/components/navLayout/index.js +116 -0
- package/dist/web/components/navigationBar/common.d.ts +15 -0
- package/dist/web/components/navigationBar/common.js +127 -0
- package/dist/web/components/navigationBar/h5Menu.d.ts +14 -0
- package/dist/web/components/navigationBar/h5Menu.js +72 -0
- package/dist/web/components/navigationBar/horizontalMenu.d.ts +12 -0
- package/dist/web/components/navigationBar/horizontalMenu.js +99 -0
- package/dist/web/components/navigationBar/index.css +762 -0
- package/dist/web/components/navigationBar/index.d.ts +13 -0
- package/dist/web/components/navigationBar/index.js +157 -0
- package/dist/web/components/navigationBar/verticalMenu.d.ts +13 -0
- package/dist/web/components/navigationBar/verticalMenu.js +38 -0
- package/dist/web/components/phone/index.d.ts +18 -0
- package/dist/web/components/phone/index.js +4 -0
- package/dist/web/components/phoneCode/index.d.ts +18 -0
- package/dist/web/components/phoneCode/index.js +4 -0
- package/dist/web/components/picker/datePicker.d.ts +10 -0
- package/dist/web/components/picker/datePicker.js +31 -0
- package/dist/web/components/picker/picker.d.ts +6 -0
- package/dist/web/components/picker/picker.js +45 -0
- package/dist/web/components/picker/timePicker.d.ts +7 -0
- package/dist/web/components/picker/timePicker.js +42 -0
- package/dist/web/components/richText/const.d.ts +1 -0
- package/dist/web/components/richText/const.js +2 -0
- package/dist/web/components/richText/index.css +93 -0
- package/dist/web/components/richText/index.d.ts +51 -0
- package/dist/web/components/richText/index.js +298 -0
- package/dist/web/components/richTextView/index.css +63 -0
- package/dist/web/components/richTextView/index.d.ts +7 -0
- package/dist/web/components/richTextView/index.js +44 -0
- package/dist/web/components/scrollView/index.d.ts +27 -0
- package/dist/web/components/scrollView/index.js +95 -0
- package/dist/web/components/share/index.d.ts +34 -0
- package/dist/web/components/share/index.js +4 -0
- package/dist/web/components/slot/index.d.ts +6 -0
- package/dist/web/components/slot/index.js +9 -0
- package/dist/web/components/swiper/index.css +106 -0
- package/dist/web/components/swiper/index.d.ts +24 -0
- package/dist/web/components/swiper/index.js +149 -0
- package/dist/web/components/tabs/index.css +64 -0
- package/dist/web/components/tabs/index.d.ts +13 -0
- package/dist/web/components/tabs/index.js +15 -0
- package/dist/web/components/tabs/tabs.h5.d.ts +4 -0
- package/dist/web/components/tabs/tabs.h5.js +42 -0
- package/dist/web/components/tabs/tabs.pc.d.ts +3 -0
- package/dist/web/components/tabs/tabs.pc.js +40 -0
- package/dist/web/components/text/index.css +26 -0
- package/dist/web/components/text/index.d.ts +14 -0
- package/dist/web/components/text/index.js +17 -0
- package/dist/web/components/uploaderFileView/index.css +11 -0
- package/dist/web/components/uploaderFileView/index.d.ts +10 -0
- package/dist/web/components/uploaderFileView/index.js +61 -0
- package/dist/web/components/uploaderView/index.css +31 -0
- package/dist/web/components/uploaderView/index.d.ts +17 -0
- package/dist/web/components/uploaderView/index.js +48 -0
- package/dist/web/components/userInfo/index.d.ts +26 -0
- package/dist/web/components/userInfo/index.js +4 -0
- package/dist/web/components/wedaVideo/index.css +42 -0
- package/dist/web/components/wedaVideo/index.d.ts +17 -0
- package/dist/web/components/wedaVideo/index.js +159 -0
- package/dist/web/index.d.ts +8 -0
- package/dist/web/index.js +4 -0
- package/dist/web/utils/classnames.d.ts +2 -0
- package/dist/web/utils/classnames.js +37 -0
- package/dist/web/utils/constant.d.ts +23 -0
- package/dist/web/utils/constant.js +24 -0
- package/dist/web/utils/debounce.d.ts +2 -0
- package/dist/web/utils/debounce.js +92 -0
- package/dist/web/utils/events.d.ts +1 -0
- package/dist/web/utils/events.js +2 -0
- package/dist/web/utils/getLocalCounter.d.ts +1 -0
- package/dist/web/utils/getLocalCounter.js +4 -0
- package/dist/web/utils/isObjectEqual.d.ts +2 -0
- package/dist/web/utils/isObjectEqual.js +12 -0
- package/dist/web/utils/loading-fallback.d.ts +2 -0
- package/dist/web/utils/loading-fallback.js +2 -0
- package/dist/web/utils/lodash.d.ts +1 -0
- package/dist/web/utils/lodash.js +2 -0
- package/dist/web/utils/platform.d.ts +18 -0
- package/dist/web/utils/platform.js +191 -0
- package/dist/web/utils/tcb.d.ts +23 -0
- package/dist/web/utils/tcb.js +82 -0
- package/dist/web/utils/tmap.d.ts +3 -0
- package/dist/web/utils/tmap.js +21 -0
- package/dist/web/utils/useSetState.d.ts +1 -0
- package/dist/web/utils/useSetState.js +8 -0
- package/dist/web/utils/useSyncValue.d.ts +4 -0
- package/dist/web/utils/useSyncValue.js +15 -0
- package/dist/web/utils/weui.d.ts +1 -0
- package/dist/web/utils/weui.js +2 -0
- package/dist/web/weda-ui.css +90 -0
- package/package.json +12 -12
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
/* eslint-disable react/jsx-key */
|
|
2
|
+
import React, { useState, useEffect, useCallback, useImperativeHandle, } from 'react';
|
|
3
|
+
import { usePlatform } from '../../utils/platform';
|
|
4
|
+
import classNames from '../../utils/classnames';
|
|
5
|
+
import './index.css';
|
|
6
|
+
import { ConfigProvider } from 'tea-component';
|
|
7
|
+
import LotteryAction from './lotteryUtil';
|
|
8
|
+
const CLASS_PREFIX = 'weda-lottery';
|
|
9
|
+
const lotteryAction = new LotteryAction();
|
|
10
|
+
export default React.forwardRef(function Lottery({ className, id, style, prizeList, enablePrize, prizeResult, events }, ref) {
|
|
11
|
+
const platform = usePlatform();
|
|
12
|
+
const [activedId, setActivedId] = useState(-1);
|
|
13
|
+
const [isStartLottery, setIsStartLottery] = useState(false);
|
|
14
|
+
const [lotteryList, setLotteryList] = useState([]);
|
|
15
|
+
const [btnActived, setBtnActived] = useState(false);
|
|
16
|
+
//获取初始化默认数据,数据不足8条设置默认,超过8条获取前8条
|
|
17
|
+
const lotteryListDefault = () => {
|
|
18
|
+
const list = [];
|
|
19
|
+
if (prizeList == null) {
|
|
20
|
+
return list;
|
|
21
|
+
}
|
|
22
|
+
for (let i = 0; i < 8; i++) {
|
|
23
|
+
if (i < prizeList.length) {
|
|
24
|
+
const prize = prizeList[i];
|
|
25
|
+
list.push({
|
|
26
|
+
idx: i + 1,
|
|
27
|
+
selected: false,
|
|
28
|
+
desc: prize.title,
|
|
29
|
+
src: prize.image,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
list.push({
|
|
34
|
+
idx: i + 1,
|
|
35
|
+
selected: false,
|
|
36
|
+
desc: '',
|
|
37
|
+
src: '',
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return list;
|
|
42
|
+
};
|
|
43
|
+
const startLottery = useCallback(() => {
|
|
44
|
+
setLotteryList(lotteryListDefault());
|
|
45
|
+
setBtnActived(true);
|
|
46
|
+
if (lotteryAction.isStart)
|
|
47
|
+
return;
|
|
48
|
+
events === null || events === void 0 ? void 0 : events.clickLotteryButton();
|
|
49
|
+
setIsStartLottery(true);
|
|
50
|
+
}, [
|
|
51
|
+
lotteryAction.isStart,
|
|
52
|
+
setIsStartLottery,
|
|
53
|
+
setBtnActived,
|
|
54
|
+
lotteryListDefault,
|
|
55
|
+
setLotteryList,
|
|
56
|
+
]);
|
|
57
|
+
useImperativeHandle(ref, () => {
|
|
58
|
+
return {
|
|
59
|
+
methods: {
|
|
60
|
+
start: startLottery,
|
|
61
|
+
},
|
|
62
|
+
};
|
|
63
|
+
}, [startLottery]);
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
setLotteryList(lotteryListDefault());
|
|
66
|
+
}, [prizeList]);
|
|
67
|
+
useEffect(() => {
|
|
68
|
+
lotteryAction.animationCallback = ({ idx, isEnd }) => {
|
|
69
|
+
setActivedId(idx == -1 ? 0 : idx);
|
|
70
|
+
if (isEnd) {
|
|
71
|
+
setBtnActived(false);
|
|
72
|
+
const list = lotteryList.map((item, index) => {
|
|
73
|
+
if (index === idx - 1) {
|
|
74
|
+
item.selected = true;
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
item.selected = false;
|
|
78
|
+
}
|
|
79
|
+
return item;
|
|
80
|
+
});
|
|
81
|
+
setLotteryList(list);
|
|
82
|
+
setActivedId(-1);
|
|
83
|
+
setTimeout(() => {
|
|
84
|
+
events.finishLottery({
|
|
85
|
+
prize: idx,
|
|
86
|
+
result: list[idx - 1],
|
|
87
|
+
});
|
|
88
|
+
//延迟700毫秒显示的视觉效果更好,否则看不清结果就弹出dialog盖住了
|
|
89
|
+
}, 700);
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
}, [lotteryList]);
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
// 当满足开启抽奖条件并且点击了开奖开关时,启用抽奖
|
|
95
|
+
if (enablePrize && isStartLottery) {
|
|
96
|
+
lotteryAction.start(prizeResult, () => {
|
|
97
|
+
window.app.showToast({
|
|
98
|
+
title: '网络异常',
|
|
99
|
+
icon: 'none',
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
// 当不选取变量作为结果的时候,按照设置给定结果
|
|
103
|
+
lotteryAction.end(prizeResult);
|
|
104
|
+
setIsStartLottery(false);
|
|
105
|
+
}
|
|
106
|
+
else if (!enablePrize) {
|
|
107
|
+
//立马停止抽奖
|
|
108
|
+
lotteryAction.stop();
|
|
109
|
+
}
|
|
110
|
+
}, [isStartLottery, enablePrize]);
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
// 设置抽奖结果
|
|
113
|
+
lotteryAction.end(prizeResult);
|
|
114
|
+
}, [prizeResult]);
|
|
115
|
+
const [widthRatio, setWidthRatio] = useState(1);
|
|
116
|
+
const [heightRatio, setHeightRatio] = useState(1);
|
|
117
|
+
// 上下5个球的宽度
|
|
118
|
+
const [dotWidth, setDotWidth] = useState(217 / 14);
|
|
119
|
+
// 左右5个球的高度
|
|
120
|
+
const [dotHeight, setDotHeight] = useState(217 / 14);
|
|
121
|
+
const standardWidth = 326;
|
|
122
|
+
const standardHeight = 326;
|
|
123
|
+
const cls = classNames({
|
|
124
|
+
[CLASS_PREFIX]: true,
|
|
125
|
+
[className]: className,
|
|
126
|
+
[`${CLASS_PREFIX}-mobile`]: platform === 'h5',
|
|
127
|
+
});
|
|
128
|
+
// 将获取的style 转化为 px, 用户输入的单位可能有(纯数字,px, rem, %, rpx)
|
|
129
|
+
// 注: 前端输入宽高,不带单位和带rem单位,code 中获取的都是rem 单位,也就是输入1304,输出‘46.5714rem’; 输入‘1304rem’, 输出‘1304rem’, 所以rem目前不支持正常的比列
|
|
130
|
+
// 带上px单位和不带单位,输出的都是rem,且转化的值一样的,所以不需要特殊处理,也就是 输入 1304 和 1304px ,前端拿到的都是‘46.5714rem’
|
|
131
|
+
// rpx 是小程序的单位,并且在pc 上加病没作用,所以rpx 不处理
|
|
132
|
+
// % 暂时也不处理,因为不确定用户的百分比是以什么为标准的
|
|
133
|
+
const getStyleUnit = (targetValue) => {
|
|
134
|
+
if (!targetValue)
|
|
135
|
+
return -1;
|
|
136
|
+
const value = targetValue.toString();
|
|
137
|
+
// 获取单位
|
|
138
|
+
const fotData = value.match(/^\d+(?:\.\d+)?([a-zA-Z%]+)?$/);
|
|
139
|
+
let unit = 'rem';
|
|
140
|
+
if (fotData && fotData[1]) {
|
|
141
|
+
unit = fotData[1];
|
|
142
|
+
}
|
|
143
|
+
return unit;
|
|
144
|
+
};
|
|
145
|
+
const getRatio = (value, unit) => {
|
|
146
|
+
let actualValue;
|
|
147
|
+
if (unit.toString() === 'rem') {
|
|
148
|
+
actualValue = value * 14 * 2;
|
|
149
|
+
}
|
|
150
|
+
return actualValue;
|
|
151
|
+
};
|
|
152
|
+
// 通过页面配置拿到用户设置的宽,高,直接获取的宽和高,会被转化为rem, 需要将rem 转为 px. 规则: e/2/14
|
|
153
|
+
// css 输出的px到页面rem, 转化规则为: e/14
|
|
154
|
+
useEffect(() => {
|
|
155
|
+
if (!style || style == undefined || platform === 'h5') {
|
|
156
|
+
setWidthRatio(1);
|
|
157
|
+
setDotWidth(217 / 14);
|
|
158
|
+
setHeightRatio(1);
|
|
159
|
+
setDotHeight(217 / 14);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (style && style !== undefined) {
|
|
163
|
+
// 如果宽和高不存在,则还远吗比例为默认值-1,也就是保持视觉稿默认的宽和高
|
|
164
|
+
if (!style.width) {
|
|
165
|
+
setWidthRatio(1);
|
|
166
|
+
setDotWidth(217 / 14);
|
|
167
|
+
}
|
|
168
|
+
if (!style.height) {
|
|
169
|
+
setHeightRatio(1);
|
|
170
|
+
setDotHeight(217 / 14);
|
|
171
|
+
}
|
|
172
|
+
if (style.width) {
|
|
173
|
+
// 现将获取的rem 转化为px
|
|
174
|
+
const actualValue = getRatio(parseFloat(style.width.toString()), getStyleUnit(style.width));
|
|
175
|
+
// setWidthRatio();
|
|
176
|
+
const setValue = Math.floor((actualValue / (standardWidth * 2)) * 1000) / 1000;
|
|
177
|
+
setWidthRatio(setValue);
|
|
178
|
+
const dotWidth = (setValue * 43 * 4 + setValue * 9 * 5) / 14;
|
|
179
|
+
setDotWidth(dotWidth);
|
|
180
|
+
}
|
|
181
|
+
if (style.height) {
|
|
182
|
+
// 现将获取的rem 转化为px
|
|
183
|
+
const actualValue = getRatio(parseFloat(style.height.toString()), getStyleUnit(style.height));
|
|
184
|
+
const setValue = Math.floor((actualValue / (standardHeight * 2)) * 1000) / 1000;
|
|
185
|
+
setHeightRatio(setValue);
|
|
186
|
+
const dotHeight = (setValue * 43 * 4 + setValue * 9 * 5) / 14;
|
|
187
|
+
setDotHeight(dotHeight);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}, [style]);
|
|
191
|
+
const renderDot = (direction, list) => {
|
|
192
|
+
return (React.createElement(React.Fragment, null,
|
|
193
|
+
React.createElement("div", { className: classNames(`${CLASS_PREFIX}__dot`, `${CLASS_PREFIX}__dot-${direction}`) }, list.map((item, index) => {
|
|
194
|
+
return (React.createElement("div", { key: index, className: `${CLASS_PREFIX}__dot-item`, style: {
|
|
195
|
+
width: `${(9 * widthRatio) / 14}rem`,
|
|
196
|
+
height: `${(9 * heightRatio) / 14}rem`,
|
|
197
|
+
marginBottom: `${direction}` === 'vertical'
|
|
198
|
+
? `${(43 * heightRatio) / 14}rem`
|
|
199
|
+
: '0',
|
|
200
|
+
marginRight: `${direction}` === 'horizontal'
|
|
201
|
+
? `${(43 * widthRatio) / 14}rem`
|
|
202
|
+
: '0',
|
|
203
|
+
} }));
|
|
204
|
+
}))));
|
|
205
|
+
};
|
|
206
|
+
const dotList = [
|
|
207
|
+
{
|
|
208
|
+
single: true,
|
|
209
|
+
position: 'left-top',
|
|
210
|
+
direction: '',
|
|
211
|
+
list: [],
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
single: true,
|
|
215
|
+
position: 'left-bottom',
|
|
216
|
+
direction: '',
|
|
217
|
+
list: [],
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
single: true,
|
|
221
|
+
position: 'right-top',
|
|
222
|
+
direction: '',
|
|
223
|
+
list: [],
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
single: true,
|
|
227
|
+
position: 'right-bottom',
|
|
228
|
+
direction: '',
|
|
229
|
+
list: [],
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
single: false,
|
|
233
|
+
position: 'top',
|
|
234
|
+
direction: 'horizontal',
|
|
235
|
+
list: ['1', '2', '3', '4', '5'],
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
single: false,
|
|
239
|
+
position: 'bottom',
|
|
240
|
+
direction: 'horizontal',
|
|
241
|
+
list: ['1', '2', '3', '4', '5'],
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
single: false,
|
|
245
|
+
position: 'left',
|
|
246
|
+
direction: 'vertical',
|
|
247
|
+
list: ['1', '2', '3', '4', '5'],
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
single: false,
|
|
251
|
+
position: 'right',
|
|
252
|
+
direction: 'vertical',
|
|
253
|
+
list: ['1', '2', '3', '4', '5'],
|
|
254
|
+
},
|
|
255
|
+
];
|
|
256
|
+
return (React.createElement(ConfigProvider, { classPrefix: "wedatea2td" },
|
|
257
|
+
React.createElement("div", { className: "body", key: "lottery", "data-testid": "lottery" },
|
|
258
|
+
React.createElement("div", { className: cls, id: id, style: style },
|
|
259
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__wrap` },
|
|
260
|
+
dotList.map((dot, index) => {
|
|
261
|
+
return (React.createElement("div", { key: index },
|
|
262
|
+
dot.single && (React.createElement("div", { key: `${dot.direction}-${index}`, className: classNames(`${CLASS_PREFIX}__dot-single`, `${CLASS_PREFIX}__dot-${dot.position}`), style: {
|
|
263
|
+
width: `${(9 * widthRatio) / 14}rem`,
|
|
264
|
+
height: `${(9 * heightRatio) / 14}rem`,
|
|
265
|
+
top: `${dot.position}` === 'left-top' ||
|
|
266
|
+
`${dot.position}` === 'right-top'
|
|
267
|
+
? `${(9 * heightRatio) / 14}rem`
|
|
268
|
+
: '',
|
|
269
|
+
bottom: `${dot.position}` === 'left-bottom' ||
|
|
270
|
+
`${dot.position}` === 'right-bottom'
|
|
271
|
+
? `${(9 * heightRatio) / 14}rem`
|
|
272
|
+
: '',
|
|
273
|
+
left: `${dot.position}` === 'left-top' ||
|
|
274
|
+
`${dot.position}` === 'left-bottom'
|
|
275
|
+
? `${(6 * widthRatio) / 14}rem`
|
|
276
|
+
: '',
|
|
277
|
+
right: `${dot.position}` === 'right-top' ||
|
|
278
|
+
`${dot.position}` === 'right-bottom'
|
|
279
|
+
? `${(6 * widthRatio) / 14}rem`
|
|
280
|
+
: '',
|
|
281
|
+
} })),
|
|
282
|
+
!dot.single && (React.createElement("div", { key: `${dot.direction}-${index}`, className: `${CLASS_PREFIX}__dot-${dot.position}`, style: {
|
|
283
|
+
left: `${dot.position}` === 'top' ||
|
|
284
|
+
`${dot.position}` === 'bottom'
|
|
285
|
+
? `calc((${'100%'} - ${dotWidth}rem) / 2)`
|
|
286
|
+
: `${dot.position}` === 'left'
|
|
287
|
+
? `${(widthRatio * 18 - widthRatio * 9) / 2 / 14}rem`
|
|
288
|
+
: '',
|
|
289
|
+
top: `${dot.position}` === 'left' ||
|
|
290
|
+
`${dot.position}` === 'right'
|
|
291
|
+
? `calc((100% - ${dotHeight}rem) / 2)`
|
|
292
|
+
: `${dot.position}` === 'top'
|
|
293
|
+
? `${(heightRatio * 18 - heightRatio * 9) / 2 / 14}rem`
|
|
294
|
+
: '',
|
|
295
|
+
bottom: `${dot.position}` === 'bottom'
|
|
296
|
+
? `${(heightRatio * 18 - heightRatio * 9) / 2 / 14}rem`
|
|
297
|
+
: '',
|
|
298
|
+
right: `${dot.position}` === 'right'
|
|
299
|
+
? `${(widthRatio * 18 - widthRatio * 9) / 2 / 14}rem`
|
|
300
|
+
: '',
|
|
301
|
+
} }, true && renderDot(dot.direction, dot.list)))));
|
|
302
|
+
}),
|
|
303
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__inner`, style: {
|
|
304
|
+
paddingTop: `${(18 * heightRatio) / 14}rem`,
|
|
305
|
+
paddingBottom: `${(18 * heightRatio) / 14}rem`,
|
|
306
|
+
paddingLeft: `${(18 * widthRatio) / 14}rem`,
|
|
307
|
+
paddingRight: `${(18 * widthRatio) / 14}rem`,
|
|
308
|
+
} },
|
|
309
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__inner-wrap` },
|
|
310
|
+
React.createElement("ul", { className: `${CLASS_PREFIX}__list` }, lotteryList.map((item, index) => {
|
|
311
|
+
return (React.createElement("li", { "data-testid": "lottery-item", key: index, className: classNames(`${CLASS_PREFIX}__turntable-item`, item.idx === activedId ? 'is-actived' : '', item.selected ? 'is-selected' : ''), style: {
|
|
312
|
+
width: `calc((${'100%'} - ${(widthRatio * 8 * 4) / 14}rem) / 3)`,
|
|
313
|
+
height: `calc((${'100%'} - ${(heightRatio * 8 * 4) / 14}rem) / 3)`,
|
|
314
|
+
top: `${index}` == '0' ||
|
|
315
|
+
`${index}` == '1' ||
|
|
316
|
+
`${index}` == '2'
|
|
317
|
+
? `${(heightRatio * 8) / 14}rem`
|
|
318
|
+
: `${index}` == '3'
|
|
319
|
+
? `calc((${'100%'} - ${(heightRatio * 8 * 4) / 14}rem) / 3 + ${(heightRatio * 8 * 2) / 14}rem)`
|
|
320
|
+
: '',
|
|
321
|
+
bottom: `${index}` == '4' ||
|
|
322
|
+
`${index}` == '5' ||
|
|
323
|
+
`${index}` == '6'
|
|
324
|
+
? `${(heightRatio * 8) / 14}rem`
|
|
325
|
+
: `${index}` == '7'
|
|
326
|
+
? `calc((${'100%'} - ${(heightRatio * 8 * 4) / 14}rem) / 3 + ${(heightRatio * 8 * 2) / 14}rem)`
|
|
327
|
+
: '',
|
|
328
|
+
right: `${index}` == '2' ||
|
|
329
|
+
`${index}` == '3' ||
|
|
330
|
+
`${index}` == '4'
|
|
331
|
+
? `${(widthRatio * 8) / 14}rem`
|
|
332
|
+
: '',
|
|
333
|
+
left: `${index}` == '0' ||
|
|
334
|
+
`${index}` == '6' ||
|
|
335
|
+
`${index}` == '7'
|
|
336
|
+
? `${(widthRatio * 8) / 14}rem`
|
|
337
|
+
: `${index}` == '1' || `${index}` == '5'
|
|
338
|
+
? `calc((${'100%'} - ${(widthRatio * 8 * 4) / 14}rem) / 3 + ${(widthRatio * 8 * 2) / 14}rem)`
|
|
339
|
+
: '',
|
|
340
|
+
} },
|
|
341
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__turntable-cell`, style: {
|
|
342
|
+
borderLeftWidth: `${(4 * widthRatio) / 14}rem`,
|
|
343
|
+
borderRightWidth: `${(4 * widthRatio) / 14}rem`,
|
|
344
|
+
borderTopWidth: `${(4 * heightRatio) / 14}rem`,
|
|
345
|
+
borderBottomWidth: `${(4 * heightRatio) / 14}rem`,
|
|
346
|
+
paddingTop: `${(8 * heightRatio) / 14}rem`,
|
|
347
|
+
paddingBottom: `${(8 * heightRatio) / 14}rem`,
|
|
348
|
+
paddingLeft: `${(2 * widthRatio) / 14}rem`,
|
|
349
|
+
paddingRight: `${(2 * widthRatio) / 14}rem`,
|
|
350
|
+
} },
|
|
351
|
+
item.src && (React.createElement("div", { className: `${CLASS_PREFIX}__turntable-cell-image`, style: {
|
|
352
|
+
height: `${(heightRatio * 40) / 14}rem`,
|
|
353
|
+
} },
|
|
354
|
+
React.createElement("img", { src: item.src, alt: item.desc, className: `${CLASS_PREFIX}__turntable-cell-icon`, style: {
|
|
355
|
+
width: `${(widthRatio * 40) / 14}rem`,
|
|
356
|
+
height: `${(heightRatio * 40) / 14}rem`,
|
|
357
|
+
} }))),
|
|
358
|
+
item.desc && (React.createElement("div", { className: `${CLASS_PREFIX}__turntable-cell-desc`, style: {
|
|
359
|
+
marginTop: `${(heightRatio * 6) / 14}rem`,
|
|
360
|
+
fontSize: `${(widthRatio * 12) / 14}rem`,
|
|
361
|
+
lineHeight: `${(heightRatio * 17) / 14}rem`,
|
|
362
|
+
} }, item.desc)))));
|
|
363
|
+
})),
|
|
364
|
+
React.createElement("div", { className: classNames(`${CLASS_PREFIX}__turntable-btn`, btnActived ? 'is-actived' : ''), style: {
|
|
365
|
+
width: `calc((${'100%'} - ${(widthRatio * 8 * 4) / 14}rem) / 3)`,
|
|
366
|
+
height: `calc((${'100%'} - ${(heightRatio * 8 * 4) / 14}rem) / 3)`,
|
|
367
|
+
top: `calc((${'100%'} - ${(heightRatio * 8 * 4) / 14}rem) / 3 + ${(heightRatio * 8 * 2) / 14}rem)`,
|
|
368
|
+
left: `calc((${'100%'} - ${(heightRatio * 8 * 4) / 14}rem) / 3 + ${(heightRatio * 8 * 2) / 14}rem)`,
|
|
369
|
+
} },
|
|
370
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__btn-inner`, style: {
|
|
371
|
+
paddingTop: `${(9 * heightRatio) / 14}rem`,
|
|
372
|
+
paddingBottom: `${(9 * heightRatio) / 14}rem`,
|
|
373
|
+
paddingLeft: `${(9 * widthRatio) / 14}rem`,
|
|
374
|
+
paddingRight: `${(9 * widthRatio) / 14}rem`,
|
|
375
|
+
} },
|
|
376
|
+
React.createElement("div", { className: `${CLASS_PREFIX}__btn` },
|
|
377
|
+
React.createElement("a", { "data-testid": "start-lottery", className: `${CLASS_PREFIX}__btn-image`, style: {
|
|
378
|
+
paddingTop: `${(11 * heightRatio) / 14}rem`,
|
|
379
|
+
paddingBottom: `${(11 * heightRatio) / 14}rem`,
|
|
380
|
+
paddingLeft: `${(15 * widthRatio) / 14}rem`,
|
|
381
|
+
paddingRight: `${(15 * widthRatio) / 14}rem`,
|
|
382
|
+
}, onClick: startLottery },
|
|
383
|
+
React.createElement("p", { className: `${CLASS_PREFIX}__btn-text`, style: {
|
|
384
|
+
fontSize: `${(widthRatio * 18) / 14}rem`,
|
|
385
|
+
lineHeight: `${(widthRatio * 22) / 14}rem`,
|
|
386
|
+
} },
|
|
387
|
+
"\u5F00\u59CB",
|
|
388
|
+
React.createElement("br", null),
|
|
389
|
+
"\u62BD\u5956"))))))))))));
|
|
390
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export default class LotteryAction {
|
|
2
|
+
idx: number;
|
|
3
|
+
isStart: boolean;
|
|
4
|
+
endId: any;
|
|
5
|
+
speed: number;
|
|
6
|
+
duration: number;
|
|
7
|
+
maxIdx: number;
|
|
8
|
+
animationCallback: ({ idx, isEnd }: {
|
|
9
|
+
idx: any;
|
|
10
|
+
isEnd: any;
|
|
11
|
+
}) => void;
|
|
12
|
+
isError: boolean;
|
|
13
|
+
isSpeedUp: boolean;
|
|
14
|
+
timeout: number;
|
|
15
|
+
timer: any;
|
|
16
|
+
constructor();
|
|
17
|
+
start(prizeResult: any, errorCallback: any): void;
|
|
18
|
+
end(prizeResult: any): void;
|
|
19
|
+
error(): void;
|
|
20
|
+
stop(): void;
|
|
21
|
+
pointOnCubicBezier(cp: any, t: any): number;
|
|
22
|
+
loop(): void;
|
|
23
|
+
}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
export default class LotteryAction {
|
|
2
|
+
constructor() {
|
|
3
|
+
Object.defineProperty(this, "idx", {
|
|
4
|
+
enumerable: true,
|
|
5
|
+
configurable: true,
|
|
6
|
+
writable: true,
|
|
7
|
+
value: void 0
|
|
8
|
+
});
|
|
9
|
+
// 开始抽奖
|
|
10
|
+
Object.defineProperty(this, "isStart", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true,
|
|
14
|
+
value: void 0
|
|
15
|
+
});
|
|
16
|
+
// 结束位置
|
|
17
|
+
Object.defineProperty(this, "endId", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
configurable: true,
|
|
20
|
+
writable: true,
|
|
21
|
+
value: void 0
|
|
22
|
+
});
|
|
23
|
+
// 抽奖速度
|
|
24
|
+
Object.defineProperty(this, "speed", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
configurable: true,
|
|
27
|
+
writable: true,
|
|
28
|
+
value: void 0
|
|
29
|
+
});
|
|
30
|
+
// 持续时长
|
|
31
|
+
Object.defineProperty(this, "duration", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
configurable: true,
|
|
34
|
+
writable: true,
|
|
35
|
+
value: void 0
|
|
36
|
+
});
|
|
37
|
+
Object.defineProperty(this, "maxIdx", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
configurable: true,
|
|
40
|
+
writable: true,
|
|
41
|
+
value: void 0
|
|
42
|
+
});
|
|
43
|
+
// 回调动作
|
|
44
|
+
Object.defineProperty(this, "animationCallback", {
|
|
45
|
+
enumerable: true,
|
|
46
|
+
configurable: true,
|
|
47
|
+
writable: true,
|
|
48
|
+
value: void 0
|
|
49
|
+
});
|
|
50
|
+
// 是否异常
|
|
51
|
+
Object.defineProperty(this, "isError", {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
configurable: true,
|
|
54
|
+
writable: true,
|
|
55
|
+
value: void 0
|
|
56
|
+
});
|
|
57
|
+
// 是否加速
|
|
58
|
+
Object.defineProperty(this, "isSpeedUp", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
configurable: true,
|
|
61
|
+
writable: true,
|
|
62
|
+
value: void 0
|
|
63
|
+
});
|
|
64
|
+
// 超时时间
|
|
65
|
+
Object.defineProperty(this, "timeout", {
|
|
66
|
+
enumerable: true,
|
|
67
|
+
configurable: true,
|
|
68
|
+
writable: true,
|
|
69
|
+
value: void 0
|
|
70
|
+
});
|
|
71
|
+
Object.defineProperty(this, "timer", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true,
|
|
74
|
+
writable: true,
|
|
75
|
+
value: void 0
|
|
76
|
+
});
|
|
77
|
+
// 当前位置
|
|
78
|
+
this.idx = -1;
|
|
79
|
+
// 开始抽奖
|
|
80
|
+
this.isStart = false;
|
|
81
|
+
// 结束位置
|
|
82
|
+
this.endId = undefined;
|
|
83
|
+
// 抽奖速度
|
|
84
|
+
this.speed = 0;
|
|
85
|
+
// 持续时长
|
|
86
|
+
this.duration = 2000;
|
|
87
|
+
// 长度
|
|
88
|
+
this.maxIdx = 8;
|
|
89
|
+
// 回调动作
|
|
90
|
+
this.animationCallback = ({ idx, isEnd }) => { };
|
|
91
|
+
// 是否异常
|
|
92
|
+
this.isError = false;
|
|
93
|
+
// 是否加速
|
|
94
|
+
this.isSpeedUp = false;
|
|
95
|
+
//超时时间
|
|
96
|
+
this.timeout = 6000;
|
|
97
|
+
}
|
|
98
|
+
start(prizeResult, errorCallback) {
|
|
99
|
+
setTimeout(() => {
|
|
100
|
+
this.isStart = false;
|
|
101
|
+
const reg = /^\+?[1-9]\d*$/;
|
|
102
|
+
if (!reg.test(prizeResult)) {
|
|
103
|
+
this.isError = true;
|
|
104
|
+
if (errorCallback) {
|
|
105
|
+
errorCallback();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}, this.duration);
|
|
109
|
+
// 在转动时长的一半,开始减速转动
|
|
110
|
+
setTimeout(() => {
|
|
111
|
+
this.isSpeedUp = false;
|
|
112
|
+
}, this.duration / 2);
|
|
113
|
+
// 超时,当出现一些意外的情况终止动画
|
|
114
|
+
setTimeout(() => {
|
|
115
|
+
if (this.endId === undefined) {
|
|
116
|
+
this.end(prizeResult);
|
|
117
|
+
}
|
|
118
|
+
}, this.timeout);
|
|
119
|
+
this.isStart = true;
|
|
120
|
+
this.isError = false;
|
|
121
|
+
this.isSpeedUp = true;
|
|
122
|
+
this.loop();
|
|
123
|
+
}
|
|
124
|
+
end(prizeResult) {
|
|
125
|
+
this.endId = prizeResult;
|
|
126
|
+
}
|
|
127
|
+
error() {
|
|
128
|
+
this.isError = true;
|
|
129
|
+
}
|
|
130
|
+
stop() {
|
|
131
|
+
this.isStart = false;
|
|
132
|
+
this.end(-1);
|
|
133
|
+
clearTimeout(this.timer);
|
|
134
|
+
}
|
|
135
|
+
pointOnCubicBezier(cp, t) {
|
|
136
|
+
const x = Math.pow(1 - t, 2) * cp[0] +
|
|
137
|
+
2 * t * (1 - t) * cp[1] +
|
|
138
|
+
Math.pow(t, 2) * cp[2];
|
|
139
|
+
return x;
|
|
140
|
+
}
|
|
141
|
+
loop() {
|
|
142
|
+
const { animationCallback } = this;
|
|
143
|
+
this.timer = setTimeout(() => {
|
|
144
|
+
const over = !this.isStart && this.endId !== undefined;
|
|
145
|
+
// emit
|
|
146
|
+
animationCallback({ idx: this.idx, isEnd: false });
|
|
147
|
+
// compare
|
|
148
|
+
if (this.idx < this.maxIdx) {
|
|
149
|
+
this.idx++;
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
this.idx = 1;
|
|
153
|
+
}
|
|
154
|
+
// continue
|
|
155
|
+
if (!(over && String(this.idx) === String(this.endId)) && !this.isError) {
|
|
156
|
+
if (this.isSpeedUp) {
|
|
157
|
+
const point = this.pointOnCubicBezier([500, 50, 100], 1 / 10);
|
|
158
|
+
this.speed = point;
|
|
159
|
+
if (this.speed < 100) {
|
|
160
|
+
this.speed = 100;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
const point = this.pointOnCubicBezier([100, 50, 500], 1 / 10);
|
|
165
|
+
this.speed = point;
|
|
166
|
+
if (this.speed > 1000) {
|
|
167
|
+
this.speed = 1000;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
this.loop();
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
if (this.isError)
|
|
174
|
+
return;
|
|
175
|
+
animationCallback({ idx: this.idx, isEnd: true });
|
|
176
|
+
this.idx = -1;
|
|
177
|
+
}
|
|
178
|
+
}, this.speed);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
.lcap-modal .lcap-modal__mask {
|
|
2
|
+
top: 0;
|
|
3
|
+
left: 0;
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
z-index: 1000;
|
|
7
|
+
position: fixed;
|
|
8
|
+
background: rgba(0, 0, 0, 0.5);
|
|
9
|
+
transition: all 300ms ease-out;
|
|
10
|
+
}
|
|
11
|
+
.lcap-modal .lcap-modal__dialog {
|
|
12
|
+
transform: translateY(100%);
|
|
13
|
+
transition: all 300ms ease-out;
|
|
14
|
+
width: 100%;
|
|
15
|
+
max-height: 90%;
|
|
16
|
+
min-height: 16.78571rem;
|
|
17
|
+
padding: 0.53571rem 0.53571rem 1.78571rem;
|
|
18
|
+
z-index: 2000;
|
|
19
|
+
border-top-left-radius: 0.53571rem;
|
|
20
|
+
border-top-right-radius: 0.53571rem;
|
|
21
|
+
background: white;
|
|
22
|
+
position: fixed;
|
|
23
|
+
left: 0;
|
|
24
|
+
right: 0;
|
|
25
|
+
bottom: 0;
|
|
26
|
+
}
|
|
27
|
+
.lcap-modal .lcap-modal__dialog.enter {
|
|
28
|
+
transform: translateY(0);
|
|
29
|
+
}
|
|
30
|
+
.lcap-modal .lcap-modal__close_btn {
|
|
31
|
+
top: 0.35714rem;
|
|
32
|
+
right: 0.71429rem;
|
|
33
|
+
position: absolute;
|
|
34
|
+
cursor: pointer;
|
|
35
|
+
}
|
|
36
|
+
.lcap-modal .lcap-modal__confirm_btn {
|
|
37
|
+
padding-bottom: constant(safe-area-inset-bottom);
|
|
38
|
+
/* 兼容 iOS < 11.2 */
|
|
39
|
+
padding-bottom: env(safe-area-inset-bottom);
|
|
40
|
+
/* 兼容 iOS >= 11.2 */
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
.lcap-modal .lcap-modal__confirm_btn .lcap-modal__default_btn {
|
|
44
|
+
left: 0;
|
|
45
|
+
color: rgb(255, 255, 255);
|
|
46
|
+
right: 0;
|
|
47
|
+
width: 100%;
|
|
48
|
+
bottom: 0;
|
|
49
|
+
position: fixed;
|
|
50
|
+
background: rgb(50, 129, 248);
|
|
51
|
+
border-width: 0;
|
|
52
|
+
border-radius: 0;
|
|
53
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ModalProps } from 'tea-component';
|
|
3
|
+
import type { CommonPropsType, ICompRef } from '../../types';
|
|
4
|
+
export interface PropTypes extends ModalProps, CommonPropsType {
|
|
5
|
+
content: string;
|
|
6
|
+
customButton: React.ReactNode;
|
|
7
|
+
customContent: React.ReactNode;
|
|
8
|
+
isDefaultButton: boolean;
|
|
9
|
+
outerRef: React.Ref<TCompRef>;
|
|
10
|
+
}
|
|
11
|
+
declare type TCompRef = ICompRef<{
|
|
12
|
+
close: () => void;
|
|
13
|
+
open: () => void;
|
|
14
|
+
toggle: () => void;
|
|
15
|
+
}>;
|
|
16
|
+
declare const _default: React.ForwardRefExoticComponent<PropTypes & React.RefAttributes<TCompRef>>;
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { usePlatform } from '../../utils/platform';
|
|
3
|
+
import { ModalPc } from './modal.pc';
|
|
4
|
+
import { ModalH5 } from './modal.h5';
|
|
5
|
+
export default React.forwardRef(function WeDaModal(props, ref) {
|
|
6
|
+
const platform = usePlatform();
|
|
7
|
+
if (platform === 'h5') {
|
|
8
|
+
return React.createElement(ModalH5, { ...props, outerRef: ref });
|
|
9
|
+
}
|
|
10
|
+
return React.createElement(ModalPc, { ...props, outerRef: ref });
|
|
11
|
+
});
|