xujing 5 年前
父节点
当前提交
a2d06722cd
共有 5 个文件被更改,包括 47 次插入20 次删除
  1. 11
    2
      src/actions/project.js
  2. 2
    1
      src/constants/project.js
  3. 1
    1
      src/pages/city/index.js
  4. 14
    14
      src/pages/project/index.js
  5. 19
    2
      src/reducers/project.js

+ 11
- 2
src/actions/project.js 查看文件

1
 import {
1
 import {
2
   PROJECT_DETAIL,
2
   PROJECT_DETAIL,
3
-  PROJECT_LIST
3
+  PROJECT_LIST,
4
+  PROJECT_SCREEN
4
 } from '@constants/project'
5
 } from '@constants/project'
5
 
6
 
6
 import {
7
 import {
7
   API_ITEMS_DETAIL,
8
   API_ITEMS_DETAIL,
8
-  API_ITEMS_LIST
9
+  API_ITEMS_LIST,
10
+  API_BANNER_LIST
9
 } from '@constants/api'
11
 } from '@constants/api'
10
 
12
 
11
 import { createAction } from '@utils/redux'
13
 import { createAction } from '@utils/redux'
30
   url: `${API_ITEMS_DETAIL}/${id}`,
32
   url: `${API_ITEMS_DETAIL}/${id}`,
31
   type: PROJECT_DETAIL
33
   type: PROJECT_DETAIL
32
 })
34
 })
35
+
36
+/**
37
+ * 获取开屏广告
38
+ *  @param {*} payload 
39
+ * 
40
+*/
41
+export const dispatchProjectScreen = (payload) => createAction({ url: `${API_BANNER_LIST}/screen`, payload, type: PROJECT_SCREEN })

+ 2
- 1
src/constants/project.js 查看文件

1
 export const PROJECT_LIST = 'PROJECT_LIST'
1
 export const PROJECT_LIST = 'PROJECT_LIST'
2
 export const PROJECT_DETAIL = 'PROJECT_DETAIL'
2
 export const PROJECT_DETAIL = 'PROJECT_DETAIL'
3
-
3
+export const PROJECT_SCREEN = 'PROJECT_SCREEN'
4
+export const SET_SCREEN_SHOWED = 'SET_SCREEN_SHOWED'
4
 export const LOCATION_CITY = 'LOCATION_CITY'
5
 export const LOCATION_CITY = 'LOCATION_CITY'

+ 1
- 1
src/pages/city/index.js 查看文件

40
       list
40
       list
41
     })
41
     })
42
   }
42
   }
