李志伟 3 years ago
parent
commit
ea43a3cdd3

+ 31
- 12
src/hotel/components/HouseManage/houseManage.jsx View File

1
-import Taro from '@tarojs/taro'
1
+import Taro, {useDidShow } from '@tarojs/taro'
2
 import see from '@/assets/icons/landlord/查看入住人.png'
2
 import see from '@/assets/icons/landlord/查看入住人.png'
3
 import share from '@/assets/icons/landlord/分享链接.png'
3
 import share from '@/assets/icons/landlord/分享链接.png'
4
 import del from '@/assets/icons/landlord/删除.png'
4
 import del from '@/assets/icons/landlord/删除.png'
5
 import addImg from '@/assets/icons/landlord/添加.png'
5
 import addImg from '@/assets/icons/landlord/添加.png'
6
 import iconsearch from '@/assets/icons/housemantj/search.png'
6
 import iconsearch from '@/assets/icons/housemantj/search.png'
7
-import './houseManage.less'
8
-import {useState, useEffect,useRef } from 'react'
9
-import {useDidShow } from '@tarojs/taro'
7
+import React,{useState, useEffect,useRef, useImperativeHandle } from 'react'
10
 import {getRoomList,deleteRoom} from '@/services/landlord'
8
 import {getRoomList,deleteRoom} from '@/services/landlord'
11
 import ShareRoom from '../shareRoom/ShareRoom.jsx'
9
 import ShareRoom from '../shareRoom/ShareRoom.jsx'
10
+import './houseManage.less'
12
 
11
 
13
-
14
-export default (props) => {
12
+export default React.forwardRef((props, ref) => {
15
   const {hotel}=props
13
   const {hotel}=props
16
   const [detail, setDetail] = useState([])
14
   const [detail, setDetail] = useState([])
15
+
16
+  const shareDataRef = useRef()
17
+
17
   // 判断是否首次加载
18
   // 判断是否首次加载
18
   const mounted = useRef(false)
19
   const mounted = useRef(false)
19
 
20
 
33
   }
34
   }
34
 
35
 
35
   const [showCutover, setShowCutover] = useState(false)
36
   const [showCutover, setShowCutover] = useState(false)
36
-  const [roomId, setRoomId] = useState()
37
-  const ShowMoldeOn = (roomId) => {
38
-    setRoomId(roomId)
37
+  const [room, setRoom] = useState({})
38
+  const ShowMoldeOn = (room) => {
39
+    setRoom(room)
39
     setShowCutover(true)
40
     setShowCutover(true)
40
   }
41
   }
41
   const onClose = () => {
42
   const onClose = () => {
60
     }
61
     }
61
   })
62
   })
62
 
63
 
64
+  useImperativeHandle(ref, () => ({
65
+    getShareMessage: () => {
66
+      const { shareImage, roomOrderId } = shareDataRef.current
67
+
68
+      return {
69
+        title: '',
70
+        path: `/pages/index/index?tab=1&roomId=${room.roomId}&roomOrderId=${roomOrderId}`,
71
+        imageUrl: shareImage,
72
+      }
73
+    }
74
+  }))
75
+
76
+  const handleFinish = (val) => {
77
+    shareDataRef.current = val
78
+    setShowCutover(false)
79
+    // 打开分享弹窗
80
+  }
81
+
63
   return (
82
   return (
64
     <view>
83
     <view>
65
       <view style={{ padding: '0 30rpx', height: '100%' }}>
84
       <view style={{ padding: '0 30rpx', height: '100%' }}>
68
             <image className='searchicon' src={iconsearch} />
87
             <image className='searchicon' src={iconsearch} />
69
             <view className="searchword">请输入关键字搜索</view>
88
             <view className="searchword">请输入关键字搜索</view>
70
           </view>
89
           </view>
71
-          <ShareRoom showCutover={showCutover} onClose={onClose}  roomId={roomId}/>
90
+          <ShareRoom showCutover={showCutover} onClose={onClose}  room={room} onFinish={handleFinish} />
72
         <scroll-view scroll-y="true" scroll-view='true' bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" style={{ height: 'calc(100vh - 255px)' }}>
91
         <scroll-view scroll-y="true" scroll-view='true' bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" style={{ height: 'calc(100vh - 255px)' }}>
73
 
92
 
74
           <view>
93
           <view>
78
               <view className='houseName'>{item.roomName}</view>
97
               <view className='houseName'>{item.roomName}</view>
79
               <view className='operation'>
98
               <view className='operation'>
80
                 <view><image src={see} />查看入住人</view>
99
                 <view><image src={see} />查看入住人</view>
81
-                <view onClick={()=>ShowMoldeOn(item.roomId)}><image src={share}/>分享链接</view>
100
+                <view onClick={()=>ShowMoldeOn(item)}><image src={share}/>分享链接</view>
82
                 <view onClick={()=>{handelDelete(item.roomId)}}><image src={del} />删除房源</view>
101
                 <view onClick={()=>{handelDelete(item.roomId)}}><image src={del} />删除房源</view>
83
               </view>
102
               </view>
84
             </view>
103
             </view>
95
     
114
     
96
       </view>
115
       </view>
97
   )
116
   )
98
-}
117
+})

+ 22
- 9
src/hotel/components/shareRoom/ShareRoom.jsx View File

8
 
8
 
9
 export default (props) => {
9
 export default (props) => {
10
   const { showCutover, onClose,roomId } = props
10
   const { showCutover, onClose,roomId } = props
11
-  const [date, setDate] = useState('')
12
-  const [roomNum, setRoomNum] = useState(0)
13
-  const handelDate = (e) => {
14
-    setDate(e.detail.value)
11
+  const [startDate, setStartDate] = useState('')
12
+  const [endDate, setEndDate] = useState('')
13
+  const [roomNum, setRoomNum] = useState()
14
+  const handelStartDate = (e) => {
15
+    setStartDate(e.detail.value)
16
+  }
17
+  const handelEndDate = (e) => {
18
+    setEndDate(e.detail.value)
15
   }
19
   }
16
 const handelShare=()=>{
20
 const handelShare=()=>{
17
-  if(roomNum!=0&&date!=''){
18
-    console.log(roomNum,date,roomId)
21
+  if(roomNum!=''&&startDate!=''&&endDate!=''){
22
+    console.log(roomNum,startDate,roomId)
19
   }
23
   }
20
 }
24
 }
21
   return (
25
   return (
22
     <Popup show={showCutover} onClose={onClose}>
26
     <Popup show={showCutover} onClose={onClose}>
27
+      <Label style={{color:'black'}}>请输入入住人信息</Label>
23
       <View><Label>入住人数:</Label><Input focus dataField='nm' onInput={(e) => setRoomNum(e.detail.value )} value={roomNum} type='number' placeholder='请输入入住人数' /></View>
28
       <View><Label>入住人数:</Label><Input focus dataField='nm' onInput={(e) => setRoomNum(e.detail.value )} value={roomNum} type='number' placeholder='请输入入住人数' /></View>
24
       <View>
29
       <View>
25
-        <Label>入住时间:</Label>
26
-        <Picker mode='date' onChange={handelDate}>
30
+        <Label>入住开始时间:</Label>
31
+        <Picker mode='date' onChange={handelStartDate}>
32
+          <View className='picker'  >
33
+            {startDate == '' ? '请选择入住开始时间' : startDate}
34
+          </View>
35
+        </Picker>
36
+      </View>
37
+      <View>
38
+        <Label>入住结束时间:</Label>
39
+        <Picker mode='date' onChange={handelEndDate}>
27
           <View className='picker'  >
40
           <View className='picker'  >
28
-            {date == '' ? '请选择入住时间' : date}
41
+            {endDate == '' ? '请选择入住结束时间' : endDate}
29
           </View>
42
           </View>
30
         </Picker>
43
         </Picker>
31
       </View>
44
       </View>

+ 2
- 1
src/hotel/pages/landlord/landlord.config.js View File

5
   usingComponents: {
5
   usingComponents: {
6
     "mp-tabbar": "weui-miniprogram/tabbar/tabbar",
6
     "mp-tabbar": "weui-miniprogram/tabbar/tabbar",
7
     "mp-dialog": "weui-miniprogram/dialog/dialog"
7
     "mp-dialog": "weui-miniprogram/dialog/dialog"
8
-  }
8
+  },
9
+  enableShareAppMessage: true
9
 }
10
 }

+ 14
- 3
src/hotel/pages/landlord/landlord.jsx View File

1
-import React, { useState, useEffect } from 'react'
2
-import { useRouter } from '@tarojs/taro'
1
+import React, { useState, useEffect, useRef } from 'react'
2
+import Taro,{ useRouter,useShareAppMessage } from '@tarojs/taro'
3
 import HouseManage from '../../components/HouseManage/houseManage'
3
 import HouseManage from '../../components/HouseManage/houseManage'
4
 import Income from '../../components/Income/income'
4
 import Income from '../../components/Income/income'
5
 import TabBar from '@/components/CustTabBar'
5
 import TabBar from '@/components/CustTabBar'
23
   const [account, setAccount] = useState()
23
   const [account, setAccount] = useState()
24
   const [accountlog, setAccountLog] = useState([])
24
   const [accountlog, setAccountLog] = useState([])
25
 
25
 
26
+  const houseRef = useRef()
27
+
26
   useEffect(() => {
28
   useEffect(() => {
27
     getHotelManage().then((res) => {
29
     getHotelManage().then((res) => {
28
       const { hotelList: list, account: acc, hotel: current } = res
30
       const { hotelList: list, account: acc, hotel: current } = res
59
     }
61
     }
60
   }, [tab])
62
   }, [tab])
61
 
63
 
64
+  useShareAppMessage(() => {
65
+    return houseRef.current.getShareMessage()
66
+  })
67
+
68
+  useEffect(() => {
69
+    // 禁止右上角分享
70
+    Taro.hideShareMenu()
71
+  }, [])
72
+
62
   return (
73
   return (
63
     <view className='page-index'>
74
     <view className='page-index'>
64
       <CustomNav title={hotel?.hotelName} logo={hotel?.logo} />
75
       <CustomNav title={hotel?.hotelName} logo={hotel?.logo} />
65
       <view className='index-container'>
76
       <view className='index-container'>
66
         {currentTab === 0 && <Income hotelList={hotelList} hotel={hotel} account={account} onHotelChange={handleHotelChange} accountlog={accountlog} />}
77
         {currentTab === 0 && <Income hotelList={hotelList} hotel={hotel} account={account} onHotelChange={handleHotelChange} accountlog={accountlog} />}
67
-        {currentTab === 1 && <HouseManage hotel={hotel} />}
78
+        {currentTab === 1 && <HouseManage hotel={hotel} ref={houseRef} />}
68
       </view>
79
       </view>
69
       <view className='index-tabbar'>
80
       <view className='index-tabbar'>
70
         <TabBar extClass='custom-tabbar bottomTab' current={currentTab} onChange={handleTabChange}>
81
         <TabBar extClass='custom-tabbar bottomTab' current={currentTab} onChange={handleTabChange}>

+ 6
- 3
src/pages/details/components/Extend/extend.jsx View File

1
 import { Video } from '@tarojs/components';
1
 import { Video } from '@tarojs/components';
2
+import './extend.less'
2
 
3
 
3
 export default (props) => {
4
 export default (props) => {
4
   const { item } = props
5
   const { item } = props
5
   return (
6
   return (
6
-    <>{
7
+    <>
8
+    {
7
       item.contentType == 'image' ?
9
       item.contentType == 'image' ?
8
-        <image src={item.content} mode='widthFix' style={{ width: '100%' }} /> :
10
+        <image src={item.content} mode='widthFix' style={{ width: '100%'}} /> :
9
         item.contentType == 'text' ?
11
         item.contentType == 'text' ?
10
           <view className='storezn'>{item.content}</view> :
12
           <view className='storezn'>{item.content}</view> :
11
           <Video
13
           <Video
12
             controls
14
             controls
13
             autoplay={false}
15
             autoplay={false}
14
             loop={false}
16
             loop={false}
15
-            muted={false} style={{ width: "100%", height: '200px' }} src={item.content}></Video>
17
+            muted={false} style={{ width: "100%", height: '200px' }} src={item.content}>              
18
+          </Video>
16
     }
19
     }
17
     </>
20
     </>
18
   )
21
   )

+ 6
- 0
src/pages/details/components/Extend/extend.less View File

1
+.storezn{
2
+  font-size: 28px;    
3
+  color: #202020;
4
+  line-height: 54px;
5
+  margin-bottom: 40px;
6
+}

+ 18
- 27
src/pages/details/mjDetails/sceneryDetails.less View File

110
     margin-right: 10px;
110
     margin-right: 10px;
111
   }
111
   }
112
 }
112
 }
113
+.showMore{
114
+  width: 100%;
115
+  background: linear-gradient(0deg, rgba(248, 248, 248, 0.58) 42%, rgba(248, 248, 248, 0) 100%);
116
+  font-size: 28px;
117
+  font-weight: bold;
118
+  color: #202020;
119
+  text-align: center;
120
+  position: absolute;
121
+  bottom: -40px;
122
+  padding-top: 77px;
123
+  padding-bottom: 20px;
124
+  .moreTip{
125
+    width: 38px;
126
+    height: 19px;
127
+    margin-top: 14px;
128
+  }
129
+}
113
 .foodCard{
130
 .foodCard{
114
   background: #FFF;
131
   background: #FFF;
115
   box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
132
   box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
245
     bottom:15%;
262
     bottom:15%;
246
   }
263
   }
247
 }
264
 }
248
-.showMore{
249
-  width: 100%;
250
-  background: linear-gradient(0deg, rgba(248, 248, 248, 0.58) 42%, rgba(248, 248, 248, 0) 100%);
251
-  font-size: 28px;
252
-  font-weight: bold;
253
-  color: #202020;
254
-  text-align: center;
255
-  position: absolute;
256
-  bottom: -40px;
257
-  padding-top: 77px;
258
-  padding-bottom: 20px;
259
-  .moreTip{
260
-    width: 38px;
261
-    height: 19px;
262
-    margin-top: 14px;
263
-  }
264
-}
265
-.storezn{
266
-  font-size: 28px;
267
-    
268
-    color: #202020;
269
-  line-height: 54px;
270
-  margin-bottom: 40px;
271
-}
272
-.storezn+image{
273
-  width: 100%;
274
-}  
265
+
275
 .bottom{
266
 .bottom{
276
   font-size: 28px;    
267
   font-size: 28px;    
277
   color: #C0C8D3;
268
   color: #C0C8D3;

+ 3
- 4
src/services/landlord.js View File

53
 
53
 
54
 
54
 
55
 /**
55
 /**
56
- * 房源详情
57
- * @param {*} id 
56
+ * 分享房源
57
+ * @param {*} data 
58
  * @returns 
58
  * @returns 
59
  */
59
  */
60
-export const getRoomDetail = (id) => request(`/taRoom/${id}`)
61
-
60
+ export const shareRoom = (data) => request('/roomOrder', { method: 'post', data })