index.html 3.8 KB
<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <title>2.5地址管理</title>
    <meta name="viewport" content="initial-scale=1,maximum-scale=1, minimum-scale=1">
    <link rel="stylesheet" href="__TMPL__/public/assets/css/base.css">
    <link rel="stylesheet" href="__TMPL__/public/assets/css/swiper.min.css">
    <link rel="stylesheet" href="__TMPL__/public/assets/css/common/address_manage.css">
    <script src="__TMPL__/public/assets/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="__TMPL__/public/assets/js/swiper.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="__TMPL__/public/assets/js/base.js" type="text/javascript" charset="utf-8"></script>
    <style>

    </style>
</head>

<body>
    <div class="container">
        <div class="address_out_box" style="padding-bottom: 1.5rem;">
            <volist name="list" id="list">
            <div class="address_in_box">
                <div class="user_box">
                    <div class="left_ltem">
                        <p class="user_name">{$list.name}</p>
                        <span class="phone"> {$list.tel}</span>
                    </div>
                    <div class="right_item">
                        <p class="moren">
                            <p class="moren_box <eq name='list.is_check'  value='1'>choose_box</eq>" index="{$list.id}">
                        <img class="duigou" src="__TMPL__/public/assets/images/duigou.png" alt=""></p> 默认地址
                        </p>
                    </div>
                </div>
                <div class="address_box" index="{$list.id}">
                    <p class="user_address">{$list.city}{$list.address}
                        <span class="edit_box" index="{$list.id}">
                            <a href="{:url('Address/edit',array('id'=>$list.id))}">
                            <img class="add_pic" src="__TMPL__/public/assets/images/edit.png" alt="">
                            </a>
                            <img class="del_icon" src="__TMPL__/public/assets/images/delete.png" alt="">
                        </span>
                    </p>
                </div>
            </div>
            </volist>
        </div>
    </div>
    <footer class="footer">
        <p class="add_address">新增收货地址</p>
    </footer>
    </div>
    <script>

        //默认地址勾选
        $('.moren_box').on('click', function() {
            var address_id = $(this).attr('index');
            var obj = $(this);
            console.log(address_id)
            $.ajax({
                type: "POST",
                url: "{:url('Address/isCheck')}",
                data: {
                    "address_id": address_id,
                },
                success: function (data) {
                    if (data.code == '1') {
                        $('.moren_box').removeClass('choose_box');
                        obj.addClass('choose_box');
                    } else {
                        alert(data.message);
                    }
                },
                error: function () {
                }
            })
        })

        //添加地址跳转
        $('.add_address').on('click', function() {
            window.location.href = "{:url('Address/add')}"
        })

        // 删除
        $('.del_icon').click(function () {
            var id = "{$list.id}";
            $.ajax({
                type:"POST",
                url:"{:url('Address/del')}",
                data:{
                    "id":id,
                },
                success:function (data) {
                    alert(data.message);
                    window.location.reload()
                },
                error:function () {
                }
            })
        })
    </script>
</body>

</html>