新頁面的登陸



html1中index.htmlhtml

<a th:href="@{initGuestLogin}" class="link" > <span th:if="${ #strings.isEmpty(session.UVO.guestName)}">登陸</span></a>java

GustController.java
session

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

    public String initGuestLogin(Model model, Device device) {post

    log.info("客戶登陸界面初始化");spa

    GoodsForm goodsForm = new GoodsForm();.net

    goodsForm.setType("糧食");orm

    model.addAttribute("goodsForm", goodsForm);htm

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

    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" class="form-horizontal" th:object="${guestForm}"  method="post">

  <div class="form-group">

   <label for="inputEmail3" class="col-sm-4 control-label">用戶名:</label>

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

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

   </div>

  </div>

  <div class="form-group">

   <label for="inputPassword3" class="col-sm-4 control-label">密 碼:</label>

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

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

      <i class="formInfo red">密碼錯誤</i>

   </div>

  </div>

 

  <div class="form-group">

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

      <div class="checkbox w300 cf"><label class="fl"><input type="checkbox"/> 記住密碼</label><a href="#" class="fr link">忘記密碼?</a></div>

   </div>

  </div>

  <div class="form-group">

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

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

   

   </div>

  </div>

</form>



GustController.java

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

    public String guestLogin(Model model, HttpSession session, GuestForm guestForm, Device device) {

log.info("客戶登陸,驗證客戶信息,成功後進入系統");

GuestForm result = guestService.searchGuest(guestForm);

if(result != null) {

UVO uvo = new UVO();

uvo.setGuestId(result.getGuestId());

uvo.setGuestName(result.getGuestName());

uvo.setPassword(guestForm.getPassword());

uvo.setGender(result.getGender());

uvo.setAddress(result.getAddress());

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 goodsForm = new GoodsForm();

    goodsForm.setType("糧食");

    model.addAttribute("goodsForm", goodsForm);

    model.addAttribute("list", goodsService.searchGoodsList(goodsForm));

    CartForm cartForm = new CartForm();

    cartForm.setGuestId(uvo.getGuestId());

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

    if(device.isNormal()) {

    return "shop/index";

    } else {

    return "mobile/index";

    }

} else {

model.addAttribute("message", "用戶名或密碼錯誤!");

GoodsForm goodsForm = new GoodsForm();

    goodsForm.setType("糧食");

    model.addAttribute("goodsForm", goodsForm);

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

    model.addAttribute("cartList", cartList);

if(device.isNormal()) {

    return "shop/login";

    } else {

    return "mobile/login";

    }

}

}

相關文章
相關標籤/搜索