Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
html
/
zhufuyuCommon
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Wiki
Members
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
1ce838c3
authored
Oct 09, 2019
by
mamingqun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
分享功能实现
parent
c4c77657
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
3 deletions
+61
-3
src/App.vue
+27
-0
src/main.js
+1
-1
src/views/Detail.vue
+33
-2
No files found.
src/App.vue
View file @
1ce838c3
...
@@ -18,6 +18,10 @@ import config from '@/config/config.js'
...
@@ -18,6 +18,10 @@ import config from '@/config/config.js'
import
{
requestWxInit
}
from
"@/utils/wxShare"
import
{
requestWxInit
}
from
"@/utils/wxShare"
export
default
{
export
default
{
created
()
{
// 通过url中是否含有shareId来判断是否是分享出去的详情页,再由路由推向对应详情页
this
.
judgeShare
()
},
mounted
()
{
mounted
()
{
console
.
log
(
'NODE_ENV'
)
console
.
log
(
'NODE_ENV'
)
console
.
log
(
process
.
env
.
NODE_ENV
)
console
.
log
(
process
.
env
.
NODE_ENV
)
...
@@ -28,6 +32,29 @@ export default {
...
@@ -28,6 +32,29 @@ export default {
console
.
log
(
'accessToken'
)
console
.
log
(
'accessToken'
)
console
.
log
(
localStorage
.
getItem
(
'accessToken'
))
console
.
log
(
localStorage
.
getItem
(
'accessToken'
))
requestWxInit
(
'测试标题'
,
'描述啊描述'
,
config
.
shareIcon
,
config
.
shareLink
)
requestWxInit
(
'测试标题'
,
'描述啊描述'
,
config
.
shareIcon
,
config
.
shareLink
)
},
methods
:
{
judgeShare
()
{
if
(
location
.
href
.
includes
(
"shareId"
))
{
// 用是否有shareId 来判断是不是分享出去的链接
var
id
=
this
.
getshareId
(
location
.
href
)
this
.
$router
.
replace
({
path
:
"detail"
,
query
:
{
detailId
:
id
}
});
}
else
{
}
},
getshareId
(
str
)
{
var
arr
=
str
.
split
(
"?"
);
var
newArr
=
arr
[
1
].
split
(
"&"
);
var
id
=
null
;
newArr
.
forEach
(
ele
=>
{
if
(
ele
.
includes
(
"shareId"
))
{
id
=
ele
.
match
(
/
\d
+/g
)[
0
];
}
});
return
id
;
},
}
}
}
}
</
script
>
</
script
>
...
...
src/main.js
View file @
1ce838c3
...
@@ -23,7 +23,7 @@ window.$axios = axios
...
@@ -23,7 +23,7 @@ window.$axios = axios
// 微信授权
// 微信授权
if
(
process
.
env
.
NODE_ENV
===
'development'
&&
!
process
.
env
.
VUE_APP_BUILD_TYPE
)
{
if
(
process
.
env
.
NODE_ENV
===
'development'
&&
!
process
.
env
.
VUE_APP_BUILD_TYPE
)
{
// 调试开发,替换这里token
// 调试开发,替换这里token
let
testToken
=
'
OJBwh2ZvViYyQ1phNZEghwf9D8dyAImCD5twnjl0
'
let
testToken
=
'
34B4TeqZ04fnqbfjnxU0o1WOnwaNj76APXvSkb65
'
axios
.
defaults
.
headers
.
common
[
'sysType'
]
=
config
.
sysType
axios
.
defaults
.
headers
.
common
[
'sysType'
]
=
config
.
sysType
axios
.
defaults
.
headers
.
common
[
'accessToken'
]
=
testToken
axios
.
defaults
.
headers
.
common
[
'accessToken'
]
=
testToken
localStorage
.
setItem
(
'accessToken'
,
testToken
)
localStorage
.
setItem
(
'accessToken'
,
testToken
)
...
...
src/views/Detail.vue
View file @
1ce838c3
<
template
>
<
template
>
<div>
Detail页面
</div>
<div>
<h1>
{{
detailId
}}
</h1>
<div>
Detail页面
</div>
</div>
</
template
>
</
template
>
<
script
>
<
script
>
export
default
{
import
config
from
'@/config/config.js'
import
{
requestWxInit
}
from
"@/utils/wxShare"
export
default
{
data
()
{
return
{
detailId
:
null
,
shareUrl
:
null
}
},
activated
()
{
this
.
setShareUrl
()
requestWxInit
(
'详情页啊'
,
'详情啊啊啊啊'
,
config
.
shareIcon
,
this
.
shareUrl
)
},
deactivated
()
{
setTimeout
(()
=>
{
this
.
detailId
=
null
requestWxInit
(
'测试标题222'
,
'从详情页回来的'
,
config
.
shareIcon
,
config
.
shareLink
)
});
},
methods
:
{
setShareUrl
()
{
this
.
detailId
=
this
.
$route
.
query
.
detailId
this
.
shareUrl
=
config
.
shareLink
.
includes
(
'?'
)
?
`
${
config
.
shareLink
}
&shareId=
${
this
.
detailId
}
`
:
`
${
config
.
shareLink
}
?shareId=
${
this
.
detailId
}
`
;
}
}
}
}
</
script
>
</
script
>
\ No newline at end of file
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