



- //取值
- var confirmTj = true;
- var cardNum = $('#cardNum').val();
- var name = $('#name').val();
- // alert(name);
- var sex = $("input[name='sex']:checked").val();
- // alert(sex);
- var tel = $('#tel').val();
- var address = $('#address').val();
- //非空提示的消除
- $("input:radio[name='sex']").change(function () {
- $('#sexWarning').text("");
- });
- $('#cardNum').change(function () {
- $('#cardNumWarning').text("");
- })
- $('#name').change(function () {
- $('#nameWarning').text("");
- })
- $('#tel').change(function () {
- $('#telWarning').text("");
- })
- $('#address').change(function () {
- $('#addressWarning').text("");
- })
- "1.0" encoding="UTF-8" ?>
- mapper
- PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
- "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
- <mapper namespace="com.pro.Dao.AddCardDao">
- <select id="selectCardNum" parameterType="Card" resultType="Card">
- select * from card where cardNum=#{cardNum}
- select>
- <insert id="insertCard" parameterType="Card">
- insert into card set cardNum=#{cardNum},name=#{name},tel=#{tel},sex=#{sex},address=#{address},vip=#{vip}
- insert>
- mapper>
- package com.pro.Dao;
-
- import com.pro.domain.Card;
-
- public interface AddCardDao {
- Card selectCardNum(Card card);
-
- void insertCard(Card card);
- }
- package com.pro.service;
-
- import com.pro.Dao.AddCardDao;
- import com.pro.domain.Card;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
-
- @Service
- public class AddCardServiceImpl implements AddCardService {
- @Autowired
- private AddCardDao addCardDao;
-
- @Override
- public String checkCardNum(Card card) {
- Card card1 = addCardDao.selectCardNum(card);
- String mes = "该卡号已存在!";
- if(card1 == null){
- mes = "";
- }
- System.out.println(mes);
- return mes;
- }
-
- @Override
- public String saveCard(Card card) {
- addCardDao.insertCard(card);
- String mes = "恭喜您,办理成功!";
- return mes;
- }
- }
- package com.pro.Controller;
-
- import com.pro.domain.Card;
- import com.pro.service.AddCardService;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Controller;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.ResponseBody;
-
- @Controller
- public class AddCardController {
-
- @Autowired
- private AddCardService addCardService;
-
- //点击办卡,跳转到办卡界面(李俊)
- @RequestMapping("/ljAddCard")
- public String ljAddCard(){
- return "addCard";
- }
-
- //查询卡号是否已经存在(李俊)
- @RequestMapping("/ljCheckCardNum")
- @ResponseBody
- public String ljCheckCardNum(Card card){
- System.out.println(card);
- String mes = addCardService.checkCardNum(card);
- System.out.println(mes);
- return mes;
- }
-
- //办卡(李俊)
- @RequestMapping("/ljToAddCard")
- @ResponseBody
- public String ljToAddCard(Card card){
- String mes = addCardService.checkCardNum(card);
- if(mes.length() > 0){
- return "卡号已被占用,请重新输入!";
- }else{
- String mes1 = addCardService.saveCard(card);
- return mes1;
- }
- }
- }
- <%--
- Created by IntelliJ IDEA.
- User: Administrator
- Date: 2022/8/27 0027
- Time: 10:46
- To change this template use File | Settings | File Templates.
- --%>
- <%@ page contentType="text/html;charset=UTF-8" language="java" %>
- <link href="css/bootstrap.css" rel="stylesheet">
- <script src="js/jquery-3.6.0.js">script>
- <script src="js/proper.mini.js">script>
- <script src="js/bootstrap.js">script>
- <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
- <html>
- <head>
- <title>Titletitle>
- <style>
-
- #father {
- position: absolute;
- left: 5%;
- top: 5%;
- height: 200px;
- /*background-color: black;*/
- /*scale 缩放*/
- transform: scale(1);
- /*播放,绑定动画 */
- animation: beat 0.5s linear infinite alternate;
- }
-
- #father1 {
- position: absolute;
- right: 5%;
- top: 5%;
- height: 200px;
- /*background-color: black;*/
- /*scale 缩放*/
- transform: scale(1);
- /*播放,绑定动画 */
- animation: beat 0.5s linear infinite alternate;
- }
-
- /*css3动画 只需要关键的画面
- keyframes:关键帧(画面) 动画名称
- */
- @keyframes beat {
- /* 动画开始的画面 */
- 0% {
- /*缩放*/
- transform: scale(1);
- }
- /*动画结束的画面*/
- 100% {
- /*结束*/
- transform: scale(1.1);
- }
- }
-
- .left, .right {
- float: left;
- width: 100px;
- height: 160px;
- background-color: pink;
- border-radius: 50px 50px 0px 0px;
- }
-
- .left {
- transform: translateX(29px) rotate(-45deg);
- /*盒子-阴影 横向,纵向,模糊半径 影子扩展 */
- box-shadow: 0px 0px 30px 0px pink;
- }
-
- .right {
- /*translateX横向位移 rotate:旋转*/
- transform: translateX(-29px) rotate(45deg);
- /*盒子-阴影 横向,纵向,模糊半径 影子扩展 */
- box-shadow: 0px 0px 30px 0px pink;
-
- }
-
-
- #content {
- width: 500px;
- position: absolute;
- left: 50%;
- transform: translateX(-50%);
- }
-
- .pay {
- float: left;
- text-align: center;
- background-color: chartreuse;
- /*background-color: whitesmoke;*/
- }
-
- #Vip {
- display: none;
- width: 400px;
- position: absolute;
- left: 50%;
- transform: translateX(-50%);
- background-color: darkgray;
- }
-
- #vipStatusTr {
- display: none;
- }
-
- #paySuccess {
- position: relative;
- /* left: 50%;
- top: 50%;*/
- /*transform: translate(20%,180%);*/
- }
- #frm span{
- color: firebrick;
- }
- style>
- head>
- <script>
- $(function () {
- $('#buyVip').click(function () {
- $('#Vip').show();
- // alert("hhhhhh");
- // document.getElementById('Vip').style.display='block';
- })
-
- //付款成功后修改
- $('#paySuccess').click(function () {
- $('#Vip').hide();
- //支付成功后修改vip卡状态
- $('#vipStatus').val("1");
- //支
- $('#afterPay').html("您已购买Vip")
-
- })
-
- //确定提交
- $('#tj').click(function () {
- $('#checkCardNumResult').text("");
- //点击提交后提示置为空
- //取值
- var confirmTj = true;
- var cardNum = $('#cardNum').val();
- var name = $('#name').val();
- // alert(name);
- var sex = $("input[name='sex']:checked").val();
- // alert(sex);
- var tel = $('#tel').val();
- var address = $('#address').val();
-
- if (cardNum.length < 1) {
- confirmTj = false;
- $('#cardNumWarning').text("请输入新卡卡号!")
- }
- if (name.length < 1) {
- confirmTj = false;
- $('#nameWarning').text("请输入名字!")
- }
- if (sex != "男" && sex != "女") {
- confirmTj = false;
- $('#sexWarning').text("请选择性别")
- }
- if (tel.length < 1) {
- confirmTj = false;
- $('#telWarning').text("请输入手机号!")
- }
- if (address.length < 1) {
- confirmTj = false;
- $('#addressWarning').text("请输入地址!")
- }
-
- if (confirmTj == true) {
- $.ajax({
- url: 'ljToAddCard',
- type: 'post',
- // data: {},
- //另一种方式,序列化,就能拿到表单里面的数据,但是这样写需要注意传的数据要和User类能对上
- data: $('#frm').serialize(),
- //如果不需要返回数据,就不用写
- dataType: 'text',
- success: function (res) {
- //没写过滤器会乱码
- alert(res);
- }
- })
- $('#cardNum').val("");
- }
- })
-
- //非空提示的消除
- $("input:radio[name='sex']").change(function () {
- $('#sexWarning').text("");
- });
- $('#cardNum').change(function () {
- $('#cardNumWarning').text("");
- })
- $('#name').change(function () {
- $('#nameWarning').text("");
- })
- $('#tel').change(function () {
- $('#telWarning').text("");
- })
- $('#address').change(function () {
- $('#addressWarning').text("");
- })
-
-
- //查询新注册的卡号是否已经存在
- $('#cardNum').change(function () {
- var cardNum = $(this).val();
- checkCardNum(cardNum);
- })
- //关闭vip充值页面
- $('#closeVip').click(function () {
- $('#Vip').hide();
- })
-
- })
- function checkCardNum(v) {
- $.ajax({
- url: 'ljCheckCardNum',
- type: 'post',
- data: {cardNum: v},
- //另一种方式,序列化,就能拿到表单里面的数据,但是这样写需要注意传的数据要和User类能对上
- // data:$('#frm').serialize(),
- //如果不需要返回数据,就不用写
- dataType: 'text',
- success: function (res) {
- //没写过滤器会乱码
- $('#checkCardNumResult').text(res);
- }
- })
- }
- script>
- <body>
- <div id="father">
- <div class="left">
- <button type="button" class="btn btn-info" style="border-radius: 50px 50px 0px 0px">vip卡更多优惠哦!button>
- div>
- <div class="right">div>
- div>
- <div id="content">
- <form id="frm">
- <table class="table table-striped">
- <thead>
- <tr>
- <th scope="col" colspan="2" style="text-align: center"><b style="font-size: 20px">新卡办理b>th>
- tr>
- thead>
- <tbody style="margin-top: 5px">
- <tr>
- <th scope="row">卡号th>
- <td><input type="text" placeholder="请输入新卡卡号:" name="cardNum" id="cardNum">
- <span id="checkCardNumResult" style="color: darkblue">span>
- <span id="cardNumWarning">span>
- td>
- tr>
- <tr>
- <th scope="row">姓名th>
- <td>
- <input type="text" placeholder="请输入办卡人姓名:" name="name" id="name">
- <span id="nameWarning">span>td>
- td>
- tr>
- <tr>
- <th scope="row">手机号th>
- <td>
- <input type="text" placeholder="请输入手机号" name="tel" id="tel">
- <span id="telWarning">span>td>
- td>
- tr>
- <tr>
- <th scope="row">性别th>
- <td>
- <input type="radio" name="sex" id="payVip" value="男">男
- <input type="radio" name="sex" value="女">女
- <span id="sexWarning">span>td>
- td>
- tr>
- <tr>
- <th scope="row">地址th>
- <td>
- <input type="text" placeholder="请输入地址" name="address" id="address">
- <span id="addressWarning">span>td>
- td>
-
- tr>
- <tr id="vipStatusTr">
- <th scope="row">Vip状态th>
- <td>
- <input type="text" name="vip" value="0" id="vipStatus">
- td>
- tr>
-
- <tr>
- <th scope="row">是否购买Vipth>
- <td id="afterPay">
- <a id="buyVip" style="border-radius: 10px">88元购买<b>Vipb>a>
- <%-- <button>測試button>--%>
- td>
- tr>
- tbody>
- table>
- form>
- <table>
- <tr>
- <td colspan="2" style="text-align: center;width: 500px" align="center">
- <button class="btn btn-success" id="tj">提交button>
- <button class="btn btn-info">返回button>
- td>
- tr>
- table>
-
-
- div>
-
- <div id="father1">
- <div class="left">div>
- <div class="right">
- <button type="button" class="btn btn-info" style="border-radius: 50px 50px 0px 0px">vip卡好礼不断!button>
- div>
- div>
-
- <div id="Vip">
- <div style="width: 100%" class="pay">
- <span>
- <b>微信支付b>
- <a href="#" style="float: right" id="closeVip">Xa>
- span>
-
- <div style="width: 80%;background-color: #17a2b8;height: 300px;margin-left: 10%">
- <img src="image/pay2.jpg" alt="" style="width: 100%">
- div>
- div>
- <div style="width: 100%" class="pay">
- <span><b>支付宝b>span>
- <div style="width: 80%;background-color: #17a2b8;height: 300px;margin-left: 10%">
- <img src="image/pay1.png" alt="" style="width: 100%">
- div>
- div>
-
- <div style="width: 100%;float: right" class="pay">
- <button id="paySuccess" style="border-radius: 10px">支付成功button>
- div>
- td>
- tr>
- div>
-
- body>
- html>