|
@@ -33,6 +33,10 @@ export default function Index (props) {
|
33
|
33
|
const [BannerList, setBannerList] = useState([])
|
34
|
34
|
// const [ActivityList, setActivityList] = useState([])
|
35
|
35
|
const [NewsList, setNewsList] = useState([])
|
|
36
|
+ const [ShowNotice, setShowNotice] = useState(false)
|
|
37
|
+ const [NoticeInfo, setNoticeInfo] = useState(null)
|
|
38
|
+ const [NoticeWidth, setNoticeWidth] = useState(0)
|
|
39
|
+ const [NoticeParentWidth, setNoticeParentWidth] = useState(0)
|
36
|
40
|
|
37
|
41
|
// 宣传位
|
38
|
42
|
const [propagandaList, setPropagandaList] = useState([])
|
|
@@ -41,7 +45,27 @@ export default function Index (props) {
|
41
|
45
|
Init()
|
42
|
46
|
})
|
43
|
47
|
|
|
48
|
+ useEffect(() => {
|
|
49
|
+ if (NoticeInfo !== null) {
|
|
50
|
+ window.setTimeout(() => {
|
|
51
|
+ let QueryParent = Taro.createSelectorQuery()
|
|
52
|
+ let QueryChild = Taro.createSelectorQuery()
|
|
53
|
+ QueryParent.select('#NoticeParent').boundingClientRect()
|
|
54
|
+ QueryChild.select('#NoticeText').boundingClientRect()
|
|
55
|
+ QueryParent.exec((res) => {
|
|
56
|
+ setNoticeParentWidth(res[0].width)
|
|
57
|
+ QueryChild.exec((cres) => {
|
|
58
|
+ setNoticeWidth(cres[0].width)
|
|
59
|
+ })
|
|
60
|
+ })
|
|
61
|
+ }, 100)
|
|
62
|
+ // let NoticeText = document.getElementById('NoticeText')
|
|
63
|
+ // console.log(NoticeText.boundingClientRect[0].width)
|
|
64
|
+ }
|
|
65
|
+ }, [NoticeInfo])
|
|
66
|
+
|
44
|
67
|
const Init = (done = () => { }) => { // 初始化
|
|
68
|
+ GetNotice() // 获取通知
|
45
|
69
|
let DownCount = 0
|
46
|
70
|
GetBanner(() => { // 获取轮播图
|
47
|
71
|
DownCount += 1
|
|
@@ -70,6 +94,15 @@ export default function Index (props) {
|
70
|
94
|
})
|
71
|
95
|
}
|
72
|
96
|
|
|
97
|
+ const GetNotice = () => { // 获取通知
|
|
98
|
+ request({ ...apis.getGongGaoList, args: { orgId: user.orgId }, params: { annType: 'notice', pageNum: 1, pageSize: 1 } }).then((res) => {
|
|
99
|
+ setNoticeInfo(res.records[0])
|
|
100
|
+ if (res.records !== null && res.records.length > 0) {
|
|
101
|
+ setShowNotice(true)
|
|
102
|
+ }
|
|
103
|
+ })
|
|
104
|
+ }
|
|
105
|
+
|
73
|
106
|
const GetBanner = (done = () => { }) => { // 获取轮播图
|
74
|
107
|
setBannerList([])
|
75
|
108
|
request({ ...apis.getBanner, params: { showType: 'banner', showPosition: 'index', pageNum: 1, pageSize: 5 } }).then((res) => {
|
|
@@ -169,6 +202,17 @@ export default function Index (props) {
|
169
|
202
|
|
170
|
203
|
<view>
|
171
|
204
|
|
|
205
|
+ {/* 通知栏 */}
|
|
206
|
+ <view className={ShowNotice ? 'NoticeContent flex-h active' : 'NoticeContent flex-h'}>
|
|
207
|
+ <text className='iconfont icontongzhi1'></text>
|
|
208
|
+ <view id='NoticeParent' className='flex-item' onClick={() => { Taro.navigateTo({ url: `/pages/WuYe/GongGaoDetail/index?id=${NoticeInfo.id}` }) }}>
|
|
209
|
+ <view style={{ width: `${NoticeWidth > NoticeParentWidth ? NoticeWidth : NoticeParentWidth}px` }}>
|
|
210
|
+ <text id='NoticeText'>{NoticeInfo === null ? '' : NoticeInfo.announcementTitle}</text>
|
|
211
|
+ </view>
|
|
212
|
+ </view>
|
|
213
|
+ <text className='iconfont iconguanbi' onClick={() => { setShowNotice(false) }}></text>
|
|
214
|
+ </view>
|
|
215
|
+
|
172
|
216
|
{/* 欢迎词 */}
|
173
|
217
|
<Text className='Welcome'>欢迎来到远道智慧社区!</Text>
|
174
|
218
|
|