博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
关于怎么实现前端页面中的前端的部分
阅读量:6715 次
发布时间:2019-06-25

本文共 5933 字,大约阅读时间需要 19 分钟。

hot3.png

114538_ht6a_2411987.png

114539_Q1gc_2411987.png

怎么实现页面的登录等注册功能的排版和页面跳转

1.   <div class="container cf" th:fragment="page-top-bar">

<div class="phone">

<a href="#" class="btnLink" id="qrBtn"> <i class="ico-phone"></i>手机版商城 <i class="arrowB"></i></a>

<div class="qr" id="qrBox">

<i class="dot"></i>

<img src="images1/qr.jpg" alt=""/>

<p class="mt5">扫描二维码<br/>安装安卓客户端</p>

</div>

</div>

<p class="userInfo">您好, 

<span th:if="${#strings.isEmpty(session.UVO.guestName)}">

<a th:href="@{initGuestLogin}"><span class="button-t">登录</span></a></span>

<span th:if="${not #strings.isEmpty(session.UVO.guestId)}">

<a th:href="@{initEditGuest}"><span class="button-t" th:text="${session.UVO.guestId}">张三</span></a>

&nbsp;&nbsp;

<a th:href="@{/}" th:if="${not #strings.isEmpty(session.UVO.guestId)}"><span class="button-t">退出</span></a>

</span>

<span th:if="${ #strings.isEmpty(session.UVO.guestId)}">

<i class="line">|</i><a th:href="initGuestRegister" class="link">注册</a></span>

<i class="line">|</i><a href="init" class="link">分销商入口</a></p>

</div>

//用到的href链接到的是controller

//if用来判断用户是否登录

//当点击登录时调到initGuestLogin  这个controller

    @RequestMapping(value = "initGuestLogin", method = RequestMethod.GET)

    public String initGuestLogin(Model model, Device device) {

    log.info("客户登录界面初始化");

    GoodsForm goodsForm = new GoodsForm();

    List<GoodsForm> commodityType = goodsService.getType();

    goodsForm.setCommodityTypeId(commodityType.get(0).getCommodityTypeId());

    model.addAttribute("goodsForm", goodsForm);

    model.addAttribute("commodityType",commodityType);

    List<CartForm> cartList = new ArrayList<>();

    model.addAttribute("cartList", cartList);

    GuestForm guestForm = new GuestForm();

    model.addAttribute("guestForm", guestForm);

    if(device.isNormal()) {

    return "shop/login";

    } else {

    return "mobile/login";

    }

    }

login.html页面实现登录功能

<div class="container mt20 regBox ">

<form action="guestLogin" th:object="${guestForm}" method="post" class="form-horizontal">

 <div class="form-group">

   <label>用户名:</label>

   <div class="col-sm-8">

   <input type="text" name="guestId" class="form-control" />

   </div>

 </div>

 <div class="form-group">

   <label>密 码:</label>

   <div class="col-sm-8">

     <input type="password" name="password" class="form-control"/>

   </div>

 </div>

 

 <div class="form-group">

   <div>

    <button type="submit" class="btnYellow yh">登 录</button>

   </div>

 </div>

</form>

<!-- 登录 -->

</div>

将红色部分提交到guestLogin这个controller 中

@RequestMapping(value = "guestLogin", method = RequestMethod.POST)

    public String guestLogin(Model model, HttpSession session, @Valid @ModelAttribute("guestForm")GuestForm guestForm,BindingResult result1, Device device) { 

log.info("客户登录,验证客户信息,成功后进入系统");

GuestForm result = guestService.searchGuest(guestForm);

GoodsForm goodsForm = new GoodsForm();

           model.addAttribute("goodsForm", goodsForm);

if(result != null) {

UVO uvo = new UVO();

uvo.setGuestId(result.getGuestId());

uvo.setGuestName(result.getGuestName());

uvo.setPassword(guestForm.getPassword());

uvo.setGender(result.getGender());

uvo.setEmail(result.getEmail());

uvo.setMobile(result.getMobile());

uvo.setQq(result.getQq());

uvo.setPhone(result.getPhone());

uvo.setZip(result.getZip());

session.setAttribute("UVO", uvo);

GoodsForm goodsForm1 = new GoodsForm();

}

   CartForm cartForm = new CartForm();

   cartForm.setGuestId(uvo.getGuestId());

   model.addAttribute("cartList", cartService.searchCartList(cartForm));

return "shop/index";

} else {

model.addAttribute("message", "用户名或密码错误!");

   List<CartForm> cartList = new ArrayList<>();

   model.addAttribute("cartList", cartList);

return "shop/login";

}

}

