UNPKG

yylib-quick-mobile

Version:

yylib-quick-mobile

38 lines (37 loc) 1.01 kB
import React, {Component} from 'react'; import YYIcon from '../icon/YYIcon'; import {Toast} from 'antd-mobile'; class YYScan extends Component {//扫描二维码 onClick() { var _this = this; var {type} = this.props; var params = {command:type}; if (window.YYPlugin) { window.YYPlugin.call("CommonPlugin", "scan", params, function success(info){ if(_this.props.onClick){ if (type==='invoice') {//扫码发票 _this.props.onClick(info); } else { _this.props.onClick(info.result); } } }); } else { Toast.info('请在手机上进行调试或检查yyplus的引入!') } } render() { let { icon, iconColor } = this.props; return ( <YYIcon type={icon} color={iconColor} size="xs" onClick={this.onClick.bind(this)}/> ); } } YYScan.defaultProps = { icon: 'Scan', iconColor: '#0091fa', type: 'noDail' } export default YYScan;