- //语音读text里面的文字
- var text=document.getElementById('ready').value;
- alert(text);
- var obj = api.require('speechRecognizer');
- obj.read({
- readStr:'缘'+text
- },function(ret,err) {
- if(ret.status) {
- ret.speakProgress
- }else{
- err.msg
- }
- });
- //QQ分享
- 在config里面添加
-
-
- //分享新闻到QQ页面JS
- function weichat(){
- //判断是否安装了QQ
- var obj = api.require('qq');
- obj.installed(function(ret,err){
- if(ret.status){
- //如果安装了就登陆QQ
- var obj = api.require('qq');
- obj.login(function(ret,err){
- if(ret.status)
- {
- var obj = api.require('qq');
- obj.shareNews({
- url:'http://www.uzmap.com',
- title:'新闻分享',
- description:'新闻描述',
- imgUrl:'http://upload.wabei.cn/2011/0807/20110807025817844.jpg'
- });
- }else
- {
- alert("登录失败");
- }
- });
-
- }else{
- api.alert({msg: "没有安装"});
- }
- });
- }
- //分享图片到QQ
- function weichat(){
- //判断是否安装了QQ
- var obj = api.require('qq');
- obj.installed(function(ret,err){
- if(ret.status){
- //如果安装了就登陆QQ
- var obj = api.require('qq');
- obj.login(function(ret,err){
- if(ret.status)
- {
- var obj = api.require('qq');
- obj.shareImage({
- title:'test',
- description:'testd',
- imgPath:'widget://icon/icon150x150.png'//图片地址为APP目录下的图片
- },function(ret,err){
- alert(ret.status);
- if(ret.status)
- {
- alert(1);
-
- }else
- {
- api.alert({msg:err.msg});
- }
- });
- }else
- {
- alert("登录失败");
- }
- });
-
- }else{
- api.alert({msg: "没有安装"});
- }
- });
- }
- //分享音乐
- function weichat(){
- //判断是否安装了QQ
- var obj = api.require('qq');
- obj.installed(function(ret,err){
- if(ret.status){
- //如果安装了就登陆QQ
- var obj = api.require('qq');
- obj.login(function(ret,err){
- if(ret.status)
- {
- var obj = api.require('qq');
- obj.shareMusic({
- url:'http://play.baidu.com/?__m=mboxCtrl.playSong&__a=120125029&__o=song/120125029||playBtn&fr=altg8||www.baidu.com#',//音乐的地址
- title:'小苹果',//音乐名字
- description:'小小苹果',//音乐描述
- imgUrl:'http://musicdata.baidu.com/data2/pic/122112246/122112246.jpg', //音乐的图片地址
- type:'QZone'//分享内容到好友或空间,取值范围QZone,QFriend,可为空
- },function(ret,err){
- alert(ret.status);
- if(ret.status)
- {
- alert(1);
-
- }else
- {
- api.alert({msg:err.msg});
- }
- });
- }else
- {
- alert("登录失败");
- }
- });
-
- }else{
- api.alert({msg: "没有安装"});
- }
- });
- }
- //分享视频
- function weichat(){
- //判断是否安装了QQ
- var obj = api.require('qq');
- obj.installed(function(ret,err){
- if(ret.status){
- //如果安装了就登陆QQ
- var obj = api.require('qq');
- obj.login(function(ret,err){
- if(ret.status)
- {
- var obj = api.require('qq');
- var obj = api.require('qq');
- obj.shareVideo({
- url:'http://www.iqiyi.com/w_19rs3ri1x9.html',
- title:'视频',
- description:'王力宏',
- imgUrl:'widget://icon/icon150x150.png'
- },function(ret,err){
- alert(ret.status);
- if(ret.status)
- {
- alert(1);
-
- }else
- {
- api.alert({msg:err.msg});
- }
- });
- }else
- {
- alert("登录失败");
- }
- });
-
- }else{
- api.alert({msg: "没有安装"});
- }
- });
- }
- //分享到新浪微博
- function sinaWeiBo(){
- var sinaWeiBo = api.require('sinaWeiBo');
- sinaWeiBo.auth(function(ret,err){
- if (ret.status) {
- sinaWeiBo.sendRequest({
- contentType: 'text',
- text: '山不在高,有仙则名;水不在深,有龙则灵。',
- imageUrl: 'WeiShare://icon/icon150x150.png'
- },function(ret,err){
- if (ret.status) {
- api.alert({
- title: '发表微博',
- msg: '发表成功',
- buttons: ['确定']
- });
- }else{
- api.alert({
- title: '发表微博',
- msg: '发表失败',
- buttons: ['确定']
- });
- };
- });
- }else{
- api.alert({msg:'授权失败'+err.msg});
- }
- });
- }
- //打开图片浏览器
- function sinaWeiBo(){
- var obj = api.require('imageBrowser');
- obj.openImages({
- imageUrls: ['widget://icon/icon150x150.png','widget://launch/launch1080x1920.png'],
- showList:true,
- activeIndex:3
- });
- }
- //扫描信用卡
- function sinaWeiBo() {
- var obj = api.require('cardReader');
- obj.open(function(ret, err) {
- if (ret.status) {
- api.alert({
- msg : '卡號:' + ret.cardNum + '過期的月' + ret.expiryMonth + '過期的年' + ret.expiryYear + 'cvv號' + ret.cvv
- });
- } else {
- api.alert({
- msg : err.msg
- });
- }
- });
- }
- //获取通讯录的姓名与电话号码
- function sinaWeiBo() {
- api.openContacts(
- function(ret,err){
- if(ret.status){
- var msg = '姓名:'+ret.name+'--电话:'+ret.phone;
- api.alert({msg:msg});
- }else{
- api.alert({msg:err.msg});
- };
- }
- );
- }
- //消失的提示框
- function show(){
- api.toast({
- msg: '网络错误',
- duration:2000,
- location: 'bottom'
- });
- }
复制代码
|