Skip to content
This repository has been archived by the owner on Dec 6, 2021. It is now read-only.

Commit

Permalink
fix(button): #56 miniapp event handles failed
Browse files Browse the repository at this point in the history
  • Loading branch information
b2nil committed Oct 28, 2020
1 parent e4271f2 commit fcefbbf
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/components/button/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { h, defineComponent, computed, mergeProps, PropType } from 'vue'
import { Button, View, Form } from '@tarojs/components'
import { CommonEventFunction } from "@tarojs/components/types/common"
import { ButtonProps } from "@tarojs/components/types/Button"
import { AtButtonProps } from "types/button"
import AtLoading from '../loading/index'
import { getEnvs } from '../../utils/common'
Expand Down Expand Up @@ -164,18 +162,19 @@ const AtButton = defineComponent({
}

interface miniAppEventHandleProps {
error?: typeof props.onError
onError?: typeof props.onError
onContact?: typeof props.onContact
onOpenSetting?: typeof props.onOpenSetting
getphonenumber?: typeof props.onGetPhoneNumber
getuserinfo?: typeof props.onGetUserInfo
onGetPhoneNumber?: typeof props.onGetPhoneNumber
onGetUserInfo?: typeof props.onGetUserInfo
onGetAuthorize?: typeof props.onGetAuthorize
onLaunchapp?: typeof props.onLaunchapp
}

function getWxButtonProps(): miniAppEventHandleProps {
if (!props.openType) return {}

const wxButtonProps: miniAppEventHandleProps = { error: handleError }
const wxButtonProps: miniAppEventHandleProps = {}

switch (props.openType) {
case 'contact':
Expand All @@ -185,12 +184,18 @@ const AtButton = defineComponent({
wxButtonProps.onOpenSetting = handleOpenSetting
break
case 'getPhoneNumber':
wxButtonProps.getphonenumber = handleGetPhoneNumber
wxButtonProps.onGetPhoneNumber = handleGetPhoneNumber
break
case 'getUserInfo':
wxButtonProps.getuserinfo = handleGetUserInfo
wxButtonProps.onGetUserInfo = handleGetUserInfo
break
case 'getAuthorize':
wxButtonProps.onGetAuthorize = handleGetAuthorize
break
case 'launchApp':
wxButtonProps.onLaunchapp = handleLaunchapp
wxButtonProps.onError = handleError
break
case 'launchApp': wxButtonProps.onLaunchapp = handleLaunchapp
default:
break
}
Expand All @@ -215,7 +220,7 @@ const AtButton = defineComponent({
sendMessageImg: props.sendMessageImg,
showMessageCard: props.showMessageCard,
appParameter: props.appParameter,
...{ on: getWxButtonProps() }
...getWxButtonProps()
})

return () => (
Expand Down

0 comments on commit fcefbbf

Please sign in to comment.