前言:业务场景 需要给手机号码拨打电话与发送短信。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