安装
安装插件
cordova plugin add cordova-plugin-wechat --variable wechatappid=YOUR_WECHAT_APPID
安装ionic2、3调用
npm install wechat-chenyu --save
You also need to install the Ionic Native package for each plugin you want to add. Please see the Ionic Native documentation for complete instructions on how to add and use the plugins.
Documentation
For the full Ionic Native documentation, please visit https://ionicframework.com/docs/native/.
调用
To use a plugin, import and add the plugin provider to your @NgModule
, and then inject it where you wish to use it.
import {WechatChenyu} from "wechat-chenyu";
...
@NgModule({
...
providers: [
...
WechatChenyu
...
]
...
})
export class AppModule { }
import {WechatChenyu} from "wechat-chenyu";
@Component({ ... })
export class xxxxPage {
constructor(private wechatChenyu: WechatChenyu){}
WchatPay(obj) {
console.log(obj);
let params = {
partnerid: obj.partnerid,
prepayid: obj.prepayid,
noncestr: obj.noncestr,
timestamp: obj.timestamp,
sign: obj.sign
}
this.wechatChenyu.sendPaymentRequest(params).then((data) => {
}, eoor => {
}
);
}
isInstalled(){
this.wechatChenyu.isInstalled().then();
}
auth(){
this.wechatChenyu.auth().then();
}
share(){
let obj={
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: 1
};
this.wechatChenyu.share(obj).then();
}
}
参数列表
scene 0, // 聊天界面 1, // 朋友圈 2 // 收藏