import { DataManager } from "../libs/tw/manager/DataManager";
import { NetName } from "../libs/tw/enum/NetName";

export default class DoShare {
   
    static _instance: DoShare;
    static get instance() {
        return DoShare._instance || (DoShare._instance = new DoShare())
    }

    doShare(state){
        var linkShare="http://activity.m.duiba.com.cn/customShare/share?id=3446&yunji_from=3";
        var linkHelp="https://activity.m.duiba.com.cn/customShare/share?id=3346&yunji_from=3";
        var link
        if(state=="help"){
            link=`${linkHelp}&shareCode=${DataManager.ins.getData(NetName.GET_SHARECODE).shareCode}`
        }else{
            link=`${linkShare}`
        }
        var shareData = {
            title: window["shareData"].title,//标题
            desc: window["shareData"].desc,//描述
            link: link,//链接
            imgUrl: window["shareData"].imgUrl,//图片
        }
        console.log(shareData)
        window["invokeWX"](shareData)
        window["wx"].ready(function(){
            console.log("微信好了")
            window["invokeWX"](shareData);
        });
    }

    doShareApp(state){
        var linkShare="http://activity.m.duiba.com.cn/customShare/share?id=3446&yunji_from=4";
        var linkHelp="https://activity.m.duiba.com.cn/customShare/share?id=3346&yunji_from=4";
        var link
        if(state=="help"){
            link=`${linkHelp}&shareCode=${DataManager.ins.getData(NetName.GET_SHARECODE).shareCode}`
        }else{
            link=`${linkShare}`
        }
		let href=`yunji://doubleTwelve/share?link=${encodeURIComponent(link)}&imgUrl=${window["shareData"].imgUrl}&title=${window["shareData"].title}&content=${window["shareData"].desc}`;
		window.location.href = href
    }
}