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 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM