<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="Kesion.NET.WebSite.Api.alipay.AlipayLogin" %>
<%@ Import Namespace="Kesion.Cache"%>
<%@ Import Namespace="Kesion.Publics"%>
<%@ Import Namespace="System.Collections.Generic"%>
<%

    if (MyCache.GetAccountAPIConfig("alipay", "enable") != "true")
    {
        Utils.ShowError("对不起，本站没有开通支付宝快捷登录!", "error.gif", 2, KSCMS.GetInstallDir());
    }

    #region 记录来源页面,以便登录成功返回
    if (!string.IsNullOrEmpty(KSCMS.S("backurl")))
    {
        new TemporaryVar().ComeUrl = KSCMS.S("backurl");
    }
    else
    {
        if (KSCMS.GetComeUrl() != null && KSCMS.GetComeUrl().ToLower().IndexOf("backurl=") != -1)  //登录来的,如原商城要求登录，再点注册
        {
            (new TemporaryVar()).ComeUrl = Utils.SplitString(KSCMS.GetComeUrl().ToLower(), "backurl=")[1];
        }
        else
        {
            (new TemporaryVar()).ComeUrl = KSCMS.GetComeUrl();
        }
    }
    #endregion
    
    string app_id=MyCache.GetAccountAPIConfig("alipay","apiid");
    string redirect_uri=MyCache.GetAccountAPIConfig("alipay","apireturnurl");
    //支付宝登陆第一步      获取构造用户登陆授权     回调地址和后台配置的回调地址是一样的
    KSCMS.Redirect(" https://openauth.alipay.com/oauth2/publicAppAuthorize.htm?app_id="+app_id+"&scope=auth_user&redirect_uri="+redirect_uri+"&state=init");
     
%>