张延森 4 年前
父节点
当前提交
68ca7849be

+ 3
- 0
src/app.config.js 查看文件

@@ -29,5 +29,8 @@ export default {
29 29
     'scope.userLocation': {
30 30
       'desc': '你的位置信息将用于房源信息定位'
31 31
     }
32
+  },
33
+  useExtendedLib: {
34
+    weui: true
32 35
   }
33 36
 }

+ 0
- 4
src/compents/tab/index.jsx 查看文件

@@ -18,15 +18,11 @@ const getColor = (role) => {
18 18
 
19 19
 
20 20
 const tab = (props) => {
21
-
22 21
     const user = useSelector(state => state.user)
23 22
 
24 23
     const { value, openType, pageState, formType, color, styleType='', ...prop } = props
25 24
 
26 25
     const [state, setState] = useState(1)
27
-    useEffect(() => {
28
-
29
-    }, [])
30 26
     
31 27
     //  &-on{
32 28
     //     color: #fed12f;

+ 2
- 2
src/pages/customer/index.js 查看文件

@@ -73,11 +73,11 @@ const index = (props) => {
73 73
     })
74 74
 
75 75
   }, [props.houseId, props.orderId, regUnFinished])
76
- 
76
+
77 77
   return (
78 78
     <View className='index' >
79 79
 
80
-<NavCustom houseInfo={houseInfo}></NavCustom>
80
+      <NavCustom houseInfo={houseInfo}></NavCustom>
81 81
       {pageState=='1'&&<Register oderId={orderId} dataSource={orderInfo} onFinished={handleRegisterFinished}></Register>}
82 82
 
83 83
       {pageState!='1'&&<Layout type='custom'>

+ 19
- 17
src/pages/customer/register/index.jsx 查看文件

@@ -161,26 +161,28 @@ const register = props => {
161 161
     setList([...list]);
162 162
   };
163 163
   const { personNum } = props.dataSource?.houseSetting || {};
164
+
164 165
   return (
165 166
      <View className="register">
166
-      {personNum>0&& <View>
167
+      {personNum>0&& 
168
+      <View>
167 169
          <Layout>
168
-        {list.map((x, index) => {
169
-          let inx = index;
170
-          return (
171
-            <InputGroup
172
-              key={inx}
173
-              index={index}
174
-              dataSource={x}
175
-              onChange={onChangeList(inx)}
176
-            />
177
-          );
178
-        })}
179
-      </Layout>
180
-
181
-      <Tab value={["开启旅程"]} onClick={e => onClick(e)}></Tab>
182
-       </View>}
183
-      
170
+          {list.map((x, index) => {
171
+            let inx = index;
172
+            return (
173
+              <InputGroup
174
+                key={inx}
175
+                index={index}
176
+                dataSource={x}
177
+                onChange={onChangeList(inx)}
178
+              />
179
+            );
180
+          })}
181
+        </Layout>
182
+
183
+        <Tab value={["开启旅程"]} onClick={e => onClick(e)}></Tab>
184
+      </View>
185
+      }
184 186
     </View>
185 187
   );
186 188
 };

+ 35
- 30
src/pages/guide/index.jsx 查看文件

@@ -165,37 +165,42 @@ const guide = props => {
165 165
               )}
166 166
             </ContainerLayout>
167 167
           </View>
168
-          <View className="guide-view">
169
-            <Text className="guide-view-info">停车位置</Text>
170
-            <ContainerLayout
171
-              className="guide-view-layout"
172
-              style={{ display: "flex", justifyContent: "space-between" }}
173
-              onClick={() => onToMap("park")}
174
-            >
175
-              <View>
176
-                <View className="guide-view-layout-text1">
177
-                  {detail.shortParking}
178
-                </View>
179
-                <View className="guide-view-layout-text2">
180
-                  {detail.parking}
181
-                </View>
182
-              </View>
183
-              {user.role == userRloe.customer && (
184
-                <View
185
-                  style={{
186
-                    float: "right",
187
-                    display: "flex",
188
-                    justifyContent: "center",
189
-                    flexDirection: "column"
190
-                  }}
191
-                  onClick={() => onOpenLocation(detail.parkLngLat)}
168
+          {
169
+            detail.parking &&
170
+            (
171
+              <View className="guide-view">
172
+                <Text className="guide-view-info">停车位置</Text>
173
+                <ContainerLayout
174
+                  className="guide-view-layout"
175
+                  style={{ display: "flex", justifyContent: "space-between" }}
176
+                  onClick={() => onToMap("park")}
192 177
                 >
193
-                  <Image className="icon" src={icon} />
194
-                  <View className="icontext">去这里</View>
195
-                </View>
196
-              )}
197
-            </ContainerLayout>
198
-          </View>
178
+                  <View>
179
+                    <View className="guide-view-layout-text1">
180
+                      {detail.shortParking}
181
+                    </View>
182
+                    <View className="guide-view-layout-text2">
183
+                      {detail.parking}
184
+                    </View>
185
+                  </View>
186
+                  {user.role == userRloe.customer && (
187
+                    <View
188
+                      style={{
189
+                        float: "right",
190
+                        display: "flex",
191
+                        justifyContent: "center",
192
+                        flexDirection: "column"
193
+                      }}
194
+                      onClick={() => onOpenLocation(detail.parkLngLat)}
195
+                    >
196
+                      <Image className="icon" src={icon} />
197
+                      <View className="icontext">去这里</View>
198
+                    </View>
199
+                  )}
200
+                </ContainerLayout>
201
+              </View>
202
+            )
203
+          }
199 204
           <View className="guide-view">
200 205
             <Text className="guide-view-info">wifi信息</Text>
201 206
             <ContainerLayout

+ 0
- 3
src/pages/house/add/index.jsx 查看文件

@@ -45,9 +45,6 @@ const houseadd = (props) => {
45 45
     <ScrollView scrollY style={{ height: 'calc(100vh - 180rpx)' }} >
46 46
     <View className='page-container' >
47 47
         <View className='house-add'>
48
-        
49
-
50
-
51 48
             <View>
52 49
               {userRole == 'guide' && <Guide userRole={userRole} />}
53 50
               {userRole == 'recommend' && <Recommend userRole={userRole} />}

+ 1
- 3
src/pages/house/addnewhouse/index.jsx 查看文件

@@ -70,11 +70,9 @@ const index = (props) => {
70 70
         const value = e.detail.value
71 71
         const data = {
72 72
             ...value,
73
-            // address: `${value.address}____${value.addressdetail}`,
74
-            // parking: `${value.parking}____${value.parkingdetail}`,
75 73
             lngLat: `${address.latitude || ''},${address.longitude || ''}`,
76 74
             parkLngLat: `${parking.latitude || ''},${parking.longitude || ''}`,
77
-            
75
+            shopId: user.shopId,
78 76
             desc:imgUrl,
79 77
         }
80 78
         console.log(data,e.detail.value,'formSubmit')

+ 13
- 8
src/pages/house/list/index.jsx 查看文件

@@ -6,6 +6,7 @@ import React, {
6 6
   useImperativeHandle
7 7
 } from "react";
8 8
 import Taro, { useDidShow } from "@tarojs/taro";
9
+import { useSelector } from 'react-redux'
9 10
 import "./index.scss";
10 11
 import { View, Text, Input, Image } from "@tarojs/components";
11 12
 import ContainerLayout from "../../../compents/container/index";
@@ -14,11 +15,12 @@ import request from "@/util/request";
14 15
 import RecycleList from "@/compents/RecycleList";
15 16
 
16 17
 let house = (props, ref) => {
18
+  const user = useSelector(state => state.user)
17 19
   const [list, setList] = useState([]);
18 20
   const [radioHouse, setRadioHouse] = useState();
19 21
   const [width, setWidth] = useState();
20 22
   const [height, setHeight] = useState();
21
-  const [queryParams, setQueryParams] = useState({ pageNum: 1, pageSize: 10 });
23
+  const [queryParams, setQueryParams] = useState({ pageNum: 1, pageSize: 10, shopId: user.shopId });
22 24
   const [total, setTotal] = useState(0);
23 25
 
24 26
   useImperativeHandle(ref, () => ({
@@ -31,12 +33,11 @@ let house = (props, ref) => {
31 33
   const radioHouseState = useMemo(() => props.radioHouseState, [
32 34
     props.radioHouseState
33 35
   ]);
34
-
35
-  wx.setNavigationBarTitle({
36
-    title: "民宿房源管理"
37
-  });
36
+  
38 37
 
39 38
   const getHouseList = () => {
39
+    if (!queryParams.shopId) return
40
+
40 41
     request({
41 42
       url: "/taHouse",
42 43
       params: queryParams
@@ -81,7 +82,9 @@ let house = (props, ref) => {
81 82
   }
82 83
 
83 84
   useEffect(() => {
84
-    
85
+    wx.setNavigationBarTitle({
86
+      title: "民宿房源管理"
87
+    });
85 88
 
86 89
     Taro.nextTick(() => {
87 90
       Taro.createSelectorQuery()
@@ -133,14 +136,16 @@ let house = (props, ref) => {
133 136
     getHouseList();
134 137
   }, [queryParams]);
135 138
 
139
+  useEffect(() => {
140
+      setQueryParams({ ...queryParams, shopId: user.shopId })
141
+  }, [user.shopId])
142
+
136 143
   // useDidShow(() => {
137 144
   //   setQueryParams({ ...queryParams })
138 145
   // })
139 146
  
140 147
   return (
141 148
     <View className="houselist">
142
-     
143
-
144 149
       {(!list || !list.length) && <View className="nodata"> 暂无数据</View>}
145 150
       <RecycleList
146 151
         height={height}

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

@@ -1,5 +1,8 @@
1 1
 export default {
2 2
   // navigationBarTitleText: '首页',
3 3
   navigationStyle: "custom",
4
-  enableShareAppMessage: true
4
+  enableShareAppMessage: true,
5
+  usingComponents: {
6
+    "mp-actionSheet": "weui-miniprogram/actionsheet/actionsheet"
7
+  }
5 8
 }

+ 14
- 2
src/pages/index/index.jsx 查看文件

@@ -15,10 +15,10 @@ const index = props => {
15 15
   const { houseId, orderId } = router.params;
16 16
   const user = useSelector(state => state.user);
17 17
 
18
-  console.log(user);
19
-
20 18
   const dispatch = useDispatch();
21 19
 
20
+  const shopList = (user.shopList || []).map(x => ({text: x.name, value: x.shopId}))
21
+
22 22
   useEffect(() => {
23 23
     if (user.role == roleList.landlord) {
24 24
       wx.setNavigationBarTitle({
@@ -51,6 +51,11 @@ const index = props => {
51 51
     setShowAuthPhone(false);
52 52
   };
53 53
 
54
+  const handleSelectShop = e => {
55
+    const shopId = e.detail.value
56
+    dispatch({ type: "SET_SHOP", shopId });
57
+  }
58
+
54 59
   return (
55 60
     <View className="index">
56 61
       {user.personId && (
@@ -86,6 +91,13 @@ const index = props => {
86 91
       {/* </View>
87 92
     </ScrollView>
88 93
     <Tab value={userRole} onClick={(e) => onTabClick(e)}></Tab> */}
94
+      {
95
+        shopList.length > 0 && !user.shopId &&
96
+        (
97
+          <mp-actionSheet show actions={shopList} title="请选择店铺" showCancel={false} onActiontap={handleSelectShop}>
98
+          </mp-actionSheet>
99
+        )
100
+      }
89 101
     </View>
90 102
   );
91 103
 };

+ 4
- 12
src/pages/share/index.jsx 查看文件

@@ -10,12 +10,6 @@ import Container from '../../compents/container/index'
10 10
 import './index.scss'
11 11
 import request from '../../util/request';
12 12
 
13
-// Page({
14
-//     data: {
15
-//         text: 'init data',
16
-//         array: [{ msg: '1' }, { msg: '2' }]
17
-//     }
18
-// })
19 13
 const defaultImgUrl= 'https://zhiyun-image.oss-cn-shanghai.aliyuncs.com/shigongli/shigongli_share_default-min.jpg'
20 14
 
21 15
 const Index = () => {
@@ -24,11 +18,12 @@ const Index = () => {
24 18
     const user = useSelector(state => state.user)
25 19
 
26 20
     const now = new Date()
27
-    const today = now.toJSON().substring(0, 10)
21
+    const nextDate = new Date()
22
+    nextDate.setDate(nextDate.getDate() + 1)
28 23
 
29 24
     const [personNum, setPersonNum] = useState(0)
30
-    const [startTime, setStartTime] = useState(today)
31
-    const [endTime, setEndTime] = useState(today)
25
+    const [startTime, setStartTime] = useState(now.toJSON().substring(0, 10))
26
+    const [endTime, setEndTime] = useState(nextDate.toJSON().substring(0, 10))
32 27
     // const [data,setData] = useState({})
33 28
     const [shareObj, setShareObj] = useState()
34 29
     const [showShareModal, setShowShareModal] = useState(false)
@@ -73,9 +68,6 @@ const Index = () => {
73 68
     }  
74 69
 
75 70
     const handleShareReady = () => {
76
-
77
-
78
-
79 71
         const data = {
80 72
             houseId,
81 73
             personNum,

+ 29
- 0
src/reducers/user.js 查看文件

@@ -40,10 +40,28 @@ export default function user(state = INITIAL_STATE, action) {
40 40
           wx.setNavigationBarTitle({
41 41
             title: '民宿房源管理'
42 42
           })
43
+
44
+        const shopList = action.user.shopKeeperList.reduce((acc, item) => {
45
+          const shop = item.taShop
46
+          if (!shop) return acc
47
+
48
+          const exist = !!acc.filter(x => x.shopId === shop.shopId)[0]
49
+          if (!exist) {
50
+            acc.push(shop)
51
+          }
52
+
53
+          return acc
54
+        }, [])
55
+
56
+        // 默认当前的, 但是如果有多个, 则需要用户来确定
57
+        const shopId = shopList.length > 1 ? undefined : shopList[0]
58
+
43 59
         return {
44 60
           ...state,
45 61
           ...action.user,
46 62
           role: 'landlord',
63
+          shopList,
64
+          shopId,
47 65
           // role: 'customer',
48 66
         }
49 67
       } else {
@@ -60,6 +78,17 @@ export default function user(state = INITIAL_STATE, action) {
60 78
     case 'phone': {
61 79
       return state
62 80
     }
81
+    case 'SET_SHOP': {
82
+      const shopId = action.shopId
83
+      if (!shopId) {
84
+        return state
85
+      }
86
+
87
+      return {
88
+        ...state,
89
+        shopId
90
+      }
91
+    }
63 92
 
64 93
     default:
65 94
       return state