43
-
43
+ 
44
   handleSelected(item) {
44
   handleSelected(item) {
45
     this.props.dispatchCitySelected(item).then(res => {
45
     this.props.dispatchCitySelected(item).then(res => {
46
       Taro.navigateBack({
46
       Taro.navigateBack({

+ 14
- 14
src/pages/project/index.js 查看文件

5
 import Banner from './banner'
5
 import Banner from './banner'
6
 import HelpGroupBanner from './swiper'
6
 import HelpGroupBanner from './swiper'
7
 // import ActivityItem from '../activity/item'
7
 // import ActivityItem from '../activity/item'
8
-
9
 import ready from '@utils/ready'
8
 import ready from '@utils/ready'
10
 import { getLocationCity } from '@services/map'
9
 import { getLocationCity } from '@services/map'
11
 
10
 
14
 import { queryActivityList } from '@services/activity'
13
 import { queryActivityList } from '@services/activity'
15
 import { dispatchCitySelected } from '@actions/city'
14
 import { dispatchCitySelected } from '@actions/city'
16
 import { ROLE_CODE, DECREASE_UNREADNUM } from '@constants/user'
15
 import { ROLE_CODE, DECREASE_UNREADNUM } from '@constants/user'
16
+import { SET_SCREEN_SHOWED } from '@constants/project'
17
 import { getStore, connect } from '@tarojs/redux'
17
 import { getStore, connect } from '@tarojs/redux'
18
 import * as actions from '@actions/project'
18
 import * as actions from '@actions/project'
19
 import { transferImage } from '@utils/tools'
19
 import { transferImage } from '@utils/tools'
85
   componentDidShow() {
85
   componentDidShow() {
86
     if (this.props.curCity.id) {
86
     if (this.props.curCity.id) {
87
       ready.queue(() => {
87
       ready.queue(() => {
88
+        // debugger
88
         this.loadData()
89
         this.loadData()
89
       })
90
       })
90
     }
91
     }
153
     this.loadBannerList()
154
     this.loadBannerList()
154
     this.loadHelpGroupList()
155
     this.loadHelpGroupList()
155
     this.loadNewsList()
156
     this.loadNewsList()
157
+    this.loadOpenScreenBanner()
156
     // this.loadActivityList()
158
     // this.loadActivityList()
157
     this.loadList()
159
     this.loadList()
158
 
160
 
163
     const payload = {}
165
     const payload = {}
164
     if (curCity.id) {
166
     if (curCity.id) {
165
       payload.cityId = curCity.id
167
       payload.cityId = curCity.id
166
-    } else {
167
-
168
     }
168
     }
169
+
169
     // 获取开屏广告图
170
     // 获取开屏广告图
170
-    queryBanners('screen', payload).then(res => {
171
+    this.props.dispatchProjectScreen(payload).then(res => {
171
       const banner = res[0]
172
       const banner = res[0]
172
-      if (banner) {
173
+      debugger
174
+      const maskVisible = this.props.screenShow !== (banner || {}).contentId
175
+
176
+      if (maskVisible) {
173
         Taro.hideTabBar({
177
         Taro.hideTabBar({
174
           animation: true
178
           animation: true
175
         })
179
         })
176
       }
180
       }
181
+
177
       this.setState({
182
       this.setState({
178
-        maskVisible: banner ? true : false,
183
+        maskVisible,
179
         maskBanner: banner
184
         maskBanner: banner
185
+      }, () => {
186
+        const { dispatch } = getStore()
187
+        dispatch({ type: SET_SCREEN_SHOWED, payload: (banner || {}).contentId })
180
       })
188
       })
181
     })
189
     })
182
   }
190
   }
183
-  componentWillReceiveProps(nextProps) {
184
-    console.log(nextProps.curCity, "curCitycurCitycurCitycurCitycurCity")
185
-    console.log(this.state.maskBanner, "maskBannermaskBannermaskBannermaskBannermaskBanner")
186
-
187
-    if (!this.state.maskBanner && JSON.stringify(nextProps.curCity) != '{}') {
188
 
191
 
189
-      this.loadOpenScreenBanner()
190
-    }
191
-  }
192
   loadBannerList() {
192
   loadBannerList() {
193
     const { curCity } = this.props
193
     const { curCity } = this.props
194
     // 获取首页banner
194
     // 获取首页banner

+ 19
- 2
src/reducers/project.js 查看文件

1
 import {
1
 import {
2
   PROJECT_DETAIL,
2
   PROJECT_DETAIL,
3
-  PROJECT_LIST
3
+  PROJECT_LIST,
4
+  PROJECT_SCREEN,
5
+  SET_SCREEN_SHOWED,
4
 } from '@constants/project'
6
 } from '@constants/project'
5
 
7
 
6
 
8
 
7
 const INITIAL_STATE = {
9
 const INITIAL_STATE = {
8
   proList: {},
10
   proList: {},
9
-  projectDetail: {}
11
+  projectDetail: {},
12
+  screen: {},
13
+  screenShow: undefined,
10
 }
14
 }
11
 
15
 
12
 export default function project(state = INITIAL_STATE, action) {
16
 export default function project(state = INITIAL_STATE, action) {
27
         }
31
         }
28
       }
32
       }
29
     }
33
     }
34
+    case PROJECT_SCREEN: {
35
+      return {
36
+        ...state,
37
+        screen: (action.payload || [])[0] || {}
38
+      }
39
+    }
40
+
41
+    case SET_SCREEN_SHOWED: {
42
+      return {
43
+        ...state,
44
+        screenShow: action.payload,
45
+      }
46
+    }
30
 
47
 
31
     default:
48
     default:
32
       return state
49
       return state