Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
crisis-event-miniprogram
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
liangyuhang
crisis-event-miniprogram
Commits
fb743853
Commit
fb743853
authored
Aug 03, 2022
by
liangyuhang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
除了详情页需要登录,其他都不需要登录
parent
37bcd045
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
81 additions
and
29 deletions
+81
-29
app.js
+14
-14
pages/index/index.js
+2
-1
pages/library/library.js
+1
-1
pages/report/report.js
+1
-1
pages/search-page/search-page.js
+1
-1
pages/search-result/search-result.js
+2
-2
pages/usercenter/usercenter.js
+51
-4
pages/usercenter/usercenter.wxml
+4
-0
utils/http.js
+5
-5
No files found.
app.js
View file @
fb743853
...
...
@@ -4,20 +4,20 @@ import {getRequest} from './utils/http'
App
({
onLaunch
()
{
//每次打开小程序时刷新token
let
openId
=
wx
.
getStorageSync
(
'openId'
);
if
(
openId
){
// console.log(openId)
getRequest
(
'/mobile/refreshToken?openId='
+
openId
).
then
(
res
=>
{
if
(
res
){
console
.
log
(
"刷新token"
)
wx
.
setStorageSync
(
'token'
,
res
.
data
.
data
.
token
)
}
})
}
else
{
wx
.
reLaunch
({
url
:
'/pages/login/login'
,
})
}
//
let openId = wx.getStorageSync('openId');
//
if(openId){
//
// console.log(openId)
//
getRequest('/mobile/refreshToken?openId='+openId).then(res=>{
//
if(res){
//
console.log("刷新token")
//
wx.setStorageSync('token', res.data.data.token)
//
}
//
})
//
}else{
//
wx.reLaunch({
//
url: '/pages/login/login',
//
})
//
}
},
globalData
:
{
// userInfo: null,
...
...
pages/index/index.js
View file @
fb743853
...
...
@@ -51,8 +51,9 @@ Page({
setCrisisDynamicData
(){
http
.
getRequest
(
'/mobile/index/event/recently'
).
then
(
res
=>
{
if
(
res
){
// console.log(res)
this
.
setData
({
crisisDynamic
:
res
.
data
.
data
.
list
crisisDynamic
:
res
.
data
.
data
})
}
})
...
...
pages/library/library.js
View file @
fb743853
...
...
@@ -49,7 +49,7 @@ Page({
wx
.
showLoading
({
title
:
'加载中...'
})
http
.
getRequest
(
'/
events
?page='
+
this
.
data
.
page
+
'&size='
+
this
.
data
.
size
+
'&industry='
+
this
.
data
.
industry
).
then
(
res
=>
{
http
.
getRequest
(
'/
mobile/eventList
?page='
+
this
.
data
.
page
+
'&size='
+
this
.
data
.
size
+
'&industry='
+
this
.
data
.
industry
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
){
// console.log(res)
this
.
setData
({
...
...
pages/report/report.js
View file @
fb743853
...
...
@@ -46,7 +46,7 @@ Page({
wx
.
showLoading
({
title
:
'加载中...'
})
http
.
getRequest
(
'/
reports
?page='
+
this
.
data
.
page
+
'&size='
+
this
.
data
.
size
+
'&category='
+
this
.
data
.
category
).
then
(
res
=>
{
http
.
getRequest
(
'/
mobile/reportList
?page='
+
this
.
data
.
page
+
'&size='
+
this
.
data
.
size
+
'&category='
+
this
.
data
.
category
).
then
(
res
=>
{
if
(
res
.
data
.
code
==
200
){
this
.
setData
({
reportList
:
this
.
data
.
reportList
.
concat
(
res
.
data
.
data
.
list
),
...
...
pages/search-page/search-page.js
View file @
fb743853
...
...
@@ -86,7 +86,7 @@ Page({
},
// 获取热点危机
getHotSearch
(){
http
.
getRequest
(
'/search/event/online-top5'
).
then
(
res
=>
{
http
.
getRequest
(
'/
mobile/
search/event/online-top5'
).
then
(
res
=>
{
// console.log(res)
if
(
res
){
this
.
setData
({
...
...
pages/search-result/search-result.js
View file @
fb743853
...
...
@@ -68,7 +68,7 @@ Page({
},
//根据关键词查询事件列表
getEventListByKeyword
(
params
){
http
.
getRequest
(
'/search/events'
,
params
).
then
(
res
=>
{
http
.
getRequest
(
'/
mobile/
search/events'
,
params
).
then
(
res
=>
{
// console.log(res)
if
(
res
){
this
.
setData
({
...
...
@@ -80,7 +80,7 @@ Page({
},
//根据关键词查询报告列表
getReportListByKeyword
(
params
){
http
.
getRequest
(
'/search/reports'
,
params
).
then
(
res
=>
{
http
.
getRequest
(
'/
mobile/
search/reports'
,
params
).
then
(
res
=>
{
// console.log(res)
if
(
res
){
this
.
setData
({
...
...
pages/usercenter/usercenter.js
View file @
fb743853
...
...
@@ -12,6 +12,53 @@ Page({
headUrl
:
wx
.
getStorageSync
(
'headUrl'
),
roleId
:
wx
.
getStorageSync
(
'roleId'
)
},
onGetPhoneNumber
(
e
){
wx
.
showLoading
({
title
:
'正在登录...'
})
if
(
e
.
detail
.
iv
)
{
wx
.
login
({
success
:
res
=>
{
// console.log(res)
let
data
=
{
encryptedData
:
e
.
detail
.
encryptedData
,
iv
:
e
.
detail
.
iv
,
code
:
res
.
code
}
http
.
postRequest
(
'/mobile/login'
,
data
).
then
(
res
=>
{
wx
.
hideLoading
()
if
(
res
){
console
.
log
(
res
)
wx
.
setStorageSync
(
'token'
,
res
.
data
.
data
.
token
)
wx
.
setStorageSync
(
'userName'
,
res
.
data
.
data
.
userName
)
wx
.
setStorageSync
(
'headUrl'
,
res
.
data
.
data
.
headUrl
)
wx
.
setStorageSync
(
'roleId'
,
res
.
data
.
data
.
roleId
)
wx
.
setStorageSync
(
'isLogin'
,
true
)
this
.
setData
({
token
:
res
.
data
.
data
.
token
,
userName
:
res
.
data
.
data
.
userName
,
headUrl
:
res
.
data
.
data
.
headUrl
,
roleId
:
res
.
data
.
data
.
roleId
,
isLogin
:
true
})
}
})
},
fail
:
err
=>
{
// console.log('登录失败!')
wx
.
showToast
({
title
:
'登录失败!'
,
icon
:
'none'
})
}
})
}
else
{
wx
.
showToast
({
title
:
'您已拒绝授权'
,
icon
:
'none'
})
}
},
getUserProfile
(
e
){
wx
.
getUserProfile
({
desc
:
'用于完善会员资料'
,
// 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
...
...
@@ -25,10 +72,10 @@ Page({
})
},
logout
(
e
){
wx
.
setStorageSync
(
'token'
,
'
'
)
wx
.
setStorageSync
(
'userName'
,
'
'
)
wx
.
setStorageSync
(
'headUrl'
,
'
'
)
wx
.
setStorageSync
(
'roleId'
,
'
'
)
wx
.
removeStorageSync
(
'token
'
)
wx
.
removeStorageSync
(
'userName
'
)
wx
.
removeStorageSync
(
'headUrl
'
)
wx
.
removeStorageSync
(
'roleId
'
)
wx
.
setStorageSync
(
'isLogin'
,
false
)
this
.
setData
({
token
:
''
,
...
...
pages/usercenter/usercenter.wxml
View file @
fb743853
...
...
@@ -54,6 +54,10 @@
<view wx:if="{{isLogin}}">
<button class="logout-btn" bindtap="logout">退出登录</button>
</view>
<view wx:else>
<button open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber" class="login-btn">点此登录</button>
</view>
</view>
...
...
utils/http.js
View file @
fb743853
...
...
@@ -5,11 +5,11 @@ const imgURL = baseURL+'/app/'
const
request
=
function
(
url
,
options
){
wx
.
getStorageSync
(
'token'
)
let
token
=
wx
.
getStorageSync
(
'token'
)
if
(
url
!=
'/mobile/login'
&&
!
token
){
wx
.
reLaunch
({
url
:
'/pages/login/login'
,
})
}
//
if(url!='/mobile/login' && !token){
//
wx.reLaunch({
//
url: '/pages/login/login',
//
})
//
}
return
new
Promise
((
resolve
,
reject
)
=>
{
wx
.
request
({
url
:
baseURL
+
url
,
...
...
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