diff --git a/index.html b/index.html index 4672e2b..73972be 100644 --- a/index.html +++ b/index.html @@ -13,8 +13,8 @@
-

sssss

- - diff --git a/static/js/api/index.js b/static/js/api/index.js index d3e3087..880a778 100644 --- a/static/js/api/index.js +++ b/static/js/api/index.js @@ -1,5 +1,6 @@ /*-------------- -* 用户登录、注册相关 +* 获取用户、登录、注册相关 -----------------*/ var captchaImage_get = '/captchaImage'; //图形验证码接口 -var login_post = '/login'; //用户登录接口 \ No newline at end of file +var login_post = '/login'; //用户登录接口 +var getInfo_get = '/getInfo' //获取用户信息 diff --git a/static/js/common/main.js b/static/js/common/main.js index f543246..cb0b576 100644 --- a/static/js/common/main.js +++ b/static/js/common/main.js @@ -38,12 +38,12 @@ requirejs.config({ nprogress: { deps: ['jquery'], exports: 'nprogress' - }, + } } }); //所有页面都需要的js,先行加载 -require(['jquery', 'bootstrap', 'nprogress',"API"]); +require(['jquery','nprogress',"API"]); require(["jquery"], function ($) { //ajax加载页面跳转 diff --git a/static/js/common/tools.js b/static/js/common/tools.js index ae08dcd..0bc2572 100644 --- a/static/js/common/tools.js +++ b/static/js/common/tools.js @@ -12,12 +12,12 @@ define(['jquery', 'dialog'], function ($, dialog) { * @param url (String) * @param data (Json) 需要提交的数据 * @param cb(Function) 回调函数 - * @param noHead(Boolean) 是否需要Bearer + * @param Bearer(Boolean) 是否需要Bearer,不需要传true */ - doPost: function (url, data, cb, noHead) { + doPost: function (url, data, cb, Bearer) { var _this = this; var headAttribute = ''; - if(noHead && noHead==true){ + if(Bearer && Bearer==true || _this.getCookie('Admin-Token')==''){ headAttribute = function (xhr) { xhr.setRequestHeader("Content-Type", 'application/json;charset=utf-8'); } @@ -57,13 +57,13 @@ define(['jquery', 'dialog'], function ($, dialog) { * @param url(String) * @param data(Json) 需要提交的数据 * @param cb(Function) 回调函数 - * @param noHead(Boolean) 是否需要Bearer + * @param noHead(Boolean) 是否需要Bearer,不需要传true */ - doGet: function (uri, data, cb , noHead) { + doGet: function (uri, data, cb , Bearer) { var _this = this; var url = ajaxJsUrl+uri + '?'; var headAttribute = '' - if(noHead && noHead==true){ + if(Bearer && Bearer==true || _this.getCookie('Admin-Token')==''){ headAttribute = function (xhr) { xhr.setRequestHeader("Content-Type", 'application/json;charset=utf-8'); } @@ -101,6 +101,9 @@ define(['jquery', 'dialog'], function ($, dialog) { }else{ cb(data); } + }, + error:function(data){ + console.log(data) } }); }, diff --git a/static/js/project/index.js b/static/js/project/index.js index 73c3c97..f8a3985 100644 --- a/static/js/project/index.js +++ b/static/js/project/index.js @@ -1,24 +1,33 @@ /** - * Created by Administrator on 2017/3/8. + * Created by Administrator on 2021/4/5. */ define(['jquery', "template", "Tools"], function ($, template, Tools) { + //数据存储 var module = { initData: { - title: '基本例子', + title: '例子', isAdmin: true, - list: ['文艺', '博客', '摄影', '电影', '民谣', '旅行', '吉他'] - } + list: ['测试', '测试2', '测试3', '测试4', '测试4'] + }, + userData:{} //用户信息 }; var tools = new Tools(); module.init = function (page) { - let _this = this; - var navMian = template('nav-mian-text', module.initData); - $("#nav-mian").html(navMian); - - - + //template.js demo案例 + var exampleMian = template('example-mian-dom', module.initData); + $("#example-mian").html(exampleMian); + //获取用户信息 + tools.doGet(getInfo_get,{},module.getInfoData) }; - module.login = function () { }; + + //获取用户信息 + module.getInfoData = function(data){ + if(data.code == 200){ + module.userData = data.user; + var userInfoMian = template('userinfo-main-dom', module.userData); + $("#userinfo-main").html(userInfoMian); + } + } return module; }); \ No newline at end of file diff --git a/static/js/project/user/login.js b/static/js/project/user/login.js index 8ce717a..68e9334 100644 --- a/static/js/project/user/login.js +++ b/static/js/project/user/login.js @@ -3,12 +3,12 @@ * Created by liuminjian on 2021/4/5. * */ - define(['jquery', "template", "Tools"], function ($, template, Tools) { + define(['jquery', "Tools"], function ($, Tools) { //数据存储 var module = { uuid:'' //验证码uuid }; - //自定义方法 + //自定义公共方法 var tools = new Tools(); //默认进入页面加载方法 diff --git a/user/login.html b/user/login.html index 0157985..7e1adbc 100644 --- a/user/login.html +++ b/user/login.html @@ -24,6 +24,6 @@
- \ No newline at end of file