生活随笔
收集整理的這篇文章主要介紹了
ionic2微信支付,分享,登录
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
安裝
安裝插件 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 : ? " <action>dotalist</action> " , ????????????????????????? media : ? " YOUR_MEDIA_OBJECT_HERE " ????????????????????? } , ????????????????????? scene : ? 1 ??? ????????????????? } ; ???????? this . wechatChenyu . share ( obj ) . then ( ) ; ?? ????? } ????? }
參數列表
scene 0, // 聊天界面 1, // 朋友圈 2 // 收藏
總結
以上是生活随笔 為你收集整理的ionic2微信支付,分享,登录 的全部內容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔 網站內容還不錯,歡迎將生活随笔 推薦給好友。