zoukankan      html  css  js  c++  java
  • react 实现点击跳转到拨号界面

    import React, { Component } from 'react';
    import {
        View,
        Text,
        Image,
        StyleSheet,
        TouchableOpacity,
        NativeModules,
        Platform,
        StatusBar,
        ScrollView,
        Alert ,
        Linking
    } from "react-native";
    import { Toast } from "../../components/base/Toast";
    class GrabSheetVc extends Component {
        constructor(props) {
            super(props);
            this.state = {  }
            this.phone = 18888888888
        }
     render() {
            return (
      
    <View style={styles.v4}>
                                <TouchableOpacity style={{ borderRadius: 27, overflow: 'hidden', marginTop: 13 }} onPress={this.callMerchant}>
                                    <Image
                                        source={require('../../../resource/order/telephone.png')}
                                        style={{  Utils.fontRem * 54, height: Utils.fontRem * 54 }}
                                        resizeMode='contain'
                                    />
                                </TouchableOpacity>
                                <Text style={{ fontSize: 14, color: '#333', marginTop: 9.5 }}>联系雇主</Text>
    </View>
    )}
    }
     /**
       *  拨打电话
       * @param {string} phone 版本号
       * @example
       * call('18888888888')
       */
      call = phone => {
        const url = `tel:${phone}`;
        Linking.canOpenURL(url)
          .then(supported => {
            if (!supported) {
              return Alert.alert('提示', `您的设备不支持该功能,请手动拨打 ${phone}`, [
                { text: '确定' }
              ]);
            }
            return Linking.openURL(url);
          })
          .catch(err => Toast.show(`出错了:${err}`, 1.5));
      };
      callMerchant = (phone) => {
        this.call(this.phone);
      };

     

  • 相关阅读:
    将Nginx添加到windows服务中
    springboot使用redis管理session
    GIT常用命令
    阻止360、谷歌浏览器表单自动填充
    谈谈对Spring IOC的理解
    同一个Nginx服务器同一端口配置多个代理服务
    LeetCode 653. Two Sum IV
    109. Convert Sorted List to Binary Search Tree(根据有序链表构造平衡的二叉查找树)
    108. Convert Sorted Array to Binary Search Tree(从有序数组中构造平衡的BST)
    LeetCode 236. Lowest Common Ancestor of a Binary Tree(二叉树求两点LCA)
  • 原文地址:https://www.cnblogs.com/james-L/p/11940262.html
Copyright © 2011-2022 走看看