Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_admin
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_admin
Commits
fc843f07
Commit
fc843f07
authored
Aug 04, 2023
by
yaya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:添加图片裁剪上传功能
parent
4dfb2984
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
100 additions
and
31 deletions
+100
-31
.idea/inspectionProfiles/Project_Default.xml
.idea/inspectionProfiles/Project_Default.xml
+0
-6
src/api/business/goodsNew.js
src/api/business/goodsNew.js
+8
-0
src/views/goods/components/CutEditImageDialog.vue
src/views/goods/components/CutEditImageDialog.vue
+38
-4
src/views/goods/components/CutImageDialog.vue
src/views/goods/components/CutImageDialog.vue
+39
-9
src/views/goods/components/lamaImageDialog.vue
src/views/goods/components/lamaImageDialog.vue
+1
-1
src/views/goods/components/selectImageDialog.vue
src/views/goods/components/selectImageDialog.vue
+4
-8
src/views/goods/infoSet.vue
src/views/goods/infoSet.vue
+10
-3
No files found.
.idea/inspectionProfiles/Project_Default.xml
deleted
100644 → 0
View file @
4dfb2984
<component
name=
"InspectionProjectProfileManager"
>
<profile
version=
"1.0"
>
<option
name=
"myName"
value=
"Project Default"
/>
<inspection_tool
class=
"Eslint"
enabled=
"true"
level=
"WARNING"
enabled_by_default=
"true"
/>
</profile>
</component>
\ No newline at end of file
src/api/business/goodsNew.js
View file @
fc843f07
...
...
@@ -23,3 +23,11 @@ export function saveImageBase64(params) {
data
:
params
})
}
export
function
saveCroppingRecord
(
params
)
{
return
request
({
url
:
'
/item/saveCroppingRecord
'
,
method
:
'
post
'
,
data
:
params
})
}
src/views/goods/components/CutEditImageDialog.vue
View file @
fc843f07
...
...
@@ -78,7 +78,7 @@
</
template
>
<
script
>
import
{
VuePictureCut
,
VuePictureCutMask
,
VuePictureCutMenu
}
from
'
vue-picture-cut
'
import
{
VuePictureCut
,
VuePictureCutMask
,
VuePictureCutMenu
,
createUtils
}
from
'
vue-picture-cut
'
import
SelectImageDialog
from
'
./selectImageDialog
'
import
LamaImageDialog
from
'
./lamaImageDialog
'
...
...
@@ -101,12 +101,13 @@ export default {
},
data
()
{
return
{
utils
:
null
,
pictureCut
:
null
,
// src: this.imageBase64,
cutInfo
:
{
initAngle
:
0
,
maxPixel
:
500
,
encoderOptions
:
0.8
encoderOptions
:
1
},
mastInfo
:
{
width
:
1
,
...
...
@@ -117,7 +118,7 @@ export default {
menuInfo
:
{
format
:
'
image/jpeg/png
'
,
maxPixel
:
500
,
encoderOptions
:
0.8
encoderOptions
:
1
},
showLamaImageDialog
:
false
,
imageBase64
:
''
,
...
...
@@ -136,7 +137,7 @@ export default {
if
(
this
.
imageBase64
)
{
setTimeout
(()
=>
{
this
.
pictureCut
=
this
.
$refs
[
'
pictureCut
'
]
console
.
log
(
'
==7777777777==
'
,
this
.
pictureCut
)
this
.
utils
=
createUtils
(
this
.
pictureCut
)
},
1000
)
}
},
...
...
@@ -148,11 +149,44 @@ export default {
},
// 裁剪图片结果
cutChange
(
res
)
{
this
.
handleUploadParam
()
this
.
imageBase64
=
''
this
.
$emit
(
'
cutEditSuccess
'
,
this
.
editImageUrl
,
res
.
base64
)
// console.log('=====blob', this.blob)
console
.
log
(
'
=====base64
'
,
this
.
base64
)
},
/**
* 上传裁剪参数
*/
handleUploadParam
()
{
const
options
=
this
.
utils
.
getOptions
()
// console.log('配置:', options)
if
(
options
&&
options
.
img
&&
options
.
img
.
showRect
)
{
const
rectW
=
options
.
img
.
showRect
.
w
// 展示图片宽
const
rectH
=
options
.
img
.
showRect
.
h
// 展示图片高
const
rectX
=
options
.
img
.
showRect
.
x
// 偏移量处理后x
const
rectY
=
options
.
img
.
showRect
.
y
// 偏移量处理后y
const
offsetX
=
rectX
+
rectW
/
2
// 偏移量x 正数右 负数左
const
offsetY
=
rectY
*
2
// 偏移量y 正数上 负数下
const
{
w
,
h
}
=
options
.
mask
const
obj
=
{
width
:
rectW
,
height
:
rectH
,
x
:
Math
.
ceil
(
rectW
/
2
-
w
/
2
-
offsetX
),
y
:
Math
.
ceil
(
rectH
/
2
-
h
/
2
-
offsetY
),
maskW
:
w
,
maskH
:
h
}
const
param
=
{
imageUrl
:
this
.
editImageUrl
,
coordinate
:
JSON
.
stringify
(
obj
)
}
// console.log('====params==', param)
this
.
$emit
(
'
uploadEditImage
'
,
param
)
}
},
handlerGetBase64
(
currentImageUrl
,
imgUrlBase64
)
{
this
.
changeImageUrl
=
currentImageUrl
if
(
imgUrlBase64
)
{
...
...
src/views/goods/components/CutImageDialog.vue
View file @
fc843f07
...
...
@@ -90,7 +90,7 @@
</
template
>
<
script
>
import
{
VuePictureCut
,
VuePictureCutMask
,
VuePictureCutMenu
}
from
'
vue-picture-cut
'
import
{
VuePictureCut
,
VuePictureCutMask
,
VuePictureCutMenu
,
createUtils
}
from
'
vue-picture-cut
'
import
SelectImageDialog
from
'
./selectImageDialog
'
export
default
{
...
...
@@ -112,20 +112,17 @@ export default {
imageList
:
{
type
:
Array
,
default
:
()
=>
[]
},
editImageUrl
:
{
type
:
String
,
default
:
''
}
},
data
()
{
return
{
pictureCut
:
null
,
utils
:
null
,
// src: this.imageBase64,
cutInfo
:
{
initAngle
:
0
,
maxPixel
:
500
,
encoderOptions
:
0.8
encoderOptions
:
1
},
mastInfo
:
{
width
:
1
,
...
...
@@ -136,11 +133,12 @@ export default {
menuInfo
:
{
format
:
'
image/jpeg/png
'
,
maxPixel
:
500
,
encoderOptions
:
0.8
encoderOptions
:
1
},
selectImageDialogVisible
:
false
,
selectType
:
0
,
imageBase64
:
''
imageBase64
:
''
,
currentImageUrl
:
''
}
},
watch
:
{
...
...
@@ -155,6 +153,7 @@ export default {
if
(
this
.
imageBase64
)
{
setTimeout
(()
=>
{
this
.
pictureCut
=
this
.
$refs
[
'
pictureCut
'
]
this
.
utils
=
createUtils
(
this
.
pictureCut
)
console
.
log
(
'
==7777777777==
'
,
this
.
pictureCut
)
},
1000
)
}
...
...
@@ -184,13 +183,44 @@ export default {
},
// 裁剪图片结果
cutChange
(
res
)
{
this
.
handleUploadParam
()
this
.
imageBase64
=
''
this
.
$emit
(
'
cutSuccess
'
,
this
.
imageType
,
res
)
// console.log('=====blob', this.blob)
console
.
log
(
'
=====base64
'
,
this
.
base64
)
},
handleUploadParam
()
{
const
options
=
this
.
utils
.
getOptions
()
// console.log('配置:', options)
if
(
options
&&
options
.
img
&&
options
.
img
.
showRect
&&
this
.
currentImageUrl
)
{
const
rectW
=
options
.
img
.
showRect
.
w
// 展示图片宽
const
rectH
=
options
.
img
.
showRect
.
h
// 展示图片高
const
rectX
=
options
.
img
.
showRect
.
x
// 偏移量处理后x
const
rectY
=
options
.
img
.
showRect
.
y
// 偏移量处理后y
const
offsetX
=
rectX
+
rectW
/
2
// 偏移量x 正数右 负数左
const
offsetY
=
rectY
*
2
// 偏移量y 正数上 负数下
const
{
w
,
h
}
=
options
.
mask
const
obj
=
{
width
:
rectW
,
height
:
rectH
,
x
:
Math
.
ceil
(
rectW
/
2
-
w
/
2
-
offsetX
),
y
:
Math
.
ceil
(
rectH
/
2
-
h
/
2
-
offsetY
),
maskW
:
w
,
maskH
:
h
}
const
param
=
{
imageUrl
:
this
.
currentImageUrl
,
coordinate
:
JSON
.
stringify
(
obj
)
}
console
.
log
(
'
====params==
'
,
param
)
this
.
$emit
(
'
uploadImage
'
,
param
)
}
},
handlerGetBase64
(
currentImageUrl
,
imgUrlBase64
)
{
this
.
c
hange
ImageUrl
=
currentImageUrl
this
.
c
urrent
ImageUrl
=
currentImageUrl
if
(
imgUrlBase64
)
{
this
.
imageBase64
=
imgUrlBase64
}
else
{
...
...
src/views/goods/components/lamaImageDialog.vue
View file @
fc843f07
...
...
@@ -27,7 +27,7 @@ export default {
},
data
()
{
return
{
iframeSrc
:
'
http
://lama.wanwudezhi.work/
'
iframeSrc
:
'
https
://lama.wanwudezhi.work/
'
}
},
mounted
()
{
...
...
src/views/goods/components/selectImageDialog.vue
View file @
fc843f07
...
...
@@ -74,26 +74,22 @@ export default {
this
.
$message
.
error
(
'
该图片不支持该操作
'
)
return
}
this
.
currentImageUrl
=
this
.
imageList
[
this
.
currentPosition
]
if
(
this
.
selectType
===
1
)
{
// 去水印
this
.
copyContent
(
this
.
imageList
[
this
.
currentPosition
])
this
.
$message
.
success
(
'
复制链接成功,粘贴链接去水印吧
'
)
this
.
showLamaImageDialog
=
true
this
.
currentImageUrl
=
this
.
imageList
[
this
.
currentPosition
]
}
else
{
this
.
handleSelectSuccess
(
this
.
imageList
[
this
.
currentPosition
])
/* this.$emit('selectSuccess', this.imageList[this.currentPosition])
this.$emit('closeDialog')
this.currentImageUrl = ''*/
this
.
handleSelectSuccess
(
this
.
currentImageUrl
)
}
},
handleGetImageBase64
(
imgUrlBase64
)
{
this
.
$emit
(
'
imageBase64Str
'
,
this
.
currentImageUrl
,
imgUrlBase64
)
handleGetImageBase64
(
imgUrlBase64
,
width
,
height
)
{
this
.
$emit
(
'
imageBase64Str
'
,
this
.
currentImageUrl
,
imgUrlBase64
,
width
,
height
)
this
.
showLamaImageDialog
=
false
this
.
$emit
(
'
closeDialog
'
)
},
// 选择线上图片后的图片链接
async
handleSelectSuccess
(
url
)
{
this
.
changeImageUrl
=
url
const
base64Str
=
await
this
.
getBase64Image
(
url
)
this
.
$emit
(
'
imageBase64Str
'
,
this
.
currentImageUrl
,
base64Str
)
this
.
showLamaImageDialog
=
false
...
...
src/views/goods/infoSet.vue
View file @
fc843f07
...
...
@@ -149,13 +149,15 @@
:image-list=
"imageList"
:show-cut-dialog=
"cutImageDialogVisible"
@
cutImageDialogClose=
"cutImageDialogVisible = false"
@
cutSuccess=
"handleCutSuccess"
/>
@
cutSuccess=
"handleCutSuccess"
@
uploadImage=
"handleUploadImage"
/>
<CutEditImageDialog
v-if=
"cutEditImageDialogVisible"
:edit-image-url=
"editImageUrl"
:show-cut-dialog=
"cutImageDialogVisible"
@
cutEditImageDialogClose=
"cutEditImageDialogVisible = false"
@
cutEditSuccess=
"handleSaveImageBase64"
/>
@
cutEditSuccess=
"handleSaveImageBase64"
@
uploadEditImage=
"handleUploadImage"
/>
</div>
</
template
>
...
...
@@ -165,7 +167,7 @@ import { VuePictureCut, VuePictureCutMask, VuePictureCutMenu } from 'vue-picture
import
{
getToken
}
from
'
@/utils/auth
'
import
SelectImageDialog
from
'
./components/selectImageDialog
'
import
{
listCategories
}
from
'
@/api/business/goods
'
import
{
detailGoods
,
editGoods
,
saveImageBase64
}
from
'
@/api/business/goodsNew
'
import
{
detailGoods
,
editGoods
,
saveImageBase64
,
saveCroppingRecord
}
from
'
@/api/business/goodsNew
'
import
CheckLargeImageDialog
from
'
./components/CheckLargeImageDialog
'
import
CutImageDialog
from
'
./components/CutImageDialog
'
import
CutEditImageDialog
from
'
./components/CutEditImageDialog
'
...
...
@@ -394,6 +396,11 @@ export default {
}
})
},
handleUploadImage
(
param
)
{
param
.
itemId
=
this
.
currentGoodId
saveCroppingRecord
(
param
).
then
((
response
)
=>
{
})
},
// 裁剪工具取消
cutCancel
()
{
this
.
src
=
''
...
...
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