Prechádzať zdrojové kódy

Merge remote-tracking branch 'origin/master'

叶本泽 3 rokov pred
rodič
commit
5909ceb39f

+ 164 - 0
src/main/webapp/ShoppingCart.html

@@ -0,0 +1,164 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="UTF-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge">
+    <meta name="viewport" content="width=device-width, initial-scale=1.0">
+    <title>Document</title>
+    <link rel="stylesheet" type="text/css" href="css/testingCss.css">
+</head>
+<body>
+    <form action="ShoppingCart.html" method="get">
+        <div class="Store">
+            <a id="lable">
+                <input type="checkbox">
+                <div id="StoreIcon">
+                    <img src="https://assets.burberry.com/is/image/Burberryltd/0c498f053ef33c97aab8f9a472265caed3e75a39.jpg?$BBY_V2_SL_3x4$=&wid=1903&hei=2537">
+                </div>
+                <h3>StoreA</h3>
+            </a>
+            <div class="goods">
+                <input name="seleceed" type="checkbox">
+                <div id="GoodsIcon">
+                    <img src="https://assets.burberry.com/is/image/Burberryltd/0c498f053ef33c97aab8f9a472265caed3e75a39.jpg?$BBY_V2_SL_3x4$=&wid=1903&hei=2537">
+                </div>
+                <div id="exp">
+                    <h3>GoodsA</h3>
+                    <p>info & selected</p>
+                    <div id="count">
+                        <div>-</div>
+                        <input name="count" type="text">
+                        <div>+</div>
+                    </div>
+                </div>
+            </div>
+        </div>
+    
+    
+        <div class="Store">
+            <a id="lable">
+                <input type="checkbox">
+                <div id="StoreIcon">
+                    <img src="https://assets.burberry.com/is/image/Burberryltd/0c498f053ef33c97aab8f9a472265caed3e75a39.jpg?$BBY_V2_SL_3x4$=&wid=1903&hei=2537">
+                </div>
+                <h3>StoreB</h3>
+            </a>
+            <div class="goods">
+                <input name="selected" type="checkbox">
+                <div id="GoodsIcon">
+                    <img src="https://assets.burberry.com/is/image/Burberryltd/0c498f053ef33c97aab8f9a472265caed3e75a39.jpg?$BBY_V2_SL_3x4$=&wid=1903&hei=2537">
+                </div>
+                <div id="exp">
+                    <h3>GoodsB</h3>
+                    <p>info & selected</p>
+                    <div id="count">
+                        <div>-</div>
+                        <input name="count" type="text">
+                        <div>+</div>
+                    </div>
+                </div>
+            </div>
+            <div class="goods">
+                <input name="selected" type="checkbox">
+                <div id="GoodsIcon">
+                    <img src="https://assets.burberry.com/is/image/Burberryltd/0c498f053ef33c97aab8f9a472265caed3e75a39.jpg?$BBY_V2_SL_3x4$=&wid=1903&hei=2537">
+                </div>
+                <div id="exp">
+                    <h3>GoodsC</h3>
+                    <p>info & selected</p>
+                    <div id="count">
+                        <div>-</div>
+                        <input name="count" type="text">
+                        <div>+</div>
+                    </div>
+                </div>
+            </div>
+        </div>
+        <div id="BottomBar">
+            <input type="submit" name="submit" value="Delete">
+            <input type="submit" name="submit" value="Settle">
+        </div>
+    </form>
+
+    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
+    <script>
+        $("form>div.Store>div.goods>div#exp>div#count>div").click(function()
+        {
+            if(this.innerHTML == "-")
+            {
+                let text = $(this).next()[0];
+                let num = Number.parseInt(text.value);
+                // console.dir(num);
+                if(num.toString() == "NaN") num = 0;
+                else num = Math.max(0,--num);
+                text.value = num;
+            }
+            else
+            if(this.innerHTML == "+")
+            {
+                let text = $(this).prev()[0];
+                let num = Number.parseInt(text.value);
+                // console.dir(num);
+                if(num.toString() == "NaN") num = 1;
+                else num = Math.max(0,++num);
+                text.value = num;
+            }
+        });
+        $("form>div.Store>a#lable>input").change(function()
+        {
+            let items = $(this).parent().parent().children("div.goods").children("input");
+            // console.dir(items);
+            for(let i = 0; i < items.length; ++i)
+            {
+                items[i].checked = this.checked;
+            }
+        });
+        $("form>div.Store>div.goods>input").change(function()
+        {
+            let lableChecker = $(this).parent().parent().children("a#lable").children("input");
+            if(this.checked)
+            {
+                let otherGoods = $(this).parent().parent().children("div.goods").children("input").not(this);
+                for(let i = 0; i < otherGoods.length; ++i)
+                {
+                    // console.dir(otherGoods[i].checked);
+                    if(!otherGoods[i].checked)
+                    {
+                        return;
+                    }
+                }
+                lableChecker.prop("checked", true);
+            }
+            else
+            {
+                lableChecker.prop("checked", false);
+            }
+        })
+        $("form>div.Store>div.goods>div#exp>div#count>input").focusout(function()
+        {
+            let num = Number.parseInt(this.value);
+            if(num.toString() == "NaN") num = 0;
+            this.value = num;
+        }).keyup(function()
+        {
+            let num = Number.parseInt(this.value);
+            if(num.toString() == "NaN") num = 0;
+            this.value = num;
+        }).keydown(function()
+        {
+            let num = Number.parseInt(this.value);
+            if(num.toString() == "NaN") num = 0;
+            this.value = num;
+        });
+        $("form>div#BottomBar>input[type='submit']").click(function()
+        {
+            let counts = $("form>div#Store>div.goods>div#exp>div#count>input");
+            for (let index = 0; index < counts.length; index++) {
+                let num = Number.parseInt( counts[index].value);
+                if(num.toString() == "NaN") num = 0;
+                counts[index].value = num;
+            }
+        });
+    </script>
+</body>
+</html>

