|
@@ -1,48 +1,54 @@
|
|
-import React, { PropsWithChildren } from 'react'
|
|
|
|
-import Taro, { useLoad, useReady } from '@tarojs/taro'
|
|
|
|
-import { View, Video, Navigator, AdCustom } from '@tarojs/components'
|
|
|
|
|
|
+import { PropsWithChildren, useState } from 'react'
|
|
|
|
+import { View, Video, Navigator } from '@tarojs/components'
|
|
|
|
+import useGetCustomClient from '@/hooks/useGetCustomClient'
|
|
import './index.less'
|
|
import './index.less'
|
|
|
|
|
|
-const WEB_VIEW_URL = 'plugin-private://wxf7261ed54f2e450e/pages/webview/index'
|
|
|
|
|
|
+const WEB_VIEW_URL = 'plugin-private://wxf7261ed54f2e450e/pages/customPage/index'
|
|
const VIDEO_SRC = 'https://xycdn.yishihui.com/ad/prod/video/material_AD_1700025739_1700025739924.mp4'
|
|
const VIDEO_SRC = 'https://xycdn.yishihui.com/ad/prod/video/material_AD_1700025739_1700025739924.mp4'
|
|
|
|
|
|
-function PqCustom(props: PropsWithChildren<CustomPropsType>) {
|
|
|
|
- const customWidth = props.width || 100
|
|
|
|
|
|
+function PqCustom({ width, zIndex }: PropsWithChildren<CustomPropsType>) {
|
|
function onClick() {
|
|
function onClick() {
|
|
- console.log(props)
|
|
|
|
}
|
|
}
|
|
|
|
|
|
return (
|
|
return (
|
|
<View className='pq-custom' onClick={onClick}>
|
|
<View className='pq-custom' onClick={onClick}>
|
|
- <View className='icon'>广告</View>
|
|
|
|
- <View className='close-icon'>❌</View>
|
|
|
|
- <Navigator url={WEB_VIEW_URL}>
|
|
|
|
- <Custom width={customWidth}/>
|
|
|
|
- </Navigator>
|
|
|
|
|
|
+ <View className='custom-container'>
|
|
|
|
+ <View className='icon' style={{zIndex: (zIndex || 1) + 1}}>
|
|
|
|
+ 广告
|
|
|
|
+ </View>
|
|
|
|
+ <View className='close-icon'style={{zIndex: (zIndex || 1) + 1}}>
|
|
|
|
+ </View>
|
|
|
|
+
|
|
|
|
+ <Navigator url={WEB_VIEW_URL}>
|
|
|
|
+ <Custom width={width} zIndex={zIndex} />
|
|
|
|
+ </Navigator>
|
|
|
|
+ </View>
|
|
</View>
|
|
</View>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
function Custom({ width, zIndex }) {
|
|
function Custom({ width, zIndex }) {
|
|
- useReady(() => {
|
|
|
|
- const res = Taro.getSystemInfoSync()
|
|
|
|
- console.log(res)
|
|
|
|
- const clientRect = Taro.getMenuButtonBoundingClientRect()
|
|
|
|
- console.log(clientRect)
|
|
|
|
- })
|
|
|
|
|
|
+ const [style, setStyle] = useState({ width: '0px', height: 'px', zIndex })
|
|
|
|
|
|
- const style = {
|
|
|
|
- width: `${width || 100}px`,
|
|
|
|
- zIndex: zIndex || 1,
|
|
|
|
- height: `${(width || 100) * 16 / 9}px`
|
|
|
|
- }
|
|
|
|
|
|
+ useGetCustomClient((customClient) => {
|
|
|
|
+ let clientWidth = customClient.width
|
|
|
|
+ let clientHeight = customClient.height
|
|
|
|
+ if (width) {
|
|
|
|
+ clientWidth = width
|
|
|
|
+ clientHeight = width / 375 * 667
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ setStyle({
|
|
|
|
+ zIndex: zIndex || 1,
|
|
|
|
+ width: `${clientWidth}px`,
|
|
|
|
+ height: `${clientHeight}px`
|
|
|
|
+ })
|
|
|
|
+ })
|
|
return (
|
|
return (
|
|
- <View className='custom'>
|
|
|
|
- <Video className='custom-video' style={style} autoplay={false} controls={false} loop src={VIDEO_SRC} />
|
|
|
|
|
|
+ <View className='custom' style={style}>
|
|
|
|
+ <Video className='custom-video' autoplay={false} controls={false} loop src={VIDEO_SRC} />
|
|
</View>
|
|
</View>
|
|
)
|
|
)
|
|
}
|
|
}
|
|
|
|
|
|
-// 计算可视区
|
|
|
|
-
|
|
|
|
export default PqCustom
|
|
export default PqCustom
|