ionic 微信分享
来源:互联网 发布:数据挖掘的特点 编辑:程序博客网 时间:2024/05/21 08:46
先添加cordova插件:
$ cordova plugin add cordova-plugin-wechat --variable wechatappid=YOUR_WECHAT_APPID
controllers.js
app.controller('DashCtrl', function($scope, $ionicActionSheet, $ionicPopup) { document.addEventListener("deviceready", onDeviceReady, false); function onDeviceReady() { console.log(Wechat); Wechat.isInstalled(function (installed) { alert("Wechat installed: " + (installed ? "Yes" : "No")); }, function (reason) { alert("Failed: " + reason); }); var scope = "snsapi_userinfo", state = "_" + (+new Date()); Wechat.auth(scope, state, function (response) { // you may use response.code to get the access token. alert(JSON.stringify(response)); }, function (reason) { alert("Failed: " + reason); }); // Add similar listeners for other events }////只是个小DEMO所以就直接登录微信了,如果需要单独登录稍微改一下就可以了 $scope.share = function(title, desc, url, thumb) { $ionicActionSheet.show({ buttons: [ { text:'分享给微信好友' }, { text:'分享至微信朋友圈' } ], titleText: '分享', cancelText:'取消', cancel: function() { // 取消时执行 }, buttonClicked: function(index) { console.log(index); if(index == 0) { $scope.shareViaWechat(0, title, desc, url, thumb); } if(index == 1) { $scope.shareViaWechat(1, title, desc, url, thumb); } } }); }; $scope.shareViaWechat = function(scene, title, desc, url, thumb) { //scene:1 表示分享到朋友圈 //scene:0 表示分享给好友 console.log(scene); var msg = { title: "Hi, there", description: "This is description.", thumb: "www/img/pyq.png", mediaTagName: "TEST-TAG-001", messageExt: "这是第三方带的测试字段", messageAction: "<action>dotalist</action>", //media: "YOUR_MEDIA_OBJECT_HERE", //网页链接 media: { type: Wechat.Type.WEBPAGE, webpageUrl: "http://tech.qq.com/zt2012/tmtdecode/252.htm" } } //分享文字 // Wechat.share({ // text: "This is just a plain string", // scene: Wechat.Scene.TIMELINE // share to Timeline // }, function () { // alert("Success"); // }, function (reason) { // alert("Failed: " + reason); // }); //分享链接,设置好标题,描述,图片,链接 参数就OK。 Wechat.share({ message: msg, scene: scene // share to Timeline }, function () { alert("Success"); }, function (reason) { alert("Failed: " + reason); }); };})
html
<ion-icon class="button button-assertive button-outlinebutton-block" ng-click="share()">分享</ion-icon>
阅读全文
0 0
- ionic 微信分享
- ionic 微信分享
- ionic -- 微信分享之IOS版
- ionic 微信、微信朋友圈、qq、qq空间分享
- ionic android app 微信/朋友圈分享网页
- ionic 微信分享只显示默认图片问题
- ionic微信对接
- Ionic 微信支付
- 为Cordova + Ionic + AngularJS 应用添加微信分享功能
- ionic开发——微信分享准备工作之签名和包名的获取方法
- ionic开发——微信分享朋友,朋友圈的实现方法
- ionic开发——微信分享准备工作之签名和包名的获取方法
- ionic -- 使用cordova的插件实现分享到QQ、微博、微信
- ionic第三方QQ,微博,微信的登录,分享功能的实现和注意事项
- 微信--分享,关注
- 微信分享好友
- 微信分享
- 微信分享App
- 中缀表达式与后缀表达式的转换及后缀表达式的计算
- lua笔记
- Python垃圾回收机制及gc理解
- 【LeetCode】Sum of Square Numbers 解题报告
- PHP autoload 机制探究
- ionic 微信分享
- 暑期ACM集训-网络流
- HDU1690(最短路 两种解法 Dijkstra和Floyd)
- 更新oracle数据库时间字段全部数据
- Spring设计模式探幽(1)
- 在win2012下部署安装.NET4.0(4.5)框架
- shell脚本
- HDU 2089 分拆素数和 (素数打表)
- ios 关于截图