添加微信分分享按钮
diff --git a/platforms/android/android.json b/platforms/android/android.json
index 105b5f2..02e24ed 100644
--- a/platforms/android/android.json
+++ b/platforms/android/android.json
@@ -107,6 +107,14 @@
{
"xml": "<preference name=\"QQ_APP_ID\" value=\"101885581\" />",
"count": 1
+ },
+ {
+ "xml": "<feature name=\"Wechat\"><param name=\"android-package\" value=\"xu.li.cordova.wechat.Wechat\" /></feature>",
+ "count": 1
+ },
+ {
+ "xml": "<preference name=\"WECHATAPPID\" value=\"wxa483e2c392b08993\" />",
+ "count": 1
}
]
}
@@ -116,7 +124,7 @@
"/*": [
{
"xml": "<uses-permission android:name=\"android.permission.WRITE_EXTERNAL_STORAGE\" />",
- "count": 2
+ "count": 3
},
{
"xml": "<uses-permission android:name=\"android.permission.CAMERA\" android:required=\"false\" />",
@@ -137,6 +145,22 @@
{
"xml": "<uses-permission android:name=\"android.permission.USE_FINGERPRINT\" />",
"count": 1
+ },
+ {
+ "xml": "<uses-permission android:name=\"android.permission.INTERNET\" />",
+ "count": 1
+ },
+ {
+ "xml": "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\" />",
+ "count": 1
+ },
+ {
+ "xml": "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\" />",
+ "count": 1
+ },
+ {
+ "xml": "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\" />",
+ "count": 1
}
],
"/manifest": [
@@ -283,6 +307,14 @@
{
"xml": "<activity android:exported=\"true\" android:name=\"de.niklasmerz.cordova.biometric.BiometricActivity\" android:theme=\"@style/TransparentTheme\" />",
"count": 1
+ },
+ {
+ "xml": "<activity android:exported=\"true\" android:label=\"@string/launcher_name\" android:launchMode=\"singleTask\" android:name=\".wxapi.WXEntryActivity\" android:taskAffinity=\"com.dalipolice.app\"><intent-filter><action android:name=\"android.intent.action.VIEW\" /><category android:name=\"android.intent.category.DEFAULT\" /><data android:scheme=\"wxa483e2c392b08993\" /></intent-filter></activity>",
+ "count": 1
+ },
+ {
+ "xml": "<activity android:exported=\"true\" android:label=\"@string/launcher_name\" android:launchMode=\"singleTop\" android:name=\".wxapi.WXPayEntryActivity\"><intent-filter><action android:name=\"android.intent.action.VIEW\" /><category android:name=\"android.intent.category.DEFAULT\" /><data android:scheme=\"wxa483e2c392b08993\" /></intent-filter></activity>",
+ "count": 1
}
]
}
@@ -401,6 +433,11 @@
"cordova-plugin-qqsdk": {
"QQ_APP_ID": "101885581",
"PACKAGE_NAME": "com.dalipolice.app"
+ },
+ "cordova-plugin-wechat": {
+ "WECHATAPPID": "wxa483e2c392b08993",
+ "UNIVERSALLINK": "YOUR_UNIVERSAL_LINK",
+ "PACKAGE_NAME": "com.dalipolice.app"
}
},
"dependent_plugins": {},
@@ -764,6 +801,14 @@
"clobbers": [
"QQSDK"
]
+ },
+ {
+ "id": "cordova-plugin-wechat.Wechat",
+ "file": "plugins/cordova-plugin-wechat/www/wechat.js",
+ "pluginId": "cordova-plugin-wechat",
+ "clobbers": [
+ "Wechat"
+ ]
}
],
"plugin_metadata": {
@@ -786,6 +831,7 @@
"cordova-plugin-brightness": "0.1.5",
"cordova-plugin-fingerprint-aio": "3.0.1",
"cordova-plugin-prevent-screenshot-coffice": "1.0.1",
- "cordova-plugin-qqsdk": "0.9.7"
+ "cordova-plugin-qqsdk": "0.9.7",
+ "cordova-plugin-wechat": "3.0.0"
}
}
diff --git a/platforms/android/app/build.gradle b/platforms/android/app/build.gradle
index e758e33..6a72223 100644
--- a/platforms/android/app/build.gradle
+++ b/platforms/android/app/build.gradle
@@ -92,6 +92,7 @@
// PLUGIN GRADLE EXTENSIONS START
apply from: "../cordova-plugin-qrscanner/dlapp-qrscanner.gradle"
apply from: "../cordova-plugin-fingerprint-aio/app-build.gradle"
+apply from: "../cordova-plugin-wechat/app-android-build.gradle"
// PLUGIN GRADLE EXTENSIONS END
def hasBuildExtras1 = file('build-extras.gradle').exists()
diff --git a/platforms/android/app/src/main/AndroidManifest.xml b/platforms/android/app/src/main/AndroidManifest.xml
index 4b6fab6..7ccac86 100644
--- a/platforms/android/app/src/main/AndroidManifest.xml
+++ b/platforms/android/app/src/main/AndroidManifest.xml
@@ -90,6 +90,20 @@
</intent-filter>
</activity>
<activity android:configChanges="orientation|keyboardHidden" android:name="com.tencent.connect.common.AssistActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.Translucent.NoTitleBar" />
+ <activity android:exported="true" android:label="@string/launcher_name" android:launchMode="singleTask" android:name=".wxapi.WXEntryActivity" android:taskAffinity="com.dalipolice.app">
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:scheme="wxa483e2c392b08993" />
+ </intent-filter>
+ </activity>
+ <activity android:exported="true" android:label="@string/launcher_name" android:launchMode="singleTop" android:name=".wxapi.WXPayEntryActivity">
+ <intent-filter>
+ <action android:name="android.intent.action.VIEW" />
+ <category android:name="android.intent.category.DEFAULT" />
+ <data android:scheme="wxa483e2c392b08993" />
+ </intent-filter>
+ </activity>
</application>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" android:required="false" />
diff --git a/platforms/android/app/src/main/assets/www/cordova_plugins.js b/platforms/android/app/src/main/assets/www/cordova_plugins.js
index 08297e5..02af8e9 100644
--- a/platforms/android/app/src/main/assets/www/cordova_plugins.js
+++ b/platforms/android/app/src/main/assets/www/cordova_plugins.js
@@ -359,6 +359,14 @@
"clobbers": [
"QQSDK"
]
+ },
+ {
+ "id": "cordova-plugin-wechat.Wechat",
+ "file": "plugins/cordova-plugin-wechat/www/wechat.js",
+ "pluginId": "cordova-plugin-wechat",
+ "clobbers": [
+ "Wechat"
+ ]
}
];
module.exports.metadata = {
@@ -381,6 +389,7 @@
"cordova-plugin-brightness": "0.1.5",
"cordova-plugin-fingerprint-aio": "3.0.1",
"cordova-plugin-prevent-screenshot-coffice": "1.0.1",
- "cordova-plugin-qqsdk": "0.9.7"
+ "cordova-plugin-qqsdk": "0.9.7",
+ "cordova-plugin-wechat": "3.0.0"
};
});
\ No newline at end of file
diff --git a/platforms/android/app/src/main/assets/www/main.html b/platforms/android/app/src/main/assets/www/main.html
index 8cced49..d9dcb90 100644
--- a/platforms/android/app/src/main/assets/www/main.html
+++ b/platforms/android/app/src/main/assets/www/main.html
@@ -1,206 +1,242 @@
<!doctype html>
<html>
-<head>
- <meta charset="utf-8">
- <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
- <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
- <link rel="stylesheet" type="text/css" href="css/aui.css" />
- <link rel="stylesheet" type="text/css" href="css/weui.min.css">
- <link rel="stylesheet" type="text/css" href="css/jquery-weui.min.css">
- <link rel="stylesheet" type="text/css" href="css/index.css" />
- <link rel="stylesheet" type="text/css" href="css/aui-slide.css">
- <style type="text/css">
- .aui-slide-node{
- /*background: transparent!important;*/
- }
- </style>
-</head>
-<body>
- <div id="main1">
- <div id="maintop">
- <div id="startslider" class="main" style="height: 240px;display: block;">
- <div class="aui-slide-wrap" >
- <div class="aui-slide-node" style="padding:36px 30px 30px 30px;background-color: #ACEAF5" >
- <img src="img/p1.png" style="background-color: #ACEAF5"/>
- </div>
- <div class="aui-slide-node" style="padding:36px 30px 30px 30px;background-color: #a4e4d4">
- <img src="img/p2.png" style="background-color: #a4e4d4"/>
- </div>
- <div class="aui-slide-node " style="padding:36px 30px 30px 30px;background-color: #65abe7">
- <img src="img/p3.png" style="background-color: #65abe7"/>
- </div>
- <div class="aui-slide-node " style="padding:36px 30px 30px 30px;background-color: #357a8a">
- <img src="img/p4.png" style="background-color: #357a8a"/>
- </div>
- </div>
- <div class="aui-slide-page-wrap"><!--分页容器--></div>
- </div>
- </div>
- <div style="position: absolute;bottom:50px;width: 100%;top:240px" id="maincontent">
- <section class="aui-content " style="height: 100%">
- <div class="aui-grid" style="height: 100%">
- <div class="aui-row" style="height: 50%">
- <div class="aui-col-xs-6 mainmeun-div" id="qrcodeBtn" style="background: #BBE6EC;">
- <div>
- <div class="center-in"><img src="img/m4.png" class="meun-img"class="meun-img"></div>
- <div class="aui-grid-label" style="margin-top:10px;font-size: 22px;">读码</div>
- </div>
- </div>
- <div class="aui-col-xs-6 mainmeun-div" id="scanBtn" style="background: #91DDEA;">
- <div>
- <div class="center-in"><img src="img/m2.png" class="meun-img"></div>
- <div class="aui-grid-label" style="margin-top:10px;font-size: 22px;">扫码</div>
- </div>
- </div>
- </div>
- <div class="aui-row" style="height: 50%">
- <div class="aui-col-xs-6 mainmeun-div" id="qrcodeBtn1" style="background: #fff;">
- <div>
- <div class="center-in"><img src="img/m3.png" class="meun-img"></div>
- <div class="aui-grid-label" style="margin-top:10px;font-size: 22px;">访码</div>
- </div>
- </div>
- <div class="aui-col-xs-6 mainmeun-div" id="moreFuncBtn" style="background: #FDD479;">
- <div>
- <div class="center-in"><img src="img/m1.png" class="meun-img"></div>
- <div class="aui-grid-label" style="margin-top:10px;font-size: 22px;">更多</div>
- </div>
- </div>
- </div>
- </div>
- </section>
- </div>
- </div>
- <div id="main2" style="display: none">
- <header class="aui-bar aui-bar-nav" style="padding-top:25px;font-size: 22px">
- 消息
- </header>
- <section class="aui-content">
- <div class="weui-loadmore weui-loadmore_line" >
- <span class="weui-loadmore__tips" style="background: transparent;" id="nodatahint">暂无消息</span>
- </div>
- </section>
- </div>
- <div id="main3" style="display: none;">
- <header class="aui-bar aui-bar-nav" style="padding-top:25px;font-size: 22px">
- 我的
- </header>
- <!-- bg-white -->
- <section class="aui-content aui-margin-b-15" style=" margin-top: -2px;">
- <div class="aui-list aui-media-list aui-list-noborder aui-bg-info user-info">
- <div class="aui-list-item aui-list-item-middle top-btn">
- <div class="aui-media-list-item-inner ">
- <div class="aui-list-item-media" style="width:3rem;">
- <img src="img/icon_header.png" class="aui-img-round" id="userlogo">
- </div>
- <div class="aui-list-item-inner">
- <div class="aui-list-item-text text-white aui-font-size-18" id="username">匿名</div>
- <div class="aui-list-item-text text-white">
- <div><i class="aui-iconfont aui-icon-mobile aui-font-size-14"></i><span id="userphone"></span></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </section>
- <section class="aui-content">
- <ul class="aui-list aui-list-in aui-margin-b-15">
- <li class="aui-list-item" onclick="app.toCard()">
- <div class="aui-list-item-label-icon">
- <i class="aui-iconfont aui-icon-cert aui-text-info"></i>
- </div>
- <div class="aui-list-item-inner aui-list-item-arrow">
- <div class="aui-list-item-title">市民卡签约</div>
- <div class="aui-list-item-right" id="usersign"></div>
- </div>
- </li>
- <!--<li class="aui-list-item" id="accsignbtn">-->
- <!--<div class="aui-list-item-label-icon">-->
- <!--<i class="aui-iconfont aui-icon-pencil aui-text-danger"></i>-->
- <!--</div>-->
- <!--<div class="aui-list-item-inner aui-list-item-arrow">-->
- <!--<div class="aui-list-item-title">签约代扣免密付</div>-->
- <!--<div class="aui-list-item-right" id="usersign"></div>-->
- <!--</div>-->
- <!--</li>-->
- </ul>
- <ul class="aui-list aui-list-in aui-margin-b-15">
- <li class="aui-list-item" id="usersec">
- <div class="aui-list-item-label-icon">
- <i class="aui-iconfont aui-icon-lock aui-text-info"></i>
- </div>
- <div class="aui-list-item-inner aui-list-item-arrow">
- <div class="aui-list-item-title">账户安全</div>
- </div>
- </li>
- </ul>
- <ul class="aui-list aui-list-in">
- <li class="aui-list-item" id="usersec" onclick="app.verisonCheck()">
- <div class="aui-list-item-label-icon">
- <i class="aui-iconfont aui-icon-info aui-text-info"></i>
- </div>
- <div class="aui-list-item-inner aui-list-item-arrow">
- <div class="aui-list-item-title">版本检测</div>
- <div class="aui-list-item-right" id="versioncheck">
- </div>
- </div>
- </li>
- </ul>
- <ul class="aui-list aui-list-in">
- <li class="aui-list-item" id="share" >
- <div class="aui-list-item-label-icon">
- <i class="aui-iconfont aui-icon-info aui-text-info"></i>
- </div>
- <div class="aui-list-item-inner aui-list-item-arrow">
- <div class="aui-list-item-title">分享测试</div>
- <div class="aui-list-item-right" id="versioncheck">
- </div>
- </div>
- </li>
- </ul>
- <div style="padding: 20px;margin-top: 40px;">
- <a href="javascript:app.logout();" class="weui-btn weui-btn_warn">退出登录</a>
- </div>
- </section>
- </div>
- <footer class="aui-bar aui-bar-tab aui-border-t" id="footer">
- <div class="aui-bar-tab-item aui-active" tapmode onclick="switchTo(1)" id="tab1">
- <i class="aui-iconfont aui-icon-home"></i>
- <div class="aui-bar-tab-label">首页</div>
- </div>
- <div class="aui-bar-tab-item" tapmode onclick="switchTo(2)" id="tab2">
- <i class="aui-iconfont aui-icon-comment"></i>
- <div class="aui-bar-tab-label">消息</div>
- </div>
- <div class="aui-bar-tab-item" tapmode onclick="switchTo(3)" id="tab3">
- <i class="aui-iconfont aui-icon-my"></i>
- <div class="aui-bar-tab-label">我的</div>
- </div>
- </footer>
-</body>
-<script type="text/javascript" src="cordova.js"></script>
-<script type="text/javascript" src="js/lib/jquery-2.1.4.js"></script>
-<script type="text/javascript" src="js/lib/aui-tab.js"></script>
-<script type="text/javascript" src="js/lib/aui-dialog.js"></script>
-<script type="text/javascript" src="js/lib/aui-slide.js"></script>
-<script type="text/javascript" src="js/server.js"></script>
-<script type="text/javascript" src="js/mainmenu.js"></script>
-<script type="text/javascript">
-var share = document.getElementById("share")
- share.onclick=function(){
- var args = {};
- args.client = QQSDK.ClientType.QQ;//QQSDK.ClientType.QQ,QQSDK.ClientType.TIM;
- args.scene = QQSDK.Scene.QQ;//QQSDK.Scene.QQZone,QQSDK.Scene.Favorite
- args.url = 'https://cordova.apache.org/';
- args.title = '这个是 Cordova QQ 新闻分享的标题';
- args.description = '这个是 Cordova QQ 新闻分享的描述';
- args.image = 'https://cordova.apache.org/static/img/cordova_bot.png';
- QQSDK.shareNews(function () {
- alert('shareNews success');
- }, function (failReason) {
- alert(failReason);
- }, args);
- }
-</script>
-</html>
\ No newline at end of file
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
+ <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
+ <link rel="stylesheet" type="text/css" href="css/aui.css" />
+ <link rel="stylesheet" type="text/css" href="css/weui.min.css">
+ <link rel="stylesheet" type="text/css" href="css/jquery-weui.min.css">
+ <link rel="stylesheet" type="text/css" href="css/index.css" />
+ <link rel="stylesheet" type="text/css" href="css/aui-slide.css">
+ <style type="text/css">
+ .aui-slide-node {
+ /*background: transparent!important;*/
+ }
+ </style>
+ </head>
+ <body>
+ <div id="main1">
+ <div id="maintop">
+ <div id="startslider" class="main" style="height: 240px;display: block;">
+ <div class="aui-slide-wrap">
+ <div class="aui-slide-node" style="padding:36px 30px 30px 30px;background-color: #ACEAF5">
+ <img src="img/p1.png" style="background-color: #ACEAF5" />
+ </div>
+ <div class="aui-slide-node" style="padding:36px 30px 30px 30px;background-color: #a4e4d4">
+ <img src="img/p2.png" style="background-color: #a4e4d4" />
+ </div>
+ <div class="aui-slide-node " style="padding:36px 30px 30px 30px;background-color: #65abe7">
+ <img src="img/p3.png" style="background-color: #65abe7" />
+ </div>
+ <div class="aui-slide-node " style="padding:36px 30px 30px 30px;background-color: #357a8a">
+ <img src="img/p4.png" style="background-color: #357a8a" />
+ </div>
+ </div>
+ <div class="aui-slide-page-wrap">
+ <!--分页容器-->
+ </div>
+ </div>
+ </div>
+ <div style="position: absolute;bottom:50px;width: 100%;top:240px" id="maincontent">
+ <section class="aui-content " style="height: 100%">
+ <div class="aui-grid" style="height: 100%">
+ <div class="aui-row" style="height: 50%">
+ <div class="aui-col-xs-6 mainmeun-div" id="qrcodeBtn" style="background: #BBE6EC;">
+ <div>
+ <div class="center-in"><img src="img/m4.png" class="meun-img" class="meun-img"></div>
+ <div class="aui-grid-label" style="margin-top:10px;font-size: 22px;">读码</div>
+ </div>
+ </div>
+ <div class="aui-col-xs-6 mainmeun-div" id="scanBtn" style="background: #91DDEA;">
+ <div>
+ <div class="center-in"><img src="img/m2.png" class="meun-img"></div>
+ <div class="aui-grid-label" style="margin-top:10px;font-size: 22px;">扫码</div>
+ </div>
+ </div>
+ </div>
+ <div class="aui-row" style="height: 50%">
+ <div class="aui-col-xs-6 mainmeun-div" id="qrcodeBtn1" style="background: #fff;">
+ <div>
+ <div class="center-in"><img src="img/m3.png" class="meun-img"></div>
+ <div class="aui-grid-label" style="margin-top:10px;font-size: 22px;">访码</div>
+ </div>
+ </div>
+ <div class="aui-col-xs-6 mainmeun-div" id="moreFuncBtn" style="background: #FDD479;">
+ <div>
+ <div class="center-in"><img src="img/m1.png" class="meun-img"></div>
+ <div class="aui-grid-label" style="margin-top:10px;font-size: 22px;">更多</div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </section>
+ </div>
+ </div>
+ <div id="main2" style="display: none">
+ <header class="aui-bar aui-bar-nav" style="padding-top:25px;font-size: 22px">
+ 消息
+ </header>
+ <section class="aui-content">
+ <div class="weui-loadmore weui-loadmore_line">
+ <span class="weui-loadmore__tips" style="background: transparent;" id="nodatahint">暂无消息</span>
+ </div>
+ </section>
+ </div>
+ <div id="main3" style="display: none;">
+ <header class="aui-bar aui-bar-nav" style="padding-top:25px;font-size: 22px">
+ 我的
+ </header>
+ <!-- bg-white -->
+ <section class="aui-content aui-margin-b-15" style=" margin-top: -2px;">
+ <div class="aui-list aui-media-list aui-list-noborder aui-bg-info user-info">
+ <div class="aui-list-item aui-list-item-middle top-btn">
+ <div class="aui-media-list-item-inner ">
+ <div class="aui-list-item-media" style="width:3rem;">
+ <img src="img/icon_header.png" class="aui-img-round" id="userlogo">
+ </div>
+ <div class="aui-list-item-inner">
+ <div class="aui-list-item-text text-white aui-font-size-18" id="username">匿名</div>
+ <div class="aui-list-item-text text-white">
+ <div><i class="aui-iconfont aui-icon-mobile aui-font-size-14"></i><span id="userphone"></span></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </section>
+ <section class="aui-content">
+ <ul class="aui-list aui-list-in aui-margin-b-15">
+ <li class="aui-list-item" onclick="app.toCard()">
+ <div class="aui-list-item-label-icon">
+ <i class="aui-iconfont aui-icon-cert aui-text-info"></i>
+ </div>
+ <div class="aui-list-item-inner aui-list-item-arrow">
+ <div class="aui-list-item-title">市民卡签约</div>
+ <div class="aui-list-item-right" id="usersign"></div>
+ </div>
+ </li>
+ <!--<li class="aui-list-item" id="accsignbtn">-->
+ <!--<div class="aui-list-item-label-icon">-->
+ <!--<i class="aui-iconfont aui-icon-pencil aui-text-danger"></i>-->
+ <!--</div>-->
+ <!--<div class="aui-list-item-inner aui-list-item-arrow">-->
+ <!--<div class="aui-list-item-title">签约代扣免密付</div>-->
+ <!--<div class="aui-list-item-right" id="usersign"></div>-->
+ <!--</div>-->
+ <!--</li>-->
+ </ul>
+ <ul class="aui-list aui-list-in aui-margin-b-15">
+ <li class="aui-list-item" id="usersec">
+ <div class="aui-list-item-label-icon">
+ <i class="aui-iconfont aui-icon-lock aui-text-info"></i>
+ </div>
+ <div class="aui-list-item-inner aui-list-item-arrow">
+ <div class="aui-list-item-title">账户安全</div>
+ </div>
+ </li>
+ </ul>
+ <ul class="aui-list aui-list-in">
+ <li class="aui-list-item" id="usersec" onclick="app.verisonCheck()">
+ <div class="aui-list-item-label-icon">
+ <i class="aui-iconfont aui-icon-info aui-text-info"></i>
+ </div>
+ <div class="aui-list-item-inner aui-list-item-arrow">
+ <div class="aui-list-item-title">版本检测</div>
+ <div class="aui-list-item-right" id="versioncheck">
+ </div>
+ </div>
+ </li>
+ </ul>
+ <ul class="aui-list aui-list-in">
+ <li class="aui-list-item" id="shareqq">
+ <div class="aui-list-item-label-icon">
+ <i class="aui-iconfont aui-icon-info aui-text-info"></i>
+ </div>
+ <div class="aui-list-item-inner aui-list-item-arrow">
+ <div class="aui-list-item-title">qq分享测试</div>
+ <div class="aui-list-item-right" id="versioncheck">
+ </div>
+ </div>
+ </li>
+ </ul>
+ <ul class="aui-list aui-list-in">
+ <li class="aui-list-item" id="sharewx">
+ <div class="aui-list-item-label-icon">
+ <i class="aui-iconfont aui-icon-info aui-text-info"></i>
+ </div>
+ <div class="aui-list-item-inner aui-list-item-arrow">
+ <div class="aui-list-item-title">wx分享测试</div>
+ <div class="aui-list-item-right" id="versioncheck">
+ </div>
+ </div>
+ </li>
+ </ul>
+ <div style="padding: 20px;margin-top: 40px;">
+ <a href="javascript:app.logout();" class="weui-btn weui-btn_warn">退出登录</a>
+ </div>
+ </section>
+ </div>
+ <footer class="aui-bar aui-bar-tab aui-border-t" id="footer">
+ <div class="aui-bar-tab-item aui-active" tapmode onclick="switchTo(1)" id="tab1">
+ <i class="aui-iconfont aui-icon-home"></i>
+ <div class="aui-bar-tab-label">首页</div>
+ </div>
+ <div class="aui-bar-tab-item" tapmode onclick="switchTo(2)" id="tab2">
+ <i class="aui-iconfont aui-icon-comment"></i>
+ <div class="aui-bar-tab-label">消息</div>
+ </div>
+ <div class="aui-bar-tab-item" tapmode onclick="switchTo(3)" id="tab3">
+ <i class="aui-iconfont aui-icon-my"></i>
+ <div class="aui-bar-tab-label">我的</div>
+ </div>
+ </footer>
+ </body>
+ <script type="text/javascript" src="cordova.js"></script>
+ <script type="text/javascript" src="js/lib/jquery-2.1.4.js"></script>
+ <script type="text/javascript" src="js/lib/aui-tab.js"></script>
+ <script type="text/javascript" src="js/lib/aui-dialog.js"></script>
+ <script type="text/javascript" src="js/lib/aui-slide.js"></script>
+ <script type="text/javascript" src="js/server.js"></script>
+ <script type="text/javascript" src="js/mainmenu.js"></script>
+ <script type="text/javascript">
+ var shareqq = document.getElementById("shareqq");
+ var sharewx = document.getElementById("sharewx");
+ shareqq.onclick = function() {
+ var args = {};
+ args.client = QQSDK.ClientType.QQ; //QQSDK.ClientType.QQ,QQSDK.ClientType.TIM;
+ args.scene = QQSDK.Scene.QQ; //QQSDK.Scene.QQZone,QQSDK.Scene.Favorite
+ args.url = 'https://cordova.apache.org/';
+ args.title = '这个是 Cordova QQ 新闻分享的标题';
+ args.description = '这个是 Cordova QQ 新闻分享的描述';
+ args.image = 'https://cordova.apache.org/static/img/cordova_bot.png';
+ QQSDK.shareNews(function() {
+ alert('shareNews success');
+ }, function(failReason) {
+ alert(failReason);
+ }, args);
+ }
+ sharewx.onclick = function() {
+ Wechat.share({
+ message: {
+ title: "Hi, there",
+ description: "This is description.",
+ thumb: "www/img/thumbnail.png",
+ mediaTagName: "TEST-TAG-001",
+ messageExt: "这是第三方带的测试字段",
+ messageAction: "<action>dotalist</action>",
+ media: {
+ type: Wechat.Type.WEBPAGE,
+ webpageUrl: "http://www.jason-z.com"
+ }
+ },
+ scene: Wechat.Scene.TIMELINE // share to Timeline
+ }, function () {
+ alert("Success");
+ }, function (reason) {
+ alert("Failed: " + reason);
+ });
+ }
+ </script>
+</html>
diff --git a/platforms/android/app/src/main/java/com/dalipolice/app/wxapi/EntryActivity.java b/platforms/android/app/src/main/java/com/dalipolice/app/wxapi/EntryActivity.java
new file mode 100644
index 0000000..9d25f66
--- /dev/null
+++ b/platforms/android/app/src/main/java/com/dalipolice/app/wxapi/EntryActivity.java
@@ -0,0 +1,176 @@
+package com.dalipolice.app.wxapi;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.os.Bundle;
+import android.util.Log;
+
+import com.tencent.mm.opensdk.constants.ConstantsAPI;
+import com.tencent.mm.opensdk.modelbase.BaseReq;
+import com.tencent.mm.opensdk.modelbase.BaseResp;
+import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
+import com.tencent.mm.opensdk.modelmsg.SendAuth;
+import com.tencent.mm.opensdk.openapi.IWXAPI;
+import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
+import com.tencent.mm.opensdk.modelbiz.ChooseCardFromWXCardPackage;
+
+import org.apache.cordova.CallbackContext;
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+
+import xu.li.cordova.wechat.Wechat;
+
+/**
+ * Created by xu.li<AthenaLightenedMyPath@gmail.com> on 9/1/15.
+ */
+public class EntryActivity extends Activity implements IWXAPIEventHandler {
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ IWXAPI api = Wechat.getWxAPI(this);
+
+ if (api == null) {
+ startMainActivity();
+ } else {
+ api.handleIntent(getIntent(), this);
+ }
+ }
+
+ @Override
+ protected void onNewIntent(Intent intent) {
+ super.onNewIntent(intent);
+
+ setIntent(intent);
+
+ IWXAPI api = Wechat.getWxAPI(this);
+ if (api == null) {
+ startMainActivity();
+ } else {
+ api.handleIntent(intent, this);
+ }
+
+ }
+
+ @Override
+ public void onResp(BaseResp resp) {
+ Log.d(Wechat.TAG, resp.toString());
+
+ CallbackContext ctx = Wechat.getCurrentCallbackContext();
+
+ if (ctx == null) {
+ startMainActivity();
+ return ;
+ }
+
+ switch (resp.errCode) {
+ case BaseResp.ErrCode.ERR_OK:
+ switch (resp.getType()) {
+ case ConstantsAPI.COMMAND_SENDAUTH:
+ auth(resp);
+ break;
+ case ConstantsAPI.COMMAND_CHOOSE_CARD_FROM_EX_CARD_PACKAGE:
+ plunckInvoiceData(resp);
+ break;
+ case ConstantsAPI.COMMAND_LAUNCH_WX_MINIPROGRAM:
+ Log.d(Wechat.TAG, "miniprogram back;");
+ WXLaunchMiniProgram.Resp miniProResp = (WXLaunchMiniProgram.Resp) resp;
+ launchMiniProResp(miniProResp);
+ break;
+ case ConstantsAPI.COMMAND_PAY_BY_WX:
+ default:
+ ctx.success();
+ break;
+ }
+ break;
+ case BaseResp.ErrCode.ERR_USER_CANCEL:
+ ctx.error(Wechat.ERROR_WECHAT_RESPONSE_USER_CANCEL);
+ break;
+ case BaseResp.ErrCode.ERR_AUTH_DENIED:
+ ctx.error(Wechat.ERROR_WECHAT_RESPONSE_AUTH_DENIED);
+ break;
+ case BaseResp.ErrCode.ERR_SENT_FAILED:
+ ctx.error(Wechat.ERROR_WECHAT_RESPONSE_SENT_FAILED);
+ break;
+ case BaseResp.ErrCode.ERR_UNSUPPORT:
+ ctx.error(Wechat.ERROR_WECHAT_RESPONSE_UNSUPPORT);
+ break;
+ case BaseResp.ErrCode.ERR_COMM:
+ ctx.error(Wechat.ERROR_WECHAT_RESPONSE_COMMON);
+ break;
+ default:
+ ctx.error(Wechat.ERROR_WECHAT_RESPONSE_UNKNOWN);
+ break;
+ }
+
+ finish();
+ }
+
+ @Override
+ public void onReq(BaseReq req) {
+ finish();
+ }
+
+ protected void startMainActivity() {
+ Intent intent = new Intent();
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ intent.setPackage(getApplicationContext().getPackageName());
+ getApplicationContext().startActivity(intent);
+ }
+
+ protected void launchMiniProResp(WXLaunchMiniProgram.Resp launchMiniProResp){
+ CallbackContext ctx = Wechat.getCurrentCallbackContext();
+ String extraData =launchMiniProResp.extMsg; //对应小程序组件 <button open-type="launchApp"> 中的 app-parameter 属性
+ JSONObject response = new JSONObject();
+ try {
+ response.put("extMsg", extraData);
+ }catch (Exception e){
+ Log.e(Wechat.TAG, e.getMessage());
+ }
+ ctx.success(response);
+ }
+
+ protected void auth(BaseResp resp) {
+ SendAuth.Resp res = ((SendAuth.Resp) resp);
+
+ Log.d(Wechat.TAG, res.toString());
+
+ // get current callback context
+ CallbackContext ctx = Wechat.getCurrentCallbackContext();
+
+ if (ctx == null) {
+ return ;
+ }
+
+ JSONObject response = new JSONObject();
+ try {
+ response.put("code", res.code);
+ response.put("state", res.state);
+ response.put("country", res.country);
+ response.put("lang", res.lang);
+ } catch (JSONException e) {
+ Log.e(Wechat.TAG, e.getMessage());
+ }
+
+ ctx.success(response);
+ }
+
+ protected void plunckInvoiceData(BaseResp resp) {
+
+ CallbackContext ctx = Wechat.getCurrentCallbackContext();
+ ChooseCardFromWXCardPackage.Resp resp1 = (ChooseCardFromWXCardPackage.Resp) resp;
+ JSONObject response = new JSONObject();
+
+ try {
+ JSONArray resp2 = new JSONArray(resp1.cardItemList);
+ response.put("data", resp2);
+ } catch (JSONException e) {
+ Log.e(Wechat.TAG, e.getMessage());
+ }
+
+ ctx.success(response);
+ }
+}
\ No newline at end of file
diff --git a/platforms/android/app/src/main/java/com/dalipolice/app/wxapi/WXEntryActivity.java b/platforms/android/app/src/main/java/com/dalipolice/app/wxapi/WXEntryActivity.java
new file mode 100644
index 0000000..8dc5c1e
--- /dev/null
+++ b/platforms/android/app/src/main/java/com/dalipolice/app/wxapi/WXEntryActivity.java
@@ -0,0 +1,4 @@
+package com.dalipolice.app.wxapi;
+
+public class WXEntryActivity extends EntryActivity {
+}
diff --git a/platforms/android/app/src/main/java/com/dalipolice/app/wxapi/WXPayEntryActivity.java b/platforms/android/app/src/main/java/com/dalipolice/app/wxapi/WXPayEntryActivity.java
new file mode 100644
index 0000000..d461aac
--- /dev/null
+++ b/platforms/android/app/src/main/java/com/dalipolice/app/wxapi/WXPayEntryActivity.java
@@ -0,0 +1,5 @@
+package com.dalipolice.app.wxapi;
+
+public class WXPayEntryActivity extends EntryActivity {
+
+}
diff --git a/platforms/android/app/src/main/java/xu/li/cordova/wechat/Util.java b/platforms/android/app/src/main/java/xu/li/cordova/wechat/Util.java
new file mode 100644
index 0000000..28bada2
--- /dev/null
+++ b/platforms/android/app/src/main/java/xu/li/cordova/wechat/Util.java
@@ -0,0 +1,102 @@
+package xu.li.cordova.wechat;
+
+import android.content.Context;
+import android.os.Environment;
+import android.util.Log;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+public class Util {
+
+ /**
+ * Read bytes from InputStream
+ *
+ * @link http://stackoverflow.com/questions/2436385/android-getting-from-a-uri-to-an-inputstream-to-a-byte-array
+ * @param inputStream
+ * @return
+ * @throws IOException
+ */
+ public static byte[] readBytes(InputStream inputStream) throws IOException {
+ // this dynamically extends to take the bytes you read
+ ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream();
+
+ // this is storage overwritten on each iteration with bytes
+ int bufferSize = 1024;
+ byte[] buffer = new byte[bufferSize];
+
+ // we need to know how may bytes were read to write them to the byteBuffer
+ int len = 0;
+ while ((len = inputStream.read(buffer)) != -1) {
+ byteBuffer.write(buffer, 0, len);
+ }
+
+ // and then we can return your byte array.
+ return byteBuffer.toByteArray();
+ }
+
+ public static File getCacheFolder(Context context) {
+ File cacheDir = null;
+ if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
+ cacheDir = new File(Environment.getExternalStorageDirectory(), "cache");
+ if (!cacheDir.isDirectory()) {
+ cacheDir.mkdirs();
+ }
+ }
+
+ if(!cacheDir.isDirectory()) {
+ cacheDir = context.getCacheDir(); //get system cache folder
+ }
+
+ return cacheDir;
+ }
+
+ public static File downloadAndCacheFile(Context context, String url) {
+ URL fileURL = null;
+ try {
+ fileURL = new URL(url);
+
+ Log.d(Wechat.TAG, String.format("Start downloading file at %s.", url));
+
+ HttpURLConnection connection = (HttpURLConnection) fileURL.openConnection();
+ connection.connect();
+
+ if (connection.getResponseCode() != HttpURLConnection.HTTP_OK) {
+ Log.e(Wechat.TAG, String.format("Failed to download file from %s, response code: %d.", url, connection.getResponseCode()));
+ return null;
+ }
+
+ InputStream inputStream = connection.getInputStream();
+
+ File cacheDir = getCacheFolder(context);
+ File cacheFile = new File(cacheDir, url.substring(url.lastIndexOf("/") + 1));
+ FileOutputStream outputStream = new FileOutputStream(cacheFile);
+
+ byte buffer[] = new byte[4096];
+ int dataSize;
+ while ((dataSize = inputStream.read(buffer)) != -1) {
+ outputStream.write(buffer, 0, dataSize);
+ }
+ outputStream.close();
+
+ Log.d(Wechat.TAG, String.format("File was downloaded and saved at %s.", cacheFile.getAbsolutePath()));
+
+ return cacheFile;
+ } catch (MalformedURLException e) {
+ e.printStackTrace();
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return null;
+ }
+}
diff --git a/platforms/android/app/src/main/java/xu/li/cordova/wechat/Wechat.java b/platforms/android/app/src/main/java/xu/li/cordova/wechat/Wechat.java
new file mode 100644
index 0000000..291110c
--- /dev/null
+++ b/platforms/android/app/src/main/java/xu/li/cordova/wechat/Wechat.java
@@ -0,0 +1,761 @@
+package xu.li.cordova.wechat;
+
+import android.content.Context;
+import android.content.SharedPreferences;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.os.Environment;
+import android.os.Build;
+import android.util.Base64;
+import android.util.Log;
+import android.webkit.URLUtil;
+
+import com.tencent.mm.opensdk.modelbiz.WXLaunchMiniProgram;
+import com.tencent.mm.opensdk.modelmsg.SendAuth;
+import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
+import com.tencent.mm.opensdk.modelmsg.WXAppExtendObject;
+import com.tencent.mm.opensdk.modelmsg.WXEmojiObject;
+import com.tencent.mm.opensdk.modelmsg.WXFileObject;
+import com.tencent.mm.opensdk.modelmsg.WXImageObject;
+import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
+import com.tencent.mm.opensdk.modelmsg.WXMusicObject;
+import com.tencent.mm.opensdk.modelmsg.WXTextObject;
+import com.tencent.mm.opensdk.modelmsg.WXVideoObject;
+import com.tencent.mm.opensdk.modelmsg.WXWebpageObject;
+import com.tencent.mm.opensdk.modelmsg.WXMiniProgramObject;
+import com.tencent.mm.opensdk.modelpay.PayReq;
+import com.tencent.mm.opensdk.openapi.IWXAPI;
+import com.tencent.mm.opensdk.openapi.WXAPIFactory;
+
+import com.tencent.mm.opensdk.modelbiz.ChooseCardFromWXCardPackage;
+
+import org.apache.cordova.CallbackContext;
+import org.apache.cordova.CordovaArgs;
+import org.apache.cordova.CordovaPlugin;
+import org.apache.cordova.PluginResult;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ByteArrayInputStream;
+import org.apache.cordova.CordovaPreferences;
+
+public class Wechat extends CordovaPlugin {
+
+ public static final String TAG = "Cordova.Plugin.Wechat";
+
+ public static final String PREFS_NAME = "Cordova.Plugin.Wechat";
+ public static final String WXAPPID_PROPERTY_KEY = "wechatappid";
+
+ public static final String ERROR_WECHAT_NOT_INSTALLED = "未安装微信";
+ public static final String ERROR_INVALID_PARAMETERS = "参数格式错误";
+ public static final String ERROR_SEND_REQUEST_FAILED = "发送请求失败";
+ public static final String ERROR_WECHAT_RESPONSE_COMMON = "普通错误";
+ public static final String ERROR_WECHAT_RESPONSE_USER_CANCEL = "用户点击取消并返回";
+ public static final String ERROR_WECHAT_RESPONSE_SENT_FAILED = "发送失败";
+ public static final String ERROR_WECHAT_RESPONSE_AUTH_DENIED = "授权失败";
+ public static final String ERROR_WECHAT_RESPONSE_UNSUPPORT = "微信不支持";
+ public static final String ERROR_WECHAT_RESPONSE_UNKNOWN = "未知错误";
+
+ public static final String EXTERNAL_STORAGE_IMAGE_PREFIX = "external://";
+ public static final int REQUEST_CODE_ENABLE_PERMISSION = 55433;
+ public static final String ANDROID_WRITE_EXTERNAL_STORAGE = "android.permission.WRITE_EXTERNAL_STORAGE";
+
+ public static final String KEY_ARG_MESSAGE = "message";
+ public static final String KEY_ARG_SCENE = "scene";
+ public static final String KEY_ARG_TEXT = "text";
+ public static final String KEY_ARG_MESSAGE_TITLE = "title";
+ public static final String KEY_ARG_MESSAGE_DESCRIPTION = "description";
+ public static final String KEY_ARG_MESSAGE_THUMB = "thumb";
+ public static final String KEY_ARG_MESSAGE_MEDIA = "media";
+ public static final String KEY_ARG_MESSAGE_MEDIA_TYPE = "type";
+ public static final String KEY_ARG_MESSAGE_MEDIA_WEBPAGEURL = "webpageUrl";
+ public static final String KEY_ARG_MESSAGE_MEDIA_IMAGE = "image";
+ public static final String KEY_ARG_MESSAGE_MEDIA_TEXT = "text";
+ public static final String KEY_ARG_MESSAGE_MEDIA_MUSICURL = "musicUrl";
+ public static final String KEY_ARG_MESSAGE_MEDIA_MUSICDATAURL = "musicDataUrl";
+ public static final String KEY_ARG_MESSAGE_MEDIA_VIDEOURL = "videoUrl";
+ public static final String KEY_ARG_MESSAGE_MEDIA_FILE = "file";
+ public static final String KEY_ARG_MESSAGE_MEDIA_EMOTION = "emotion";
+ public static final String KEY_ARG_MESSAGE_MEDIA_EXTINFO = "extInfo";
+ public static final String KEY_ARG_MESSAGE_MEDIA_URL = "url";
+ public static final String KEY_ARG_MESSAGE_MEDIA_USERNAME = "userName";
+ public static final String KEY_ARG_MESSAGE_MEDIA_MINIPROGRAMTYPE = "miniprogramType";
+ public static final String KEY_ARG_MESSAGE_MEDIA_MINIPROGRAM = "miniProgram";
+ public static final String KEY_ARG_MESSAGE_MEDIA_PATH = "path";
+ public static final String KEY_ARG_MESSAGE_MEDIA_WITHSHARETICKET = "withShareTicket";
+ public static final String KEY_ARG_MESSAGE_MEDIA_HDIMAGEDATA = "hdImageData";
+
+ public static final int TYPE_WECHAT_SHARING_APP = 1;
+ public static final int TYPE_WECHAT_SHARING_EMOTION = 2;
+ public static final int TYPE_WECHAT_SHARING_FILE = 3;
+ public static final int TYPE_WECHAT_SHARING_IMAGE = 4;
+ public static final int TYPE_WECHAT_SHARING_MUSIC = 5;
+ public static final int TYPE_WECHAT_SHARING_VIDEO = 6;
+ public static final int TYPE_WECHAT_SHARING_WEBPAGE = 7;
+ public static final int TYPE_WECHAT_SHARING_MINI = 8;
+
+ public static final int SCENE_SESSION = 0;
+ public static final int SCENE_TIMELINE = 1;
+ public static final int SCENE_FAVORITE = 2;
+
+ public static final int MAX_THUMBNAIL_SIZE = 320;
+
+ protected static CallbackContext currentCallbackContext;
+ protected static IWXAPI wxAPI;
+ protected static String appId;
+ protected static CordovaPreferences wx_preferences;
+
+ @Override
+ protected void pluginInitialize() {
+
+ super.pluginInitialize();
+
+ String id = getAppId(preferences);
+
+ // save app id
+ saveAppId(cordova.getActivity(), id);
+
+ // init api
+ initWXAPI();
+
+ Log.d(TAG, "plugin initialized.");
+ }
+
+ protected void initWXAPI() {
+ IWXAPI api = getWxAPI(cordova.getActivity());
+ if(wx_preferences == null) {
+ wx_preferences = preferences;
+ }
+ if (api != null) {
+ api.registerApp(getAppId(preferences));
+ }
+ }
+
+ /**
+ * Get weixin api
+ * @param ctx
+ * @return
+ */
+ public static IWXAPI getWxAPI(Context ctx) {
+ if (wxAPI == null) {
+ String appId = getSavedAppId(ctx);
+
+ if (!appId.isEmpty()) {
+ wxAPI = WXAPIFactory.createWXAPI(ctx, appId, true);
+ }
+ }
+
+ return wxAPI;
+ }
+
+ @Override
+ public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {
+ Log.d(TAG, String.format("%s is called. Callback ID: %s.", action, callbackContext.getCallbackId()));
+
+ if (action.equals("share")) {
+ return share(args, callbackContext);
+ } else if (action.equals("sendAuthRequest")) {
+ return sendAuthRequest(args, callbackContext);
+ } else if (action.equals("sendPaymentRequest")) {
+ return sendPaymentRequest(args, callbackContext);
+ } else if (action.equals("isWXAppInstalled")) {
+ return isInstalled(callbackContext);
+ }else if (action.equals("chooseInvoiceFromWX")){
+ return chooseInvoiceFromWX(args, callbackContext);
+ }else if(action.equals("openMiniProgram")){
+ return openMiniProgram(args,callbackContext);
+ }
+
+ return false;
+ }
+
+ protected boolean share(CordovaArgs args, final CallbackContext callbackContext)
+ throws JSONException {
+ final IWXAPI api = getWxAPI(cordova.getActivity());
+
+ // check if installed
+ if (!api.isWXAppInstalled()) {
+ callbackContext.error(ERROR_WECHAT_NOT_INSTALLED);
+ return true;
+ }
+
+ // check if # of arguments is correct
+ final JSONObject params;
+ try {
+ params = args.getJSONObject(0);
+ } catch (JSONException e) {
+ callbackContext.error(ERROR_INVALID_PARAMETERS);
+ return true;
+ }
+
+ final SendMessageToWX.Req req = new SendMessageToWX.Req();
+ req.transaction = buildTransaction();
+
+ if (params.has(KEY_ARG_MESSAGE)) {
+ //小程序卡片单独构建
+ JSONObject message = params.getJSONObject(KEY_ARG_MESSAGE);
+ if (message.has(KEY_ARG_MESSAGE_MEDIA)) {
+ JSONObject media = message.getJSONObject(KEY_ARG_MESSAGE_MEDIA);
+ int type = media.has(KEY_ARG_MESSAGE_MEDIA_TYPE) ? media
+ .getInt(KEY_ARG_MESSAGE_MEDIA_TYPE) : TYPE_WECHAT_SHARING_MINI;
+ if (type == TYPE_WECHAT_SHARING_MINI) {
+ req.transaction = buildTransaction(KEY_ARG_MESSAGE_MEDIA_MINIPROGRAM);
+ }
+ }
+ }
+
+ if (params.has(KEY_ARG_SCENE)) {
+ switch (params.getInt(KEY_ARG_SCENE)) {
+ case SCENE_FAVORITE:
+ req.scene = SendMessageToWX.Req.WXSceneFavorite;
+ break;
+ case SCENE_TIMELINE:
+ req.scene = SendMessageToWX.Req.WXSceneTimeline;
+ break;
+ case SCENE_SESSION:
+ req.scene = SendMessageToWX.Req.WXSceneSession;
+ break;
+ default:
+ req.scene = SendMessageToWX.Req.WXSceneTimeline;
+ }
+ } else {
+ req.scene = SendMessageToWX.Req.WXSceneTimeline;
+ }
+
+ // run in background
+ cordova.getThreadPool().execute(new Runnable() {
+
+ @Override
+ public void run() {
+ try {
+ req.message = buildSharingMessage(params);
+ } catch (JSONException e) {
+ Log.e(TAG, "Failed to build sharing message.", e);
+
+ // clear callback context
+ currentCallbackContext = null;
+
+ // send json exception error
+ callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
+ }
+
+ if (api.sendReq(req)) {
+ Log.i(TAG, "Message has been sent successfully.");
+ } else {
+ Log.i(TAG, "Message has been sent unsuccessfully.");
+
+ // clear callback context
+ currentCallbackContext = null;
+
+ // send error
+ callbackContext.error(ERROR_SEND_REQUEST_FAILED);
+ }
+ }
+ });
+
+ // send no result
+ sendNoResultPluginResult(callbackContext);
+
+ return true;
+ }
+
+ protected boolean sendAuthRequest(CordovaArgs args, CallbackContext callbackContext) {
+ final IWXAPI api = getWxAPI(cordova.getActivity());
+
+ final SendAuth.Req req = new SendAuth.Req();
+ try {
+ req.scope = args.getString(0);
+ req.state = args.getString(1);
+ } catch (JSONException e) {
+ Log.e(TAG, e.getMessage());
+
+ req.scope = "snsapi_userinfo";
+ req.state = "wechat";
+ }
+
+ if (api.sendReq(req)) {
+ Log.i(TAG, "Auth request has been sent successfully.");
+
+ // send no result
+ sendNoResultPluginResult(callbackContext);
+ } else {
+ Log.i(TAG, "Auth request has been sent unsuccessfully.");
+
+ // send error
+ callbackContext.error(ERROR_SEND_REQUEST_FAILED);
+ }
+
+ return true;
+ }
+
+ protected boolean sendPaymentRequest(CordovaArgs args, CallbackContext callbackContext) {
+
+ // check if # of arguments is correct
+ final JSONObject params;
+ try {
+ params = args.getJSONObject(0);
+ } catch (JSONException e) {
+ callbackContext.error(ERROR_INVALID_PARAMETERS);
+ return true;
+ }
+
+ PayReq req = new PayReq();
+
+ try {
+ // final String appid = params.getString("appid");
+ // final String savedAppid = getSavedAppId(cordova.getActivity());
+ // if (!savedAppid.equals(appid)) {
+ // this.saveAppId(cordova.getActivity(), appid);
+ // }
+ req.appId = getAppId(preferences);
+ req.partnerId = params.has("mch_id") ? params.getString("mch_id") : params.getString("partnerid");
+ req.prepayId = params.has("prepay_id") ? params.getString("prepay_id") : params.getString("prepayid");
+ req.nonceStr = params.has("nonce") ? params.getString("nonce") : params.getString("noncestr");
+ req.timeStamp = params.getString("timestamp");
+ req.sign = params.getString("sign");
+ req.packageValue = "Sign=WXPay";
+ } catch (Exception e) {
+ Log.e(TAG, e.getMessage());
+
+ callbackContext.error(ERROR_INVALID_PARAMETERS);
+ return true;
+ }
+
+ final IWXAPI api = getWxAPI(cordova.getActivity());
+
+ if (api.sendReq(req)) {
+ Log.i(TAG, "Payment request has been sent successfully.");
+
+ // send no result
+ sendNoResultPluginResult(callbackContext);
+ } else {
+ Log.i(TAG, "Payment request has been sent unsuccessfully.");
+
+ // send error
+ callbackContext.error(ERROR_SEND_REQUEST_FAILED);
+ }
+
+ return true;
+ }
+
+ protected boolean chooseInvoiceFromWX(CordovaArgs args, CallbackContext callbackContext) {
+
+ final IWXAPI api = getWxAPI(cordova.getActivity());
+
+ // check if # of arguments is correct
+ final JSONObject params;
+ try {
+ params = args.getJSONObject(0);
+ } catch (JSONException e) {
+ callbackContext.error(ERROR_INVALID_PARAMETERS);
+ return true;
+ }
+
+ ChooseCardFromWXCardPackage.Req req = new ChooseCardFromWXCardPackage.Req();
+
+ try {
+ req.appId = getAppId(preferences);
+ req.cardType = "INVOICE";
+ req.signType = params.getString("signType");
+ req.cardSign = params.getString("cardSign");
+ req.nonceStr = params.getString("nonceStr");
+ req.timeStamp = params.getString("timeStamp");
+ req.canMultiSelect = "1";
+ } catch (Exception e) {
+ Log.e(TAG, e.getMessage());
+
+ callbackContext.error(ERROR_INVALID_PARAMETERS);
+ return true;
+ }
+
+ if (api.sendReq(req)) {
+ Log.i(TAG, "Invoice request has been sent successfully.");
+
+ // send no result
+ sendNoResultPluginResult(callbackContext);
+ } else {
+ Log.i(TAG, "Invoice request has been sent unsuccessfully.");
+
+ // send error
+ callbackContext.error(ERROR_SEND_REQUEST_FAILED);
+ }
+
+ return true;
+ }
+
+ protected boolean isInstalled(CallbackContext callbackContext) {
+ final IWXAPI api = getWxAPI(cordova.getActivity());
+
+ if (!api.isWXAppInstalled()) {
+ callbackContext.success(0);
+ } else {
+ callbackContext.success(1);
+ }
+
+ return true;
+ }
+
+
+ protected WXMediaMessage buildSharingMessage(JSONObject params)
+ throws JSONException {
+ Log.d(TAG, "Start building message.");
+
+ // media parameters
+ WXMediaMessage.IMediaObject mediaObject = null;
+ WXMediaMessage wxMediaMessage = new WXMediaMessage();
+
+ if (params.has(KEY_ARG_TEXT)) {
+ WXTextObject textObject = new WXTextObject();
+ textObject.text = params.getString(KEY_ARG_TEXT);
+ mediaObject = textObject;
+ wxMediaMessage.description = textObject.text;
+ } else {
+ JSONObject message = params.getJSONObject(KEY_ARG_MESSAGE);
+ JSONObject media = message.getJSONObject(KEY_ARG_MESSAGE_MEDIA);
+
+ wxMediaMessage.title = message.getString(KEY_ARG_MESSAGE_TITLE);
+ wxMediaMessage.description = message.getString(KEY_ARG_MESSAGE_DESCRIPTION);
+
+ // thumbnail
+ Bitmap thumbnail = getThumbnail(message, KEY_ARG_MESSAGE_THUMB);
+ if (thumbnail != null) {
+ wxMediaMessage.setThumbImage(thumbnail);
+ thumbnail.recycle();
+ }
+
+ // check types
+ int type = media.has(KEY_ARG_MESSAGE_MEDIA_TYPE) ? media
+ .getInt(KEY_ARG_MESSAGE_MEDIA_TYPE) : TYPE_WECHAT_SHARING_WEBPAGE;
+
+ switch (type) {
+ case TYPE_WECHAT_SHARING_APP:
+ WXAppExtendObject appObject = new WXAppExtendObject();
+ appObject.extInfo = media.getString(KEY_ARG_MESSAGE_MEDIA_EXTINFO);
+ appObject.filePath = media.getString(KEY_ARG_MESSAGE_MEDIA_URL);
+ mediaObject = appObject;
+ break;
+
+ case TYPE_WECHAT_SHARING_EMOTION:
+ WXEmojiObject emoObject = new WXEmojiObject();
+ InputStream emoji = getFileInputStream(media.getString(KEY_ARG_MESSAGE_MEDIA_EMOTION));
+ if (emoji != null) {
+ try {
+ emoObject.emojiData = Util.readBytes(emoji);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ mediaObject = emoObject;
+ break;
+
+ case TYPE_WECHAT_SHARING_FILE:
+ WXFileObject fileObject = new WXFileObject();
+ InputStream file = getFileInputStream(media.getString(KEY_ARG_MESSAGE_MEDIA_FILE));
+ if (file != null) {
+ try {
+ fileObject.fileData = Util.readBytes(file);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ mediaObject = fileObject;
+ break;
+
+ case TYPE_WECHAT_SHARING_IMAGE:
+ Bitmap image = getBitmap(message.getJSONObject(KEY_ARG_MESSAGE_MEDIA), KEY_ARG_MESSAGE_MEDIA_IMAGE, 0);
+ // give some tips to user
+ if(image != null) {
+ mediaObject = new WXImageObject(image);
+ image.recycle();
+ }
+ break;
+
+ case TYPE_WECHAT_SHARING_MUSIC:
+ WXMusicObject musicObject = new WXMusicObject();
+ musicObject.musicUrl = media.getString(KEY_ARG_MESSAGE_MEDIA_MUSICURL);
+ musicObject.musicDataUrl = media.getString(KEY_ARG_MESSAGE_MEDIA_MUSICDATAURL);
+ mediaObject = musicObject;
+ break;
+
+ case TYPE_WECHAT_SHARING_VIDEO:
+ WXVideoObject videoObject = new WXVideoObject();
+ videoObject.videoUrl = media.getString(KEY_ARG_MESSAGE_MEDIA_VIDEOURL);
+ mediaObject = videoObject;
+ break;
+
+ case TYPE_WECHAT_SHARING_MINI:
+ WXMiniProgramObject miniProgramObj = new WXMiniProgramObject();
+ try {
+ miniProgramObj.webpageUrl = media.getString(KEY_ARG_MESSAGE_MEDIA_WEBPAGEURL); // 兼容低版本的网页链接
+ miniProgramObj.miniprogramType = media.getInt(KEY_ARG_MESSAGE_MEDIA_MINIPROGRAMTYPE);// 正式版:0,测试版:1,体验版:2
+ miniProgramObj.userName = media.getString(KEY_ARG_MESSAGE_MEDIA_USERNAME); // 小程序原始id
+ miniProgramObj.path = media.getString(KEY_ARG_MESSAGE_MEDIA_PATH); //小程序页面路径
+ miniProgramObj.withShareTicket = media.getBoolean(KEY_ARG_MESSAGE_MEDIA_WITHSHARETICKET); // 是否使用带shareTicket的分享
+ wxMediaMessage = new WXMediaMessage(miniProgramObj);
+ wxMediaMessage.title = message.getString(KEY_ARG_MESSAGE_TITLE); // 小程序消息title
+ wxMediaMessage.description = message.getString(KEY_ARG_MESSAGE_DESCRIPTION); // 小程序消息desc
+ wxMediaMessage.thumbData = Util.readBytes(getFileInputStream(media.getString(KEY_ARG_MESSAGE_MEDIA_HDIMAGEDATA))); // 小程序消息封面图片,小于128k
+ return wxMediaMessage;
+ }catch (Exception e){
+ Log.e(TAG, e.getMessage());
+ }
+ break;
+
+ case TYPE_WECHAT_SHARING_WEBPAGE:
+ default:
+ mediaObject = new WXWebpageObject(media.getString(KEY_ARG_MESSAGE_MEDIA_WEBPAGEURL));
+ }
+ }
+
+ wxMediaMessage.mediaObject = mediaObject;
+
+ return wxMediaMessage;
+ }
+
+ private String buildTransaction() {
+ return String.valueOf(System.currentTimeMillis());
+ }
+
+ private String buildTransaction(final String type) {
+ return type + System.currentTimeMillis();
+ }
+
+ protected Bitmap getThumbnail(JSONObject message, String key) {
+ return getBitmap(message, key, MAX_THUMBNAIL_SIZE);
+ }
+
+ protected Bitmap getBitmap(JSONObject message, String key, int maxSize) {
+ Bitmap bmp = null;
+ String url = null;
+
+ try {
+ if (!message.has(key)) {
+ return null;
+ }
+
+ url = message.getString(key);
+
+ // get input stream
+ InputStream inputStream = getFileInputStream(url);
+ if (inputStream == null) {
+ return null;
+ }
+
+ // decode it
+ // @TODO make sure the image is not too big, or it will cause out of memory
+ BitmapFactory.Options options = new BitmapFactory.Options();
+ bmp = BitmapFactory.decodeStream(inputStream, null, options);
+
+ // scale
+ if (maxSize > 0 && (options.outWidth > maxSize || options.outHeight > maxSize)) {
+
+ Log.d(TAG, String.format("Bitmap was decoded, dimension: %d x %d, max allowed size: %d.",
+ options.outWidth, options.outHeight, maxSize));
+
+ int width = 0;
+ int height = 0;
+
+ if (options.outWidth > options.outHeight) {
+ width = maxSize;
+ height = width * options.outHeight / options.outWidth;
+ } else {
+ height = maxSize;
+ width = height * options.outWidth / options.outHeight;
+ }
+
+ Bitmap scaled = Bitmap.createScaledBitmap(bmp, width, height, true);
+ bmp.recycle();
+
+ int length = scaled.getRowBytes() * scaled.getHeight();
+
+ if(length > (maxSize/10)*1024) {
+ scaled = compressImage(scaled,(maxSize/10));
+ }
+
+ bmp = scaled;
+ }
+
+ inputStream.close();
+
+ } catch (JSONException e) {
+ bmp = null;
+ e.printStackTrace();
+ } catch (IOException e) {
+ bmp = null;
+ e.printStackTrace();
+ }
+
+ return bmp;
+ }
+
+
+ /**
+ * compress bitmap by quility
+ */
+ protected Bitmap compressImage(Bitmap image,Integer maxSize) {
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
+ int options = 90;
+
+ while (baos.toByteArray().length / 1024 > maxSize) {
+ baos.reset();
+ image.compress(Bitmap.CompressFormat.JPEG, options, baos);
+ options -= 10;
+ }
+ ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());
+ Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null);
+ return bitmap;
+ }
+
+ /**
+ * Get input stream from a url
+ */
+ protected InputStream getFileInputStream(String url) {
+ InputStream inputStream = null;
+ try {
+
+ if (URLUtil.isHttpUrl(url) || URLUtil.isHttpsUrl(url)) {
+
+ if (Build.VERSION.SDK_INT > Build.VERSION_CODES.M) {
+ if (!cordova.hasPermission(ANDROID_WRITE_EXTERNAL_STORAGE)) {
+ cordova.requestPermission(this, REQUEST_CODE_ENABLE_PERMISSION, ANDROID_WRITE_EXTERNAL_STORAGE);
+ }
+ }
+
+ File file = Util.downloadAndCacheFile(webView.getContext(), url);
+
+ if (file == null) {
+ Log.d(TAG, String.format("File could not be downloaded from %s.", url));
+ return null;
+ }
+
+ // url = file.getAbsolutePath();
+ inputStream = new FileInputStream(file);
+
+ Log.d(TAG, String.format("File was downloaded and cached to %s.", file.getAbsolutePath()));
+
+ } else if (url.startsWith("data:image")) { // base64 image
+
+ String imageDataBytes = url.substring(url.indexOf(",") + 1);
+ byte imageBytes[] = Base64.decode(imageDataBytes.getBytes(), Base64.DEFAULT);
+ inputStream = new ByteArrayInputStream(imageBytes);
+
+ Log.d(TAG, "Image is in base64 format.");
+
+ } else if (url.startsWith(EXTERNAL_STORAGE_IMAGE_PREFIX)) { // external path
+
+ url = Environment.getExternalStorageDirectory().getAbsolutePath() + url.substring(EXTERNAL_STORAGE_IMAGE_PREFIX.length());
+ inputStream = new FileInputStream(url);
+
+ Log.d(TAG, String.format("File is located on external storage at %s.", url));
+
+ } else if (!url.startsWith("/")) { // relative path
+
+ inputStream = cordova.getActivity().getApplicationContext().getAssets().open(url);
+
+ Log.d(TAG, String.format("File is located in assets folder at %s.", url));
+
+ } else {
+
+ inputStream = new FileInputStream(url);
+
+ Log.d(TAG, String.format("File is located at %s.", url));
+
+ }
+
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ return inputStream;
+ }
+
+ public static String getAppId(CordovaPreferences f_preferences) {
+ if (appId == null) {
+ if(f_preferences != null) {
+ appId = f_preferences.getString(WXAPPID_PROPERTY_KEY, "");
+ }else if(wx_preferences != null){
+ appId = wx_preferences.getString(WXAPPID_PROPERTY_KEY, "");
+ }
+ }
+
+ return appId;
+ }
+
+ /**
+ * Get saved app id
+ * @param ctx
+ * @return
+ */
+ public static String getSavedAppId(Context ctx) {
+ SharedPreferences settings = ctx.getSharedPreferences(PREFS_NAME, 0);
+ return settings.getString(WXAPPID_PROPERTY_KEY, "");
+ }
+
+ /**
+ * Save app id into SharedPreferences
+ * @param ctx
+ * @param id
+ */
+ public static void saveAppId(Context ctx, String id) {
+ if (id!=null && id.isEmpty()) {
+ return ;
+ }
+
+ SharedPreferences settings = ctx.getSharedPreferences(PREFS_NAME, 0);
+ SharedPreferences.Editor editor = settings.edit();
+ editor.putString(WXAPPID_PROPERTY_KEY, id);
+ editor.commit();
+ }
+
+ public static CallbackContext getCurrentCallbackContext() {
+ return currentCallbackContext;
+ }
+
+ private void sendNoResultPluginResult(CallbackContext callbackContext) {
+ // save current callback context
+ currentCallbackContext = callbackContext;
+
+ // send no result and keep callback
+ PluginResult result = new PluginResult(PluginResult.Status.NO_RESULT);
+ result.setKeepCallback(true);
+ callbackContext.sendPluginResult(result);
+ }
+
+ protected boolean openMiniProgram(CordovaArgs args, CallbackContext callbackContext){
+ currentCallbackContext = callbackContext;
+ String appId = getAppId(preferences);; // 填应用AppId
+ IWXAPI api = WXAPIFactory.createWXAPI(cordova.getActivity(), appId);
+
+ final JSONObject params;
+ try {
+ params = args.getJSONObject(0);
+ } catch (JSONException e) {
+ callbackContext.error(ERROR_INVALID_PARAMETERS);
+ return true;
+ }
+
+ WXLaunchMiniProgram.Req req = new WXLaunchMiniProgram.Req();
+ try {
+ req.userName = params.getString(KEY_ARG_MESSAGE_MEDIA_USERNAME); // 填小程序原始id
+ req.path = params.getString(KEY_ARG_MESSAGE_MEDIA_PATH); //拉起小程序页面的可带参路径,不填默认拉起小程序首页
+ req.miniprogramType = params.getInt(KEY_ARG_MESSAGE_MEDIA_MINIPROGRAMTYPE);// 可选打开 开发版,体验版和正式版
+ api.sendReq(req);
+ }catch (Exception e){
+ callbackContext.error(ERROR_INVALID_PARAMETERS);
+ Log.e(TAG,e.getMessage());
+ }
+ return true;
+ }
+
+}
diff --git a/platforms/android/app/src/main/res/xml/config.xml b/platforms/android/app/src/main/res/xml/config.xml
index e85c38a..6675ca2 100644
--- a/platforms/android/app/src/main/res/xml/config.xml
+++ b/platforms/android/app/src/main/res/xml/config.xml
@@ -58,6 +58,9 @@
<access origin="http://*.ptlogin2.qq.com/*" />
<access origin="http://*.qq.com/*" />
<access origin="http://q2.qlogo.cn/*" />
+ <feature name="Wechat">
+ <param name="android-package" value="xu.li.cordova.wechat.Wechat" />
+ </feature>
<name short="大理智警">dlapp</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
@@ -86,6 +89,7 @@
<allow-intent href="market:*" />
<preference name="loglevel" value="DEBUG" />
<preference name="QQ_APP_ID" value="101885581" />
+ <preference name="WECHATAPPID" value="wxa483e2c392b08993" />
<preference name="AutoHideSplashScreen" value="true" />
<preference name="SplashScreenDelay" value="0" />
<preference name="SplashShowOnlyFirstTime" value="true" />
diff --git a/platforms/android/cordova-plugin-wechat/app-android-build.gradle b/platforms/android/cordova-plugin-wechat/app-android-build.gradle
new file mode 100644
index 0000000..317ddcb
--- /dev/null
+++ b/platforms/android/cordova-plugin-wechat/app-android-build.gradle
@@ -0,0 +1,7 @@
+repositories {
+ jcenter()
+}
+
+dependencies {
+ compile 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+'
+}
diff --git a/platforms/android/platform_www/cordova_plugins.js b/platforms/android/platform_www/cordova_plugins.js
index 08297e5..02af8e9 100644
--- a/platforms/android/platform_www/cordova_plugins.js
+++ b/platforms/android/platform_www/cordova_plugins.js
@@ -359,6 +359,14 @@
"clobbers": [
"QQSDK"
]
+ },
+ {
+ "id": "cordova-plugin-wechat.Wechat",
+ "file": "plugins/cordova-plugin-wechat/www/wechat.js",
+ "pluginId": "cordova-plugin-wechat",
+ "clobbers": [
+ "Wechat"
+ ]
}
];
module.exports.metadata = {
@@ -381,6 +389,7 @@
"cordova-plugin-brightness": "0.1.5",
"cordova-plugin-fingerprint-aio": "3.0.1",
"cordova-plugin-prevent-screenshot-coffice": "1.0.1",
- "cordova-plugin-qqsdk": "0.9.7"
+ "cordova-plugin-qqsdk": "0.9.7",
+ "cordova-plugin-wechat": "3.0.0"
};
});
\ No newline at end of file
diff --git a/platforms/android/platform_www/plugins/cordova-plugin-wechat/www/wechat.js b/platforms/android/platform_www/plugins/cordova-plugin-wechat/www/wechat.js
new file mode 100644
index 0000000..7f86ab9
--- /dev/null
+++ b/platforms/android/platform_www/plugins/cordova-plugin-wechat/www/wechat.js
@@ -0,0 +1,190 @@
+cordova.define("cordova-plugin-wechat.Wechat", function(require, exports, module) {
+var exec = require('cordova/exec');
+
+module.exports = {
+ Scene: {
+ SESSION: 0, // 聊天界面
+ TIMELINE: 1, // 朋友圈
+ FAVORITE: 2 // 收藏
+ },
+
+ Type: {
+ APP: 1,
+ EMOTION: 2,
+ FILE: 3,
+ IMAGE: 4,
+ MUSIC: 5,
+ VIDEO: 6,
+ WEBPAGE: 7,
+ MINI: 8
+ },
+
+ Mini: {
+ RELEASE: 0, // 正式版
+ TEST: 1, // 测试版
+ PREVIEW: 2 // 体验版
+ },
+
+ isInstalled: function (onSuccess, onError) {
+ exec(onSuccess, onError, "Wechat", "isWXAppInstalled", []);
+ },
+
+ /**
+ * Share a message to wechat app
+ *
+ * @example
+ * <code>
+ * Wechat.share({
+ * message: {
+ * title: "Message Title",
+ * description: "Message Description(optional)",
+ * mediaTagName: "Media Tag Name(optional)",
+ * thumb: "http://YOUR_THUMBNAIL_IMAGE",
+ * media: {
+ * type: Wechat.Type.WEBPAGE, // webpage
+ * webpageUrl: "https://github.com/xu-li/cordova-plugin-wechat" // webpage
+ * }
+ * },
+ * scene: Wechat.Scene.TIMELINE // share to Timeline
+ * }, function () {
+ * alert("Success");
+ * }, function (reason) {
+ * alert("Failed: " + reason);
+ * });
+ * </code>
+ */
+ share: function (message, onSuccess, onError) {
+ exec(onSuccess, onError, "Wechat", "share", [message]);
+ },
+
+ /**
+ * Sending an auth request to Wechat
+ *
+ * @example
+ * <code>
+ * Wechat.auth(function (response) { alert(response.code); });
+ * </code>
+ */
+ auth: function (scope, state, onSuccess, onError) {
+ if (typeof scope == "function") {
+ // Wechat.auth(function () { alert("Success"); });
+ // Wechat.auth(function () { alert("Success"); }, function (error) { alert(error); });
+ return exec(scope, state, "Wechat", "sendAuthRequest");
+ }
+
+ if (typeof state == "function") {
+ // Wechat.auth("snsapi_userinfo", function () { alert("Success"); });
+ // Wechat.auth("snsapi_userinfo", function () { alert("Success"); }, function (error) { alert(error); });
+ return exec(state, onSuccess, "Wechat", "sendAuthRequest", [scope]);
+ }
+
+ return exec(onSuccess, onError, "Wechat", "sendAuthRequest", [scope, state]);
+ },
+
+ /**
+ * Send a payment request
+ *
+ * @link https://pay.weixin.qq.com/wiki/doc/api/app.php?chapter=9_1
+ * @example
+ * <code>
+ * var params = {
+ * mch_id: '10000100', // merchant id
+ * prepay_id: 'wx201411101639507cbf6ffd8b0779950874', // prepay id returned from server
+ * nonce: '1add1a30ac87aa2db72f57a2375d8fec', // nonce string returned from server
+ * timestamp: '1439531364', // timestamp
+ * sign: '0CB01533B8C1EF103065174F50BCA001', // signed string
+ * };
+ * Wechat.sendPaymentRequest(params, function () {
+ * alert("Success");
+ * }, function (reason) {
+ * alert("Failed: " + reason);
+ * });
+ * </code>
+ */
+ sendPaymentRequest: function (params, onSuccess, onError) {
+ exec(onSuccess, onError, "Wechat", "sendPaymentRequest", [params]);
+ },
+
+ /**
+ * jumpToBizProfile (跳转到某个微信公众号)2016-11-11 测试是失效的,囧
+ *
+ * @link https://segmentfault.com/a/1190000007204624
+ * @link https://segmentfault.com/q/1010000003907796
+ * @example
+ * <code>
+ * var params = {
+ * info: 'gh_xxxxxxx', // 公众帐号原始ID
+ * type: 'Normal' // 普通号
+ * }
+ * or
+ * var params = {
+ * info: 'extMsg', // 相关的硬件二维码串
+ * type: 'Device' // 硬件号
+ * };
+ * Wechat.jumpToBizProfile(params, function () {
+ * alert("Success");
+ * }, function (reason) {
+ * alert("Failed: " + reason);
+ * });
+ * </code>
+ */
+
+ jumpToBizProfile: function (params, onSuccess, onError) {
+ exec(onSuccess, onError, "Wechat", "jumpToBizProfile", [params]);
+ },
+
+ /**
+ * jumpToWechat (因为jumpToBizProfile失效了,暂时新增了一个临时的api)
+ *
+ * @link https://segmentfault.com/a/1190000007204624
+ * @example
+ * <code>
+ * var url = "wechat://" 现阶段貌似只支持这一个协议了
+ * Wechat.jumpToWechat(url, function () {
+ * alert("Success");
+ * }, function (reason) {
+ * alert("Failed: " + reason);
+ * });
+ * </code>
+ */
+ jumpToWechat: function (url, onSuccess, onError) {
+ exec(onSuccess, onError, "Wechat", "jumpToWechat", [url]);
+ },
+
+ /**
+ * chooseInvoiceFromWX exq:choose invoices from Wechat card list
+ *
+ * @example
+ * <code>
+ * params: signType, cardSign, nonceStr, timeStamp all required
+ * Wechat.chooseInvoiceFromWX(params, function () {
+ * alert("Success");
+ * }, function (reason) {
+ * alert("Failed: " + reason);
+ * });
+ * </code>
+ */
+ chooseInvoiceFromWX: function (params, onSuccess, onError) {
+ exec(onSuccess, onError, "Wechat", "chooseInvoiceFromWX", [params]);
+ },
+
+ /**
+ * openMiniProgram exq:app opens wechat mini program
+ *
+ * @example
+ * <code>
+ * params: userName, path, miniprogramType all required
+ * Wechat.openMiniProgram(params, function (data) {
+ * alert(data.extMsg);
+ * }, function (reason) {
+ * alert("Failed: " + reason);
+ * });
+ * </code>
+ */
+ openMiniProgram: function (params, onSuccess, onError) {
+ exec(onSuccess, onError, "Wechat", "openMiniProgram", [params]);
+ }
+
+};
+
+});
diff --git a/platforms/android/project.properties b/platforms/android/project.properties
index 0a6f4b6..e0172f1 100644
--- a/platforms/android/project.properties
+++ b/platforms/android/project.properties
@@ -15,4 +15,5 @@
cordova.gradle.include.1=cordova-plugin-qrscanner/dlapp-qrscanner.gradle
cordova.system.library.2=com.android.support:support-v4:24.1.1+
cordova.gradle.include.2=cordova-plugin-fingerprint-aio/app-build.gradle
-cordova.system.library.3=com.android.support:support-v4:24.1.1+
\ No newline at end of file
+cordova.system.library.3=com.android.support:support-v4:24.1.1+
+cordova.gradle.include.3=cordova-plugin-wechat/app-android-build.gradle
\ No newline at end of file