Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
light
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
夜猫
light
Commits
99f8c89a
Commit
99f8c89a
authored
Nov 11, 2022
by
zhushengjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
圆盘拖动
parent
9625559d
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
209 additions
and
17 deletions
+209
-17
index.css
components/circleCom/index.css
+35
-0
index.js
components/circleCom/index.js
+137
-0
index.json
components/circleCom/index.json
+3
-0
index.tyml
components/circleCom/index.tyml
+24
-0
index.json
pages/testDemo/index.json
+2
-1
index.tyml
pages/testDemo/index.tyml
+1
-16
index.tyss
pages/testDemo/index.tyss
+7
-0
No files found.
components/circleCom/index.css
0 → 100644
View file @
99f8c89a
/* c:\Users\Tina\Desktop\tuya-miniapp-explorer-template\components/circleCom.css */
.app
{
height
:
100vh
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
background-color
:
#264653
;
}
.circle-container
{
position
:
relative
;
z-index
:
30
;
}
.circle-container
.circle
{
position
:
absolute
;
z-index
:
10
;
left
:
0
;
top
:
0
;
border-radius
:
50%
;
border
:
10px
solid
#ffffff
;
display
:
flex
;
justify-content
:
center
;
align-items
:
center
;
color
:
#ffffff
;
font-size
:
20px
;
-webkit-user-select
:
none
;
}
.circle-container
.circle-bar
{
position
:
absolute
;
z-index
:
50
;
border-radius
:
50%
;
background-color
:
transparent
;
border
:
4px
solid
rgba
(
255
,
255
,
255
,
1
);
cursor
:
pointer
;
box-shadow
:
0
5px
12px
rgba
(
0
,
0
,
0
,
0.6
);
}
components/circleCom/index.js
0 → 100644
View file @
99f8c89a
// c:\Users\Tina\Desktop\tuya-miniapp-explorer-template\components/circleCom.js
Component
({
options
:
{},
properties
:
{
},
data
:
{
isDrag
:
false
,
angleValue
:
0
,
// 角度信息 0 ~ 360
angelShow
:
0
,
// 角度展示 0 ~ 180
tempValue
:[
2700
,
6500
],
// 色温范围
tempshow
:(
6500
-
2700
)
/
2
+
2700
,
// 色温展示
containerWidth
:
200
,
//容器宽度
containerHeight
:
200
,
//容器高度
containerOffset
:
{
// 容器位置
x
:
50
,
y
:
50
},
mouse_offset
:
{
x
:
0
,
y
:
0
},
circle_r
:
100
,
// 圆形外半径(容器宽度/2)
circle_b
:
42
,
// 圆形边距
bar_r
:
21
,
// 小球半径(圆形边距/2)
angleLimit
:
135
,
// 角度限制
barStyle_left
:
79
,
// 小球位置(容器宽度/2-小球半径)
barStyle_top
:
0
},
pageLifetimes
:
{
show
:
function
()
{
const
that
=
this
const
query
=
this
.
createSelectorQuery
()
query
.
select
(
"#container"
).
boundingClientRect
(
function
(
res
)
{
that
.
setData
({
'containerOffset.x'
:
res
.
left
,
'containerOffset.y'
:
res
.
top
})
}).
exec
()
}
},
// 组件生命周期
methods
:
{
barTouch
:
function
(
e
)
{
this
.
getMouseOffset
(
e
)
},
barMove
:
function
(
e
)
{
const
event_offset_x
=
(
e
.
touches
[
0
].
clientX
-
this
.
data
.
mouse_offset
.
x
-
this
.
data
.
containerOffset
.
x
-
this
.
data
.
circle_r
)
const
event_offset_y
=
-
(
e
.
touches
[
0
].
clientY
-
this
.
data
.
mouse_offset
.
y
-
this
.
data
.
containerOffset
.
y
-
this
.
data
.
circle_r
)
const
radian
=
Math
.
atan2
(
event_offset_y
,
event_offset_x
)
const
x
=
Math
.
cos
(
radian
)
*
(
this
.
data
.
circle_r
-
this
.
data
.
circle_b
/
2
)
const
y
=
Math
.
sin
(
radian
)
*
(
this
.
data
.
circle_r
-
this
.
data
.
circle_b
/
2
)
const
left
=
x
-
this
.
data
.
bar_r
+
this
.
data
.
circle_r
const
top
=
this
.
data
.
circle_r
-
(
y
+
this
.
data
.
bar_r
)
this
.
updateContent
(
radian
)
if
(
!
this
.
data
.
isDrag
)
{
return
}
this
.
setData
({
barStyle_left
:
left
,
barStyle_top
:
top
})
},
updateContent
:
function
(
radian
)
{
let
angle
=
radian
*
(
180
/
Math
.
PI
)
// -180 ~ 180
if
(
angle
>=
-
180
&&
angle
<=
90
)
{
angle
=
90
-
angle
}
else
{
angle
=
360
-
(
angle
-
90
)
}
// 0 ~ 360
const
angleValue
=
Math
.
floor
(
angle
)
// 0 ~ 180
const
angelShow
=
angleValue
>
180
?
360
-
angleValue
:
angleValue
const
tempStart
=
this
.
data
.
tempValue
[
0
]
const
tempEnd
=
this
.
data
.
tempValue
[
1
]
const
angleLimit
=
this
.
data
.
angleLimit
let
tempshow
=
(
tempEnd
-
tempStart
)
/
2
+
tempStart
// 中间值 角度对应0
if
(
angleValue
<
180
){
tempshow
=
tempshow
+
(
tempEnd
-
tempshow
)
/
angleLimit
*
angelShow
}
if
(
angleValue
>
180
){
tempshow
=
tempshow
-
(
tempEnd
-
tempshow
)
/
angleLimit
*
angelShow
}
if
(
angelShow
>
135
)
{
this
.
setData
({
isDrag
:
false
,
})
return
}
else
if
(
!
this
.
data
.
isDrag
)
{
this
.
setData
({
isDrag
:
true
,
})
}
tempshow
=
Math
.
floor
(
tempshow
)
this
.
setData
({
angleValue
:
angleValue
,
angelShow
:
angelShow
,
tempshow
:
tempshow
})
},
getMouseOffset
:
function
(
e
)
{
// 移动距离:小球的坐标位置-容器的偏移位置-小球相对容器的偏移位置-小球半径
const
mouse_offset_x
=
(
e
.
touches
[
0
].
clientX
-
this
.
data
.
containerOffset
.
x
-
e
.
currentTarget
.
offsetLeft
-
this
.
data
.
bar_r
)
const
mouse_offset_y
=
-
(
e
.
touches
[
0
].
clientY
-
this
.
data
.
containerOffset
.
y
-
e
.
currentTarget
.
offsetTop
-
this
.
data
.
bar_r
)
this
.
setData
({
'mouse_offset.x'
:
mouse_offset_x
,
'mouse_offset.y'
:
mouse_offset_y
})
}
}
});
\ No newline at end of file
components/circleCom/index.json
0 → 100644
View file @
99f8c89a
{
"component"
:
true
}
components/circleCom/index.tyml
0 → 100644
View file @
99f8c89a
<view class="circle-container" id="container"
style="width:{{containerWidth}}px;
height:{{containerHeight}}px;
background-image: url(../../assets/images/test/tempBg.png);
background-size:{{containerWidth}}px {{containerHeight}}px
"
>
<view class="circle"
style="width:{{circle_r}}px;
height:{{circle_r}}px;
left:{{containerWidth/2-circle_r/2}}px;
top:{{containerWidth/2-circle_r/2}}px">
{{tempshow}}K
</view>
<view class="circle-bar"
style="left:{{barStyle_left}}px;
top:{{barStyle_top}}px;
width:{{bar_r*2}}px;
height:{{bar_r*2}}px;"
catchtouchstart="barTouch"
catchtouchmove="barMove"
>
</view>
</view>
pages/testDemo/index.json
View file @
99f8c89a
...
...
@@ -6,6 +6,7 @@
"enablePullDownRefresh"
:
true
,
"onReachBottomDistance"
:
100
,
"usingComponents"
:
{
"mpicon"
:
"@tuya-miniapp/miniapp-components-plus/iconEx/index"
"mpicon"
:
"@tuya-miniapp/miniapp-components-plus/iconEx/index"
,
"circleCom"
:
"/components/circleCom/index"
}
}
\ No newline at end of file
pages/testDemo/index.tyml
View file @
99f8c89a
...
...
@@ -12,22 +12,7 @@
<view style="backgroundColor:black; height: 100vh">
<view class="{{!dpCodes.switch_led ? 'backimg' :''}} content">
<view ty:if="{{dpCodes.switch_led}}" class="img-container">
<image
src="/assets/images/test/tempBg.png"
style="width:{{radius * 2}}rpx;height: {{radius * 2}}rpx;borderRadius:{{radius}}rpx"
/>
<view class="thumb" style="left{{-thumbSize / 2}}px;
top: {{-tempProps.thumbSize / 2}}px;
width: {{tempProps.thumbSize}}px;
height: {{tempProps.thumbSize}}px;
borderRadius: {{tempProps.thumbSize / 2}}px;
opacity: {{disabled ? 0.2 : 1}};
transform:translate({{tempProps.thumbX}}px,{{tempProps.thumbY}}px);
"
catchtouchstart="controlTemp"
>
</view>
<circleCom></circleCom>
</view>
<view>
<view ty:if="{{dpCodes.switch_led}}" class="config-list">
...
...
pages/testDemo/index.tyss
View file @
99f8c89a
...
...
@@ -133,3 +133,10 @@
background-color: transparent;
border: 5px solid #fff;
}
.circleContent {
/* display: flex;
justify-content: center;
align-items: center; */
padding:50px
}
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