罗广聪

引入打电话

... ... @@ -10,10 +10,41 @@ import {
AlertIOS,
AsyncStorage,
Button,
ScrollView
ScrollView,
Linking
} from "react-native";
import { StackNavigator, TabNavigator } from "react-navigation";
const LaunchURL = function (url) {
Linking.canOpenURL(url).then(supported => {
if (!supported) {
console.log('Can\'t handle url: ' + url);
} else {
Linking.openURL(url)
.catch(err => {
if (url.includes('telprompt')) {
// telprompt was cancelled and Linking openURL method sees this as an error
// it is not a true error so ignore it to prevent apps crashing
// see https://github.com/anarchicknight/react-native-communications/issues/39
} else {
console.warn('openURL error', err)
}
});
}
}).catch(err => console.warn('An unexpected error happened', err));
};
const phonecall = function (phoneNumber, prompt) {
let url;
if (Platform.OS !== 'android') {
url = prompt ? 'telprompt:' : 'tel:';
}
else {
url = 'tel:';
}
url += phoneNumber;
LaunchURL(url);
}
export default class Mine extends Component {
constructor(props) {
super(props);
... ... @@ -171,7 +202,7 @@ export default class Mine extends Component {
)}
</View>
{/* 设置昵称和职业 */}
{/* 设置个人信息 */}
{this.state.IS_LOGIN == "yes" ? (
<View style={styles.midContainer}>
{/* 更改昵称 */}
... ... @@ -281,6 +312,7 @@ export default class Mine extends Component {
</View>
) : null}
{/* 评价和客服 */}
<View style={styles.midContainer}>
<TouchableOpacity style={styles.itemContainer}>
<View style={styles.itemLeft}>
... ... @@ -293,7 +325,9 @@ export default class Mine extends Component {
/>
</View>
</TouchableOpacity>
<TouchableOpacity style={styles.itemContainer}>
<TouchableOpacity style={styles.itemContainer} onPress={() => {
phonecall("4001-608876", true);
}}>
<View style={styles.itemLeft}>
<Text style={styles.leftTitle}>客服电话</Text>
</View>
... ... @@ -307,15 +341,14 @@ export default class Mine extends Component {
</TouchableOpacity>
</View>
{/* 当前版本 */}
<View style={styles.midContainer}>
<TouchableOpacity style={styles.itemContainer}>
<View style={styles.itemLeft}>
<Text style={styles.leftTitle}>当前版本</Text>
</View>
<View style={styles.itemRight}>
<Text style={styles.itemRightContent}>
V1.0.0
</Text>
<Text style={styles.itemRightContent}>V1.0.0</Text>
</View>
</TouchableOpacity>
</View>
... ...