Skip to content

king12555/cordova-plugin-wechat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cordova-plugin-wechat

A cordova plugin, a JS version of Wechat SDK

Feature

Share title, description, image, and link to wechat moment(朋友圈)

Install

  1. cordova plugin add cordova-plugin-wechat --variable wechatappid=YOUR_WECHAT_APPID, or using plugman, phonegap, ionic

  2. cordova build ios or cordova build android

  3. (iOS only) if your cordova version <5.1.1,check the URL Type using XCode

API使用方式

检测是否安装微信

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); });

微信分享text

Wechat.share({ text: "This is just a plain string", scene: Wechat.Scene.TIMELINE // share to Timeline }, function () { alert("Success"); }, function (reason) { alert("Failed: " + reason); });

微信分享media

Wechat.share({ message: { title: "Hi, there", description: "This is description.", thumb: "www/img/thumbnail.png", mediaTagName: "TEST-TAG-001", messageExt: "这是第三方带的测试字段", messageAction: "dotalist", media: "YOUR_MEDIA_OBJECT_HERE" }, scene: Wechat.Scene.TIMELINE // share to Timeline }, function () { alert("Success"); }, function (reason) { alert("Failed: " + reason); });

微信分享

Wechat.share({ message: { ... media: { type: Wechat.Type.WEBPAGE, webpageUrl: "http://tech.qq.com/zt2012/tmtdecode/252.htm" } }, scene: Wechat.Scene.TIMELINE // share to Timeline }, function () { alert("Success"); }, function (reason) { alert("Failed: " + reason); });

微信支付

var params = { partnerid: '10000100', // merchant id prepayid: 'wx201411101639507cbf6ffd8b0779950874', // prepay id noncestr: '1add1a30ac87aa2db72f57a2375d8fec', // nonce timestamp: '1439531364', // timestamp sign: '0CB01533B8C1EF103065174F50BCA001', // signed string };

Wechat.sendPaymentRequest(params, function () { alert("Success"); }, function (reason) { alert("Failed: " + reason); });

外部js引用方式

微信支付

第一步:需要引用WXPaySDKPlugin.js

第二步,获取微信支付参数

var params = { partnerid: '10000100', // merchant id prepayid: 'wx201411101639507cbf6ffd8b0779950874', // prepay id noncestr: '1add1a30ac87aa2db72f57a2375d8fec', // nonce timestamp: '1439531364', // timestamp sign: '0CB01533B8C1EF103065174F50BCA001', // signed string }; WXPaySDKPlugin.sendPaymentRequest(params, function () { alert("Success"); }, function (reason) { alert("Failed: " + reason); });

TODO

  1. Add android version

  2. Share to wechat session(聊天) and wechat favorite(收藏)

  3. Add other media types, including music etc.

  4. Other APIs

  5. Android Version update

LICENSE

MIT LICENSE

About

微信支付

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published