| @@ -13,8 +13,8 @@ | |||||
| <body> | <body> | ||||
| <div class="main"> | <div class="main"> | ||||
| <p class="btnclick">sssss</p> | |||||
| <script id="nav-mian-text" type="text/html"> | |||||
| <script id="example-mian-dom" type="text/html"> | |||||
| {{if isAdmin}} | {{if isAdmin}} | ||||
| <h1>{{title}}</h1> | <h1>{{title}}</h1> | ||||
| <ul> | <ul> | ||||
| @@ -24,9 +24,20 @@ | |||||
| </ul> | </ul> | ||||
| {{/if}} | {{/if}} | ||||
| </script> | </script> | ||||
| <div id="nav-mian"> | |||||
| <div id="example-mian"> | |||||
| </div> | </div> | ||||
| <script id="userinfo-main-dom" type="text/html"> | |||||
| <p>当前村:{{deptName}}</p> | |||||
| <p>当前账套:{{bookName}}</p> | |||||
| <p>角色名称:{{remark}}</p> | |||||
| <p>用户名:{{nickName}}</p> | |||||
| <ul> | |||||
| {{each roles as value i}} | |||||
| <li>{{value.roleSort}}-{{value.roleName}}({{value.roleKey}})</li> | |||||
| {{/each}} | |||||
| </ul> | |||||
| </script> | |||||
| <div id="userinfo-main"></div> | |||||
| </div> | </div> | ||||
| </body> | </body> | ||||
| @@ -1,5 +1,6 @@ | |||||
| /*-------------- | /*-------------- | ||||
| * 用户登录、注册相关 | |||||
| * 获取用户、登录、注册相关 | |||||
| -----------------*/ | -----------------*/ | ||||
| var captchaImage_get = '/captchaImage'; //图形验证码接口 | var captchaImage_get = '/captchaImage'; //图形验证码接口 | ||||
| var login_post = '/login'; //用户登录接口 | |||||
| var login_post = '/login'; //用户登录接口 | |||||
| var getInfo_get = '/getInfo' //获取用户信息 | |||||
| @@ -38,12 +38,12 @@ requirejs.config({ | |||||
| nprogress: { | nprogress: { | ||||
| deps: ['jquery'], | deps: ['jquery'], | ||||
| exports: 'nprogress' | exports: 'nprogress' | ||||
| }, | |||||
| } | |||||
| } | } | ||||
| }); | }); | ||||
| //所有页面都需要的js,先行加载 | //所有页面都需要的js,先行加载 | ||||
| require(['jquery', 'bootstrap', 'nprogress',"API"]); | |||||
| require(['jquery','nprogress',"API"]); | |||||
| require(["jquery"], function ($) { | require(["jquery"], function ($) { | ||||
| //ajax加载页面跳转 | //ajax加载页面跳转 | ||||
| @@ -12,12 +12,12 @@ define(['jquery', 'dialog'], function ($, dialog) { | |||||
| * @param url (String) | * @param url (String) | ||||
| * @param data (Json) 需要提交的数据 | * @param data (Json) 需要提交的数据 | ||||
| * @param cb(Function) 回调函数 | * @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 _this = this; | ||||
| var headAttribute = ''; | var headAttribute = ''; | ||||
| if(noHead && noHead==true){ | |||||
| if(Bearer && Bearer==true || _this.getCookie('Admin-Token')==''){ | |||||
| headAttribute = function (xhr) { | headAttribute = function (xhr) { | ||||
| xhr.setRequestHeader("Content-Type", 'application/json;charset=utf-8'); | xhr.setRequestHeader("Content-Type", 'application/json;charset=utf-8'); | ||||
| } | } | ||||
| @@ -57,13 +57,13 @@ define(['jquery', 'dialog'], function ($, dialog) { | |||||
| * @param url(String) | * @param url(String) | ||||
| * @param data(Json) 需要提交的数据 | * @param data(Json) 需要提交的数据 | ||||
| * @param cb(Function) 回调函数 | * @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 _this = this; | ||||
| var url = ajaxJsUrl+uri + '?'; | var url = ajaxJsUrl+uri + '?'; | ||||
| var headAttribute = '' | var headAttribute = '' | ||||
| if(noHead && noHead==true){ | |||||
| if(Bearer && Bearer==true || _this.getCookie('Admin-Token')==''){ | |||||
| headAttribute = function (xhr) { | headAttribute = function (xhr) { | ||||
| xhr.setRequestHeader("Content-Type", 'application/json;charset=utf-8'); | xhr.setRequestHeader("Content-Type", 'application/json;charset=utf-8'); | ||||
| } | } | ||||
| @@ -101,6 +101,9 @@ define(['jquery', 'dialog'], function ($, dialog) { | |||||
| }else{ | }else{ | ||||
| cb(data); | cb(data); | ||||
| } | } | ||||
| }, | |||||
| error:function(data){ | |||||
| console.log(data) | |||||
| } | } | ||||
| }); | }); | ||||
| }, | }, | ||||
| @@ -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) { | define(['jquery', "template", "Tools"], function ($, template, Tools) { | ||||
| //数据存储 | |||||
| var module = { | var module = { | ||||
| initData: { | initData: { | ||||
| title: '基本例子', | |||||
| title: '例子', | |||||
| isAdmin: true, | isAdmin: true, | ||||
| list: ['文艺', '博客', '摄影', '电影', '民谣', '旅行', '吉他'] | |||||
| } | |||||
| list: ['测试', '测试2', '测试3', '测试4', '测试4'] | |||||
| }, | |||||
| userData:{} //用户信息 | |||||
| }; | }; | ||||
| var tools = new Tools(); | var tools = new Tools(); | ||||
| module.init = function (page) { | 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; | return module; | ||||
| }); | }); | ||||
| @@ -3,12 +3,12 @@ | |||||
| * Created by liuminjian on 2021/4/5. | * Created by liuminjian on 2021/4/5. | ||||
| * | * | ||||
| */ | */ | ||||
| define(['jquery', "template", "Tools"], function ($, template, Tools) { | |||||
| define(['jquery', "Tools"], function ($, Tools) { | |||||
| //数据存储 | //数据存储 | ||||
| var module = { | var module = { | ||||
| uuid:'' //验证码uuid | uuid:'' //验证码uuid | ||||
| }; | }; | ||||
| //自定义方法 | |||||
| //自定义公共方法 | |||||
| var tools = new Tools(); | var tools = new Tools(); | ||||
| //默认进入页面加载方法 | //默认进入页面加载方法 | ||||
| @@ -24,6 +24,6 @@ | |||||
| </div> | </div> | ||||
| </div> | </div> | ||||
| </body> | </body> | ||||
| <script src="../static/js/common/require.js" data-main="../static/js/common/main" id="require-page" | |||||
| <script src="../static/js/common/require.js" data-main="../static/js/common/main" id="require-page" | |||||
| target-module="../static/js/project/user/login.js" defer type="text/javascript"></script> | target-module="../static/js/project/user/login.js" defer type="text/javascript"></script> | ||||
| </html> | </html> | ||||