1. 程式人生 > >Hbuilder給手機發送簡訊與撥打電話

Hbuilder給手機發送簡訊與撥打電話

        前言:業務場景 需要給手機號碼撥打電話與傳送簡訊。html5已經提供介面。

        

methods: {
                    Call: function() {
                        var that = this;
                        if(that.ptel == "暫無") {
                            return;
                        }
                        mui.confirm(
'您確定要給' + that.name + '打電話嗎?', ' ', ['確認', '取消'], function(result) { if(result.index == 0) { plus.device.dial(that.phone, false); } },'div') }, Message: function() {
var that = this; if(that.ptel == "暫無") { return; } mui.confirm('您確定要給' + that.name + '傳送簡訊嗎?', ' ', ['確認', '取消'], function(result) { if(result.index == 0) {
var msg = plus.messaging.createMessage(plus.messaging.TYPE_SMS); msg.to = [that.phone]; msg.body = ''; plus.messaging.sendMessage(msg); } },'div') } }

        

        結語:Html5+提供許多的介面。官方文件地址: http://www.html5plus.org/doc/h5p.html