1 /**
  2  * config
  3  *
  4  * @fileOverView we框架配置文件
  5  * @author <a href="mailto:zhang.gd@foxmail.com">Zhang Guangda</a>
  6  * 
  7  */
  8 define(function() {
  9 
 10 	/**
 11 	 * 配置
 12 	 * @class $we框架配置
 13 	 */
 14 	$we.conf = {
 15 
 16 		/**
 17 		 * 环境变量
 18 		 * @type {Object.<string>}
 19 		 * @constant
 20 		 */
 21 		ENV: {},
 22 
 23 		/**
 24 		 * 运行时配置
 25 		 * @type {Object}
 26 		 */
 27 		RUNTIME: {
 28 			__RANDOMSEED: Math.round(Math.random() * 10000),
 29 			__AUTOLOGIN: true,
 30 			__NOJSON: false
 31 		},
 32 
 33 		/**
 34 		 * 常量定义
 35 		 * @type {Object.<number>}
 36 		 * @constant
 37 		 */
 38 		CONSTANT: {},
 39 
 40 		/**
 41 		 * 主题颜色
 42 		 * @type {String}
 43 		 */
 44 		THEME: ""
 45 	};
 46 
 47 
 48 	// 根据 $we._url,也即当前文件的路径判断运行环境
 49 	if ($we._url.indexOf("dev.we.sdoprofile.com") != -1) {
 50 		$we.conf.ENV.__SITE = "dev";
 51 	} else if ($we._url.indexOf("test.we.sdoprofile.com") != -1) {
 52 		$we.conf.ENV.__SITE = "test";
 53 	} else if ($we._url.indexOf("we.sdoprofile.com") != -1) {
 54 		$we.conf.ENV.__SITE = "online";
 55 	} else {
 56 		$we.conf.ENV.__SITE = "localhost";
 57 	}
 58 
 59 	// 根据运行环境设定相应的http地址
 60 	if ($we.conf.ENV.__SITE == "localhost") {
 61 		/**
 62 		 * API请求接口地址
 63 		 * @type {String}
 64 		 */
 65 		$we.conf.ENV.__API = "http://dev.safe.sdo.com";
 66 		/**
 67 		 * 静态文件地址
 68 		 * @type {String}
 69 		 */
 70 		$we.conf.ENV.__STATIC = $we._url + "/..";
 71 		/**
 72 		 * CAS地址
 73 		 * @type {String}
 74 		 */
 75 		$we.conf.ENV.__CAS_SITE = "http://test.cas.sdo.com";
 76 		/**
 77 		 * MCAS地址
 78 		 * @type {String}
 79 		 */
 80 		$we.conf.ENV.__MCAS_SITE = "http://test.mcas.sdo.com";
 81 	} else if ($we.conf.ENV.__SITE == "dev") {
 82 		$we.conf.ENV.__API = "http://dev.safe.sdo.com";
 83 		$we.conf.ENV.__STATIC = "http://dev.we.sdoprofile.com/common";
 84 		$we.conf.ENV.__CAS_SITE = "http://test.cas.sdo.com";
 85 		$we.conf.ENV.__MCAS_SITE = "http://test.mcas.sdo.com";
 86 	} else if ($we.conf.ENV.__SITE == "test") {
 87 		$we.conf.ENV.__API = "http://test.safe.sdo.com";
 88 		$we.conf.ENV.__STATIC = "http://test.we.sdoprofile.com/common";
 89 		$we.conf.ENV.__CAS_SITE = "http://test.cas.sdo.com";
 90 		$we.conf.ENV.__MCAS_SITE = "http://test.mcas.sdo.com";
 91 	} else {
 92 		$we.conf.ENV.__API = "http://safe.sdo.com";
 93 		$we.conf.ENV.__STATIC = "http://we.sdoprofile.com/common";
 94 		$we.conf.ENV.__CAS_SITE = "http://cas.sdo.com";
 95 		$we.conf.ENV.__MCAS_SITE = "http://mcas.sdo.com";
 96 	}
 97 
 98 	/**
 99 	 * 插件地址
100 	 * @type {String}
101 	 */
102 	$we.conf.ENV.__PLUGIN = $we.conf.ENV.__STATIC + "/js/plugin";
103 	/**
104 	 * CAS状态的API请求地址
105 	 * @type {String}
106 	 */
107 	$we.conf.ENV.__CAS_STATE_API = $we.conf.ENV.__CAS_SITE + "/cas/loginStateService?method=checkstat";
108 	/**
109 	 * MCAS状态的API请求地址
110 	 * @type {String}
111 	 */
112 	$we.conf.ENV.__MCAS_STATE_API = $we.conf.ENV.__MCAS_SITE + "/authen/getLoginState.jsonp?appId=470&areadId=-1&authenSource=2";
113 	/**
114 	 * 登录Iframe
115 	 * @type {String}
116 	 */
117 	$we.conf.ENV.__LOGIN_FRAME = $we.conf.ENV.__API + "/login/checkCas";
118 	/**
119 	 * MLOGIN登录Iframe
120 	 * @type {String}
121 	 */
122 	$we.conf.ENV.__MLOGIN_FRAME = $we.conf.ENV.__API + "/login/checkMobileCas";
123 	/**
124 	 * API中用户信息接口API
125 	 * @type {String}
126 	 */
127 	$we.conf.ENV.__ACCOUNT_INFO_API = $we.conf.ENV.__API + "/ajaxSafe/getAccountInfo";
128 
129 	/**
130 	 * 定义空函数
131 	 * @function
132 	 */
133 	$we.emptyFunction = function() {};
134 
135 	/**
136 	 * 错误文案定义
137 	 * @type {Object}
138 	 */
139 	$we.ERROR = {
140 		AJAX_REQUEST_FAIL: "系统内部错误,请稍后再试!",
141 		AJAX_PARSE_FAIL: "系统内部错误,请稍后再试!"
142 	};
143 
144 	$we.ERRNO = {
145 		NOT_LOGIN: -1000
146 	};
147 
148 	/**
149 	 * 自定义的Error报错方法
150 	 * @function
151 	 * @param {String} msg  错误信息
152 	 * @param {Number} code 错误代码
153 	 */
154 	$we.Exception = function(msg, code) {
155 		var errstr = msg;
156 		if (code && (typeof code == "string" || typeof code == "number")) {
157 			errstr += " Errno: " + code;
158 		}
159 
160 		throw new Error(errstr);
161 	};
162 
163 	return $we.conf;
164 
165 });