Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
group-buy-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
ui
group-buy-ui
Commits
ebbb2c40
Commit
ebbb2c40
authored
Sep 28, 2021
by
Xuguangxing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 重点- 更新login
parent
34fe5d2f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
6 deletions
+61
-6
goodsCheck.mixin.js
src/mixins/goodsCheck.mixin.js
+3
-0
cookieStorage.service.js
src/service/cookieStorage.service.js
+1
-2
httpDecorator.js
src/service/httpDecorator.js
+54
-1
init.service.js
src/service/init.service.js
+3
-3
No files found.
src/mixins/goodsCheck.mixin.js
View file @
ebbb2c40
...
...
@@ -2,6 +2,7 @@ import Bridge from '@qg/js-bridge';
import
MpBridge
from
'
@/service/mp
'
;
import
{
isWxMp
,
isApp
}
from
'
@/service/validation.service
'
;
import
localStorage
from
'
@/service/localStorage.service
'
;
import
cookies
from
'
@/service/cookieStorage.service
'
;
export
default
{
data
()
{
return
{
...
...
@@ -17,6 +18,8 @@ export default {
const
appData
=
json
.
data
||
{};
if
(
appData
&&
appData
.
token
)
{
localStorage
.
set
(
'
vccToken
'
,
appData
.
token
);
cookies
.
set
(
'
vccToken
'
,
appData
.
token
);
// window.sessionStorage.setItem('vccToken', appData.token);
_this
.
$nextTick
(()
=>
{
window
.
location
.
reload
();
});
...
...
src/service/cookieStorage.service.js
View file @
ebbb2c40
import
cookies
from
'
js-cookie
'
;
const
option
=
{
domain
:
window
.
location
.
host
.
indexOf
(
'
.q-gp.com
'
)
>=
0
?
'
.q-gp.com
'
:
''
,
expires
:
365
domain
:
window
.
location
.
host
.
indexOf
(
'
.q-gp.com
'
)
>=
0
?
'
.q-gp.com
'
:
''
};
const
Cookies
=
{
get
(
key
)
{
...
...
src/service/httpDecorator.js
View file @
ebbb2c40
...
...
@@ -2,10 +2,63 @@ import HttpRequest from '@qg/ui-request';
import
{
Toast
}
from
'
@qg/cherry-ui
'
;
import
store
from
'
@/store
'
;
import
{
appVersion
}
from
'
@/service/validation.service
'
;
import
{
getVccChannel
}
from
'
./userInfo.service
'
;
import
localStorage
from
'
@/service/localStorage.service
'
;
function
getURLSearchParams
(
json
)
{
if
(
!
json
)
return
''
;
const
dataArray
=
Object
.
keys
(
json
).
map
(
key
=>
{
if
(
json
[
key
]
===
undefined
)
return
''
;
return
encodeURIComponent
(
key
)
+
'
=
'
+
encodeURIComponent
(
json
[
key
]);
});
return
dataArray
.
filter
(
item
=>
item
!==
undefined
&&
item
!==
null
).
join
(
'
&
'
);
}
const
http
=
new
HttpRequest
(
{},
{
groupBuy
:
{
response
(
res
)
{
const
{
data
,
config
}
=
res
;
const
returnRawData
=
config
.
rawData
;
if
(
returnRawData
)
return
[
data
,
null
];
if
(
data
.
businessCode
===
'
401
'
||
data
.
businessCode
===
'
0401
'
)
{
// router.push({ name: 'login' });
window
.
localStorage
.
removeItem
(
'
vccToken
'
);
window
.
sessionStorage
.
removeItem
(
'
vccToken
'
);
}
const
success
=
(
data
.
code
===
'
0000
'
&&
data
.
businessCode
===
'
0000
'
)
||
data
.
business_code
===
0
;
if
(
success
)
{
return
[
data
.
data
,
null
];
}
const
msg
=
data
.
msg
||
'
服务异常
'
;
if
(
!
config
.
hideToast
||
!
data
.
noAlert
)
{
Toast
(
msg
);
}
let
error
=
new
Error
(
msg
);
error
.
response
=
data
;
console
.
error
(
error
);
return
[
null
,
error
];
},
request
(
cfg
)
{
const
{
method
,
hideVccChannel
}
=
cfg
;
cfg
.
headers
[
'
X-Auth-Token
'
]
=
localStorage
.
get
(
'
vccToken
'
)
||
''
;
if
(
cfg
.
customHeader
)
{
Object
.
assign
(
cfg
.
headers
,
cfg
.
customHeader
);
}
if
(
!
hideVccChannel
)
{
cfg
.
headers
[
'
vccChannel
'
]
=
getVccChannel
();
cfg
.
headers
[
'
sonVccChannel
'
]
=
getVccChannel
(
'
sonVccChannel
'
);
}
if
(
method
===
'
post
'
&&
cfg
.
emulateJSON
)
{
cfg
.
headers
[
'
Content-Type
'
]
=
'
application/x-www-form-urlencoded
'
;
cfg
.
data
=
getURLSearchParams
(
cfg
.
data
);
}
return
cfg
;
}
}
},
{
strategy
:
'
groupBuy
'
,
headers
:
{
'
x-user-terminal
'
:
'
H5
'
,
version
:
appVersion
||
'
7900
'
...
...
src/service/init.service.js
View file @
ebbb2c40
...
...
@@ -10,9 +10,8 @@ export default {
// token校验,整个流程都是登陆后的
init
:
router
=>
{
router
.
beforeEach
((
to
,
from
,
next
)
=>
{
if
(
to
.
name
==
'
groupBuyList
'
&&
from
.
name
==
'
groupBuySkuInfo
'
)
{
// 这是为了详情页登录,把登录信息带回列表页所做的处理
to
.
query
.
vccToken
=
'
{token}
'
;
if
(
!
to
.
query
.
vccToken
)
{
to
.
query
.
vccToken
=
Cookies
.
get
(
'
vccToken
'
)
||
''
;
}
Cookies
.
set
(
'
h
'
,
0
);
// 所有自定义路由字段在此处理
...
...
@@ -31,6 +30,7 @@ export default {
}
if
(
value
&&
value
!==
'
{token}
'
&&
value
!==
'
{vccToken}
'
)
{
localStorage
.
set
(
item
,
value
);
Cookies
.
set
(
item
,
value
);
}
});
...
...
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