📖 File Reader
<?php /*a:2:{s:50:"D:\XiangMu\hecheng\app\mobile\view\goods\cart.html";i:1741945278;s:50:"D:\XiangMu\hecheng\app\mobile\view\public\vue.html";i:1723175572;}*/ ?>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
<title><?php echo htmlentities($config['name']); ?></title>
<link rel="stylesheet" href="/public/mobile/css/style_cart.css">
<script src="/public/mobile/js/fliexible.js"></script>
<script src="/public/mobile/js/jquery-1.10.2.js"></script>
</head>
<script src="/public/vue/vue.js"></script>
<script src="/public/vue/axios.min.js"></script>
<script src="/public/vue/vue-resource.min.js"></script>
<script src="/public/vue/request.js"></script>
<script src="/public/layui-v2.9.14/layui/layui.js"></script>
<link href="/public/layui-v2.9.14/layui/css/layui.css" rel="stylesheet">
<link href="/public/admin/css/style_mobile.css?v=4.1.0" rel="stylesheet">
<script>
layui.use('upload', function(){
var $ = layui.jquery,upload = layui.upload;
});
</script>
<style>
.layui-layer-btn .layui-layer-btn0 {
border-color: #30a2f0!important;
background-color: #30a2f0!important;
color: #fff;
}
</style>
<body>
<div id="vue">
<div class="header">
<div>
<a href="javascript:history.back(-1)">
<img src="/public/mobile/images/back.png">
</a>
</div>
<div>购物车</div>
</div>
<div class="body">
<div class="product">
<!--循环这个-->
<div class="product-box" v-for="item in list">
<div class="product-ckb">
<input type='checkbox' :checked="clsAll.indexOf(item.id)>=0" @click='checkedOne(item.id)'>
</div>
<div class="product-sx">
<div class="car_box1">
<div class="car_box1_img">
<img :src="item.img" class="product-img"/></div>
<div class="car_box1_box1">
<div><span class="product-name">{{item.goods_name}}</span></div>
<div class="product-box1">
<span class="product-price">¥<span class="price">{{item.price}}</span></span>
<div class="product-amount">
<div class="product_gw">
<em class="product-jian" @click="CartReduce(item.id,item.stocks)">-</em>
<input type="text" :value="item.goods_sum" class="product-num"/>
<em class="product-add" @click="CartIncrease(item.id,item.stocks)">+</em>
</div>
</div>
</div>
</div>
</div>
<div class="product-del" @click="CartDelete(item.id)">
<img src="/public/mobile/images/deleteico.png"/>
</div>
</div>
</div>
<!--循环这个-->
</div>
<div class="product-js">
<div class="product-al">
<div class="product-all">
<input type="checkbox" id="checkboxquanbu" @click='checkedAll()' />
</div>
<div class="all-xz">
<span class="product-all-qx">全选</span>
<div class="all-sl" style="display: none;">(<span class="product-all-sl">0</span>)</div>
</div>
</div>
<div class="all-product">
<span class="all-product-a">¥ <span class="all-price">0.00</span></span>
</div>
<a href="javascript:void(0)" @click="CartSubmit()" class="product-sett product-sett-a">结算</a>
</div>
</div>
<!--购物车空-->
<div class="kon-cat">
<div class="catkon">
<div class="kon-box">
<div class="kon-hz">
<img src="/public/mobile/images/cart-air.png" />
<span class="kon-wz">购物车什么都没有</span>
<a href="/mobile" class="kon-lj">去逛逛</a>
</div>
</div>
</div>
</div>
</div>
</body>
<style>
.layui-layer-btn .layui-layer-btn0 {
border-color: #39B449!important;
background-color: #39B449!important;
color: #fff;
}
</style>
<script>
var vm = new Vue({
el: '#vue',
data: {
'type':0,
'user_miyao': '',
'list':[],
'clsAll':[],
'isCheckedAll': false,
'clsAll_str':'',//已选中的购物车id
},
methods: {
/*购物车商品信息*/
CratList:function(){
var that = this;
req_post('/api/Goods/shopping', {'user_miyao': that.user_miyao}).then(res => {
if (res.code == 200){
that.list = res.data.list;
if (res.data.list_count > 0){
$(".kon-cat").css("display","none");
}else{
$(".all-price").text("0.00");
$(".product-all-qx").text("全选");
$(".all-sl").css("display","none");
$(".product-sett").addClass("product-sett-a");
$(".product-all em").removeClass("product-all-on");
$(".kon-cat").css("display","block");
}
}
});
},
/*购物车库存减少*/
CartReduce:function(id,stocks){
var that = this;
req_post('/api/Goods/shopping_sum_upload', {'user_miyao': that.user_miyao,'id':id,'stocks':stocks,'type':1}).then(res => {
if (res.code == 200){
that.CratList();
}
});
},
/*购物车库存增加*/
CartIncrease:function(id,stocks){
var that = this;
req_post('/api/Goods/shopping_sum_upload', {'user_miyao': that.user_miyao,'id':id,'stocks':stocks,'type':2}).then(res => {
if (res.code == 200){
that.CratList();
}
});
},
/*购物车删除*/
CartDelete:function(id){
var that = this;
parent.layer.confirm('您确定删除么?', {
btn: ['确定', '取消'], //按钮
shade: false //不显示遮罩
}, function () {
//执行关闭
var index = parent.layer.confirm();
parent.layer.close(index);
req_post('/api/Goods/shopping_del', {'user_miyao': that.user_miyao,'id':id}).then(res => {
that.CratList();
});
}, function () {
parent.layer.msg('已取消', {shift: 2});
});
},
/*复选框单选*/
checkedOne (id) {
let idIndex = this.clsAll.indexOf(id)
if (idIndex >= 0) {
// 如果已经包含了该id, 则去除(单选按钮由选中变为非选中状态)
this.clsAll.splice(idIndex, 1)
} else {
// 选中该checkbox
this.clsAll.push(id)
}
this.checked_inquire();
},
/*复选框多选*/
checkedAll () {
this.isCheckedAll = !this.isCheckedAll
if (this.isCheckedAll) {
// 全选时
this.clsAll = []
this.list.forEach(function (fruit) {
this.clsAll.push(fruit.id)
}, this)
} else {
this.clsAll = []
}
this.checked_inquire();
},
/*复选框选择查询*/
checked_inquire:function(){
var that = this;
req_post('/api/Goods/shopping_checked_inquire', {'user_miyao': that.user_miyao,'clsAll':that.clsAll}).then(res => {
if (res.code == 200){
that.clsAll_str = res.data.clsAll_str;
$(".product-all-sl").html(res.data.clsAll_count);
$(".all-price").html(res.data.order_price);
if (res.data.clsAll_count > 0){
$(".product-all-qx").text("已选");
$(".all-sl").css("display","inline-block");
$(".product-sett").removeClass("product-sett-a");
}else{
$("#checkboxquanbu").prop("checked",false);
$(".product-all-qx").text("全选");
$(".all-sl").css("display","none");
$(".product-sett").addClass("product-sett-a");
}
}
});
},
/*购物车提交*/
CartSubmit:function(){
var that = this;
window.location.href="/mobile/Order/order?cart_id="+that.clsAll_str;
},
},
created() {
var that = this;
that.user_miyao = "<?php echo htmlentities($base64_user_miyao); ?>";
that.CratList();
that.checked_inquire();
}
})
</script>
</html>