|
@@ -0,0 +1,162 @@
|
|
|
+
|
|
|
+var SYS_ADDR = location.href.replace(/bigDataPanel\/+$/, ""),
|
|
|
+ API_ADDR = "http://10.37.25.78:8568";
|
|
|
+COOKIE_PATH = location.pathname.replace(/bigDataPanel\/+$/, "");
|
|
|
+IMG_WIDTH = 264;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 加载完成时事件
|
|
|
+ */
|
|
|
+window.onload = function () {
|
|
|
+ let username = getCookies("username");
|
|
|
+ if (username == 'admin') {
|
|
|
+ sys("sys");
|
|
|
+ } else {
|
|
|
+ getSystem();
|
|
|
+ isheight = false;
|
|
|
+ }
|
|
|
+ function getSystem() {
|
|
|
+ let token = getCookies("token");
|
|
|
+ $.ajax({
|
|
|
+ headers: {
|
|
|
+ 'Authorization': 'bearer ' + token
|
|
|
+ },
|
|
|
+ url: API_ADDR + '/base/user/initData',
|
|
|
+ type: "GET",
|
|
|
+ data: {
|
|
|
+ platform: 1,
|
|
|
+ },
|
|
|
+
|
|
|
+ dataType: "json",
|
|
|
+ success: function (data) {
|
|
|
+ if (data.code == 1) {
|
|
|
+ systemInfoList = data.result.subsystem;
|
|
|
+ if (systemInfoList.length == 0) {
|
|
|
+ console.error("该账户未分配系统");
|
|
|
+ window.location.href = SYS_ADDR + "/login";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ else {
|
|
|
+ let dom = "";
|
|
|
+ let table_str = "<tr><td>";
|
|
|
+ $.each(systemInfoList, function (i, item) {
|
|
|
+ table_str += "<div class='imgdiv'><img data-systemid='" + item.id + "' value='" + i + "' class='sysitem " + item.id + "' src='" + item.icon1 + "'><div class='imgtitle'><span data-systemid='" + item.id + "' value='" + i + "' >" + item.title + "</span></div></div>"
|
|
|
+ })
|
|
|
+ table_str += "</td></tr>"
|
|
|
+ itemtotallength = IMG_WIDTH * systemInfoList.length + (systemInfoList.length - 1) * 140;
|
|
|
+ margin_left = "calc((100% - " + itemtotallength + "px)/2)";
|
|
|
+ $(".itemControl").empty().append(table_str);
|
|
|
+ $(".itemControl td .imgdiv:first").css("margin-left", margin_left);
|
|
|
+ $("#mainContainer").removeClass("hidemainContainer");
|
|
|
+ loadingCartoon();
|
|
|
+ bindInit();
|
|
|
+ closeSys();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.error(data.message);
|
|
|
+ window.location.href = SYS_ADDR + "/login";
|
|
|
+ }
|
|
|
+ }.bind(this),
|
|
|
+ error: errorCallBack.bind(this)
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 登陆错误事件
|
|
|
+ */
|
|
|
+ function errorCallBack(mesg) {
|
|
|
+ console.error(mesg);
|
|
|
+ window.location.href = SYS_ADDR + "/login";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 退出按钮绑定事件
|
|
|
+ */
|
|
|
+ function closeSys() {
|
|
|
+ $(".closesys").click(function () {
|
|
|
+ exitsystem();
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 正常退出系统
|
|
|
+ */
|
|
|
+ function exitsystem() {
|
|
|
+ $(window).unbind('beforeunload');
|
|
|
+ $(window).unbind('unload');
|
|
|
+ var exp = new Date();
|
|
|
+ let token = getCookies("token");
|
|
|
+ exp.setTime(exp.getTime() - 1);
|
|
|
+ Cookies.remove(hex_sha1("token"));
|
|
|
+ Cookies.remove(hex_sha1("username"));
|
|
|
+ Cookies.remove(hex_sha1("systemmodeid"));
|
|
|
+ Cookies.remove(hex_sha1("systemid"));
|
|
|
+ window.location.href = SYS_ADDR + "/login";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ * 系统进入按钮绑定
|
|
|
+ */
|
|
|
+ function bindInit() {
|
|
|
+
|
|
|
+ $("body").on("click", '.sysitem,.imgtitle span', function (e) {
|
|
|
+ var systemid = $(e.currentTarget).data("systemid");
|
|
|
+ sys(systemid);
|
|
|
+ })
|
|
|
+ $("body").on("click", '.goToSys', function (e) {
|
|
|
+ var systemid = $(e.currentTarget).data("systemid");
|
|
|
+ sys(systemid);
|
|
|
+ })
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 进度条
|
|
|
+ */
|
|
|
+ function loadingCartoon() {
|
|
|
+ var obj = $("#mainContainer .loadingCartoon");
|
|
|
+ var progressObj = obj.find('.progress-bar-striped');
|
|
|
+ var count, rest;
|
|
|
+ var that = this;
|
|
|
+ var loop = setInterval(function () {
|
|
|
+ count = progressObj.data('count');
|
|
|
+ rest = 100 - count;
|
|
|
+ if (rest > 21) {
|
|
|
+ count += (Math.ceil(Math.random() * 20));
|
|
|
+ } else if (rest > 10) {
|
|
|
+ count += (Math.ceil(Math.random() * 10));
|
|
|
+ } else {
|
|
|
+ count = 100;
|
|
|
+ clearInterval(loop);
|
|
|
+ obj.css("display", "none")
|
|
|
+ }
|
|
|
+ progressObj.data('count', count);
|
|
|
+ progressObj.css('width', count + '%');
|
|
|
+ progressObj.text(count + '%');
|
|
|
+ if (count > 60) {
|
|
|
+ progressObj.removeClass('progress-bar-warning').removeClass('progress-bar-danger').addClass('progress-bar-success');
|
|
|
+ } else if (count > 20) {
|
|
|
+ progressObj.removeClass('progress-bar-warning').removeClass('progress-bar-danger').addClass('progress-bar-warning');
|
|
|
+ }
|
|
|
+ }, 200);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ * 获取cookies值
|
|
|
+ */
|
|
|
+ function getCookies(name) {
|
|
|
+ var tempName = Cookies.get(hex_sha1(name));
|
|
|
+ if (tempName)
|
|
|
+ return Secret_Key(Cookies.get(hex_sha1(name)), 'decryption');
|
|
|
+ else
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ function sys(id) {
|
|
|
+ window.location.href = SYS_ADDR + "controlPanel";
|
|
|
+ }
|
|
|
+}
|