123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241 |
- <?php
- include_once "config.php";
- include_once "WeiXin.php";
- $weixin = new WeiXin($appId,$appSecret,$token);
- $apiInfo = $weixin->init()->getJsApiTicket();
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <title></title>
- <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.1.0.js"></script>
- <?php include_once "jsconfig.php";?>
- <script type="text/javascript" src="jquery.js"></script>
- </head>
- <body>
- <style>
- button{width:100%;height:70px;line-height: 70px;margin-bottom: 10px}
- </style>
- <button id="shareToQQBtn" >分享到QQ</button>
- <button id="chooseImgBtn">选择并上传图片</button>
- <button id="previewImgBtn">预览图片</button>
- <button id="downloadImgBtn">下载图片</button>
- <button id="networkTypeBtn">获取网络状态</button>
- <button id="openLocationBtn">查看位置</button>
- <button id="getLocationBtn">获取位置</button>
- <button id="scanCodeBtn">微信扫码</button>
- </body>
- <script>
-
- wx.ready(function () {
-
- wx.onMenuShareTimeline({
- title: '分享到朋友圈测试',
- link: 'http://www.baidu.com',
- imgUrl: 'http://imga.tiboo.cn/a/2015/2065121_1025233119.jpg',
- success: function () {
-
- alert('分享成功');
- },
- cancel: function () {
-
- alert('取消成功');
- }
- });
-
- wx.onMenuShareAppMessage({
- title: '分享给朋友测试',
- desc: '分享给朋友描述',
- link: 'http://www.baidu.com',
- imgUrl: 'http://imga.tiboo.cn/a/2015/2065121_1025233119.jpg',
- type: '',
- dataUrl: '',
- success: function () {
-
- alert('分享成功')
- },
- cancel: function () {
-
- alert('cancel')
- }
- });
-
- wx.onMenuShareQQ({
- title: '分享到QQ测试',
- desc: '分享到QQ描述',
- link: 'http://www.baidu.com',
- imgUrl: 'http://imga.tiboo.cn/a/2015/2065121_1025233119.jpg',
- success: function () {
-
- alert('分享成功')
- },
- cancel: function () {
-
- alert('cancel')
- }
- });
-
- $('#chooseImgBtn').bind('click',function(){
- wx.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['album', 'camera'],
- success: function (res) {
- var localIds = res.localIds;
- for(var i=0;i<localIds.length;i++)
- {
- wx.uploadImage({
- localId: localIds[i],
- isShowProgressTips: 1,
- success: function (res) {
- var serverId = res.serverId;
- }
- });
- }
- }
- });
- })
-
- $('#previewImgBtn').bind('click',function(){
- wx.previewImage({
- current: 'http://imga.tiboo.cn/a/2015/2065121_1025233119.jpg',
- urls: ['http://imga.tiboo.cn/a/2015/2065121_1025233119.jpg','http://imga.tiboo.cn/a/2015/2065121_1025233120.jpg']
- });
- })
-
- $('#downloadImgBtn').bind('click',function(){
- wx.downloadImage({
- serverId: '',
- isShowProgressTips: 1,
- success: function (res) {
- var localId = res.localId;
- alert(localId);
- }
- });
- })
-
- $('#networkTypeBtn').bind('click',function(){
- wx.getNetworkType({
- success: function (res) {
- var networkType = res.networkType;
- alert(networkType);
- }
- });
- })
-
- $('#openLocationBtn').bind('click',function(){
- wx.openLocation({
- latitude: 0,
- longitude: 0,
- name: 'test',
- address: 'fsdfsdfdsf',
- scale: 1,
- infoUrl: 'http://www.baidu.com'
- });
- })
-
- $('#getLocationBtn').bind('click',function(){
- wx.getLocation({
- type: 'wgs84',
- success: function (res) {
- var latitude = res.latitude;
- var longitude = res.longitude;
- var speed = res.speed;
- var accuracy = res.accuracy;
- }
- });
- })
-
- $('#scanCodeBtn').bind('click',function(){
- wx.scanQRCode({
- needResult: 1,
- scanType: ["qrCode","barCode"],
- success: function (res) {
- var result = res.resultStr;
- }
- });
- })
-
-
-
-
-
-
-
-
- });
-
- function shareOut(type,title,desc,link,imgUrl)
- {
- var data = {
- title: title,
- desc: desc,
- link: link,
- imgUrl: imgUrl,
- success: function () {
- },
- cancel: function () {
- }
- };
- if(type=='onMenuShareQQ')
- {
- wx.onMenuShareQQ(data);
- }
- else if(type=='onMenuShareWeibo')
- {
- wx.onMenuShareWeibo(data);
- }
- else if(type=='onMenuShareQZone')
- {
- wx.onMenuShareQZone(data);
- }
- else
- {
- alert('非法操作!');
- return;
- }
- }
- </script>
- </html>
|