/**
 * global 设定
 * @type {{baseUri}}
 */
var G = (function () {
    //'use strict';

    var baseUri = function () {
        return '/aidea';
    };

    var devMode = function () {
        return false;
    };

    var devModePost=function(){
        return 'get';
    };
    var ajax = function (type, url, data, callback) {
        var signature = cfapp.getMpInfo().signature;
        var keyInfo = cfapp.getMpInfo().key;
        var key  = CryptoJS.enc.Utf8.parse(keyInfo);
        var finalSignature =  Encrypt( signature,key);
        data.memberUid=cfapp.getMpInfo().memberId;
        data.openId=cfapp.getMpInfo().openId;
        data.requestId=cfapp.getMpInfo().requestId;
        data.signature=finalSignature;
        var  headers = {'signature':Encrypt( cfapp.getMpInfo().signature,CryptoJS.enc.Utf8.parse(cfapp.getMpInfo().key)) };
        $.ajax({
            url: url,
            headers: headers,
            type: type,
            dataType: "json",
            data: data,
            traditional: true,
            success: function (retdata) {
                callback(retdata);
            }
        });
    };

    var loginPageUri = function () {
        return baseUri() + '/static/mp/dc/login.html';
    };

    var oauth2Uri = function (appid, url, scope) {

        return "http://www.michang-tech.com.cn" + baseUri() + "/static/mp/dc/oauth2.html?appid=" + appid + "&redirect=" + encodeURIComponent(url) + "&scope=" + scope;

       // return "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + encodeURIComponent(url) + "&response_type=code&scope=" + scope + "&state=STATE#wechat_redirect";
    };
    return {
        baseUri: baseUri,
        devMode: devMode,
        ajax: ajax,
        loginPageUri: loginPageUri,
        oauth2Uri: oauth2Uri
    }
})();