Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wx-school-app
Project
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
姜雷
wx-school-app
Commits
408bd7d1
Commit
408bd7d1
authored
Sep 06, 2019
by
姜雷
Browse files
Options
Browse Files
Download
Plain Diff
合并冲突
parents
610e4442
19920257
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
134 additions
and
75 deletions
+134
-75
home.ts
src/api/home.ts
+46
-1
index.ts
src/api/index.ts
+2
-2
index.js
src/constants/index.js
+1
-2
Announcement.tsx
src/pages/Announcement/Announcement.tsx
+20
-18
Content.tsx
src/pages/Content/Content.tsx
+7
-2
Home.tsx
src/pages/Home/Home.tsx
+15
-50
useNotices.ts
src/pages/Home/hooks/useNotices.ts
+43
-0
No files found.
src/api/home.ts
View file @
408bd7d1
import
{
ResponseDataEntity
,
smaproFetch
}
from
'./index'
;
import
{
ResponseDataEntity
,
smaproFetch
,
appHomeFetch
}
from
'./index'
;
export
enum
ServiceTypeParams
{
wechatPublicV
=
1
,
...
...
@@ -22,3 +22,48 @@ export const fetchAreaService = (
smaproFetch
({
url
:
`/smpro/areaServiceConfigs/
${
data
.
areaId
}
/
${
data
.
type
}
`
,
});
export
enum
PublishClient
{
android
=
'1'
,
ios
=
'2'
,
wx
=
'3'
,
}
type
NoticeParams
=
{
customerId
:
number
;
publishClient
:
PublishClient
;
};
enum
NoticeState
{
published
=
1
,
unpublished
=
0
,
}
export
type
AppHomeNoticeAppVo
=
{
content
:
string
;
// 内容
createAt
:
string
;
// 创建时间
id
:
number
;
// 主键ID
noticeCode
:
string
;
// 公告编码
noticeImgs
:
string
;
// 公告图片
noticeTitle
:
string
;
// 公告名称
noticeType
:
string
;
// 强弹类型 1是 2否
operateId
:
number
;
// 运营商ID
operator
:
string
;
// 操作人
publishClient
:
PublishClient
;
// 发布端
sortId
:
number
;
// 排序号
state
:
NoticeState
;
// 状态 1已发布 0未发布
updateAt
:
string
;
// 更新时间
whetherClicked
:
boolean
;
// 是否点击false为否true为是
};
export
const
fetchLastNotice
=
(
entity
:
NoticeParams
,
):
Promise
<
ResponseDataEntity
<
AppHomeNoticeAppVo
>>
=>
appHomeFetch
({
url
:
'/app/home/module/newest/notice'
,
data
:
entity
,
});
export
const
fetchNoticesData
=
(
entity
:
NoticeParams
,
):
Promise
<
ResponseDataEntity
<
AppHomeNoticeAppVo
[]
>>
=>
appHomeFetch
({
url
:
'/app/home/module/notice'
,
data
:
entity
,
});
src/api/index.ts
View file @
408bd7d1
...
...
@@ -3,13 +3,13 @@ import store from '../store/index';
import
{
BASE_SERVER_URL
,
CUSTOMER_SERVER_URL
,
SCHOOL_MAIN_URL
,
LogoutCode
,
SuccessCode
,
OLD_BASE_SERVER_URL
,
SHOWER_APP_URL
,
SMPRO_URL
,
GX_URL
,
APP_HOME_URL
,
}
from
'../constants/index'
;
export
type
ResponseDataEntity
<
T
>
=
{
...
...
@@ -62,7 +62,7 @@ const createFetch = (basePath: string) => {
export
const
baseFetch
=
createFetch
(
BASE_SERVER_URL
);
export
const
oldBaseFetch
=
createFetch
(
OLD_BASE_SERVER_URL
);
export
const
customerFetch
=
createFetch
(
CUSTOMER_SERVER_URL
);
export
const
schoolMainFetch
=
createFetch
(
SCHOOL_MAIN
_URL
);
export
const
appHomeFetch
=
createFetch
(
APP_HOME
_URL
);
export
const
showerFetch
=
createFetch
(
SHOWER_APP_URL
);
export
const
smaproFetch
=
createFetch
(
SMPRO_URL
);
export
const
gxFetch
=
createFetch
(
GX_URL
);
...
...
src/constants/index.js
View file @
408bd7d1
...
...
@@ -8,8 +8,7 @@ export const BASE_SERVER_URL = 'https://ex-test-dcxy-base-app.168cad.top';
export
const
OLD_BASE_SERVER_URL
=
'https://in-test-selfbase.168cad.top'
;
export
const
CUSTOMER_SERVER_URL
=
'https://ex-test-dcxy-customer-app.168cad.top'
;
export
const
SCHOOL_MAIN_URL
=
'https://internal-test-school-home-bg.168cad.top'
;
export
const
APP_HOME_URL
=
'https://ex-test-dcxy-home-app.168cad.top'
;
export
const
ANN_LINK_URL
=
'https://ex-test-wx.168cad.top/announcement/'
;
export
const
SHOWER_APP_URL
=
'https://in-test-shower-app-server.168cad.top'
;
export
const
SOCKET_URL
=
'wss://test-shower-wss1.168cad.top:9443/ws'
;
...
...
src/pages/Announcement/Announcement.tsx
View file @
408bd7d1
...
...
@@ -3,12 +3,16 @@ import { ComponentClass } from 'react';
import
{
View
,
ScrollView
,
Image
,
Text
,
WebView
}
from
'@tarojs/components'
;
import
AnnIcon
from
'../../images/icon/ann_tongzhi_icon@2x.png'
;
import
{
fetchAllAnn
,
AnnItem
}
from
'../../api/announcement'
;
import
{
connect
}
from
'@tarojs/redux'
;
import
'./Announcement.scss'
;
import
{
Customer
}
from
'@/types/Customer/Customer'
;
import
{
shareHandle
}
from
'@/common/shareMethod'
;
import
{
fetchNoticesData
,
PublishClient
,
AppHomeNoticeAppVo
,
}
from
'@/api/home'
;
type
PageStateProps
=
{
userinfo
:
Customer
;
...
...
@@ -17,7 +21,7 @@ type PageOwnProps = {};
type
PageState
=
{
pageNum
:
number
;
pageSize
:
number
;
list
:
A
nnItem
[];
list
:
A
ppHomeNoticeAppVo
[];
linkUrl
:
string
;
};
...
...
@@ -43,24 +47,25 @@ class Announcement extends Component {
componentWillMount
()
{
const
{
userinfo
}
=
this
.
props
;
const
{
sectionId
}
=
this
.
$router
.
params
;
fetchAllAnn
({
campusId
:
userinfo
.
areaId
,
sectionId
:
sectionId
,
fetchNoticesData
({
customerId
:
userinfo
.
customerId
,
publishClient
:
PublishClient
.
wx
,
})
.
then
(
res
=>
{
const
data
=
res
.
data
;
this
.
setState
({
...
data
,
list
:
data
,
});
})
.
catch
(
err
=>
{
console
.
log
(
err
);
});
}
geAnnDetail
(
id
:
number
)
{
geAnnDetail
(
id
:
string
)
{
const
{
userinfo
}
=
this
.
props
;
Taro
.
navigateTo
({
url
:
`/pages/Content/Content?id=
${
id
}
`
,
url
:
`/pages/Content/Content?id=
${
id
}
&customerId=
${
userinfo
.
customerId
}
`
,
});
}
render
()
{
...
...
@@ -70,19 +75,16 @@ class Announcement extends Component {
{
linkUrl
&&
<
WebView
src=
{
linkUrl
}
/>
}
{
list
.
map
(
annItem
=>
(
<
View
key=
{
annItem
.
id
}
key=
{
annItem
.
noticeCode
}
className=
'Announcement-item'
onClick=
{
()
=>
this
.
geAnnDetail
(
annItem
.
id
)
}
>
<
Image
className=
'Announcement-item-img'
src=
{
annItem
.
linkUrls
[
0
]
}
/>
onClick=
{
()
=>
this
.
geAnnDetail
(
annItem
.
noticeCode
)
}
>
<
Image
className=
'Announcement-item-img'
src=
{
annItem
.
noticeImgs
}
/>
<
View
className=
'Announcement-item-Content'
>
<
Image
className=
'Announcement-item-icon'
src=
{
AnnIcon
}
/>
<
Text
className=
'Announcement-item-title'
>
{
annItem
.
title
}
</
Text
>
<
Text
className=
'Announcement-item-date'
>
{
annItem
.
updateTime
}
<
Text
className=
'Announcement-item-title'
>
{
annItem
.
noticeTitle
}
</
Text
>
<
Text
className=
'Announcement-item-date'
>
{
annItem
.
updateAt
}
</
Text
>
</
View
>
</
View
>
))
}
...
...
src/pages/Content/Content.tsx
View file @
408bd7d1
...
...
@@ -4,6 +4,7 @@ import { WebView } from '@tarojs/components';
import
{
connect
}
from
'@tarojs/redux'
;
import
{
ANN_LINK_URL
}
from
'../../constants'
;
import
{
shareHandle
}
from
'@/common/shareMethod'
;
import
useNotices
from
'../Home/hooks/useNotices'
;
type
PageOwnProps
=
{
token
:
string
;
...
...
@@ -32,14 +33,18 @@ class Content extends Component {
getLinkUrl
()
{
const
{
token
}
=
this
.
props
;
const
{
id
}
=
this
.
$router
.
params
;
const
{
id
,
customerId
}
=
this
.
$router
.
params
;
console
.
log
(
id
);
this
.
setState
({
linkUrl
:
`
${
ANN_LINK_URL
}
?id=
${
id
}
&token=
${
token
}
`
,
linkUrl
:
`
${
ANN_LINK_URL
}
?id=
${
id
}
&token=
${
token
}
&customerId=
${
customerId
}
`
,
});
}
render
()
{
const
{
linkUrl
}
=
this
.
state
;
console
.
log
(
linkUrl
);
return
linkUrl
&&
<
WebView
src=
{
linkUrl
}
/>;
}
}
...
...
src/pages/Home/Home.tsx
View file @
408bd7d1
...
...
@@ -29,9 +29,8 @@ import {
updateUserInfo
,
INITIAL_STATE
as
userINitState
,
}
from
'../../store/rootReducers/userinfo'
;
import
{
fetchAnn
,
SectionItem
}
from
'../../api/announcement'
;
import
{
appLogout
}
from
'../../api/customer'
;
import
{
Customer
}
from
'@/types/Customer/Customer'
;
import
{
Customer
,
CustomerSex
}
from
'@/types/Customer/Customer'
;
import
{
shareHandle
}
from
'@/common/shareMethod'
;
import
{
fetchAreaService
,
ServiceTypeParams
,
Service
}
from
'@/api/home'
;
import
MenuIconNormal
from
'@/components/MenuIcon/normal/MenuIconNormal'
;
...
...
@@ -44,6 +43,7 @@ import {
ControllerResponse
,
}
from
'@/api/shower'
;
import
{
updateShowerControlConfig
}
from
'@/store/rootReducers/shower'
;
import
useNotices
from
'./hooks/useNotices'
;
type
PageStateProps
=
{
userinfo
:
Customer
;
...
...
@@ -63,7 +63,6 @@ type BeanAccount = {
type
PageState
=
{
barMenuVisiable
:
boolean
;
beanAccount
:
BeanAccount
[];
annItem
:
SectionItem
;
filterBeanList
:
BeanAccount
[];
};
type
IProps
=
PageStateProps
&
PageDispatchProps
;
...
...
@@ -100,18 +99,6 @@ class Home extends Component {
barMenuVisiable
:
false
,
beanAccount
:
[],
filterBeanList
:
[],
annItem
:
{
id
:
0
,
styleType
:
''
,
name
:
''
,
titleTypeRemark
:
''
,
titleType
:
''
,
titleContent
:
''
,
sort
:
0
,
updateTime
:
0
,
itemsCount
:
0
,
items
:
[],
},
};
}
...
...
@@ -127,7 +114,6 @@ class Home extends Component {
getInitData
()
{
this
.
getServiceList
();
this
.
getAnn
();
}
getServiceList
()
{
...
...
@@ -142,24 +128,6 @@ class Home extends Component {
}
}
getAnn
()
{
const
{
userinfo
}
=
this
.
props
;
fetchAnn
({
campusId
:
userinfo
.
areaId
,
customerId
:
userinfo
.
customerId
,
})
.
then
(
res
=>
{
if
(
res
)
{
this
.
setState
({
annItem
:
res
,
});
}
})
.
catch
(
err
=>
{
console
.
error
(
err
);
});
}
goSetting
()
{
Taro
.
navigateTo
({
url
:
'/pages/UserSetting/UserSetting'
,
...
...
@@ -171,9 +139,9 @@ class Home extends Component {
url
:
'/pages/Feedback/Feedback'
,
});
}
goAnn
(
id
:
number
)
{
goAnn
(
code
:
string
)
{
Taro
.
navigateTo
({
url
:
'/pages/Announcement/Announcement?sectionId='
+
id
,
url
:
'/pages/Announcement/Announcement?sectionId='
+
code
,
});
}
...
...
@@ -249,10 +217,10 @@ class Home extends Component {
let
newPhone
=
phone
.
replace
(
/
([
0-9
]{3})([
0-9
]{4})([
0-9
]{4})
/
,
'$1****$3'
);
return
newPhone
;
};
geAnnDetail
(
id
:
number
)
{
cons
ole
.
log
(
id
)
;
geAnnDetail
(
code
:
string
)
{
cons
t
{
userinfo
}
=
this
.
props
;
Taro
.
navigateTo
({
url
:
`/pages/Content/Content?id=
${
i
d
}
`
,
url
:
`/pages/Content/Content?id=
${
code
}
&customerId=
${
userinfo
.
customerI
d
}
`
,
});
}
...
...
@@ -265,8 +233,9 @@ class Home extends Component {
render
()
{
const
{
userinfo
,
serviceList
}
=
this
.
props
;
const
{
annItem
,
barMenuVisiable
}
=
this
.
state
;
const
{
barMenuVisiable
}
=
this
.
state
;
const
noticeData
=
useNotices
();
return
(
<
View
className=
'Home'
>
{
barMenuVisiable
?
(
...
...
@@ -300,7 +269,7 @@ class Home extends Component {
</
View
>
<
View
className=
'Home-UserBox-addr'
>
{
userinfo
.
areaName
}
</
View
>
</
View
>
{
userinfo
.
customerSex
===
'2'
?
(
{
userinfo
.
customerSex
===
CustomerSex
.
girl
?
(
<
Image
className=
'Home-UserBox-headimg'
src=
{
UserHeaderF
}
...
...
@@ -436,30 +405,26 @@ class Home extends Component {
)
:
null
}
</
View
>
{
annItem
.
id
?
(
{
noticeData
.
noticeCode
?
(
<
View
className=
'Home-Announcement'
>
<
Image
className=
'bg'
src=
{
AnnouncementBg
}
/>
<
View
className=
'Home-Announcement-title'
>
<
Text
>
最新公告
</
Text
>
<
View
className=
'Home-Announcement-more'
onClick=
{
()
=>
this
.
goAnn
(
annItem
.
id
)
}
>
onClick=
{
()
=>
this
.
goAnn
(
noticeData
.
noticeCode
)
}
>
更多
<
Image
className=
'more-icon'
src=
{
MoreIcon
}
/>
</
View
>
</
View
>
{
annItem
.
items
.
length
&&
(
<
View
className=
'Home-Announcement-Content'
onClick=
{
()
=>
this
.
geAnnDetail
(
annItem
.
items
[
0
].
id
)
}
>
onClick=
{
()
=>
this
.
geAnnDetail
(
noticeData
.
noticeCode
)
}
>
<
Text
className=
'Home-Announcement-Content-title'
>
{
annItem
.
items
[
0
].
title
}
</
Text
>
<
Text
className=
'ContentDate'
>
{
annItem
.
items
[
0
].
updateTime
}
{
noticeData
.
noticeTitle
}
</
Text
>
<
Text
className=
'ContentDate'
>
{
noticeData
.
updateAt
}
</
Text
>
</
View
>
)
}
</
View
>
)
:
null
}
</
View
>
...
...
src/pages/Home/hooks/useNotices.ts
0 → 100644
View file @
408bd7d1
import
{
useEffect
,
useState
}
from
'@tarojs/taro'
;
import
{
fetchLastNotice
,
PublishClient
,
AppHomeNoticeAppVo
}
from
'@/api/home'
;
import
{
useSelector
}
from
'@tarojs/redux'
;
import
{
Customer
}
from
'@/types/Customer/Customer'
;
const
initState
:
AppHomeNoticeAppVo
=
{
content
:
''
,
// 内容
createAt
:
''
,
// 创建时间
id
:
0
,
// 主键ID
noticeCode
:
''
,
// 公告编码
noticeImgs
:
''
,
// 公告图片
noticeTitle
:
''
,
// 公告名称
noticeType
:
''
,
// 强弹类型 1是 2否
operateId
:
0
,
// 运营商ID
operator
:
''
,
// 操作人
publishClient
:
PublishClient
.
wx
,
// 发布端
sortId
:
0
,
// 排序号
state
:
1
,
// 状态 1已发布 0未发布
updateAt
:
''
,
// 更新时间
whetherClicked
:
false
,
// 是否点击false为否true为是
};
const
useNotices
=
():
AppHomeNoticeAppVo
=>
{
const
[
state
,
setState
]
=
useState
(
initState
);
const
userinfo
=
useSelector
(
(
state
:
{
userinfo
:
Customer
})
=>
state
.
userinfo
,
);
useEffect
(()
=>
{
fetchLastNotice
({
customerId
:
userinfo
.
customerId
,
publishClient
:
PublishClient
.
wx
,
})
.
then
(
res
=>
{
console
.
log
(
res
);
setState
(
res
.
data
);
})
.
catch
(
err
=>
{
console
.
log
(
err
);
});
},
[]);
return
state
;
};
export
default
useNotices
;
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