>[info] #### 视图主要是用来呈现页面效果的
```
在源码根目录下面的 web 文件夹里面
```
>[info] 将页面整合到框架里
1、复制 assets文件夹,到 ```public/static``` 目录下面,如图:
![](https://box.kancloud.cn/e8f04e9f1b38ddd17797fe2652e55af3_340x676.png)
2、在 ```index``` 模块下面的 ```view``` 文件夹下面,创建一个新的 ```index``` 文件夹,并将 ```index.html``` ,放入 ```index``` 文件夹里面;创建一个新的 ```login``` 文件夹,并将 ```login.html``` 放入 ```login``` 文件夹,并改名为 ```index.html```如图:
![](https://box.kancloud.cn/f82d7abd6b902079128b5b297a738cf4_337x277.png)
3、打开 ```login.html``` ,在每一条 CSS,JS链接之前,加上 ```__STATIC__/```,代码如下:
```
<!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8" />
<title>用户登录界面</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta content="width=device-width, initial-scale=1" name="viewport" />
<meta content="这是用户登录界面!" name="description" />
<meta content="" name="author" />
<!-- BEGIN GLOBAL MANDATORY STYLES -->
<link href="__STATIC__/assets/global/plugins/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
<link href="__STATIC__/assets/global/plugins/simple-line-icons/simple-line-icons.min.css" rel="stylesheet" type="text/css" />
<link href="__STATIC__/assets/global/plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="__STATIC__/assets/global/plugins/bootstrap-switch/css/bootstrap-switch.min.css" rel="stylesheet" type="text/css" />
<!-- END GLOBAL MANDATORY STYLES -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<link href="__STATIC__/assets/global/plugins/select2/css/select2.min.css" rel="stylesheet" type="text/css" />
<link href="__STATIC__/assets/global/plugins/select2/css/select2-bootstrap.min.css" rel="stylesheet" type="text/css" />
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN THEME GLOBAL STYLES -->
<link href="__STATIC__/assets/global/css/components.min.css" rel="stylesheet" id="style_components" type="text/css" />
<link href="__STATIC__/assets/global/css/plugins.min.css" rel="stylesheet" type="text/css" />
<!-- END THEME GLOBAL STYLES -->
<!-- BEGIN PAGE LEVEL STYLES -->
<link href="__STATIC__/assets/pages/css/login-5.min.css" rel="stylesheet" type="text/css" />
<!-- END PAGE LEVEL STYLES -->
<!-- BEGIN THEME LAYOUT STYLES -->
<!-- END THEME LAYOUT STYLES -->
<link rel="shortcut icon" href="favicon.ico" /> </head>
<!-- END HEAD -->
<body class=" login">
<!-- BEGIN : LOGIN PAGE 5-1 -->
<div class="user-login-5">
<div class="row bs-reset">
<div class="col-md-6 bs-reset mt-login-5-bsfix">
<div class="login-bg" style="background-image:url(assets/pages/img/login/bg1.jpg)">
<!--<img class="login-logo" src="assets/pages/img/login/logo.png" /> -->
</div>
</div>
<div class="col-md-6 login-container bs-reset mt-login-5-bsfix">
<div class="login-content">
<h1>用户登录</h1>
<form action="" class="login-form" method="post">
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
<span>用户名或密码或验证码不能为空! </span>
</div>
<div class="row">
<div class="col-xs-6">
<input class="form-control form-control-solid placeholder-no-fix form-group" type="text" autocomplete="off" placeholder="用户名" name="username" value="admin" required/>
</div>
<div class="col-xs-6">
<input class="form-control form-control-solid placeholder-no-fix form-group" type="password" autocomplete="off" placeholder="密码" name="password" value="123456" required/>
</div>
</div>
<div class="row">
<div class="col-xs-6">
<!-- 验证码实现 -->
<a class="forget-password">
<img src="{:url('index/login/verify')}" onclick="this.src='{:url(\'index/login/verify\')}?d='+Math.random();">
</a>
</div>
<div class="col-xs-6 ">
<input class="form-control form-control-solid placeholder-no-fix form-group" type="text" autocomplete="off" placeholder="验证码" name="code" required/>
</div>
</div>
<div class="row">
<div class="col-sm-4 col-offset-sm-2">
<button class="btn green" type="submit" style="margin-top: 10px">登录</button>
</div>
</div>
</form>
<!-- BEGIN FORGOT PASSWORD FORM -->
<form class="forget-form" action="javascript:;" method="post">
<h3 class="font-green">Forgot Password ?</h3>
<p> Enter your e-mail address below to reset your password. </p>
<div class="form-group">
<input class="form-control placeholder-no-fix form-group" type="text" autocomplete="off" placeholder="Email" name="email" /> </div>
<div class="form-actions">
<button type="button" id="back-btn" class="btn green btn-outline">Back</button>
<button type="submit" class="btn btn-success uppercase pull-right">Submit</button>
</div>
</form>
<!-- END FORGOT PASSWORD FORM -->
</div>
<div class="login-footer">
<div class="row bs-reset">
<div class="col-xs-5 bs-reset"></div>
<div class="col-xs-7 bs-reset">
<div class="login-copyright text-right">
<p>Copyright © <a href="https://www.kancloud.cn/ifeng/tp5_1_code#/catalog">基于ThinkPHP5.1的各项后台小功能代码实现</a></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- END : LOGIN PAGE 5-1 -->
<!--[if lt IE 9]>
<script src="__STATIC__/assets/global/plugins/respond.min.js"></script>
<script src="__STATIC__/assets/global/plugins/excanvas.min.js"></script>
<script src="__STATIC__/assets/global/plugins/ie8.fix.min.js"></script>
<![endif]-->
<!-- BEGIN CORE PLUGINS -->
<script src="__STATIC__/assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script src="__STATIC__/assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<script src="__STATIC__/assets/global/plugins/js.cookie.min.js" type="text/javascript"></script>
<script src="__STATIC__/assets/global/plugins/jquery-slimscroll/jquery.slimscroll.min.js" type="text/javascript"></script>
<script src="__STATIC__/assets/global/plugins/jquery.blockui.min.js" type="text/javascript"></script>
<script src="__STATIC__/assets/global/plugins/bootstrap-switch/js/bootstrap-switch.min.js" type="text/javascript"></script>
<!-- END CORE PLUGINS -->
<!-- BEGIN PAGE LEVEL PLUGINS -->
<script src="__STATIC__/assets/global/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="__STATIC__/assets/global/plugins/jquery-validation/js/additional-methods.min.js" type="text/javascript"></script>
<script src="__STATIC__/assets/global/plugins/select2/js/select2.full.min.js" type="text/javascript"></script>
<script src="__STATIC__/assets/global/plugins/backstretch/jquery.backstretch.min.js" type="text/javascript"></script>
<!-- END PAGE LEVEL PLUGINS -->
<!-- BEGIN THEME GLOBAL SCRIPTS -->
<script src="__STATIC__/assets/global/scripts/app.min.js" type="text/javascript"></script>
<!-- END THEME GLOBAL SCRIPTS -->
<!-- BEGIN PAGE LEVEL SCRIPTS -->
<script src="__STATIC__/assets/pages/scripts/login-5.min.js" type="text/javascript"></script>
<!-- END PAGE LEVEL SCRIPTS -->
<!-- BEGIN THEME LAYOUT SCRIPTS -->
<!-- END THEME LAYOUT SCRIPTS -->
<script>
$(document).ready(function()
{
$('#clickmewow').click(function()
{
$('#radio1003').attr('checked', 'checked');
});
})
</script>
</body>
</html>
```
4、修改完之后,进入链接 ```http://tp5-1.com/login``` ,会发现,我们的基本样式有了,但是没有图片。
5、到了这里,我们需要修改,```login-5.min.js```这个文件,文件路径在:``` F:\www\TP5.1\1.0\public\static\assets\pages\scripts\login-5.min.js ```。
>[warning] (这是我这里的路径,每个人的路径都是不一样的,依照源码路径来看的)。
修改方法如下:
```
<!--一共三张图片,需要修改路径 -->
"assets/pages/img/login/bg1.jpg",
"assets/pages/img/login/bg2.jpg",
"assets/pages/img/login/bg3.jpg"
<!--在前面添加static/,即可 -->
"/static/assets/pages/img/login/bg1.jpg",
"/static/assets/pages/img/login/bg2.jpg",
"/static/assets/pages/img/login/bg3.jpg"
```
修改之后,刷新一下页面,你会发现页面已经焕然一新了:
![](https://box.kancloud.cn/dede0a1ea9ea76a2b1615864d764298b_1316x656.png)
>[info] 到了这里,我们的登录模板也就算是修改好了。
至于首页模板,我就弄了一个简单的页面,用于用户登录之后的展示。
页面代码如下:
```
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>欢迎来到首页</title>
</head>
<body>
<h1>{$Think.session.name},欢迎来到{$name}</h1>
<!-- 获得 session存的ID -->
你的ID是:{$Think.session.id} <br>
<!-- 获得session存储的用户名 -->
你的 用户名 是:{$Think.session.name} <br>
<a href="{:url('index/login/logout')}">安全退出</a>
</body>
</html>
```
页面效果如下:
![](https://box.kancloud.cn/c00475a233da7df1ce293fdd55fd3141_583x202.png)
>[info] 至此,登录页面和首页的页面也就制作好了,正常访问请下载源码查看演示效果,以上是主要代码。
- 序言
- 文档更新状态
- 错误提交
- 零、前期准备
- (1)PHP开发环境
- (2)PHP开发工具
- (3)数据库相关
- (4)ThinkPHP5.1完全开发手册
- (5)URL优化
- 一、用户登录
- (1)数据表设计
- (2)项目配置
- (3)MVC - V(视图)
- (4)MVC - M(模型)
- (5)MVC - C(控制器)
- (6)源码下载
- 二、无限极分类
- (1)数据表设计
- (2)项目配置
- (3)MVC - V(视图)
- (4)MVC - M(模型)
- (5)验证器
- (6)MVC - C(控制器)
- (7)源码下载
- 三、TP5.1开发API接口,实现前后端分离
- (1)数据表设计
- (2)项目配置
- (3)HTML纯静态页面
- (4)MVC - M(模型)
- (5)MVC - C(控制器)
- (6)源码下载
- 四、TP5调用 API 接口
- (1)项目配置
- (2)MVC - V(视图)
- (3)MVC - C(控制器)
- (4)源码下载
- 五、文章分页以及修改分页样式
- (1)数据表设计
- (2)项目配置
- (3)MVC - V(视图)
- (4)MVC - M(模型)
- (5)MVC - C(控制器)
- (6)自定义分页类
- (7)源码下载
- 六、修改默认跳转页面
- (1)数据表设计
- (2)项目配置
- (3)MVC - V(视图)
- (4)MVC - M(模型)
- (5)验证器
- (6)MVC - C(控制器)
- (7)自定义跳转页面
- (8)源码下载
- 七、整合markdown在线编辑器
- (1)数据表设计
- (2)项目配置
- (3)MVC - V(视图)
- (4)MVC - C(控制器)
- (5)源码下载
- 八、整合PHPExcel导入导出功能
- (1)数据表设计
- (2)项目配置
- (3)MVC - V(视图)
- (4)MVC - C(控制器)
- (5)源码下载
- 九、整合Echarts
- (1)数据表设计
- (2)项目配置
- (3)MVC - V(视图)
- (4)MVC - C(控制器)
- (5)源码下载
- 十、接入AntV G2(可视化图形)
- (1)数据表设计
- (2)项目配置
- (3)MVC - V(视图)
- (4)MVC - C(控制器)
- (5)源码下载