浏览代码

静态页面

1002884655 4 年前
父节点
当前提交
bfb27f2d11

+ 48
- 0
src/components/AdvLayer/index.jsx 查看文件

@@ -0,0 +1,48 @@
1
+import React, { useState, useEffect } from 'react'
2
+import request, { apis } from '@/utils/request'
3
+import { Text } from '@tarojs/components'
4
+import { useModel } from '@/store'
5
+import '@/assets/css/reset.less'
6
+import '@/assets/css/iconfont.less'
7
+import './index.less'
8
+
9
+export default function AdvLayer () {
10
+
11
+  const { screen, setScreen } = useModel('screen')
12
+  const [AdvDetail, setAdvDetail] = useState(null)
13
+  const [ShowIndexAdv, setShowIndexAdv] = useState(false)
14
+
15
+  useEffect(() => {
16
+    if (screen.FirstComing) {
17
+      request({ ...apis.getIndexAdv, params: { showType: `screen`, showPosition: `index` } }).then((res) => {
18
+        setScreen({ FirstComing: false })
19
+        if (res !== null && res.length > 0) {
20
+          setAdvDetail(res[0])
21
+          setShowIndexAdv(true)
22
+        }
23
+      })
24
+    }
25
+  }, [screen])
26
+
27
+  const AdvClick = () => {
28
+    setShowIndexAdv(false)
29
+    if (AdvDetail.contentType === 'news') {
30
+      Taro.navigateTo({ url: `/pages/HuoDong/ZiXunDetail/index?id=${AdvDetail.contentId}` })
31
+    } else if (AdvDetail.contentType === 'tpNews') {
32
+      Taro.navigateTo({ url: `/pages/WuYe/FuWuDetail/index?id=${AdvDetail.contentId}` })
33
+    } else if (AdvDetail.contentType === 'notice') {
34
+      Taro.navigateTo({ url: `/pages/WuYe/GongGaoDetail/index?id=${AdvDetail.contentId}` })
35
+    } else if (AdvDetail.contentType === 'activity') {
36
+      Taro.navigateTo({ url: `/pages/HuoDong/HuoDongDetail/index?id=${AdvDetail.contentId}` })
37
+    }
38
+  }
39
+
40
+  return (
41
+    <view className='AdvLayer' style={{ display: ShowIndexAdv ? 'block' : 'none' }}>
42
+      <view className='centerLabel'>
43
+        <image mode='aspectFit' src={AdvDetail !== null ? AdvDetail.image : null} onClick={AdvClick}></image>
44
+        <Text className='iconfont iconguanbi' onClick={() => { setShowIndexAdv(false) }}></Text>
45
+      </view>
46
+    </view>
47
+  )
48
+}

+ 36
- 0
src/components/AdvLayer/index.less 查看文件

@@ -0,0 +1,36 @@
1
+.AdvLayer {
2
+  width: 100%;
3
+  position: absolute;
4
+  left: 0;
5
+  top: 0;
6
+  bottom: 0;
7
+  z-index: 20000;
8
+  background: rgba(0, 0, 0, 0.8);
9
+
10
+  >view {
11
+    width: 100%;
12
+    height: 100vw;
13
+    overflow: visible;
14
+
15
+    >image {
16
+      width: 60%;
17
+      height: 60%;
18
+      position: relative;
19
+      z-index: 1;
20
+      margin: 0 auto;
21
+      display: block;
22
+    }
23
+
24
+    >text {
25
+      display: inline-block;
26
+      color: #fff;
27
+      font-size: 60px;
28
+      position: absolute;
29
+      left: 50%;
30
+      bottom: -30px;
31
+      transform: translateX(-50%);
32
+      -webkit-transform: translateX(-50%);
33
+      z-index: 2;
34
+    }
35
+  }
36
+}

+ 25
- 0
src/components/YeZhuRenZhengPopup/index.jsx 查看文件

@@ -0,0 +1,25 @@
1
+import React, { useState } from 'react'
2
+import AddYeZhuRenZheng from '@/components/AddYeZhuRenZheng'
3
+import '@/assets/css/reset.less'
4
+import '@/assets/css/iconfont.less'
5
+import './index.less'
6
+
7
+export default function YeZhuRenZhengPopup (props) {
8
+
9
+  const { Show = false, Close = () => { } } = props
10
+
11
+  return (
12
+    <view className={Show ? 'YeZhuRenZhengPopup active' : 'YeZhuRenZhengPopup'}>
13
+      <view className='centerLabel'>
14
+        <view>
15
+          <scroll-view scroll-y='true'>
16
+            {
17
+              Show &&
18
+              <AddYeZhuRenZheng Close={Close}></AddYeZhuRenZheng>
19
+            }
20
+          </scroll-view>
21
+        </view>
22
+      </view>
23
+    </view>
24
+  )
25
+}

+ 33
- 0
src/components/YeZhuRenZhengPopup/index.less 查看文件

@@ -0,0 +1,33 @@
1
+.YeZhuRenZhengPopup {
2
+  width: 100%;
3
+  position: fixed;
4
+  left: 0;
5
+  top: 0;
6
+  bottom: 0;
7
+  background: rgba(0, 0, 0, 0.8);
8
+  display: none;
9
+
10
+  &.active {
11
+    display: block;
12
+  }
13
+
14
+  >view {
15
+    width: 100%;
16
+
17
+    >view {
18
+      padding: 0 30px;
19
+      position: relative;
20
+      overflow: hidden;
21
+
22
+      >scroll-view {
23
+        padding: 30px 0;
24
+        background: #fff;
25
+        border-radius: 10px;
26
+        position: relative;
27
+        max-height: 90vh;
28
+        overflow-y: scroll;
29
+        -webkit-overflow-scrolling: touch;
30
+      }
31
+    }
32
+  }
33
+}

+ 1
- 3
src/components/demo/index.jsx 查看文件

@@ -6,10 +6,8 @@ import './index.less'
6 6
 export default function demo (props) {
7 7
 
8 8
   return (
9
-    <Page>
10
-      <view className='demo'>
9
+    <view className='demo'>
11 10
 
12 11
     </view>
13
-    </Page>
14 12
   )
15 13
 }

+ 4
- 56
src/layouts/index.jsx 查看文件

@@ -1,13 +1,12 @@
1 1
 import React, { useState, useEffect } from 'react'
2 2
 import Taro from '@tarojs/taro'
3 3
 import { useModel } from '@/store'
4
-import { Text , ScrollView } from '@tarojs/components'
5 4
 import Spin from '@/components/Spin'
6 5
 import GetUserPhone from '@/components/GetUserPhone/index'
7 6
 import GetUserIcon from '@/components/GetUserIcon/index'
8
-import AddYeZhuRenZheng from '@/components/AddYeZhuRenZheng'
7
+import AdvLayer from '@/components/AdvLayer'
8
+import YeZhuRenZhengPopup from '@/components/YeZhuRenZhengPopup'
9 9
 import useMountTrack from '@/utils/hooks/useMountTrack'
10
-import request, { apis } from '@/utils/request'
11 10
 import { getPage } from '@/utils'
12 11
 import './index.less'
13 12
 
@@ -25,9 +24,6 @@ export default function (props) {
25 24
   const [showAuthBasic, setShowAuthBasic] = useState(false)
26 25
   const [showAuthYeZhu, setShowAuthYeZhu] = useState(false)
27 26
   const [showAuthPhone, setShowAuthPhone] = useState(false)
28
-  const [ShowAdvLayer, setShowAdvLayer] = useState(true)
29
-  const [AdvDetail, setShowAdvDetail] = useState(null)
30
-  const [ShowAddLayer, setShowAddLayer] = useState(false)
31 27
   const { user, setUser } = useModel('user')
32 28
 
33 29
   const loading = !user || !user.personId
@@ -40,20 +36,6 @@ export default function (props) {
40 36
   const needAuthYeZhu = (page.auth || []).indexOf('yezhu') > -1
41 37
   const needAuthPhone = (page.auth || []).indexOf('phone') > -1
42 38
 
43
-  useEffect(() => {
44
-    if (user !== null && user.FirstComing !== undefined && user.FirstComing) {
45
-      request({ ...apis.getIndexAdv, params: { showType: `screen`, showPosition: `index` } }).then((res) => {
46
-        if (res !== null && res.length > 0) {
47
-          setShowAdvDetail(res[0])
48
-          setUser({ ...user, ShowIndexAdv: true, FirstComing: false })
49
-        }
50
-      })
51
-    }
52
-    if (user !== null) {
53
-      setShowAddLayer(true)
54
-    }
55
-  }, [user])
56
-
57 39
   // 埋点
58 40
   useMountTrack()
59 41
 
@@ -99,51 +81,17 @@ export default function (props) {
99 81
     setShowAuthBasic(needShow)
100 82
   }, [isAuthedBasic, needAuthBasic, isAuthedPhone, isAuthedYeZhu, needAuthYeZhu])
101 83
 
102
-  const AdvClick = () => { // 首页弹窗点击事件
103
-    setShowAdvLayer(false)
104
-    if (AdvDetail.contentType === 'news') {
105
-      Taro.navigateTo({ url: `/pages/HuoDong/ZiXunDetail/index?id=${AdvDetail.contentId}` })
106
-    } else if (AdvDetail.contentType === 'tpNews') {
107
-      Taro.navigateTo({ url: `/pages/WuYe/FuWuDetail/index?id=${AdvDetail.contentId}` })
108
-    } else if (AdvDetail.contentType === 'notice') {
109
-      Taro.navigateTo({ url: `/pages/WuYe/GongGaoDetail/index?id=${AdvDetail.contentId}` })
110
-    } else if (AdvDetail.contentType === 'activity') {
111
-      Taro.navigateTo({ url: `/pages/HuoDong/HuoDongDetail/index?id=${AdvDetail.contentId}` })
112
-    }
113
-  }
114
-
115 84
   return (
116 85
     <Spin loading={loading}>
117 86
 
118 87
       {/* 广告 */}
119
-      <view className='AdvLayer' style={{ display: user !== null && user.ShowIndexAdv !== undefined && user.ShowIndexAdv ? 'block' : 'none' }}>
120
-        <view className='centerLabel'>
121
-          <image mode='aspectFit' src={AdvDetail !== null ? AdvDetail.image : null} onClick={AdvClick}></image>
122
-          <Text className='iconfont iconguanbi' onClick={() => { setUser({ ...user, ShowIndexAdv: false }) }}></Text>
123
-        </view>
124
-      </view>
125
-
88
+      <AdvLayer></AdvLayer>
126 89
       <GetUserIcon visible={showAuthBasic} onError={err => showError(`授权头像失败: ${err}`)} />
127 90
       <GetUserPhone visible={showAuthPhone} onError={err => showError(`授权手机失败: ${err}`)} />
91
+      <YeZhuRenZhengPopup Show={showAuthYeZhu} Close={() => { setShowAuthYeZhu(false) }}></YeZhuRenZhengPopup>
128 92
       {
129 93
         props.children
130 94
       }
131
-
132
-      {
133
-        user !== null &&
134
-        <view className={ShowAddLayer ? 'AddRenZhengLayer active' : 'AddRenZhengLayer'}>
135
-          <view className='centerLabel'>
136
-            <view>
137
-              <ScrollView scroll-y='true'>
138
-                {
139
-                  ShowAddLayer &&
140
-                  <AddYeZhuRenZheng Close={() => { setShowAddLayer(false) }}></AddYeZhuRenZheng>
141
-                }
142
-              </ScrollView>
143
-            </view>
144
-          </view>
145
-        </view>
146
-      }
147 95
     </Spin>
148 96
   )
149 97
 }

