Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
marketing
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈玉桐
marketing
Commits
352eb86b
Commit
352eb86b
authored
Nov 12, 2019
by
陈玉桐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加授权校验
parent
ce006eeb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
20 deletions
+21
-20
main.js
src/main.js
+21
-11
tool.vue
src/views/tool.vue
+0
-9
No files found.
src/main.js
View file @
352eb86b
...
...
@@ -3,25 +3,35 @@ import App from './App.vue'
import
router
from
'./router'
import
store
from
'./store'
import
'./styles/index.scss'
;
// global css
import
request
from
'./utils/request'
import
setWechatTitle
from
'./utils/setWechatTitle'
Vue
.
config
.
productionTip
=
false
function
getUrlParam
(
name
)
{
var
reg
=
new
RegExp
(
"(^|&)"
+
name
+
"=([^&]*)(&|$)"
);
//构造一个含有目标参数的正则表达式对象
var
r
=
window
.
location
.
search
.
substr
(
1
).
match
(
reg
);
//匹配目标参数
if
(
r
!=
null
)
return
decodeURI
(
r
[
2
]);
return
null
;
//返回参数值
}
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
console
.
log
(
localStorage
.
getItem
(
"token"
))
if
(
!
localStorage
.
getItem
(
"token"
)){
// localStorage.setItem("token","")
next
()
// // 这个redirectUrl用 当前页路径
// let redirectUrl = window.location.href
// redirectUrl = encodeURIComponent(redirectUrl)
// console.log(redirectUrl)
// const appid='wx0201b63e761568b8'
// window.location.href = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirectUrl}&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect`
}
else
{
if
(
!
getUrlParam
(
'token'
)){
//地址不携带 token
//本地没有存储 token 去请求授权 ,有存储token直接跳转
if
(
!
localStorage
.
getItem
(
"token"
)){
request
({
url
:
'/api/MarketingToolApi/Wechat/index'
,
method
:
'post'
}).
then
(
response
=>
{
})
}
else
{
next
()
}
}
else
{
//地址携带 token 获取url上的值 并存储 再跳转
localStorage
.
setItem
(
"token"
,
getUrlParam
(
'token'
))
next
()
}
})
router
.
afterEach
((
transition
)
=>
{
...
...
src/views/tool.vue
View file @
352eb86b
...
...
@@ -141,15 +141,6 @@ export default {
// console.log(response)
// })
// request({
// url: '/api/MarketingToolApi/Wechat/getWechatOpenid',
// method: 'get',
// params: {
// code : '021XpJNm1rmTCq0lZxPm1GH3Om1XpJNh'
// }
// }).then(response => {
// console.log(response)
// })
this
.
loadingShow
=
true
request
({
url
:
'/api/MarketingToolApi/Posters/template'
,
...
...
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