1.0.2 • Published 6 years ago

wechat-chenyu v1.0.2

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

npm.io

wechat Native

Ionic Native - 微信sdk,包括分享、支付、第三方登录

安装

Run following command to install Ionic Native in your project.

安装插件
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.

// app.module.ts
import {WechatChenyu} from "wechat-chenyu";

...

@NgModule({
  ...

  providers: [
    ...
    WechatChenyu
    ...
  ]
  ...
})
export class AppModule { }
import {WechatChenyu} from "wechat-chenyu";

@Component({ ... })
export class xxxxPage {
constructor(private wechatChenyu: WechatChenyu){}
   //微信支付
   // obj 是从服务器获取的参数
   WchatPay(obj) {
       console.log(obj);
       let params = {
         partnerid: obj.partnerid, // merchant id
         prepayid: obj.prepayid, // prepay id
         noncestr: obj.noncestr, // nonce
         timestamp: obj.timestamp, // timestamp
         sign: obj.sign
       }
       this.wechatChenyu.sendPaymentRequest(params).then((data) => {
         
         /*let alert = this.alertCtrl.create({
           title: '充值提示!',
           subTitle: JSON.stringify(data),
           buttons: ['确定']
         });
         alert.present();
         */
         }, eoor => {
           
         }
       );
     }
     //判断是否安装微信
     isInstalled(){
       this.wechatChenyu.isInstalled().then();
     }
     //微信登录
     auth(){
        this.wechatChenyu.auth().then(); 
     }
     //分享obj参考 https://www.npmjs.com/package/cordova-plugin-wechat
     share(){
         let obj={
                     message: {
                         title: "Hi, there",
                         description: "This is description.",
                         thumb: "www/img/thumbnail.png",
                         mediaTagName: "TEST-TAG-001",
                         messageExt: "这是第三方带的测试字段",
                         messageAction: "<action>dotalist</action>",
                         media: "YOUR_MEDIA_OBJECT_HERE"
                     },
                     scene: 1   // 代表朋友圈、参数列表
                 };
        this.wechatChenyu.share(obj).then();  
     }
     
}

参数列表

scene 0, // 聊天界面 1, // 朋友圈 2 // 收藏

联系我们

QQ:250187715 QQ群:390736068