• 第3章业务功能开发(用户登录)


    1.客户需求(需求开发说明书)

    用户在登录页面,输入用户名和密码,点击"登录"按钮或者回车,完成用户登录的功能.

    *用户名和密码不能为空

    *用户名或者密码错误,用户已过期,用户状态被锁定,ip受限 都不能登录成功

    *登录成功之后,所有业务页面显示当前用户的名称

    *实现10天记住密码

    *登录成功之后,跳转到业务主页面

    *登录失败,页面不跳转,提示信息

    2.首先明确需求,规划程序访问流程,画好UML顺序图再编写代码,方便以后对项目进行管理,同时也是开发规范的硬性要求

    3.前面已经使用mybatis逆向工程创建了UserMapper文件,自动创建的文件中已经包含了增删改查等基本操作语句,为了理解开发的流程,再自己写一个查询用户的语句添加进去。

    mapper文件目录位置

    UserMapper接口

    1. package com.it.crm.settings.mapper;
    2. import com.it.crm.settings.entity.User;
    3. import java.util.Map;
    4. public interface UserMapper {
    5. /**
    6. * This method was generated by MyBatis Generator.
    7. * This method corresponds to the database table tbl_user
    8. *
    9. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    10. */
    11. int deleteByPrimaryKey(String id);
    12. /**
    13. * This method was generated by MyBatis Generator.
    14. * This method corresponds to the database table tbl_user
    15. *
    16. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    17. */
    18. int insert(User record);
    19. /**
    20. * This method was generated by MyBatis Generator.
    21. * This method corresponds to the database table tbl_user
    22. *
    23. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    24. */
    25. int insertSelective(User record);
    26. /**
    27. * This method was generated by MyBatis Generator.
    28. * This method corresponds to the database table tbl_user
    29. *
    30. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    31. */
    32. User selectByPrimaryKey(String id);
    33. /**
    34. * This method was generated by MyBatis Generator.
    35. * This method corresponds to the database table tbl_user
    36. *
    37. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    38. */
    39. int updateByPrimaryKeySelective(User record);
    40. /**
    41. * This method was generated by MyBatis Generator.
    42. * This method corresponds to the database table tbl_user
    43. *
    44. * @mbggenerated Wed Jun 29 12:20:46 CST 2022
    45. */
    46. int updateByPrimaryKey(User record);
    47. /*
    48. 根据账号和密码查询用户
    49. */
    50. User selectUserByActAndPwd(Map<String,Object> map);
    51. }

    UserMapper.xml文件

    1. <?xml version="1.0" encoding="UTF-8" ?>
    2. <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
    3. <mapper namespace="com.it.crm.settings.mapper.UserMapper" >
    4. <resultMap id="BaseResultMap" type="com.it.crm.settings.entity.User" >
    5. <!--
    6. WARNING - @mbggenerated
    7. This element is automatically generated by MyBatis Generator, do not modify.
    8. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    9. -->
    10. <id column="id" property="id" jdbcType="CHAR" />
    11. <result column="login_act" property="loginAct" jdbcType="VARCHAR" />
    12. <result column="name" property="name" jdbcType="VARCHAR" />
    13. <result column="login_pwd" property="loginPwd" jdbcType="VARCHAR" />
    14. <result column="email" property="email" jdbcType="VARCHAR" />
    15. <result column="expire_time" property="expireTime" jdbcType="CHAR" />
    16. <result column="lock_state" property="lockState" jdbcType="CHAR" />
    17. <result column="deptno" property="deptno" jdbcType="CHAR" />
    18. <result column="allow_ips" property="allowIps" jdbcType="VARCHAR" />
    19. <result column="createTime" property="createtime" jdbcType="CHAR" />
    20. <result column="create_by" property="createBy" jdbcType="VARCHAR" />
    21. <result column="edit_time" property="editTime" jdbcType="CHAR" />
    22. <result column="edit_by" property="editBy" jdbcType="VARCHAR" />
    23. </resultMap>
    24. <sql id="Base_Column_List" >
    25. <!--
    26. WARNING - @mbggenerated
    27. This element is automatically generated by MyBatis Generator, do not modify.
    28. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    29. -->
    30. id, login_act, name, login_pwd, email, expire_time, lock_state, deptno, allow_ips,
    31. createTime, create_by, edit_time, edit_by
    32. </sql>
    33. <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    34. <!--
    35. WARNING - @mbggenerated
    36. This element is automatically generated by MyBatis Generator, do not modify.
    37. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    38. -->
    39. select
    40. <include refid="Base_Column_List" />
    41. from tbl_user
    42. where id = #{id,jdbcType=CHAR}
    43. </select>
    44. <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    45. <!--
    46. WARNING - @mbggenerated
    47. This element is automatically generated by MyBatis Generator, do not modify.
    48. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    49. -->
    50. delete from tbl_user
    51. where id = #{id,jdbcType=CHAR}
    52. </delete>
    53. <insert id="insert" parameterType="com.it.crm.settings.entity.User" >
    54. <!--
    55. WARNING - @mbggenerated
    56. This element is automatically generated by MyBatis Generator, do not modify.
    57. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    58. -->
    59. insert into tbl_user (id, login_act, name,
    60. login_pwd, email, expire_time,
    61. lock_state, deptno, allow_ips,
    62. createTime, create_by, edit_time,
    63. edit_by)
    64. values (#{id,jdbcType=CHAR}, #{loginAct,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR},
    65. #{loginPwd,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{expireTime,jdbcType=CHAR},
    66. #{lockState,jdbcType=CHAR}, #{deptno,jdbcType=CHAR}, #{allowIps,jdbcType=VARCHAR},
    67. #{createtime,jdbcType=CHAR}, #{createBy,jdbcType=VARCHAR}, #{editTime,jdbcType=CHAR},
    68. #{editBy,jdbcType=VARCHAR})
    69. </insert>
    70. <insert id="insertSelective" parameterType="com.it.crm.settings.entity.User" >
    71. <!--
    72. WARNING - @mbggenerated
    73. This element is automatically generated by MyBatis Generator, do not modify.
    74. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    75. -->
    76. insert into tbl_user
    77. <trim prefix="(" suffix=")" suffixOverrides="," >
    78. <if test="id != null" >
    79. id,
    80. </if>
    81. <if test="loginAct != null" >
    82. login_act,
    83. </if>
    84. <if test="name != null" >
    85. name,
    86. </if>
    87. <if test="loginPwd != null" >
    88. login_pwd,
    89. </if>
    90. <if test="email != null" >
    91. email,
    92. </if>
    93. <if test="expireTime != null" >
    94. expire_time,
    95. </if>
    96. <if test="lockState != null" >
    97. lock_state,
    98. </if>
    99. <if test="deptno != null" >
    100. deptno,
    101. </if>
    102. <if test="allowIps != null" >
    103. allow_ips,
    104. </if>
    105. <if test="createtime != null" >
    106. createTime,
    107. </if>
    108. <if test="createBy != null" >
    109. create_by,
    110. </if>
    111. <if test="editTime != null" >
    112. edit_time,
    113. </if>
    114. <if test="editBy != null" >
    115. edit_by,
    116. </if>
    117. </trim>
    118. <trim prefix="values (" suffix=")" suffixOverrides="," >
    119. <if test="id != null" >
    120. #{id,jdbcType=CHAR},
    121. </if>
    122. <if test="loginAct != null" >
    123. #{loginAct,jdbcType=VARCHAR},
    124. </if>
    125. <if test="name != null" >
    126. #{name,jdbcType=VARCHAR},
    127. </if>
    128. <if test="loginPwd != null" >
    129. #{loginPwd,jdbcType=VARCHAR},
    130. </if>
    131. <if test="email != null" >
    132. #{email,jdbcType=VARCHAR},
    133. </if>
    134. <if test="expireTime != null" >
    135. #{expireTime,jdbcType=CHAR},
    136. </if>
    137. <if test="lockState != null" >
    138. #{lockState,jdbcType=CHAR},
    139. </if>
    140. <if test="deptno != null" >
    141. #{deptno,jdbcType=CHAR},
    142. </if>
    143. <if test="allowIps != null" >
    144. #{allowIps,jdbcType=VARCHAR},
    145. </if>
    146. <if test="createtime != null" >
    147. #{createtime,jdbcType=CHAR},
    148. </if>
    149. <if test="createBy != null" >
    150. #{createBy,jdbcType=VARCHAR},
    151. </if>
    152. <if test="editTime != null" >
    153. #{editTime,jdbcType=CHAR},
    154. </if>
    155. <if test="editBy != null" >
    156. #{editBy,jdbcType=VARCHAR},
    157. </if>
    158. </trim>
    159. </insert>
    160. <update id="updateByPrimaryKeySelective" parameterType="com.it.crm.settings.entity.User" >
    161. <!--
    162. WARNING - @mbggenerated
    163. This element is automatically generated by MyBatis Generator, do not modify.
    164. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    165. -->
    166. update tbl_user
    167. <set >
    168. <if test="loginAct != null" >
    169. login_act = #{loginAct,jdbcType=VARCHAR},
    170. </if>
    171. <if test="name != null" >
    172. name = #{name,jdbcType=VARCHAR},
    173. </if>
    174. <if test="loginPwd != null" >
    175. login_pwd = #{loginPwd,jdbcType=VARCHAR},
    176. </if>
    177. <if test="email != null" >
    178. email = #{email,jdbcType=VARCHAR},
    179. </if>
    180. <if test="expireTime != null" >
    181. expire_time = #{expireTime,jdbcType=CHAR},
    182. </if>
    183. <if test="lockState != null" >
    184. lock_state = #{lockState,jdbcType=CHAR},
    185. </if>
    186. <if test="deptno != null" >
    187. deptno = #{deptno,jdbcType=CHAR},
    188. </if>
    189. <if test="allowIps != null" >
    190. allow_ips = #{allowIps,jdbcType=VARCHAR},
    191. </if>
    192. <if test="createtime != null" >
    193. createTime = #{createtime,jdbcType=CHAR},
    194. </if>
    195. <if test="createBy != null" >
    196. create_by = #{createBy,jdbcType=VARCHAR},
    197. </if>
    198. <if test="editTime != null" >
    199. edit_time = #{editTime,jdbcType=CHAR},
    200. </if>
    201. <if test="editBy != null" >
    202. edit_by = #{editBy,jdbcType=VARCHAR},
    203. </if>
    204. </set>
    205. where id = #{id,jdbcType=CHAR}
    206. </update>
    207. <update id="updateByPrimaryKey" parameterType="com.it.crm.settings.entity.User" >
    208. <!--
    209. WARNING - @mbggenerated
    210. This element is automatically generated by MyBatis Generator, do not modify.
    211. This element was generated on Wed Jun 29 12:20:46 CST 2022.
    212. -->
    213. update tbl_user
    214. set login_act = #{loginAct,jdbcType=VARCHAR},
    215. name = #{name,jdbcType=VARCHAR},
    216. login_pwd = #{loginPwd,jdbcType=VARCHAR},
    217. email = #{email,jdbcType=VARCHAR},
    218. expire_time = #{expireTime,jdbcType=CHAR},
    219. lock_state = #{lockState,jdbcType=CHAR},
    220. deptno = #{deptno,jdbcType=CHAR},
    221. allow_ips = #{allowIps,jdbcType=VARCHAR},
    222. createTime = #{createtime,jdbcType=CHAR},
    223. create_by = #{createBy,jdbcType=VARCHAR},
    224. edit_time = #{editTime,jdbcType=CHAR},
    225. edit_by = #{editBy,jdbcType=VARCHAR}
    226. where id = #{id,jdbcType=CHAR}
    227. </update>
    228. <select id="selectUserByActAndPwd" parameterType="map" resultMap="BaseResultMap">
    229. select
    230. <include refid="Base_Column_List"/>
    231. from tbl_user
    232. where login_act=#{loginAct} and login_pwd=#{loginPwd}
    233. </select>
    234. </mapper>

    4.创建service层文件

    UserService接口

    1. package com.it.crm.settings.service;
    2. import com.it.crm.settings.entity.User;
    3. import java.util.Map;
    4. public interface UserService {
    5. User queryUserByActAndPwd(Map<String,Object> map);
    6. }

    UserServiceImpl类

    1. package com.it.crm.settings.service.impl;
    2. import com.it.crm.settings.entity.User;
    3. import com.it.crm.settings.mapper.UserMapper;
    4. import com.it.crm.settings.service.UserService;
    5. import org.springframework.beans.factory.annotation.Autowired;
    6. import org.springframework.stereotype.Service;
    7. import java.util.Map;
    8. @Service("userService")
    9. public class UserServiceImpl implements UserService {
    10. @Autowired
    11. private UserMapper userMapper;
    12. @Override
    13. public User queryUserByActAndPwd(Map<String, Object> map) {
    14. return userMapper.selectUserByActAndPwd(map);
    15. }
    16. }

    5.创建web层下的controller层

    UserController类

    1. package com.it.crm.settings.web.controller;
    2. import com.it.crm.commons.contants.Contants;
    3. import com.it.crm.commons.entity.ReturnObject;
    4. import com.it.crm.commons.utils.DateUtils;
    5. import com.it.crm.settings.entity.User;
    6. import com.it.crm.settings.service.UserService;
    7. import org.springframework.beans.factory.annotation.Autowired;
    8. import org.springframework.http.HttpRequest;
    9. import org.springframework.stereotype.Controller;
    10. import org.springframework.web.bind.annotation.RequestMapping;
    11. import org.springframework.web.bind.annotation.ResponseBody;
    12. import javax.servlet.http.HttpServletRequest;
    13. import javax.servlet.http.HttpSession;
    14. import java.text.SimpleDateFormat;
    15. import java.util.Date;
    16. import java.util.HashMap;
    17. import java.util.Map;
    18. @Controller
    19. public class UserController {
    20. @Autowired
    21. private UserService userService;
    22. @RequestMapping(value = "/settings/qx/user/toLogin.do")
    23. public String toLogin(){
    24. return "settings/qx/user/login";
    25. }
    26. @RequestMapping(value = "/settings/qx/user/login.do")
    27. @ResponseBody
    28. public Object login(String loginAct, String loginPwd, String isRemPwd, HttpServletRequest request, HttpSession session){
    29. //封装参数
    30. Map<String,Object> map=new HashMap<>();
    31. map.put("loginAct",loginAct);
    32. map.put("loginPwd",loginPwd);
    33. map.put("isRemPwd",isRemPwd);
    34. //调用service层方法,查询用户
    35. User user = userService.queryUserByActAndPwd(map);
    36. //根据查询结果生成响应信息
    37. ReturnObject returnObject=new ReturnObject();
    38. if (user==null){
    39. //登录失败,用户名或密码错误
    40. returnObject.setCode(Contants.RETURN_OBJECT_CODE_FAIL);
    41. returnObject.setMessage("用户名或密码错误");
    42. }else {//进一步判断账号是否合法
    43. if (DateUtils.formateDateTime(new Date()).compareTo(user.getExpireTime())>0){
    44. //登录失败,账号已过期
    45. returnObject.setCode(Contants.RETURN_OBJECT_CODE_FAIL);
    46. returnObject.setMessage("账号已经过期");
    47. }else if ("0".equals(user.getLockState())){
    48. //登录失败,状态被锁定
    49. returnObject.setCode(Contants.RETURN_OBJECT_CODE_FAIL);
    50. returnObject.setMessage("状态被锁定");
    51. }else if (!user.getAllowIps().contains(request.getRemoteAddr())){
    52. //登录失败,ip受限
    53. returnObject.setCode(Contants.RETURN_OBJECT_CODE_FAIL);
    54. returnObject.setMessage("ip受限");
    55. }else{
    56. //登录成功
    57. returnObject.setCode(Contants.RETURN_OBJECT_CODE_SUCCESS);
    58. //把user保存到session中
    59. session.setAttribute(Contants.SESSION_USER,user);
    60. }
    61. }
    62. return returnObject;
    63. }
    64. }

    UserController类调用了该项目中的通用层commons下多个类

    如下所示

     Contants类

    把条件常量用封装好的类中的方法表示,有利于后期维护时,更改条件值时只更新该处,不需要更改整个项目

    1. package com.it.crm.commons.contants;
    2. //定义常量类,有利于后期维护
    3. public class Contants {
    4. //保存ReturnObject类中的Code值
    5. public static final String RETURN_OBJECT_CODE_SUCCESS="1";//成功
    6. public static final String RETURN_OBJECT_CODE_FAIL="0";//失败
    7. //保存session中当前用户的key
    8. public static final String SESSION_USER="sessionUser";
    9. }

     ReturnObject类

    1. package com.it.crm.commons.entity;
    2. public class ReturnObject {
    3. private String code;//处理成功或者失败的标记,1:成功,0:失败
    4. private String message;//提示信息
    5. private Object returnData;//返回其他数据
    6. public String getCode() {
    7. return code;
    8. }
    9. public void setCode(String code) {
    10. this.code = code;
    11. }
    12. public String getMessage() {
    13. return message;
    14. }
    15. public void setMessage(String message) {
    16. this.message = message;
    17. }
    18. public Object getReturnData() {
    19. return returnData;
    20. }
    21. public void setReturnData(Object returnData) {
    22. this.returnData = returnData;
    23. }
    24. @Override
    25. public String toString() {
    26. return "ReturnObject{" +
    27. "code='" + code + '\'' +
    28. ", message='" + message + '\'' +
    29. ", returnData=" + returnData +
    30. '}';
    31. }
    32. }

    DateUtils类(时间工具类)

    1. package com.it.crm.commons.utils;
    2. import java.text.SimpleDateFormat;
    3. import java.util.Date;
    4. //对Date类型数据进行处理的工具类
    5. public class DateUtils {
    6. //对指定的date对象进行格式化
    7. public static String formateDateTime(Date date){
    8. SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    9. String format = sdf.format(date);
    10. return format;
    11. }
    12. //对指定的date对象进行格式化
    13. public static String formateDate(Date date){
    14. SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
    15. String format = sdf.format(date);
    16. return format;
    17. }
    18. //对指定的date对象进行格式化
    19. public static String formateTime(Date date){
    20. SimpleDateFormat sdf=new SimpleDateFormat("HH:mm:ss");
    21. String format = sdf.format(date);
    22. return format;
    23. }
    24. }

    6.创建webapp下的登录页面

    login.jsp

    使用ajax异步传输判断,如果账号密码为空直接弹出提示框,不为空时进入UserController类 进行账号密码的各种验证,全部正确跳转到WorkBenchIndexContoller类,不正确时在登录页面上显示错误信息。

    1. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    2. <%
    3. String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
    4. %>
    5. <html>
    6. <head>
    7. <meta charset="UTF-8">
    8. <base href="<%=basePath%>">
    9. <link href="jquery/bootstrap_3.3.0/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
    10. <script type="text/javascript" src="jquery/jquery-1.11.1-min.js"></script>
    11. <script type="text/javascript" src="jquery/bootstrap_3.3.0/js/bootstrap.min.js"></script>
    12. <script type="text/javascript">
    13. $(function () {
    14. //给登录按钮添加单击事件
    15. $("#loginBtn").click(function () {
    16. //收集参数
    17. var loginAct=$.trim($("#loginAct").val());
    18. var loginPwd=$.trim($("#loginPwd").val());
    19. var isRemPwd=$("#isRemPwd").prop("checked");
    20. //表单验证
    21. if (loginAct==""){
    22. alert("用户名不能为空!");
    23. return;
    24. }if (loginPwd==""){
    25. alert("密码不能为空!");
    26. return;
    27. }
    28. //点击登录后显示正在验证
    29. $("#msg").html("正在努力验证中。。。")
    30. //发送请求
    31. $.ajax({
    32. url:'settings/qx/user/login.do',
    33. data:{
    34. loginAct:loginAct,
    35. loginPwd:loginPwd,
    36. isRemPwd:isRemPwd
    37. },
    38. type:'post',
    39. dataType:'json',
    40. success:function (data) {
    41. if (data.code=="1"){
    42. //登录成功,跳转到业务的主页面
    43. window.location.href="workbench/index.do";
    44. }else {
    45. //登录失败,显示提示信息
    46. $("#msg").html(data.message);
    47. }
    48. }
    49. });
    50. });
    51. });
    52. </script>
    53. </head>
    54. <body>
    55. <div style="position: absolute; top: 0px; left: 0px; width: 60%;">
    56. <img src="image/IMG_7114.JPG" style="width: 100%; height: 90%; position: relative; top: 50px;">
    57. </div>
    58. <div id="top" style="height: 50px; background-color: #3C3C3C; width: 100%;">
    59. <div style="position: absolute; top: 5px; left: 0px; font-size: 30px; font-weight: 400; color: white; font-family: 'times new roman'">CRM &nbsp;<span style="font-size: 12px;">客户关系管理系统</span></div>
    60. </div>
    61. <div style="position: absolute; top: 120px; right: 100px;width:450px;height:400px;border:1px solid #D5D5D5">
    62. <div style="position: absolute; top: 0px; right: 60px;">
    63. <div class="page-header">
    64. <h1>登录</h1>
    65. </div>
    66. <form action="workbench/index.html" class="form-horizontal" role="form">
    67. <div class="form-group form-group-lg">
    68. <div style="width: 350px;">
    69. <input class="form-control" id="loginAct" type="text" placeholder="用户名">
    70. </div>
    71. <div style="width: 350px; position: relative;top: 20px;">
    72. <input class="form-control" id="loginPwd" type="password" placeholder="密码">
    73. </div>
    74. <div class="checkbox" style="position: relative;top: 30px; left: 10px;">
    75. <label>
    76. <input type="checkbox" id="isRemPwd"> 十天内免登录
    77. </label>
    78. &nbsp;&nbsp;
    79. <span id="msg" style="color: red;"></span>
    80. </div>
    81. <button type="button" id="loginBtn" class="btn btn-primary btn-lg btn-block" style="width: 350px; position: relative;top: 45px;">登录</button>
    82. </div>
    83. </form>
    84. </div>
    85. </div>
    86. </body>
    87. </html>

    7.创建workbench包下的web层

     WorkBenchIndexContoller类

    登录成功时跳转到该类

    1. package com.it.crm.workbench.web.controller;
    2. import org.springframework.stereotype.Controller;
    3. import org.springframework.web.bind.annotation.RequestMapping;
    4. @Controller
    5. public class WorkBenchIndexContoller {
    6. @RequestMapping(value = "/workbench/index.do")
    7. public String index(){
    8. //跳转到业务主页面
    9. return "workbench/index";
    10. }
    11. }

     8.创建工作台首页

     index.jsp

    1. <%@ page contentType="text/html;charset=UTF-8" language="java" %>
    2. <%
    3. String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
    4. %>
    5. <html>
    6. <head>
    7. <meta charset="UTF-8">
    8. <base href="<%=basePath%>">
    9. <link href="jquery/bootstrap_3.3.0/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
    10. <script type="text/javascript" src="jquery/jquery-1.11.1-min.js"></script>
    11. <script type="text/javascript" src="jquery/bootstrap_3.3.0/js/bootstrap.min.js"></script>
    12. <script type="text/javascript">
    13. //页面加载完毕
    14. $(function(){
    15. //导航中所有文本颜色为黑色
    16. $(".liClass > a").css("color" , "black");
    17. //默认选中导航菜单中的第一个菜单项
    18. $(".liClass:first").addClass("active");
    19. //第一个菜单项的文字变成白色
    20. $(".liClass:first > a").css("color" , "white");
    21. //给所有的菜单项注册鼠标单击事件
    22. $(".liClass").click(function(){
    23. //移除所有菜单项的激活状态
    24. $(".liClass").removeClass("active");
    25. //导航中所有文本颜色为黑色
    26. $(".liClass > a").css("color" , "black");
    27. //当前项目被选中
    28. $(this).addClass("active");
    29. //当前项目颜色变成白色
    30. $(this).children("a").css("color","white");
    31. });
    32. window.open("main/index.html","workareaFrame");
    33. });
    34. </script>
    35. </head>
    36. <body>
    37. <!-- 我的资料 -->
    38. <div class="modal fade" id="myInformation" role="dialog">
    39. <div class="modal-dialog" role="document" style="width: 30%;">
    40. <div class="modal-content">
    41. <div class="modal-header">
    42. <button type="button" class="close" data-dismiss="modal">
    43. <span aria-hidden="true">×</span>
    44. </button>
    45. <h4 class="modal-title">我的资料</h4>
    46. </div>
    47. <div class="modal-body">
    48. <div style="position: relative; left: 40px;">
    49. 姓名:<b>张三</b><br><br>
    50. 登录帐号:<b>zhangsan</b><br><br>
    51. 组织机构:<b>1005,市场部,二级部门</b><br><br>
    52. 邮箱:<b>zhangsan@bjpowernode.com</b><br><br>
    53. 失效时间:<b>2017-02-14 10:10:10</b><br><br>
    54. 允许访问IP:<b>127.0.0.1,192.168.100.2</b>
    55. </div>
    56. </div>
    57. <div class="modal-footer">
    58. <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
    59. </div>
    60. </div>
    61. </div>
    62. </div>
    63. <!-- 修改密码的模态窗口 -->
    64. <div class="modal fade" id="editPwdModal" role="dialog">
    65. <div class="modal-dialog" role="document" style="width: 70%;">
    66. <div class="modal-content">
    67. <div class="modal-header">
    68. <button type="button" class="close" data-dismiss="modal">
    69. <span aria-hidden="true">×</span>
    70. </button>
    71. <h4 class="modal-title">修改密码</h4>
    72. </div>
    73. <div class="modal-body">
    74. <form class="form-horizontal" role="form">
    75. <div class="form-group">
    76. <label for="oldPwd" class="col-sm-2 control-label">原密码</label>
    77. <div class="col-sm-10" style="width: 300px;">
    78. <input type="text" class="form-control" id="oldPwd" style="width: 200%;">
    79. </div>
    80. </div>
    81. <div class="form-group">
    82. <label for="newPwd" class="col-sm-2 control-label">新密码</label>
    83. <div class="col-sm-10" style="width: 300px;">
    84. <input type="text" class="form-control" id="newPwd" style="width: 200%;">
    85. </div>
    86. </div>
    87. <div class="form-group">
    88. <label for="confirmPwd" class="col-sm-2 control-label">确认密码</label>
    89. <div class="col-sm-10" style="width: 300px;">
    90. <input type="text" class="form-control" id="confirmPwd" style="width: 200%;">
    91. </div>
    92. </div>
    93. </form>
    94. </div>
    95. <div class="modal-footer">
    96. <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
    97. <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="window.location.href='login.html';">更新</button>
    98. </div>
    99. </div>
    100. </div>
    101. </div>
    102. <!-- 退出系统的模态窗口 -->
    103. <div class="modal fade" id="exitModal" role="dialog">
    104. <div class="modal-dialog" role="document" style="width: 30%;">
    105. <div class="modal-content">
    106. <div class="modal-header">
    107. <button type="button" class="close" data-dismiss="modal">
    108. <span aria-hidden="true">×</span>
    109. </button>
    110. <h4 class="modal-title">离开</h4>
    111. </div>
    112. <div class="modal-body">
    113. <p>您确定要退出系统吗?</p>
    114. </div>
    115. <div class="modal-footer">
    116. <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
    117. <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="window.location.href='login.html';">确定</button>
    118. </div>
    119. </div>
    120. </div>
    121. </div>
    122. <!-- 顶部 -->
    123. <div id="top" style="height: 50px; background-color: #3C3C3C; width: 100%;">
    124. <div style="position: absolute; top: 5px; left: 0px; font-size: 30px; font-weight: 400; color: white; font-family: 'times new roman'">CRM &nbsp;<span style="font-size: 12px;">客户关系管理系统(LJL)</span></div>
    125. <div style="position: absolute; top: 15px; right: 15px;">
    126. <ul>
    127. <li class="dropdown user-dropdown">
    128. <a href="javascript:void(0)" style="text-decoration: none; color: white;" class="dropdown-toggle" data-toggle="dropdown">
    129. <span class="glyphicon glyphicon-user"></span>${sessionUser.name}<span class="caret"></span>
    130. </a>
    131. <ul class="dropdown-menu">
    132. <li><a href="settings/index.html"><span class="glyphicon glyphicon-wrench"></span> 系统设置</a></li>
    133. <li><a href="javascript:void(0)" data-toggle="modal" data-target="#myInformation"><span class="glyphicon glyphicon-file"></span> 我的资料</a></li>
    134. <li><a href="javascript:void(0)" data-toggle="modal" data-target="#editPwdModal"><span class="glyphicon glyphicon-edit"></span> 修改密码</a></li>
    135. <li><a href="javascript:void(0);" data-toggle="modal" data-target="#exitModal"><span class="glyphicon glyphicon-off"></span> 退出</a></li>
    136. </ul>
    137. </li>
    138. </ul>
    139. </div>
    140. </div>
    141. <!-- 中间 -->
    142. <div id="center" style="position: absolute;top: 50px; bottom: 30px; left: 0px; right: 0px;">
    143. <!-- 导航 -->
    144. <div id="navigation" style="left: 0px; width: 18%; position: relative; height: 100%; overflow:auto;">
    145. <ul id="no1" class="nav nav-pills nav-stacked">
    146. <li class="liClass"><a href="main/index.html" target="workareaFrame"><span class="glyphicon glyphicon-home"></span> 工作台</a></li>
    147. <li class="liClass"><a href="javascript:void(0);" target="workareaFrame"><span class="glyphicon glyphicon-tag"></span> 动态</a></li>
    148. <li class="liClass"><a href="javascript:void(0);" target="workareaFrame"><span class="glyphicon glyphicon-time"></span> 审批</a></li>
    149. <li class="liClass"><a href="javascript:void(0);" target="workareaFrame"><span class="glyphicon glyphicon-user"></span> 客户公海</a></li>
    150. <li class="liClass"><a href="activity/index.html" target="workareaFrame"><span class="glyphicon glyphicon-play-circle"></span> 市场活动</a></li>
    151. <li class="liClass"><a href="clue/index.html" target="workareaFrame"><span class="glyphicon glyphicon-search"></span> 线索(潜在客户)</a></li>
    152. <li class="liClass"><a href="customer/index.html" target="workareaFrame"><span class="glyphicon glyphicon-user"></span> 客户</a></li>
    153. <li class="liClass"><a href="contacts/index.html" target="workareaFrame"><span class="glyphicon glyphicon-earphone"></span> 联系人</a></li>
    154. <li class="liClass"><a href="transaction/index.html" target="workareaFrame"><span class="glyphicon glyphicon-usd"></span> 交易(商机)</a></li>
    155. <li class="liClass"><a href="visit/index.html" target="workareaFrame"><span class="glyphicon glyphicon-phone-alt"></span> 售后回访</a></li>
    156. <li class="liClass">
    157. <a href="#no2" class="collapsed" data-toggle="collapse"><span class="glyphicon glyphicon-stats"></span> 统计图表</a>
    158. <ul id="no2" class="nav nav-pills nav-stacked collapse">
    159. <li class="liClass"><a href="chart/activity/index.html" target="workareaFrame">&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-chevron-right"></span> 市场活动统计图表</a></li>
    160. <li class="liClass"><a href="chart/clue/index.html" target="workareaFrame">&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-chevron-right"></span> 线索统计图表</a></li>
    161. <li class="liClass"><a href="chart/customerAndContacts/index.html" target="workareaFrame">&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-chevron-right"></span> 客户和联系人统计图表</a></li>
    162. <li class="liClass"><a href="chart/transaction/index.html" target="workareaFrame">&nbsp;&nbsp;&nbsp;<span class="glyphicon glyphicon-chevron-right"></span> 交易统计图表</a></li>
    163. </ul>
    164. </li>
    165. <li class="liClass"><a href="javascript:void(0);" target="workareaFrame"><span class="glyphicon glyphicon-file"></span> 报表</a></li>
    166. <li class="liClass"><a href="javascript:void(0);" target="workareaFrame"><span class="glyphicon glyphicon-shopping-cart"></span> 销售订单</a></li>
    167. <li class="liClass"><a href="javascript:void(0);" target="workareaFrame"><span class="glyphicon glyphicon-send"></span> 发货单</a></li>
    168. <li class="liClass"><a href="javascript:void(0);" target="workareaFrame"><span class="glyphicon glyphicon-earphone"></span> 跟进</a></li>
    169. <li class="liClass"><a href="javascript:void(0);" target="workareaFrame"><span class="glyphicon glyphicon-leaf"></span> 产品</a></li>
    170. <li class="liClass"><a href="javascript:void(0);" target="workareaFrame"><span class="glyphicon glyphicon-usd"></span> 报价</a></li>
    171. </ul>
    172. <!-- 分割线 -->
    173. <div id="divider1" style="position: absolute; top : 0px; right: 0px; width: 1px; height: 100% ; background-color: #B3B3B3;"></div>
    174. </div>
    175. <!-- 工作区 -->
    176. <div id="workarea" style="position: absolute; top : 0px; left: 18%; width: 82%; height: 100%;">
    177. <iframe style="border-width: 0px; width: 100%; height: 100%;" name="workareaFrame"></iframe>
    178. </div>
    179. </div>
    180. <div id="divider2" style="height: 1px; width: 100%; position: absolute;bottom: 30px; background-color: #B3B3B3;"></div>
    181. <!-- 底部 -->
    182. <div id="down" style="height: 30px; width: 100%; position: absolute;bottom: 0px;"></div>
    183. </body>
    184. </html>

    项目效果展示

     直接点击登录

    输入用户名后点击登录

     全部输入后

     输入正确的用户名和密码

    数据库用户表信息如下所示

    输入李四信息登录

    输入张三信息登录

    已经进入到了工作台主页面

  • 相关阅读:
    NEXUS 4 通过superU实现root
    Windows本地安装nginx,修改端口号,跨域配置
    这18个网站能让你的页面背景炫酷起来
    C++_面向对象的引入
    供热管网安全运行监测,提升供热管网安全性能
    解决Flume数据采集中出现的几个问题
    node笔记_koa框架是什么?
    【Unity精华一记】特殊文件夹
    面试官:说说JVM内存整体结构?
    05 常见微服务项目结构
  • 原文地址:https://blog.csdn.net/weixin_59334478/article/details/125600525