+ 164 - 0
src/main/webapp/css/testingCss.css

@@ -0,0 +1,164 @@
+
+body{
+    /* background-color: transparent; */
+    position: relative;
+    margin: 0;
+    font-family: 'Harmony SC';
+    min-height: 100px;
+    min-width: 500px;
+    background-color: whitesmoke;
+}
+
+form
+{
+    border-radius: 10px;
+    /* position: relative; */
+    width: 100%;
+    min-height: 100px;
+    min-width: 500px;
+}
+form>div.Store
+{
+    position: relative;
+    margin-top: 10px;
+    margin-left: 15px;
+    margin-right: 15px;
+    border-radius: 10px;
+    background-color: white;
+    font-size: 16px;
+    overflow: hidden;
+}
+/* div#Cartlist>div.Store:last-child
+{
+    margin-bottom: 0;
+} */
+form>div.Store>*{
+    border-bottom: 1px solid gainsboro;
+}
+
+form>div.Store>*:last-child{
+    border-bottom: 0;
+}
+
+form>div.Store>a#lable
+{
+    height: 48px;
+    line-height: 48px;
+    display: flex;
+    justify-items: center;
+    overflow: hidden;
+    background-color: transparent;
+}
+form>div.Store>a#lable>input
+{
+    height: 24px;
+    width: 24px;
+    margin: 12px;
+    margin-left: calc(1ch + 12px);
+}
+form>div.Store>a#lable>div#StoreIcon
+{
+    height: 40px;
+    width: 40px;
+    margin: 4px;
+    margin-left: calc(1ch + 4px);
+    text-align: center;
+}
+form>div.Store>a#lable>div#StoreIcon>img
+{
+    max-width: 100%;
+    max-height: 100%;
+}
+form>div.Store>a#lable>h3
+{
+    margin: 0;
+}
+
+form>div.Store>div.goods{
+    height: 96px;
+    display: flex;
+    justify-items: center;
+    overflow: hidden;
+    background-color:transparent;
+}
+form>div.Store>div.goods>input{
+    height: 24px;
+    min-width: 24px;
+    margin: 36px;
+    margin-left: calc(1ch + 12px);
+    margin-right: calc(1ch + 12px);
+}
+form>div.Store>div.goods>div#GoodsIcon
+{
+    height: 88px;
+    min-width: 88px;
+    margin: 4px;
+    margin-left: calc(1ch + 4px);
+    text-align: center;
+}
+form>div.Store>div.goods>div#GoodsIcon>img
+{
+    max-width: 100%;
+    max-height: 100%;
+}
+form>div.Store>div.goods>div#exp
+{
+    position: relative;
+    margin: 8px;
+    height: 80px;
+    width: 100%;
+}
+form>div.Store>div.goods>div#exp>*
+{
+    width: 100%;
+    margin: 0;
+}
+form>div.Store>div.goods>div#exp>div#count
+{
+    position: absolute;
+    width: 25%;
+    min-width: 16ch;
+    height: 24px;
+    border-radius: 10px;
+    border: 1px solid gray;
+    margin: 0;
+    bottom: 0;
+    right: 0;
+    display: flex;
+    overflow: hidden;
+}
+form>div.Store>div.goods>div#exp>div#count>*{
+    width: 100%;
+    height: 100%;
+    margin: 0;
+    padding: 0;
+    border: 0;
+    outline: 1px solid gray;
+    text-align: center;
+    background-color: white;
+    user-select: none;
+}
+form>div.Store>div.goods>div#exp>div#count>*:hover
+{
+    background-color: gainsboro;
+}
+form>div.Store>div.goods>div#exp>div#count>*:active
+{
+    background-color: gray;
+}
+
+form>div#BottomBar
+{
+    position: fixed;
+    right: 0;
+    bottom: 0;
+    width: 100%;
+
+}
+
+
+@font-face
+{
+    font-family: 'Harmony SC';
+    src: url(../font/HarmonyOS_Sans_SC_Medium.ttf);
+}

BIN
src/main/webapp/font/HarmonyOS_Sans_SC_Medium.ttf