张延森 3 年前
父节点
当前提交
0211ff3059
共有 3 个文件被更改,包括 50 次插入6 次删除
  1. 2
    2
      config/dev.js
  2. 1
    1
      src/app.js
  3. 47
    3
      src/pages/HuoDong/HuoDongDetail/index.jsx

+ 2
- 2
config/dev.js 查看文件

@@ -4,8 +4,8 @@ module.exports = {
4 4
   },
5 5
   defineConstants: {
6 6
     // HOST: '"https://xs.ycjcjy.com"',
7
-    HOST: '"http://t.ycjcjy.com"',
8
-    // HOST: '"http://127.0.0.1:6060"'
7
+    // HOST: '"http://t.ycjcjy.com"',
8
+    HOST: '"http://127.0.0.1:6060"'
9 9
   },
10 10
   mini: {
11 11
     debugReact: true

+ 1
- 1
src/app.js 查看文件

@@ -55,7 +55,7 @@ class App extends Component {
55 55
       success: res => {
56 56
         if (res.errMsg === 'login:ok') {
57 57
           request({ ...apis.login, params: { code: res.code, from, recommender, scene, mpOpenId } }).then(x => {
58
-            setUser({ ...x.person, ShowIndexAdv: false, FirstComing: true, communityId: x.houseList !== null && x.houseList.length ? x.houseList[0].communityId : null, roomId: x.houseList !== null && x.houseList.length ? x.houseList[0].id : null, roleId: x.houseList !== null && x.houseList.length ? x.houseList[0].roleId : null })
58
+            setUser({ ...x.person, ShowIndexAdv: false, FirstComing: true, houseList: x.houseList, communityId: x.houseList !== null && x.houseList.length ? x.houseList[0].communityId : null, roomId: x.houseList !== null && x.houseList.length ? x.houseList[0].id : null, roleId: x.houseList !== null && x.houseList.length ? x.houseList[0].roleId : null })
59 59
             Taro.setStorage({ key: 'token', data: x.token })
60 60
             Taro.setStorage({ key: 'sessionKey', data: x.sessionKey })
61 61
 

+ 47
- 3
src/pages/HuoDong/HuoDongDetail/index.jsx 查看文件

@@ -7,6 +7,7 @@ import Page from '@/layouts'
7 7
 import toolclass from '@/utils/toolclass.js'
8 8
 import { getShareObject } from '@/utils/share.js'
9 9
 import GetUserPhone from '@/components/GetUserPhone/index'
10
+import Picker from '@/components/Picker'
10 11
 import '@/assets/css/reset.less'
11 12
 import '@/assets/css/iconfont.less'
12 13
 import './index.less'
@@ -23,12 +24,17 @@ export default function HuoDongDetail () {
23 24
   // const [JoinBtnStatus, setJoinBtnStatus] = useState(false)
24 25
   const [ShowJoinNumPopup, setShowJoinNumPopup] = useState(false)
25 26
   const [JoinNum, setJoinNum] = useState(null)
27
+  const [houseInfo, setHouseInfo] = useState(null)
26 28
   const [ShowGetUserPhoneLayer, setShowGetUserPhoneLayer] = useState(false)
27 29
   const [CurrnetHuoDongId] = useState(router.params.id) // 当前活动id
28 30
   const [ActivityDetail, setActivityDetail] = useState(null) // 活动详情
29 31
   const [JoinInfo, setJoinInfo] = useState(null) // 参加活动详情
30 32
   const [Status, setStatus] = useState(null) // 参加活动状态 0-立即参与 1-未开始 2-去报名 3-已报名 4-去签到 5-已签到 6-已结束
31 33
   const [StatusText, setStatusText] = useState(null) // 参加活动状态 0-立即参与 1-未开始 2-去报名 3-已报名 4-去签到 5-已签到 6-已结束
34
+  
35
+  // 只有业主以及家属可以参与活动
36
+  const [houseList, setHouseList] = useState([])
37
+  const [canJoin, setCanJoin] = useState(false)
32 38
 
33 39
   Taro.useShareAppMessage(() => {
34 40
     return getShareObject({
@@ -60,6 +66,23 @@ export default function HuoDongDetail () {
60 66
     }
61 67
   }, [Status])
62 68
 
69
+  useEffect(() => {
70
+    if (user?.houseList && user.houseList.length > 0) {
71
+      const lst = user.houseList.filter(x => x.roleId === 1 || x.roleId === 3).map(x => ({
72
+        ...x,
73
+        houseInfoId: [x.orgId, x.phaseId, x.buildingId, x.unitId, x.roomNoId].join(','),
74
+        houseName: [x.phaseName, x.buildingName, x.unitName, x.roomNoName].join('')
75
+      }))
76
+      setHouseList(lst);
77
+      setHouseInfo(lst[0]);
78
+      setCanJoin(lst.length > 0);
79
+    } else {
80
+      setHouseList([])
81
+      setHouseInfo()
82
+      setCanJoin(false)
83
+    }
84
+  }, [user?.houseList])
85
+
63 86
   const GetActivityDetail = () => { // 获取活动详情
64 87
     request({ ...apis.getActivityDetail, args: { id: CurrnetHuoDongId } }).then((res) => {
65 88
       setActivityDetail(res)
@@ -115,6 +138,11 @@ export default function HuoDongDetail () {
115 138
       Taro.showToast({ title: '请填入参加活动人数', icon: 'none' })
116 139
       setDataLock(false)
117 140
     } else {
141
+      if (!houseInfo || !houseInfo.houseInfoId) {
142
+        Taro.showToast({ title: '请选择房产', icon: 'none' })
143
+        return
144
+      }
145
+
118 146
       const { personId, phone, nickname, orgId } = user
119 147
       const { dynamicId } = ActivityDetail
120 148
       let Data = {
@@ -126,7 +154,8 @@ export default function HuoDongDetail () {
126 154
         attendNum: JoinNum - 0 || 1,
127 155
         sharePerson: null,
128 156
         sharePersonName: null,
129
-        sharePersonType: null
157
+        sharePersonType: null,
158
+        houseInfo: houseInfo.houseInfoId,
130 159
       }
131 160
       request({ ...apis.JoinActivity, data: { ...Data } }).then(() => {
132 161
         Taro.showToast({ title: '报名成功', icon: 'none' })
@@ -135,6 +164,7 @@ export default function HuoDongDetail () {
135 164
         setDataLock(false)
136 165
       }).catch((res) => {
137 166
         Taro.showToast({ title: res, icon: 'none' })
167
+        setShowJoinNumPopup(false)
138 168
         setDataLock(false)
139 169
       })
140 170
     }
@@ -210,7 +240,11 @@ export default function HuoDongDetail () {
210 240
               <RichText nodes={`${ActivityDetail.desc !== null ? ActivityDetail.desc.replace(/font-size\:\s(\d+)px/ig, 'font-size: $1rpx') : ''}`}></RichText>
211 241
             </view>
212 242
 
213
-            <text className={Status - 0 === 2 || Status - 0 === 4 ? 'active BottomBtn' : 'BottomBtn'} onClick={ToJoin}>{StatusText}</text>
243
+            {
244
+              canJoin && (
245
+                <text className={Status - 0 === 2 || Status - 0 === 4 ? 'active BottomBtn' : 'BottomBtn'} onClick={ToJoin}>{StatusText}</text>
246
+              )
247
+            }
214 248
 
215 249
           </view>
216 250
         }
@@ -219,7 +253,17 @@ export default function HuoDongDetail () {
219 253
             <text>温馨提示</text>
220 254
             <view className='flex-h Form'>
221 255
               <view>
222
-                <text>参数人数:</text>
256
+                <text>选择房产:</text>
257
+              </view>
258
+              <view className='flex-item'>
259
+                <Picker rangeKey='houseName' rangeValue='houseInfoId' range={houseList} onChange={(_, v) => setHouseInfo(v)}>
260
+                  <view>{houseInfo ? houseInfo.houseName : '请选择房产' }</view>
261
+                </Picker>
262
+              </view>
263
+            </view>
264
+            <view className='flex-h Form'>
265
+              <view>
266
+                <text>参加人数:</text>
223 267
               </view>
224 268
               <view className='flex-item'>
225 269
                 <Input placeholder='请输入活动参加人数' onInput={JoinNumChange} value={JoinNum}></Input>