//然后便在在跳到的index中根据 th:if="${not #strings.isEmpty(session.UVO.guestId)} 来完成不同的显示信息

2.  实现购物车有多少件商品便是来根据

<p class="cartbar nobox mt25 yh">

<span th:if="${cartList.size() == 0}">为空</span>

<span th:if="${cartList.size() != 0}">

有&nbsp;<a href="initCart"><strong> <span th:text="${cartList.size()}">1</span>件商品</strong></a></span></p>

来实现

<select id="selectCartList" parameterClass="cn.agriculture.web.form.CartForm"

resultClass="cn.agriculture.web.form.CartForm">

SELECT cart.cart_id as cartId,

cart.guest_id as guestId,

cart.count as count,

commodity.commodity_id as commodityId,

commodity.type as type,

supplier.supplier_name as supplierName,

brand.brand_name as brandName,

commodity.commodity_name as commodityName,

commodity.weight as weight,

commodity.is_gift as isGift,

commodity.specifications as specifications,

commodity.unit as unit,

commodity.benchmark_price as benchmarkPrice,

commodity.guide_price as guidePrice,

commodity.retail_price as retailPrice,

commodity.competition_level as competitionLevel,

commodity.note as note,

cart.update_time as updateTime,

cart.update_user as updateUser,

commodity.picture_id as pictureId

FROM cart, commodity, supplier, brand

WHERE cart.commodity_id = commodity.commodity_id

AND commodity.supplier_id = supplier.supplier_id

AND commodity.brand_id = brand.brand_id

AND cart.status = #status#

AND cart.guest_id = #guestId#

</select>

对于搜索的主要是SQL语句

<select id="selectGoodsListrelative"

parameterClass="cn.agriculture.web.form.GoodsForm"

resultClass="cn.agriculture.web.form.GoodsForm">

SELECT commodity.commodity_id as commodityId,

commodity.type as commodityTypeId,

supplier.supplier_name as supplierName,

brand.brand_name as brandName,

commodity.commodity_name as commodityName,

commodity.weight as weight,

commodity.is_gift as isGift,

commodity.specifications as specifications,

commodity.unit as unit,

commodity.benchmark_price as benchmarkPrice,

commodity.guide_price as guidePrice,

commodity.retail_price as retailPrice,

commodity.competition_level as competitionLevel,

commodity.note as note,

commodity.update_time as updateTime,

commodity.update_user as updateUser,

commodity.picture_id as pictureId,

stock.stock as stock

FROM commodity, supplier, brand, stock

WHERE commodity.commodity_id = stock.commodity_id

AND commodity.supplier_id = supplier.supplier_id

AND commodity.brand_id = brand.brand_id

AND commodity.commodity_name LIKE '%$commodityName$%'

</select>

转载于:https://my.oschina.net/u/2411987/blog/491758

你可能感兴趣的文章
如何撰写好文档?精益文档的六个实践
查看>>
随手记统一监控平台Focus设计解析
查看>>
如何在Python中使用LightFM构建可扩展的电子商务推荐系统?
查看>>
畅谈云原生(上):云原生应用应该是什么样子?
查看>>
Wiki工具使用感悟
查看>>
云因成本高昂屡被关注,上云的价值是什么?
查看>>
深入探索JVM自动资源管理
查看>>
Steve Thair谈DevOps on Windows的演变与面临的挑战
查看>>
过去一年,被我们“高估”的技术清单
查看>>
案例学习:Jigsaw模块化迁移
查看>>
ASP.NET 2.2 Preview 1首次支持Java SignalR客户端
查看>>
Netty 源码分析之 零 磨刀不误砍柴工 源码分析环境搭建
查看>>
[deviceone开发]-动画示例源码
查看>>
实现iOS图片等资源文件的热更新化(一): 从Images.xcassets导出合适的图片
查看>>
magento2 ajax机制 (customer-data)
查看>>
magento 2模块开发实例helloworld模块
查看>>
关于if-else流程图的画法
查看>>
calc 与 box-sizing 的替代
查看>>
如何使用 Java 构建微服务?
查看>>
kafka的SSL证书校验不通过
查看>>