Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taobao-mini-template
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
qinhaitao
taobao-mini-template
Commits
27224ff1
Commit
27224ff1
authored
Aug 31, 2021
by
wanghuan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
0017c2e2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
6 deletions
+53
-6
api.js
c_client/src/api.js
+3
-0
RotateWheel.jsx
...ient/src/components/_tb_comps/RotateWheel/RotateWheel.jsx
+21
-5
rotatewheel.md
c_client/src/components/_tb_comps/RotateWheel/rotatewheel.md
+29
-1
No files found.
c_client/src/api.js
View file @
27224ff1
...
...
@@ -38,6 +38,9 @@ const apiList = {
getCollectGoodsList
:
'getCollectGoodsList'
,
getItemListByItemIds
:
'getItemListByItemIds'
,
updateEnamePrizeReceived
:
'updateEnamePrizeReceived'
,
// 会员权益领取
getRotatePrizeListInfo
:
'getRotatePrizeListInfo'
,
//获取奖品列表接口,暂未实现
drawRotatePrize
:
'drawRotatePrize'
,
//大转盘抽奖接口,暂未实现
}
// 生成API
...
...
c_client/src/components/_tb_comps/RotateWheel/RotateWheel.jsx
View file @
27224ff1
...
...
@@ -38,15 +38,30 @@ const RotateWheel = (props) => {
useEffect
(()
=>
{
computePosition
()
},[])
},[
prizeList
])
/**
* @description 获取奖品列表
*/
// const getPrizeListInfo = async () => {
// const {success,data,code,message} = await API.getRotatePrizeListInfo().catch((res)=>{
// showToast({title:res?.message ? res?.message : '网络异常,请稍后再试'})
// })
// if(success && data){
// const {list} = data;
// // setPrizelist(list)
// computePosition(list)
// }
// }
/**
* @description 计算奖品位置,旋转角度
*/
const
computePosition
=
()
=>
{
if
(
!
prizeList
,
length
)
return
;
let
centerX
,
centerY
,
color
,
rotate
;
/* 获取每块奖品的中心位置 */
prizelist
.
forEach
((
ele
,
i
)
=>
{
prizelist
.
forEach
((
ele
,
i
)
=>
{
if
(
i
%
2
==
0
)
{
color
=
'#527aff'
;
}
else
{
...
...
@@ -85,13 +100,14 @@ const RotateWheel = (props) => {
*/
const
drawPrize
=
useThrottle
(
async
()
=>
{
// const {success,data,message,code} = await API.draw
Lottery
Prize().catch((res)=>{
// showToast(
res?.message ? res?.message : ''
)
// const {success,data,message,code} = await API.draw
Rotate
Prize().catch((res)=>{
// showToast(
{title:res?.message ? res?.message : '网络异常,请稍后再试'}
)
// });
// if(success && data){
// const {prizeId,id} = data;
// }
// test
let
prizeId
=
Math
.
floor
(
Math
.
random
()
*
prizelist
.
length
)
+
100
;
startRotation
(
prizeId
)
setTimeout
(()
=>
{
...
...
c_client/src/components/_tb_comps/RotateWheel/rotatewheel.md
View file @
27224ff1
...
...
@@ -19,4 +19,32 @@
##### 出参
| 配置项 | 类型 | 描述 | 默认值 | 备注 |
| :-------- | :-----: | :--------: | :-----: | :---:|
| callback | Function | 回调函数 | / |抽中奖品后的回调方法,后续的弹窗处理|
\ No newline at end of file
| callback | Function | 回调函数 | / |抽中奖品后的回调方法,后续的弹窗处理|
+
使用
```
jsx
import
RotateWheel
from
'@/components/_tb_comps/RotateWheel/RotateWheel'
const
rotateConfig
=
{
bg
:
'https://yun.duiba.com.cn/spark/assets/8b6e920ffd09fab8f9ac2de09f9154879f4d0607.png'
,
ratio
:
0.65
,
radius
:
300
,
circles
:
4
,
divideNum
:
8
,
duration
:
5000
,
timeFunction
:
'ease-out'
,
nodeInfo
:{
width
:
100
,
height
:
100
},
showWay
:
'negative'
,
//positive/negative
isShowPrizeName
:
true
}
export
const
Index
=
()
=>
{
return
(
<
RotateWheel
{
...
rotateConfig
}
callback=
{
()
=>
{}
}
/>
)
}
```
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment