李志伟 3 anni fa
parent
commit
ea43a3cdd3

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

@@ -1,19 +1,20 @@
1
-import Taro from '@tarojs/taro'
1
+import Taro, {useDidShow } from '@tarojs/taro'
2 2
 import see from '@/assets/icons/landlord/查看入住人.png'
3 3
 import share from '@/assets/icons/landlord/分享链接.png'
4 4
 import del from '@/assets/icons/landlord/删除.png'
5 5
 import addImg from '@/assets/icons/landlord/添加.png'
6 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 8
 import {getRoomList,deleteRoom} from '@/services/landlord'
11 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 13
   const {hotel}=props
16 14
   const [detail, setDetail] = useState([])
15
+
16
+  const shareDataRef = useRef()
17
+
17 18
   // 判断是否首次加载
18 19
   const mounted = useRef(false)
19 20
 
@@ -33,9 +34,9 @@ export default (props) => {
33 34
   }
34 35
 
35 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 40
     setShowCutover(true)
40 41
   }
41 42
   const onClose = () => {
@@ -60,6 +61,24 @@ export default (props) => {
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 82
   return (
64 83
     <view>
65 84
       <view style={{ padding: '0 30rpx', height: '100%' }}>
@@ -68,7 +87,7 @@ export default (props) => {
68 87
             <image className='searchicon' src={iconsearch} />
69 88
             <view className="searchword">请输入关键字搜索</view>
70 89
           </view>
71
-          <ShareRoom showCutover={showCutover} onClose={onClose}  roomId={roomId}/>
90
+          <ShareRoom showCutover={showCutover} onClose={onClose}  room={room} onFinish={handleFinish} />
72 91
         <scroll-view scroll-y="true" scroll-view='true' bindscrolltoupper="upper" bindscrolltolower="lower" bindscroll="scroll" style={{ height: 'calc(100vh - 255px)' }}>
73 92
 
74 93
           <view>
@@ -78,7 +97,7 @@ export default (props) => {
78 97
               <view className='houseName'>{item.roomName}</view>
79 98
               <view className='operation'>
80 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 101
                 <view onClick={()=>{handelDelete(item.roomId)}}><image src={del} />删除房源</view>
83 102
               </view>
84 103
             </view>
@@ -95,4 +114,4 @@ export default (props) => {
95 114
     
96 115
       </view>
97 116
   )
98
-}
117
+})

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

@@ -8,24 +8,37 @@ import { useState } from 'react'
8 8
 
9 9
 export default (props) => {
10 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 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 25
   return (
22 26
     <Popup show={showCutover} onClose={onClose}>
27
+      <Label style={{color:'black'}}>请输入入住人信息</Label>
23 28
       <View><Label>入住人数:</Label><Input focus dataField='nm' onInput={(e) => setRoomNum(e.detail.value )} value={roomNum} type='number' placeholder='请输入入住人数' /></View>
24 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 40
           <View className='picker'  >
28
-            {date == '' ? '请选择入住时间' : date}
41
+            {endDate == '' ? '请选择入住结束时间' : endDate}
29 42
           </View>
30 43
         </Picker>
31 44
       </View>

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

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

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

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

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

@@ -1,18 +1,21 @@
1 1
 import { Video } from '@tarojs/components';
2
+import './extend.less'
2 3
 
3 4
 export default (props) => {
4 5
   const { item } = props
5 6
   return (
6
-    <>{
7
+    <>
8
+    {
7 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 11
         item.contentType == 'text' ?
10 12
           <view className='storezn'>{item.content}</view> :
11 13
           <Video
12 14
             controls
13 15
             autoplay={false}
14 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 Vedi File

@@ -0,0 +1,6 @@
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 Vedi File

@@ -110,6 +110,23 @@
110 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 130
 .foodCard{
114 131
   background: #FFF;
115 132
   box-shadow: 0px 8px 38px 0px rgba(0, 0, 0, 0.12);
@@ -245,33 +262,7 @@
245 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 266
 .bottom{
276 267
   font-size: 28px;    
277 268
   color: #C0C8D3;

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

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