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, () => {
if (iswx()) { //微信端
} else {//端内
this.getFunc('2');//朋友圈 this.getFunc('2');//朋友圈
}
hideShare(); hideShare();
}, this); }, this);
this['btn2'].addEventListener(egret.TouchEvent.TOUCH_TAP, () => { this['btn2'].addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
if (iswx()) { //微信端
} else {//端内
this.getFunc('1');//好友微信 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,6 +77,7 @@ const isIphone = () => { ...@@ -67,6 +77,7 @@ const isIphone = () => {
} }
//channel 1 好友 2 朋友圈 //channel 1 好友 2 朋友圈
export const callShareApi = (shareImgUrl, channel) => { export const callShareApi = (shareImgUrl, channel) => {
try {
if (isIphone()) { if (isIphone()) {
console.log("IOS"); console.log("IOS");
console.log(window['SNNativeClient']); console.log(window['SNNativeClient']);
...@@ -78,4 +89,8 @@ export const callShareApi = (shareImgUrl, channel) => { ...@@ -78,4 +89,8 @@ export const callShareApi = (shareImgUrl, channel) => {
//分享图片用下列方法 //分享图片用下列方法
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