Commit 03d04ea9 authored by wildfirecode's avatar wildfirecode

1

parent bb353daf
export const iswx = () => {
return navigator.userAgent.toLowerCase().indexOf('micromessenger') !== -1
}
\ No newline at end of file
......@@ -4,6 +4,7 @@ import { getPrintScreenData } from "./getShowOffPic";
import { NetManager } from "../libs/tw/manager/NetManager";
import { DataManager } from "../libs/tw/manager/DataManager";
import getHomeData from "./getHomeData";
import { iswx } from "./iswx";
const img: any = document.getElementById('pic');
img.style.display = 'none';
......@@ -13,12 +14,21 @@ class Share2 extends ComponentBase {
const data = getHomeData();
this['lvTxt'].text = data.levels.length;
this['btn1'].addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
this.getFunc('2');//朋友圈
if (iswx()) { //微信端
} else {//端内
this.getFunc('2');//朋友圈
}
hideShare();
}, this);
this['btn2'].addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
this.getFunc('1');//好友微信
if (iswx()) { //微信端
} else {//端内
this.getFunc('1');//好友微信
}
hideShare();
}, this);
}
......@@ -28,7 +38,7 @@ class Share2 extends ComponentBase {
NetManager.ins.imgUrl((success) => {
const data = DataManager.ins.getData('imgURL');
img.src = data.data;
callShareApi(data.data,type);
callShareApi(data.data, type);
}, base64);
}
......@@ -67,15 +77,20 @@ const isIphone = () => {
}
//channel 1 好友 2 朋友圈
export const callShareApi = (shareImgUrl, channel) => {
if (isIphone()) {
console.log("IOS");
console.log(window['SNNativeClient']);
//分享图片方法
window['SNNativeClient'].callMediaShare(shareImgUrl, channel, (message) => { });
} else {
console.log("安卓");
console.log(window['shareApi']);
//分享图片用下列方法
window['shareApi'].callMediaShare(shareImgUrl, channel, (message) => { });
try {
if (isIphone()) {
console.log("IOS");
console.log(window['SNNativeClient']);
//分享图片方法
window['SNNativeClient'].callMediaShare(shareImgUrl, channel, (message) => { });
} else {
console.log("安卓");
console.log(window['shareApi']);
//分享图片用下列方法
window['shareApi'].callMediaShare(shareImgUrl, channel, (message) => { });
}
} catch (error) {
console.log(error)
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment