Hbuilder給手機發送短信與撥打電話

        前言:業務場景 須要給手機號碼撥打電話與發送短信。html5已經提供接口。html

        

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 html5

相關文章
相關標籤/搜索