Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
glsx
/
dj-scrm-wx-work-attachment-psd
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 54f92596
authored
Jul 12, 2022
by
张权
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
完成营销素材,&第一轮自测
1 parent
7d98609e
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
65 deletions
src/mixins/shareMixin.js
src/mixins/shareMixin.js
View file @
54f9259
...
...
@@ -68,8 +68,20 @@ export default {
imgUrl
:
titleUrl
||
imgUrl
}
if
(
entry
!=
'normal'
)
this
.
getParam
(
i
,
{
id
,
merchantId
,
uuid
})
else
this
.
shareAppMessage
(
params
,
{
id
,
merchantId
,
uuid
})
if
(
entry
!=
'normal'
){
let
pdfParam
=
{
msgtype
:
'news'
,
news
:
params
,
enterChat
:
false
}
if
(
i
.
materialType
==
1
){
this
.
sendChatMessage
(
pdfParam
,
{
id
,
merchantId
,
uuid
})
}
else
{
this
.
getParam
(
i
,
{
id
,
merchantId
,
uuid
})
}
}
else
{
this
.
shareAppMessage
(
params
,
{
id
,
merchantId
,
uuid
})
}
}
})
},
...
...
@@ -82,53 +94,57 @@ export default {
})
},
getParam
(
item
,
sendParams
){
let
str
=
decodeURIComponent
(
item
.
materialUrl
)
let
reg
=
/
(?<
=
\>)(
.*
?)(?=\<)
|
(?<
=img src="
)(
.*
?)(?=
"
)
|
(?<
=video src="
)(
.*
?)(?=
"
)
/g
let
arr
=
str
.
match
(
reg
)
arr
=
arr
.
filter
(
item
=>
item
)
let
newArr
=
[]
console
.
log
(
arr
,
123
)
arr
.
forEach
(
async
(
ele
,
id
)
=>
{
let
mediaType
=
5
let
myParam
=
{}
let
fileReg
=
/https
?
:
\/\/
/
if
(
!
ele
)
return
;
if
(
fileReg
.
test
(
ele
)){
let
imgArr
=
[
'jpg'
,
'jpeg'
,
'png'
,
'gif'
,
'webp'
,
'pjp'
,
'jfif'
,
'pjpeg'
,
'bmp'
,
'dib'
]
let
idx
=
ele
.
lastIndexOf
(
'.'
)
if
(
idx
>-
1
&&
imgArr
.
includes
(
ele
.
slice
(
idx
+
1
))){
mediaType
=
3
let
str
=
decodeURIComponent
(
item
.
materialUrl
)
let
reg
=
/
(?<
=
\>)(
.*
?)(?=\<)
|
(?<
=img src="
)(
.*
?)(?=
"
)
|
(?<
=video src="
)(
.*
?)(?=
"
)
/g
let
arr
=
str
.
match
(
reg
)
arr
=
arr
.
filter
(
item
=>
item
)
let
newArr
=
[]
arr
.
forEach
(
(
ele
,
id
)
=>
{
let
mediaType
=
5
let
myParam
=
{}
let
fileReg
=
/https
?
:
\/\/
/
if
(
!
ele
)
return
;
if
(
fileReg
.
test
(
ele
)){
let
imgArr
=
[
'jpg'
,
'jpeg'
,
'png'
,
'gif'
,
'webp'
,
'pjp'
,
'jfif'
,
'pjpeg'
,
'bmp'
,
'dib'
]
let
idx
=
ele
.
lastIndexOf
(
'.'
)
if
(
idx
>-
1
&&
imgArr
.
includes
(
ele
.
slice
(
idx
+
1
))){
mediaType
=
3
}
else
{
mediaType
=
4
}
myParam
=
this
.
uploadMaterial
({
materialName
:
item
.
materialName
,
data
:
ele
,
mediaType
},
mediaType
)
}
else
{
m
ediaType
=
4
m
yParam
=
this
.
getTextPromise
(
ele
)
}
myParam
=
await
this
.
uploadMaterial
({
materialName
:
item
.
materialName
,
data
:
ele
,
mediaType
},
mediaType
)
console
.
log
(
myParam
,
id
)
this
.
sendChatMessage
(
myParam
,
sendParams
)
}
else
{
myParam
=
{
msgtype
:
'text'
,
text
:
{
content
:
ele
},
enterChat
:
false
newArr
.
push
(
myParam
)
});
Promise
.
allSettled
(
newArr
).
then
(
async
res
=>
{
for
(
let
i
=
0
;
i
<
res
.
length
;
i
++
){
await
this
.
sendChatMessage
(
res
[
i
].
value
,
sendParams
)
}
this
.
sendChatMessage
(
myParam
,
sendParams
)
}
newArr
.
push
(
myParam
)
console
.
log
(
myParam
,
id
)
});
// return newArr
})
},
forEachSend
(
params
,
sendParams
){
let
materialArr
=
this
.
getParam
(
params
)
materialArr
.
forEach
(
item
=>
{
this
.
sendChatMessage
(
item
,
sendParams
)
getTextPromise
(
ele
){
return
new
Promise
((
resolve
,
reject
)
=>
{
resolve
({
msgtype
:
'text'
,
text
:
{
content
:
ele
},
enterChat
:
false
})
})
},
uploadMaterial
(
param
,
type
){
return
new
Promise
((
resolve
,
reject
)
=>
{
marketingApi
.
uploadMaterial
(
param
).
then
(
res
=>
{
console
.
log
(
res
,
456
)
if
(
res
?.
mediaId
){
if
(
type
==
3
){
if
(
type
==
1
){
resolve
({
msgtype
:
'file'
,
file
:
{
mediaid
:
res
.
mediaId
},
enterChat
:
false
})
}
else
if
(
type
==
3
){
resolve
({
msgtype
:
'image'
,
image
:
{
mediaid
:
res
.
mediaId
},
...
...
@@ -146,34 +162,19 @@ export default {
})
},
sendChatMessage
(
params
,
sendParams
)
{
wxConfig
.
sendChatMessage
(
params
)
.
then
(
res
=>
{
this
.
hideLoading
()
this
.
sendReadBuriedPoint
(
sendParams
)
callback
()
})
.
catch
(
err
=>
{
console
.
log
(
err
)
this
.
hideLoading
()
return
new
Promise
((
resolve
,
reject
)
=>
{
wxConfig
.
sendChatMessage
(
params
)
.
then
(
res
=>
{
this
.
hideLoading
()
this
.
sendReadBuriedPoint
(
sendParams
)
resolve
()
}).
catch
(
err
=>
{
console
.
log
(
err
)
this
.
hideLoading
()
})
})
},
// sendChatMessage (params, sendParams) {
// wxConfig
// .sendChatMessage({
// msgtype: 'text',
// text: {content:123},
// enterChat: false
// })
// .then(res => {
// this.hideLoading()
// this.sendReadBuriedPoint(sendParams)
// })
// .catch(err => {
// console.log(err)
// this.hideLoading()
// })
// },
shareAppMessage
(
params
,
sendParams
)
{
wxConfig
.
shareAppMessage
(
params
)
...
...
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