Campus retail store front-end development -6 edit lists and list management functions -9 store page

Expected page:

  • http://127.0.0.1:18080/o2o/shopadmin/shopmanagement?shopId=1 with shopId enter the store management page
  • http://127.0.0.1:18080/o2o/shopadmin/shopmanagement without shopId entering the shop owned by that user list page

1. write html

WEB-INF/html/shop/shopmanagement.html

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>商店管理</title>
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<link rel="shortcut icon" href="/favicon.ico">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet"
  href="//g.alicdn.com/msui/sm/0.6.2/css/sm.min.css">
<link rel="stylesheet"
  href="//g.alicdn.com/msui/sm/0.6.2/css/sm-extend.min.css">
<link rel="stylesheet" href="../resources/css/shop/shopmanagement.css">
</head>
<body>
  <header class="bar bar-nav">
    <h1 class="title">商店管理</h1>
  </header>
  <div class="content">
    <div class="content-block">
      <div class="row">
        <div class="col-50 mb">
          <a id="shopInfo" href="/o2o/shopadmin/shopoperation" class="button button-big button-fill">商铺信息</a>
        </div>
        <div class="col-50 mb">
          <a href="/o2o/shopadmin/productmanagement" class="button button-big button-fill">商品管理</a>
        </div>
        <div class="col-50 mb">
          <a href="/o2o/shopadmin/productcategorymanagement" class="button button-big button-fill">类别管理</a>
        </div>
        <div class="col-100 mb">
          <a href="/o2o/shopadmin/shoplist" class="button button-big button-fill button-danger">返回</a>
        </div>
      </div>
    </div>
  </div>
  <script type='text/javascript'
    src='//g.alicdn.com/sj/lib/zepto/zepto.min.js' charset='utf-8'></script>
  <script type='text/javascript'
    src='//g.alicdn.com/msui/sm/0.6.2/js/sm.min.js' charset='utf-8'></script>
  <script type='text/javascript'
    src='//g.alicdn.com/msui/sm/0.6.2/js/sm-extend.min.js' charset='utf-8'></script>
  <script type='text/javascript' 
    src='../resources/js/common/common.js' charset='utf-8'></script>
  <script type='text/javascript'
    src='../resources/js/shop/shopmanagement.js' charset="utf-8"></script>
</body>
</html>

2. Establish needed css and js files

webapp/resources/css/shop/shopmanagement.css

@charset "UTF-8";
.mb{
    margin-bottom: .5rem;
}

webapp/resources/js/shop/shopmanagement.js

/**
 * 
 */
$(function(){
    var shopId = getQueryString('shopId');
    var shopInfoUrl = '/o2o/shopadmin/getshopmanagementinfo?shopId='+shopId;
    $.getJSON(shopInfoUrl, function(data){
        if(data.redirect){
            window.location.href = data.url;
        }else{
            if(data.shopId != undefined && data.shopId != null){
                shopId = data.shopId;
            }
            $('#shopInfo').attr('href','/o2o/shopadmin/shopoperation?shopId='+shopId);
        }
    });
});

3. Establish routing shopManagement

package com.csj2018.o2o.web.shopadmin;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping(value="shopadmin",method=RequestMethod.GET)
public class ShopAdminCtroller {
    @RequestMapping(value="/shopoperation")
    public String shopOperation() {
        return "shop/shopoperation";
    }
    @RequestMapping(value="/shoplist")
    public String shopList() {
        return "shop/shoplist";
    }
    //新增
    @RequestMapping(value="/shopmanagement")
    public String shopManagement() {
        return "shop/shopmanagement";
    }
}

Access the web or perform js file in accordance with the routing address. Start with common / common.js call getQueryString get shopId.
Then call / getshopmanagementinfo:

  • If shopId did not pass coming in, and removed from the session in currentShop (which is currently to operate a shop)
    * If there are no stores information session, it redirects to return to shop list page. Select a user to re-do shop management
    * If there are shop information session, gave its shops id assigned to shopId return. Do not redirect, and manage to stay in this page
  • Once passed shopId, you can stay directly on this page do manage. Shop and objects (store id is shopId) stored in the session.

Guess you like

Origin www.cnblogs.com/csj2018/p/12430397.html
Recommended