var param = null;
mui.ready(function () {
    var nowUrl = location.href;
    var productId = nowUrl.split("?")[1];
    param = productId;
    shareProxyMemberUrl();
    document.querySelector('.loading-bg').style.display = 'none'
});
function shareProxyMemberUrl() {
    $.ajax(base_path + '/member/shareProxyMemberUrl?' + param, {
        dataType: 'json',
        type: 'POST',
        timeout: 15000,
        xhrFields: {
			withCredentials: true
		},
		crossDomain: true,
        success: function (dt) {
        	if (dt.isRedirect) {
				location.href = dt.redirectURL;
			} else {
            if (dt.status) {
                if (dt.data.qrcodeUrl == null) {
                    $("#qrcode-div").html("<img src='//s.iamberry.com/watero/images/shop/bg_2wm.jpg'/>")
                } else {
                    $("#qrcode-div").html("<img src='" + dt.data.qrcodeUrl + "'/>")
                }
                if (dt.data.data.userHead == null) {
                    $("#user-head").empty().html("<img src='//s.iamberry.com/watero/images/shop/logo_head.png' />")
                } else {
                    $("#user-head").empty().html("<img src='" + dt.data.data.userHead + "' />")
                }
                if (dt.data.data.userNickname == null) {
                    $("#user-nickname").empty().html("爱贝源")
                } else {
                    $("#user-nickname").empty().html(decodeURI(dt.data.data.userNickname))
                }
                window.repleFlag = true;
                window.wxFriend = {
                    "appId": "",
                    "imgUrl": '//s.iamberry.com/watero/images/shop/default_qrcode.png',
                    "link": dt.data.shareUrl,
                    "desc": "Watero,美国高端净水专家,4级净化,5档水温,免安装饮水一体机。",
                    "title": "美国标准,4级净化,5档水温,废水比3:1,水质TDS智能显示。",
                    "netError": "您的网络异常,请刷新重试!如多次刷新无效,请向我们反应 ~",
                    "shareTimeSuccess": "分享成功",
                    "shareTimeCancel": "已取消分享",
                    "shareAppSuccess": "分享成功",
                    "shareAppCancel": "已取消分享"
                };
                getConfig()
            } else {
                mui.alert(dt.message)
            }
            }
        },
        error: function (xhr, type, errorThrown) {
            errorfn(xhr)
        }
    })
};var mask = mui.createMask(function () {
});
mui('body').on('tap', '.share_wechat', function () {
    mask.show();
});