import { DataManager } from "../libs/tw/manager/DataManager";
import getDefaultAvatar from "./getDefaultAvatar";
import getDefaultPic from "./getDefaultPic";

export default () => {

    let { avatar, dreamPic: url, address, id, dreamTitle: title, dreamContent: content } = DataManager.ins.getData('yyh_join1_dreamDetail').data;

    // let shareUrl = 'http://yazuwei.activity-1.m.duiba.com.cn/projectx/pa1462f11/fea2bff6f.html';
    // const prefix = `?avatar=${encodeURIComponent(avatar)}&url=${encodeURIComponent(url)}&address=${address}&id2=${id}&title=${title}&content=${content}`;
    // shareUrl += prefix;

    // shareUrl = 'http://aghzact.zjkczn.com/h5/defaultActive.html?activeUrl=' + encodeURIComponent(shareUrl)

    if (!avatar)
        avatar = getDefaultAvatar();

    if (!url)
        url = getDefaultPic();

    let shareUrl = 'http://yazuwei.activity-1.m.duiba.com.cn/projectx/'+window['projectID']+'/fea2bff6f.html';
    const prefix = `?appKey=45NDpdHGZQ2fiAdMGJWz5Sdhn4sn&openBs=openbs&appID=55322&avatar=${encodeURIComponent(avatar)}&url=${encodeURIComponent(url)}&address=${encodeURIComponent(address)}&id2=${id}&title=${encodeURIComponent(title)}&content=${encodeURIComponent(content)}`;
    shareUrl += prefix;

    console.log(shareUrl);

    window['AlipayJSBridge'].call(
        'esportsShare',
        {
            title: '寻找2022个亚运梦想活动火热进行中',
            content: '快来为我的亚运梦想充能吧',
            imgUrl: 'https://yun.duiba.com.cn/db_games/yyhlogo2.png',
            url: shareUrl, type: '3'
        });
}