Browse Source

feat: 长按事件

huangzhichao 1 year ago
parent
commit
bc647c5b51
1 changed files with 12 additions and 4 deletions
  1. 12 4
      src/plugin/pages/customPage/index.tsx

+ 12 - 4
src/plugin/pages/customPage/index.tsx

@@ -1,6 +1,6 @@
-import Taro, { useLoad } from '@tarojs/taro'
+import Taro, { useDidHide, useLoad } from '@tarojs/taro'
 import { useState } from 'react'
-import useGetCustomClient, { getTopSafeHeight } from '@/hooks/useGetCustomClient'
+import { getTopSafeHeight } from '@/hooks/useGetCustomClient'
 import { View, Text, Image } from '@tarojs/components'
 import './index.less'
 
@@ -53,6 +53,10 @@ function CustomPage() {
     })
   })
 
+  useDidHide(() => {
+    console.log('hide')
+  })
+
   function navigateBack() {
     wx.navigateBack()
   }
@@ -79,20 +83,24 @@ function Page({ styleSheet, adInfo }) {
     color: styleSheet.page.color
   }
 
+  function onLongPress(evt) {
+    console.log(evt)
+  }
+
   return (
     <View className='page-content' style={pageStyle}>
       <View className='page-title' style={styleSheet.title}>
         <Text>{adInfo.title}</Text>
       </View>
       <View className='page-content' style={styleSheet.content}>
-        <Image className='page-image' src={adInfo.image} 	show-menu-by-longpress />
+        <Image className='page-image' src={adInfo.image} 	showMenuByLongpress onLongPress={onLongPress}/>
       </View>
       <View className='page-guide' style={styleSheet.guide}>
 
         <View className='guide-title'>添加方法</View>
         <View className='guide-content'>
           <Text>1、长按上面图片3秒</Text>
-          <Text>2、点击识别图中二</Text>
+          <Text>2、点击识别图中二维码</Text>
         </View>
       </View>
     </View>