Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
gl_tape
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
3
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 1fef4e97
authored
Jun 20, 2024
by
李伟康
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
commit 提交
1 parent
600b0f85
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
206 additions
and
32 deletions
components/Canvas/wn-canvas.vue
components/Canvas/zoom-pan.vue
package-lock.json
package.json
pages/boutique/components/Reception.vue
pages/equity/detail/components/MediaComponent.vue
pages/equity/detail/components/Reception.vue
pages/equity/detail/detail.vue
components/Canvas/wn-canvas.vue
View file @
1fef4e9
...
@@ -58,13 +58,12 @@
...
@@ -58,13 +58,12 @@
</view>
</view>
</view>
</view>
</template>
</template>
<movable-area
<
!-- <
movable-area
:class="['canvas-box',{fill:custom}]"
:class="['canvas-box',{fill:custom}]"
scale-area
scale-area
:style="{height:height}"
:style="{height:height}"
@touchstart="viewTouchStart"
@touchstart="viewTouchStart"
>
>
<!-- :style="{aspectRatio:aspectRatio}" -->
<movable-view
<movable-view
class="canvas-view"
class="canvas-view"
scale-min="1"
scale-min="1"
...
@@ -73,10 +72,16 @@
...
@@ -73,10 +72,16 @@
:direction="scaleValue == 1?'none':'all'"
:direction="scaleValue == 1?'none':'all'"
:scale-value="defaultScaleValue"
:scale-value="defaultScaleValue"
@scale="scale"
@scale="scale"
@
change=
"change"
> -->
:x=
"viewX"
<zoom-pan
:y=
"viewY"
:class=
"['canvas-box',{fill:custom}]"
>
:disabled=
"drawStatus"
:scale-value=
"defaultScaleValue"
scale-max=
"5"
scale-min=
"1"
@
scale=
"scale"
>
<
template
slot=
"content"
>
<canvas
<canvas
:class=
"['board-canvas',
{'draw-canvas':drawStatus}]"
:class=
"['board-canvas',
{'draw-canvas':drawStatus}]"
:canvas-id="canvasId"
:canvas-id="canvasId"
...
@@ -101,12 +106,14 @@
...
@@ -101,12 +106,14 @@
<view
class=
"skeleton-box"
></view>
<view
class=
"skeleton-box"
></view>
</
template
>
</
template
>
</template>
</template>
<!-- <image class="under-image" :src="drawImage"
</template>
</zoom-pan>
<!-- <image class="under-image" :src="drawImage"
mode="scaleToFill"
mode="scaleToFill"
/> -->
/> -->
</movable-view>
<!--
</movable-view>
</movable-area>
</movable-area>
-->
<!-- <color
<!-- <color
:colorShow="colorShow"
:colorShow="colorShow"
@colorPickTap="colorPickTapHandler"
@colorPickTap="colorPickTapHandler"
...
@@ -125,10 +132,13 @@
...
@@ -125,10 +132,13 @@
<
script
>
<
script
>
import
color
from
"./color.vue"
import
color
from
"./color.vue"
import
utils
from
"@/utils/utils.js"
;
import
zoomPan
from
'./zoom-pan.vue'
;
export
default
{
export
default
{
name
:
"wn-canvas"
,
name
:
"wn-canvas"
,
components
:
{
components
:
{
color
color
,
zoomPan
},
},
data
()
{
data
()
{
return
{
return
{
...
@@ -228,7 +238,9 @@ export default {
...
@@ -228,7 +238,9 @@ export default {
scaleValue
:
1
,
scaleValue
:
1
,
defaultScaleValue
:
1
,
defaultScaleValue
:
1
,
viewX
:
0
,
viewX
:
0
,
viewY
:
0
viewY
:
0
,
touchX
:
0
,
touchY
:
0
};
};
},
},
props
:
{
props
:
{
...
@@ -550,6 +562,7 @@ export default {
...
@@ -550,6 +562,7 @@ export default {
//开始touch
//开始touch
touchStart
(
e
)
{
touchStart
(
e
)
{
if
(
!
this
.
drawStatus
)
return
if
(
!
this
.
drawStatus
)
return
console
.
log
(
e
)
this
.
drawContext
.
setLineWidth
(
this
.
lineWidth
)
this
.
drawContext
.
setLineWidth
(
this
.
lineWidth
)
let
{
let
{
x
,
x
,
...
@@ -890,22 +903,10 @@ export default {
...
@@ -890,22 +903,10 @@ export default {
}
}
},
},
/**缩放 */
/**缩放 */
scale
(
e
)
{
this
.
scaleValue
=
e
.
detail
.
scale
scale
:
utils
.
throttle
(
function
(
e
)
{
setTimeout
(()
=>
{
this
.
scaleValue
=
e
.
scale
// this.viewX = this.viewX * this.scaleValue * -1
},
200
),
// this.viewY = this.viewY * this.scaleValue * -1
},
1
e3
)
},
change
(
e
){
// console.log(e.detail.x,e.detail.y)
},
viewTouchStart
(
e
)
{
let
touch
=
e
.
changedTouches
[
0
]
// console.log(touch.pageX,touch.pageY)
// this.viewX = -touch.pageX
// this.viewY = -touch.pageY
}
}
}
}
}
</
script
>
</
script
>
...
...
components/Canvas/zoom-pan.vue
0 → 100644
View file @
1fef4e9
<
template
>
<view
:class=
"['container zoom-pan-container',
{disabled:disabled}]"
@touchstart="handleTouchStart"
@touchmove="handleTouchMove"
@touchend="handleTouchEnd"
@touchcancel="handleTouchEnd"
>
<view
class=
"content"
:style=
"
{ transform: transformStyle ,
'transform-origin': transformOriginStyle
}"
>
<slot
name=
"content"
></slot>
</view>
</view>
</
template
>
<
script
>
import
utils
from
"@/utils/utils.js"
;
export
default
{
props
:
{
disabled
:
Boolean
,
scaleValue
:
{
type
:
Number
,
default
:
1
},
scaleMax
:
{
type
:
Number
,
default
:
10
},
scaleMin
:
{
type
:
Number
,
default
:
0.5
},
},
data
()
{
return
{
startX
:
0
,
startY
:
0
,
moveX
:
0
,
moveY
:
0
,
scale
:
1
,
lastScale
:
1
,
lastTouchDistance
:
0
,
isScaling
:
false
,
isDragging
:
false
,
transformOrigin
:
{
x
:
0
,
y
:
0
},
transformStyle
:
''
,
transformOriginStyle
:
'0px 0px'
,
scaleFactor
:
0.01
,
};
},
watch
:
{
watchScaleValue
()
{
this
.
setScale
(
this
.
scaleValue
)
}
},
computed
:
{
watchScaleValue
()
{
return
this
.
scaleValue
}
},
methods
:
{
handleTouchStart
(
e
)
{
if
(
this
.
disabled
)
return
if
(
e
.
touches
.
length
===
2
)
{
this
.
isScaling
=
true
;
this
.
lastTouchDistance
=
this
.
getTouchDistance
(
e
.
touches
);
// 初始化缩放中心为两指间的中心点
this
.
transformOrigin
=
this
.
getTouchCenter
(
e
.
touches
);
}
else
if
(
e
.
touches
.
length
===
1
)
{
this
.
isDragging
=
true
;
[
this
.
startX
,
this
.
startY
]
=
[
e
.
touches
[
0
].
pageX
,
e
.
touches
[
0
].
pageY
];
this
.
moveX
=
0
this
.
moveY
=
0
}
},
handleTouchMove
:
utils
.
throttle
(
function
(
e
)
{
if
(
this
.
disabled
)
return
if
(
this
.
isScaling
&&
e
.
touches
.
length
===
2
)
{
const
currentDistance
=
this
.
getTouchDistance
(
e
.
touches
);
const
deltaDistance
=
currentDistance
-
this
.
lastTouchDistance
;
// 根据触点距离变化和缩放因子计算新的缩放比例
const
newScale
=
this
.
lastScale
+
deltaDistance
*
this
.
scaleFactor
;
this
.
setScale
(
newScale
,
this
.
getTouchCenter
(
e
.
touches
));
// 更新缩放同时更新中心点
this
.
lastTouchDistance
=
currentDistance
;
}
else
if
(
this
.
isDragging
&&
e
.
touches
.
length
===
1
&&
this
.
scale
!==
1
)
{
const
newX
=
e
.
touches
[
0
].
pageX
;
const
newY
=
e
.
touches
[
0
].
pageY
;
this
.
moveX
=
(
newX
-
this
.
startX
)
/
this
.
scale
;
this
.
moveY
=
(
newY
-
this
.
startY
)
/
this
.
scale
;
this
.
updatePosition
();
}
},
16
),
setScale
(
scale
,
center
)
{
this
.
scale
=
Math
.
min
(
Math
.
max
(
scale
,
this
.
scaleMin
),
this
.
scaleMax
);
// 假设最大缩放为10
this
.
lastScale
=
this
.
scale
;
this
.
$emit
(
'scale'
,
{
scale
:
this
.
scale
})
// 更新transform-origin以使缩放围绕两指中心进行
if
(
center
)
this
.
transformOriginStyle
=
`
${
center
.
x
}
px
${
center
.
y
}
px`
;
this
.
updatePosition
();
},
getTouchCenter
(
touches
)
{
const
centerX
=
(
touches
[
0
].
pageX
+
touches
[
1
].
pageX
)
/
2
;
const
centerY
=
(
touches
[
0
].
pageY
+
touches
[
1
].
pageY
)
/
2
;
return
{
x
:
centerX
,
y
:
centerY
};
},
handleTouchEnd
()
{
if
(
this
.
disabled
)
return
this
.
isScaling
=
false
;
this
.
isDragging
=
false
;
},
getTouchDistance
(
touches
)
{
const
dx
=
touches
[
1
].
pageX
-
touches
[
0
].
pageX
;
const
dy
=
touches
[
1
].
pageY
-
touches
[
0
].
pageY
;
return
Math
.
sqrt
(
dx
*
dx
+
dy
*
dy
);
},
async
updatePosition
()
{
const
containerRect
=
await
this
.
getQueryInfo
(
'.container'
)
const
contentRect
=
await
this
.
getQueryInfo
(
'.content'
)
const
contentWidth
=
contentRect
.
width
*
this
.
scale
;
// 缩放后的内容宽度
const
contentHeight
=
contentRect
.
height
*
this
.
scale
;
// 缩放后的内容高度
// 计算内容可以移动的最大范围,确保内容不会超出容器
let
maxX
=
(
containerRect
.
width
-
contentWidth
)
/
2
;
let
maxY
=
(
containerRect
.
height
-
contentHeight
)
/
2
;
// 限制移动范围,确保内容不移出容器
this
.
moveX
=
Math
.
min
(
Math
.
max
(
this
.
moveX
,
-
maxX
),
maxX
);
this
.
moveY
=
Math
.
min
(
Math
.
max
(
this
.
moveY
,
-
maxY
),
maxY
);
// 更新位置并确保内容不超出容器
// 注意:此处需根据实际容器大小和内容尺寸进行调整
this
.
transformStyle
=
`translate(
${
this
.
moveX
}
px,
${
this
.
moveY
}
px) scale(
${
this
.
scale
}
)`
;
},
getQueryInfo
(
el
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
uni
.
createSelectorQuery
().
in
(
this
).
select
(
el
).
boundingClientRect
(
data
=>
{
resolve
(
data
)
}).
exec
()
})
}
},
};
</
script
>
<
style
>
.zoom-pan-container
{
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
position
:
relative
;
}
.content
{
width
:
100%
;
height
:
100%
;
position
:
absolute
;
left
:
0
;
top
:
0
;
}
.disabled
{
pointer-events
:
none
;
}
</
style
>
\ No newline at end of file
\ No newline at end of file
package-lock.json
View file @
1fef4e9
This diff is collapsed.
Click to expand it.
package.json
View file @
1fef4e9
{
{
"dependencies"
:
{
"dependencies"
:
{
"dayjs"
:
"^1.11.11"
,
"dayjs"
:
"^1.11.11"
,
"hammerjs"
:
"^2.0.8"
,
"webpack-spritesmith"
:
"^1.1.0"
"webpack-spritesmith"
:
"^1.1.0"
}
}
}
}
pages/boutique/components/Reception.vue
View file @
1fef4e9
...
@@ -537,6 +537,8 @@ export default {
...
@@ -537,6 +537,8 @@ export default {
color
:
#333333
;
color
:
#333333
;
border-radius
:
16
rpx
;
border-radius
:
16
rpx
;
box-sizing
:
border-box
;
box-sizing
:
border-box
;
line-height
:
80
rpx
;
padding
:
0
!important
;
&::placeholder
{
&::placeholder
{
color
:
#999999
;
color
:
#999999
;
}
}
...
...
pages/equity/detail/components/MediaComponent.vue
View file @
1fef4e9
...
@@ -7,10 +7,6 @@
...
@@ -7,10 +7,6 @@
class=
"content"
class=
"content"
:style=
"
{background:background}"
:style=
"
{background:background}"
>
>
<view
class=
"title"
v-if=
"title"
>
{{
title
}}
</view>
<template
v-if=
"views.length && views.length > 1"
>
<template
v-if=
"views.length && views.length > 1"
>
<tabs
<tabs
:list=
"views"
:list=
"views"
...
...
pages/equity/detail/components/Reception.vue
View file @
1fef4e9
...
@@ -251,6 +251,8 @@ export default {
...
@@ -251,6 +251,8 @@ export default {
color
:
#333333
;
color
:
#333333
;
border-radius
:
16
rpx
;
border-radius
:
16
rpx
;
box-sizing
:
border-box
;
box-sizing
:
border-box
;
line-height
:
80
rpx
;
padding
:
0
!important
;
&::placeholder
{
&::placeholder
{
color
:
#999999
;
color
:
#999999
;
}
}
...
...
pages/equity/detail/detail.vue
View file @
1fef4e9
...
@@ -110,6 +110,11 @@ export default {
...
@@ -110,6 +110,11 @@ export default {
watchPayInfo
()
{
watchPayInfo
()
{
return
this
.
$store
.
state
.
user
.
paymentType
return
this
.
$store
.
state
.
user
.
paymentType
},
},
title
()
{
let
{
id
}
=
this
,
name
=
this
.
media
.
find
((
e
)
=>
e
.
id
==
id
)?.
detailTitle
||
""
return
name
;
},
},
},
watch
:
{
watch
:
{
watchStatus
:
{
watchStatus
:
{
...
@@ -174,7 +179,7 @@ export default {
...
@@ -174,7 +179,7 @@ export default {
index
=
toolList
.
findIndex
(
item
=>
item
.
id
==
id
)
index
=
toolList
.
findIndex
(
item
=>
item
.
id
==
id
)
if
(
isDistanceSignificant
&&
index
!=
-
1
)
{
if
(
isDistanceSignificant
&&
index
!=
-
1
)
{
const
nextId
=
this
.
getNextId
(
index
,
toolList
,
startX
,
halfScreenWidth
)
const
nextId
=
this
.
getNextId
(
index
,
toolList
,
startX
,
halfScreenWidth
)
this
.
$emit
(
'update:id'
,
nextId
)
//
this.$emit('update:id', nextId)
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
error
)
console
.
log
(
error
)
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment