wzy
2020-12-14 4e5ecd152044d53cc5853037eb60361fff4d11dc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
 
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:matrix="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
 
    <meta
            content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
            name="viewport"/>
    <title th:text="${session.userInfo.shopName }"></title>
 
    <!-- Set render engine for 360 browser -->
    <meta name="renderer" content="webkit">
 
    <!-- No Baidu Siteapp-->
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
 
 
    <!-- Add to homescreen for Chrome on Android -->
    <meta name="mobile-web-app-capable" content="yes">
 
 
    <!-- Add to homescreen for Safari on iOS -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-title" content="Amaze UI"/>
 
 
    <meta name="msapplication-TileColor" content="#0e90d2">
    <script type="text/javascript"
            th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script>
    <script type="text/javascript"
            th:src="@{/js/systools/DDMBase.js}"></script>
    <link rel="stylesheet"
          th:href="@{/plugin/amazingUI/css/amazeui.min.css}">
    <link rel="stylesheet"
          th:href="@{/plugin/amazingUI/css/app.css}">
    <link rel="stylesheet" type="text/css"
          th:href="@{/css/dingPersonalCar.css}" >
 
</head>
<style>
    .foot-c {
        background: #999
    }
 
    .am-navbar .am-navbar-nav {
        padding-left: 0;
    }
 
    .am-header-right a {
        color: #fff;
    }
</style>
<script th:if="${session.CURRENT_CUSTOMER eq null}">
 
    MTools.redirect(basePath + "/admin/redirect/hive/mobile/order-search");
 
</script>
<body>
<!-- 购物车页面 -->
<!-- 头部开始 -->
<header data-am-widget="header" class="am-header color-w back-m1">
    <div class="am-header-left am-header-nav">
        <a th:href="@{/admin/redirect/hive/mobile/order?foot=4}" class=""> <i
                class="am-header-icon am-icon-chevron-left"></i>
        </a>
    </div>
 
    <h1 class="am-header-title">
        <a href="#title-link" class=""> 我的购物车 </a>
    </h1>
 
    <div class="am-header-right am-header-nav">
        <a id="clearCar"> 清空 </a>
    </div>
</header>
<!-- 头部结束 -->
 
 
<!-- 购物车表单开始 -->
<div class="main main1" id="carItemsBox">
    <div class="empty-car" th:if="${session.SHOPPING_CAR} eq null or ${#lists.size(session.SHOPPING_CAR)} eq 0">
        <p id="empty-car">购物车空空的~</p>
        <p>
            <a th:href="@{/admin/redirect/hive/mobile/order-list}"> 马上去选购! </a>
        </p>
    </div>
    <form th:if="${session.SHOPPING_CAR} ne null and ${#lists.size(session.SHOPPING_CAR)} ne 0" class="am-form am-form-horizontal" action=""
          id="dataform"
          onsubmit="javascripr:return false;">
        <!-- <input    class="am-form-field am-input-sm" type="text" placeholder="">
              <br/> -->
        <div data-am-widget="list_news"
             class="am-list-news am-list-news-default">
 
            <div class="am-list-news-bd">
                <ul class="am-list">
                    <!--缩略图在标题右边-->
                    <!-- 如果是商品 -->
                    <li th:each="item,flag:${session.SHOPPING_CAR}"
                        class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-right">
                        <div class=" am-u-sm-2 am-list-thumb am-checkbox">
                            <label class="am-checkbox">
                                <input    type="checkbox" onclick="caculateMoney()" th:isF="${item.isFree}"
                                       th:name="'carItems['+${flag.index}+'].id'"
                                       th:value="${item.id}" class="check" data-am-ucheck>
 
                            </label>
                            <!-- 增加隐藏域名 -->
 
 
                            <input    type="hidden" th:name="'carItems['+${flag.index}+'].type'"  th:value="${item.type}">
                            <input    type="hidden" th:name="'carItems['+${flag.index}+'].isFree'"
                                   th:value="${item.isFree }">
                            <input    type="hidden" th:name="'carItems['+${flag.index}+'].goodsId'"
                                   th:value="${item.goodsId}">
                        </div>
 
                        <div class=" am-u-sm-10 am-list-main am-list-item-thumb-left">
 
                            <h3 class="am-list-item-hd">
                                <span th:text="${item.shoppingGoods.name }"> </span>
                                <br/>
                                <span>价格<strong class="color-r" th:text="${item.shoppingGoods.sealPice }"></strong></span>
                                <span th:if="${item.isFree eq '是'}">【赠】 </span>
                            </h3>
                            <div class="am-list-item-text">
                                <div class="am-input-group   am-input-group-primary">
                                    <a class="am-input-group-label reduce">
                                        <i class="am-header-icon am-icon-minus"></i>
                                    </a>
                                    <input  th:name="'carItems['+${flag.index}+'].count'" type="tel"
                                           id="num" class="am-form-field " th:value="${item.count }"/>
                                    <a class="am-input-group-label add">
                                        <i class="am-header-icon am-icon-plus"></i>
                                    </a>
                                </div>
                            </div>
 
                        </div>
                    </li>
 
                    <li  class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-right">
                        <div class=" am-u-sm-2 am-list-thumb am-checkbox">
                            <label class="am-checkbox">
                                <input   type="checkbox" onclick="sellectAll(this)"  class="check" data-am-ucheck>
                            </label>
                        </div>
                        <div class=" am-u-sm-10 am-list-main am-list-item-thumb-left">
                            <h3 class="am-list-item-hd">  <span>全选</span><br/>  </h3>
                        </div>
                    </li>
                </ul>
            </div>
            <div>
 
 
 
            </div>
 
 
            <div class="ps">
                        <textarea name="remark" class=" border " clos="100"
                                  rows="2" warp="virtual" placeholder="备注信息"></textarea>
            </div>
 
 
            <div data-am-widget="navbar" class="am-navbar am-cf am-navbar-default back-m1" id="">
                <ul class="am-navbar-nav am-cf am-avg-sm-3 back-m1">
                    <li class="foot-c">
                        <a href="" class="">
                            <span class="">共<span id="goodsNum">0</span>件商品</span>
                        </a>
                    </li>
                    <li class="foot-c ">
                        <a href="###" class="">
 
                            <span class="">合计:&yen;<strong id="orderTotalMoney">0</strong></span>
 
                        </a>
                    </li>
                    <li class="back-m1">
                        <a href="###" onclick="myForm.submit()">
                            <span class="">下单</span>
 
                        </a>
                    </li>
 
                </ul>
            </div>
 
 
        </div>
 
    </form>
 
 
 
 
 
</div>
 
 
<!-- 购物车表单结束 -->
<!-- 弹出 -->
<div class="am-modal am-modal-confirm" tabindex="-1" id="my-confirm">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">提示</div>
        <div class="am-modal-bd">你确定要清空购物车吗?</div>
        <div class="am-modal-footer">
            <span class="am-modal-btn" data-am-modal-cancel>取消</span> <span
                class="am-modal-btn" data-am-modal-confirm>确定</span>
        </div>
    </div>
</div>
<script th:src="@{/plugin/amazingUI/js/handlebars.min.js}"></script>
<script th:src="@{/plugin/amazingUI/js/amazeui.widgets.helper.js}"></script>
<!-- index js -->
<script type="text/javascript">
    $(function () {
        $(".select2").select2({'width': '100%'});
        MTools.autoFullSelect();
        //数量
        $(".add").bind("click", function () {
            if ($(this).prev().val() >= 0) {
                $(this).prev().val(parseInt($(this).prev().val()) + 1);
            }
            caculateMoney();
        });
        $(".reduce").bind("click", function () {
            if ($(this).next().val() > 1) {
                $(this).next().val(parseInt($(this).next().val()) - 1);
            }
            caculateMoney();
        });
    });
 
    function sellectAll(node) {
        //
        var checked=node.checked;
        $(".am-ucheck-checkbox").each(function(){
            this.checked=checked;
        });
        caculateMoney();
 
    }
    //下单
    var myForm = MForm.initForm({
        invokeUrl: basePath + "/admin/order/addOrder",
        isvalid: false,
        afterSubmit: function (loj) {
            var msg = '';
            if (loj.attr("result").status == '200') {
                msg = '下单成功';
                layer.open({
                    shade: false,
                    content: msg,
                    className: 'showBox',
                    time: 1,
                    end: function (elem) {
                        MTools.redirect(basePath + "/admin/redirect/hive/mobile/order?foot=4");
                    }
                });
            }
        }
    });
 
    /* 弹出JS */
    $(function () {
        $('#clearCar').on('click', function () {
            $('#my-confirm').modal({
                relatedTarget: this,
                onConfirm: function (options) {
                    //请求服务器清空session    
                    $.AjaxProxy().invoke(
                        basePath + "/admin/shoppingCar/clearShoppingCar",
                        function (loj) {
                            location.reload();
                        })
                },
            });
            //清空列表
        });
    });
 
    function caculateMoney() {
        // 找到所有被选中的元素
        var money = 0.00;
        var goodsNum = 0;
        $("input:checked").each(function (i) {
            var _this = $(this);
            var freeFlag = _this.attr("isF");
            if (freeFlag == '否') {
                m = parseFloat(_this.parent().parent().next('div').find('strong').html());
                n = parseInt(_this.parent().parent().next('div').find('#num').val());
                money += m * n;
                goodsNum += n;
            }
        });
        console.log(money);
        $("#orderTotalMoney").html(money);
        $("#goodsNum").html($("input:checked").length);
    }
</script>
</body>
</html>