uni-app怎么实现点击一键拨打电话

小程序开发需求点击联系客服一键拨打电话 可以直接使用

uni-app怎么实现点击一键拨打电话_第1张图片

    联系客服
    // 联系客服
            call(phone) {
                console.log('传入的电话', phone);
                const res = uni.getSystemInfoSync();
                // ios系统默认有个模态框
                if (res.platform == 'ios') {
                    uni.makePhoneCall({
                        phoneNumber: phone,
                        success() {
                            console.log('拨打成功了');
                        },
                        fail() {
                            console.log('拨打失败了');
                        }
                    })
                } else {
                    //安卓手机手动设置一个showActionSheet
                    uni.showActionSheet({
                        itemList: [phone, '呼叫'],
                        success: function(res) {
                            console.log(res);
                            if (res.tapIndex == 1) {
                                uni.makePhoneCall({
                                    phoneNumber: phone,
                                })
                            }
                        }
                    })
                }

            }

你可能感兴趣的:(前端,开发语言,uni-app,vue.js,javascript)