网上订票系统第三天

接着前面来。

去看了看去哪网和携程网的购票流程页面,还是去把12306的页面扒了一点,功能没有那么多,感觉够用算了。

今日任务:实现用户登录,根据出发站 和终点站 进行搜索车票 ,进行预定

下面是登陆前台代码:

 

$("#btn").click(function () {
            var a = new Object();
            a.username = $("#userName").val();
            a.userpwd = $("#password").val();
            $.ajax({
                url: "http://localhost:8989/myticket/car/user/login",
                type: "post",
                dataType: "json",
                contentType: 'application/json;charset=UTF-8',
                data: JSON.stringify(a),
                success: function (data) {
                    if (data.usertype == 1){
                        document.cookie = "cookie_userid = " + data.userid;
                        document.cookie = "cookie_username = " + data.username;
                        location.href="http://localhost:8989/myticket/static/html/12306/Index/index.html";
                    }else {
                        alert("账号未激活,请前往激活后再登录");
                    }
                },
                error: function () {
                    alert("登录出错");
                }
            })
        })

后台代码:

<select id="userlogin" resultType="com.hp.entity.Userticket" parameterType="com.hp.entity.Userticket">
select *from userticket where username=#{username} and userpwd=#{userpwd};
</select>

登陆成功后进行查询 选票:

 

搜索后台代码:

<select id="getlist" resultType="com.hp.entity.Fresta">
select f.freid,f.frenumber,f.frebegintime,f.freendtime,f.freprice,f.frecarid,
s1.stationname as stbegin,s2.stationname  as stend
 from frequency f
INNER join  station  s1 on f.frebeginsid=s1.stationid 
INNER join  station  s2 on f.freendsid=s2.stationid
where f.frebeginsid in
 <foreach collection="a" index="index" open="(" separator="," close=")" item="a">
            #{a}
    </foreach> 

and f.freendsid in 
 <foreach collection="b" index="index" open="(" separator="," close=")" item="b">
            #{b}
    </foreach>

</select>
<select id="getbyid" resultType="com.hp.entity.Fresta2">
select  f.freid,f.frenumber,f.frebegintime,f.freendtime,f.freprice,f.frecarid,
s1.stationname as stbegin,s2.stationname  as stend
 from frequency f
INNER join  station  s1 on f.frebeginsid=s1.stationid 
INNER join  station  s2 on f.freendsid=s2.stationid
where f.freid=#{freid};
</select>

前台代码:

$.ajax({
            url: "http://localhost:8989/myticket/user/city/getAllcity",
            type: "post",
            dataType: "json",
            success: function (data) {

                va.serch_result=data;

            },error:function () {
                alert("城市信息出错");
            }
        })

$.ajax({
url:"http://localhost:8989/myticket/user/piao/fresta",
dataType:"json",
type:"post",
contentType:"application/json;charset=UTF-8",
data:JSON.stringify(a),
success:function (data) {
va.trainInfos = data;


},error:function (e) {
alert("查询失败");
}
})

 

遇到问题:  vue 显示数据的时候出现错误, ajax 提交数据的时候如何 使用外键 ?

 

posted @ 2020-07-17 18:07  厨房与爱  阅读(180)  评论(0编辑  收藏  举报