Commit bb353daf authored by wildfirecode's avatar wildfirecode

1

parent 44fff0cc
...@@ -13,21 +13,22 @@ class Share2 extends ComponentBase { ...@@ -13,21 +13,22 @@ 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('btn1'); this.getFunc('2');//朋友圈
hideShare(); hideShare();
}, this); }, this);
this['btn2'].addEventListener(egret.TouchEvent.TOUCH_TAP, () => { this['btn2'].addEventListener(egret.TouchEvent.TOUCH_TAP, () => {
this.getFunc('btn2'); this.getFunc('1');//好友微信
hideShare(); hideShare();
}, this); }, this);
} }
//channel 1 好友 2 朋友圈
getFunc(type: string) { getFunc(type: string) {
const base64 = getPrintScreenData(this['pic'], 0, 0, 579, 866); const base64 = getPrintScreenData(this['pic'], 0, 0, 579, 866);
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);
}, base64); }, base64);
} }
...@@ -53,4 +54,28 @@ export const showShare = () => { ...@@ -53,4 +54,28 @@ export const showShare = () => {
export const hideShare = () => { export const hideShare = () => {
layers.shareLayer.visible = false; layers.shareLayer.visible = false;
}
const isIphone = () => {
const ua = navigator.userAgent.toLocaleLowerCase();
if (ua.match(/iphone|ipad/)) {
return true;
} else if (ua.match(/android/)) {
return false;
}
}
//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) => { });
}
} }
\ No newline at end of file
const path = require('path'); const path = require('path');
const config = { const config = {
'/customActivity/duiba/imgUrl': {
data: './json/imgUrl.json'
},
'/wechatShare/getShareInfo/v2': { '/wechatShare/getShareInfo/v2': {
data: './happyclear/openTreasureBox.json' data: './happyclear/openTreasureBox.json'
}, },
......
{
"code": null,
"data": "http://yun.duiba.com.cn/duibaimage/1566979679985100400129.png",
"success": true,
"desc": null,
"timestamp": 1566979680025
}
\ 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