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"; ...@@ -4,6 +4,7 @@ import { getPrintScreenData } from "./getShowOffPic";
import { NetManager } from "../libs/tw/manager/NetManager"; import { NetManager } from "../libs/tw/manager/NetManager";
import { DataManager } from "../libs/tw/manager/DataManager"; import { DataManager } from "../libs/tw/manager/DataManager";
import getHomeData from "./getHomeData"; import getHomeData from "./getHomeData";
import { iswx } from "./iswx";
const img: any = document.getElementById('pic'); const img: any = document.getElementById('pic');
img.style.display = 'none'; img.style.display = 'none';
...@@ -13,12 +14,21 @@ class Share2 extends ComponentBase { ...@@ -13,12 +14,21 @@ class Share2 extends ComponentBase {
const data = getHomeData(); const data = getHomeData();
this['lvTxt'].text = data.levels.length; this['lvTxt'].text = data.levels.length;
this['btn1'].addEventListener(egret.TouchEvent.TOUCH_TAP, () => { this['btn1'].addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
this.getFunc('2');//朋友圈 if (iswx()) { //微信端
} else {//端内
this.getFunc('2');//朋友圈
}
hideShare(); hideShare();
}, this); }, this);
this['btn2'].addEventListener(egret.TouchEvent.TOUCH_TAP, () => { this['btn2'].addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
this.getFunc('1');//好友微信 if (iswx()) { //微信端
} else {//端内
this.getFunc('1');//好友微信
}
hideShare(); hideShare();
}, this); }, this);
} }
...@@ -28,7 +38,7 @@ class Share2 extends ComponentBase { ...@@ -28,7 +38,7 @@ class Share2 extends ComponentBase {
NetManager.ins.imgUrl((success) => { NetManager.ins.imgUrl((success) => {
const data = DataManager.ins.getData('imgURL'); const data = DataManager.ins.getData('imgURL');
img.src = data.data; img.src = data.data;
callShareApi(data.data,type); callShareApi(data.data, type);
}, base64); }, base64);
} }
...@@ -67,15 +77,20 @@ const isIphone = () => { ...@@ -67,15 +77,20 @@ const isIphone = () => {
} }
//channel 1 好友 2 朋友圈 //channel 1 好友 2 朋友圈
export const callShareApi = (shareImgUrl, channel) => { export const callShareApi = (shareImgUrl, channel) => {
if (isIphone()) { try {
console.log("IOS"); if (isIphone()) {
console.log(window['SNNativeClient']); console.log("IOS");
//分享图片方法 console.log(window['SNNativeClient']);
window['SNNativeClient'].callMediaShare(shareImgUrl, channel, (message) => { }); //分享图片方法
} else { window['SNNativeClient'].callMediaShare(shareImgUrl, channel, (message) => { });
console.log("安卓"); } else {
console.log(window['shareApi']); console.log("安卓");
//分享图片用下列方法 console.log(window['shareApi']);
window['shareApi'].callMediaShare(shareImgUrl, channel, (message) => { }); //分享图片用下列方法
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