123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- import * as WeChat from "react-native-wechat";
- WeChat.registerApp("wx51acc19c8f7a0f6f");
- export default class wechat {
-
- static shareToSessionText(descriptiontext) {
- WeChat.isWXAppInstalled().then(isInstalled => {
- if (isInstalled) {
- WeChat.shareToSession({
- type: "text",
- description: descriptiontext
- }).catch(error => {
- console.log(error.message);
- });
- } else {
- alert("请安装微信");
- }
- });
- }
-
- static shareToSessionNews(
- title_text,
- description_text,
- thumbImage_url,
- webpageUrl_url
- ) {
- WeChat.isWXAppInstalled().then(isInstalled => {
- if (isInstalled) {
- WeChat.shareToSession({
- title: title,
- description: description,
- thumbImage: thumbImage,
- type: "news",
- webpageUrl: webpageUrl
- }).catch(error => {
- alert(error.message);
- });
- } else {
- alert("请安装微信");
- }
- });
- }
-
- static shareToTimelineText(description_text) {
- WeChat.isWXAppInstalled().then(isInstalled => {
- if (isInstalled) {
- WeChat.shareToTimeline({
- type: "text",
- description: description_text
- }).catch(error => {
- console.log(error.message);
- });
- } else {
- alert("请安装微信");
- }
- });
- }
-
- static shareToTimelineNews(
- title_text,
- description_text,
- thumbImage_url,
- webpageUrl_url
- ) {
- WeChat.isWXAppInstalled().then(isInstalled => {
- if (isInstalled) {
- WeChat.shareToTimeline({
- title: title_text,
- description: description_text,
- thumbImage: thumbImage_url,
- type: "news",
- webpageUrl: webpageUrl_url
- }).catch(error => {
- console.log(error.message);
- });
- } else {
- alert("请安装微信");
- }
- });
- }
-
- static pay(partnerId, prepayId, nonceStr, timeStamp, packages, sign) {
- WeChat.isWXAppInstalled().then(isInstalled => {
- if (isInstalled) {
- WeChat.pay({
- partnerId: partnerId,
- prepayId: prepayId,
- nonceStr: nonceStr,
- timeStamp: timeStamp,
- package: packages,
- sign: sign
- })
- .then(requestJson => {
-
- if (requestJson.errCode == "0") {
-
- }
- })
- .catch(err => {
- alert("支付失败");
- });
- } else {
- alert("请安装微信");
- }
- });
- }
- }
|