+ 0
- 35
src/layouts/index.less 查看文件

@@ -1,39 +1,4 @@
1
-.AdvLayer {
2
-  width: 100%;
3
-  position: absolute;
4
-  left: 0;
5
-  top: 0;
6
-  bottom: 0;
7
-  z-index: 20000;
8
-  background: rgba(0, 0, 0, 0.8);
9 1
 
10
-  >view {
11
-    width: 100%;
12
-    height: 100vw;
13
-    overflow: visible;
14
-
15
-    >image {
16
-      width: 60%;
17
-      height: 60%;
18
-      position: relative;
19
-      z-index: 1;
20
-      margin: 0 auto;
21
-      display: block;
22
-    }
23
-
24
-    >text {
25
-      display: inline-block;
26
-      color: #fff;
27
-      font-size: 60px;
28
-      position: absolute;
29
-      left: 50%;
30
-      bottom: -30px;
31
-      transform: translateX(-50%);
32
-      -webkit-transform: translateX(-50%);
33
-      z-index: 2;
34
-    }
35
-  }
36
-}
37 2
 
38 3
 .AddRenZhengLayer {
39 4
   width: 100%;

+ 4
- 1
src/pages/WuYe/BaoXiuDetail/index.jsx 查看文件

@@ -95,7 +95,10 @@ export default function BaoXiuDetail () {
95 95
 
96 96
           {/* 更多操作 */}
97 97
           <view className='BottomBtn active'>
98
-            <text onClick={() => { Taro.navigateTo({ url: `/pages/WuYe/BaoXiuFeiYong/index?id=${CurrnetBaoXiuId}` }) }}>费用详情</text>
98
+            {
99
+              DetailInfo !== null && DetailInfo.billInvoiceId !== null &&
100
+              <text onClick={() => { Taro.navigateTo({ url: `/pages/WuYe/BaoXiuFeiYong/index?id=${CurrnetBaoXiuId}` }) }}>费用详情</text>
101
+            }
99 102
           </view>
100 103
 
101 104
           {/* 更多操作 */}

+ 2
- 0
src/store/models/index.js 查看文件

@@ -1,11 +1,13 @@
1 1
 import useSystem from './useSystem'
2 2
 import useAppRouter from './useAppRouter'
3 3
 import useUser from './useUser'
4
+import useScreen from './useScreen'
4 5
 
5 6
 const models = {
6 7
   'appRouter': useAppRouter,
7 8
   'sys': useSystem,
8 9
   'user': useUser,
10
+  'screen': useScreen
9 11
 }
10 12
 
11 13
 export default models

+ 25
- 0
src/store/models/useScreen.js 查看文件

@@ -0,0 +1,25 @@
1
+import React, { useEffect, useState } from 'react'
2
+import Taro from '@tarojs/taro'
3
+
4
+export default function useScreen () {
5
+  const [screen, setScreen] = useState({ FirstComing: true })
6
+
7
+  // const updateUser = data => {
8
+  //   // 固化到本地
9
+  //   Taro.setStorage({ key: 'user', data })
10
+  //   setUser(data)
11
+  // }
12
+
13
+  // useEffect(() => {
14
+  //   // 如果本地存在, 则读取本地信息
15
+  //   const u = Taro.getStorageSync('user')
16
+  //   if (u) {
17
+  //     setUser(u)
18
+  //   }
19
+  // }, [])
20
+
21
+  return {
22
+    screen,
23
+    setScreen
24
+  }
25
+}