Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
江名洋
/
linkwe-scrm
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 43fb6fac
authored
Feb 24, 2021
by
unknown
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
'由前端生成群活码'
1 parent
ca055cf0
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
6 deletions
linkwe-ui/package.json
linkwe-ui/src/api/common.js
linkwe-ui/src/components/Upload.vue
linkwe-ui/src/utils/common.js
linkwe-ui/src/views/drainageCode/group/baseInfo.vue
linkwe-ui/package.json
View file @
43fb6fa
...
@@ -39,6 +39,7 @@
...
@@ -39,6 +39,7 @@
},
},
"dependencies"
:
{
"dependencies"
:
{
"@riophae/vue-treeselect"
:
"0.4.0"
,
"@riophae/vue-treeselect"
:
"0.4.0"
,
"awesome-qr"
:
"^2.0.1-rc.0"
,
"axios"
:
"0.18.1"
,
"axios"
:
"0.18.1"
,
"clipboard"
:
"2.0.4"
,
"clipboard"
:
"2.0.4"
,
"core-js"
:
"3.6.5"
,
"core-js"
:
"3.6.5"
,
...
@@ -56,6 +57,7 @@
...
@@ -56,6 +57,7 @@
"promise.prototype.finally"
:
"^3.1.2"
,
"promise.prototype.finally"
:
"^3.1.2"
,
"screenfull"
:
"4.2.0"
,
"screenfull"
:
"4.2.0"
,
"sortablejs"
:
"1.8.4"
,
"sortablejs"
:
"1.8.4"
,
"uuid"
:
"^8.3.2"
,
"video.js"
:
"^7.10.2"
,
"video.js"
:
"^7.10.2"
,
"vue"
:
"2.6.10"
,
"vue"
:
"2.6.10"
,
"vue-count-to"
:
"1.0.13"
,
"vue-count-to"
:
"1.0.13"
,
...
...
linkwe-ui/src/api/common.js
View file @
43fb6fa
import
request
from
'@/utils/request'
import
request
from
'@/utils/request'
import
{
dataURLtoFile
}
from
'@/utils/common'
/**
/**
* 下载网络连接文件
* 下载网络连接文件
...
@@ -14,3 +15,24 @@ export function download(url, name) {
...
@@ -14,3 +15,24 @@ export function download(url, name) {
`/common/download/url?url=
${
url
}
&name=
${
name
}
`
`/common/download/url?url=
${
url
}
&name=
${
name
}
`
)
)
}
}
/**
* 上传文件
* @param {*} data
{
"dataURL": 本地文件(base64)
}
*/
export
function
uploadDataURL
(
dataURL
)
{
const
data
=
new
window
.
FormData
()
const
f
=
dataURLtoFile
(
dataURL
)
data
.
append
(
'file'
,
f
)
return
request
({
url
:
process
.
env
.
VUE_APP_BASE_API
+
'/common/uploadFile2Cos'
,
method
:
'post'
,
processData
:
false
,
data
,
})
}
linkwe-ui/src/components/Upload.vue
View file @
43fb6fa
...
@@ -105,6 +105,7 @@ export default {
...
@@ -105,6 +105,7 @@ export default {
// this.$emit('update:fileName', res.data.materialName)
// this.$emit('update:fileName', res.data.materialName)
this
.
$emit
(
'update:fileUrl'
,
res
.
url
)
this
.
$emit
(
'update:fileUrl'
,
res
.
url
)
this
.
$emit
(
'update:fileName'
,
res
.
fileName
)
this
.
$emit
(
'update:fileName'
,
res
.
fileName
)
this
.
$emit
(
'update:file'
,
file
)
// this.fileUrl = URL.createObjectURL(file.raw)
// this.fileUrl = URL.createObjectURL(file.raw)
}
}
},
},
...
...
linkwe-ui/src/utils/common.js
View file @
43fb6fa
...
@@ -165,3 +165,20 @@ export function handleTree(data, id, parentId, children) {
...
@@ -165,3 +165,20 @@ export function handleTree(data, id, parentId, children) {
});
});
return
result
;
return
result
;
}
}
/**
* dataURL转化为File对象
* @param {*} dataURL 本地数据 base64
*/
export
function
dataURLtoFile
(
dataURL
)
{
const
arr
=
dataURL
.
split
(
','
)
const
mime
=
arr
[
0
].
match
(
/:
(
.*
?)
;/
)[
1
]
const
bstr
=
atob
(
arr
[
1
])
let
n
=
bstr
.
length
const
u8arr
=
new
Uint8Array
(
n
)
while
(
n
)
{
u8arr
[
n
-
1
]
=
bstr
.
charCodeAt
(
n
-
1
)
n
-=
1
// to make eslint happy
}
return
new
File
([
u8arr
],
''
,
{
type
:
mime
})
}
linkwe-ui/src/views/drainageCode/group/baseInfo.vue
View file @
43fb6fa
...
@@ -47,6 +47,7 @@
...
@@ -47,6 +47,7 @@
<upload
<upload
:fileUrl
.
sync=
"form.activityHeadUrl"
:fileUrl
.
sync=
"form.activityHeadUrl"
class=
"image-uploader"
class=
"image-uploader"
@
update:file=
"handleUploadedHeadImage"
>
>
<div
slot=
"tip"
>
<div
slot=
"tip"
>
注: 只支持2M以内的jpg/png格式图片
注: 只支持2M以内的jpg/png格式图片
...
@@ -184,6 +185,9 @@
...
@@ -184,6 +185,9 @@
<
script
>
<
script
>
import
{
add
,
update
,
getDetail
}
from
'@/api/drainageCode/group'
import
{
add
,
update
,
getDetail
}
from
'@/api/drainageCode/group'
import
{
uploadDataURL
}
from
'@/api/common'
import
{
v4
as
uuidv4
}
from
'uuid'
import
{
AwesomeQR
}
from
'awesome-qr'
export
default
{
export
default
{
props
:
{
props
:
{
...
@@ -203,8 +207,16 @@ export default {
...
@@ -203,8 +207,16 @@ export default {
guide
:
''
,
guide
:
''
,
joinGroupIsTip
:
0
,
joinGroupIsTip
:
0
,
tipMsg
:
''
,
tipMsg
:
''
,
customerServerQrCode
:
''
customerServerQrCode
:
''
,
// 生成的群活码UUID
uuid
:
''
,
// 群活码链接
codeUrl
:
''
},
},
// 活码头像数据
headImage
:
null
,
// 群活码H5页面地址
h5uri
:
''
,
rules
:
{
rules
:
{
activityName
:
[
activityName
:
[
{
required
:
true
,
message
:
'请输入活码名称'
,
trigger
:
'blur'
}
{
required
:
true
,
message
:
'请输入活码名称'
,
trigger
:
'blur'
}
...
@@ -219,15 +231,59 @@ export default {
...
@@ -219,15 +231,59 @@ export default {
methods
:
{
methods
:
{
// 新增群活码
// 新增群活码
add
()
{
add
()
{
this
.
$refs
.
form
.
validate
((
valid
)
=>
{
this
.
$refs
.
form
.
validate
(
async
(
valid
)
=>
{
if
(
!
valid
)
return
if
(
!
valid
)
return
add
(
this
.
form
).
then
((
res
)
=>
{
// 用来区分群活码,生成的二维码需要带有唯一区分信息,所以由前端生成
this
.
$emit
(
'next'
,
res
.
id
)
if
(
!
this
.
form
.
uuid
)
{
this
.
form
.
uuid
=
uuidv4
().
replace
(
/-/g
,
''
)
}
let
options
=
{
text
:
this
.
qrCodeText
,
size
:
200
,
margin
:
0
}
// 添加logo信息
if
(
this
.
form
.
activityHeadUrl
)
{
options
=
Object
.
assign
(
options
,
{
logoImage
:
this
.
headImage
,
logoMargin
:
2
,
logoCornerRadius
:
3
})
}
const
qr
=
new
AwesomeQR
(
options
)
qr
.
draw
().
then
((
dataURL
)
=>
{
// 上传群活码图片到云存储
uploadDataURL
(
dataURL
).
then
((
res
)
=>
{
if
(
res
.
code
===
200
)
{
this
.
form
.
codeUrl
=
res
.
url
// 新增群活码数据至数据库
add
(
this
.
form
).
then
((
res
)
=>
{
this
.
$emit
(
'next'
,
res
.
id
)
})
}
else
{
}
})
})
})
})
})
},
},
// 获取上传的头像数据
handleUploadedHeadImage
(
file
)
{
const
reader
=
new
FileReader
()
reader
.
readAsDataURL
(
file
.
raw
)
reader
.
onload
=
()
=>
{
this
.
headImage
=
reader
.
result
}
},
// 更新群活码
// 更新群活码
update
()
{
update
()
{
this
.
$refs
.
form
.
validate
((
valid
)
=>
{
this
.
$refs
.
form
.
validate
((
valid
)
=>
{
...
@@ -252,7 +308,9 @@ export default {
...
@@ -252,7 +308,9 @@ export default {
guide
:
res
.
data
.
guide
,
guide
:
res
.
data
.
guide
,
joinGroupIsTip
:
parseInt
(
res
.
data
.
joinGroupIsTip
),
joinGroupIsTip
:
parseInt
(
res
.
data
.
joinGroupIsTip
),
tipMsg
:
res
.
data
.
tipMsg
,
tipMsg
:
res
.
data
.
tipMsg
,
customerServerQrCode
:
res
.
data
.
customerServerQrCode
customerServerQrCode
:
res
.
data
.
customerServerQrCode
,
uuid
:
res
.
data
.
uuid
,
codeUrl
:
res
.
data
.
codeUrl
}
}
}
else
{
}
else
{
}
}
...
@@ -264,7 +322,13 @@ export default {
...
@@ -264,7 +322,13 @@ export default {
if
(
!
this
.
groupCodeId
)
return
this
.
add
()
if
(
!
this
.
groupCodeId
)
return
this
.
add
()
this
.
update
()
this
.
update
()
// this.$emit('next')
this
.
$emit
(
'next'
)
}
},
computed
:
{
qrCodeText
()
{
return
process
.
env
.
VUE_APP_BASE_API
+
this
.
h5uri
+
'?id='
+
this
.
form
.
uuid
}
}
},
},
...
...
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