<div class="order_message clearfix">
<div class="left_order">
<img src="templates/default/images/order.jpg">
</div>
<div class="right_order">
<p class="order_title">春夏套装</p>
<p class="bottom_content">
<span class="price_Icon colors">¥</span><span class="details_price colors unitPrice">198</span>
<span class="rf add_order">
<span οnclick="reduce()" class="reduce"><img src="templates/default/images/reduce3.png" /></span>
<span class="numbers number">1</span>
<span οnclick="addNumber()" class="addNumber"><img src="templates/default/images/add1.png" /></span>
</span>
</p>
<p class="all_order">
<span class="rf">
<span>总价</span>
<span class="price_Icon">¥</span><span class="details_price all_nuber">198</span>
</span>
<span class="rf marginright02">
<span>共 </span><span class="number">1</span><span> 件商品</span>
</span>
</p>
</div>
</div>
<div class="sumbit">
<p class="lf"><span>应付 ¥</span><span class="all_nuber"></span></p>
<p class="rf">去付款</p>
</div>
<script src="templates/default/js/jquery-3.3.1.min.js"></script>
<script>
function reduce(){
var number=$(".number").html();
if(number==1){
statas1();
}else{
number--;
var price=parseInt($(".unitPrice").html());
var allprice=number*price;
$(".all_nuber").html(allprice);
$(".number").html(number);
}
}
function addNumber(){
var number=$(".number").html();
//获取库存
var Stock=8;
if(number>=Stock){
}else{
number++;
statas();
var price=parseInt($(".unitPrice").html());
var allprice=number*price;
$(".all_nuber").html(allprice);
$(".number").html(number);
}
}
// 如果商品数大于一,替换减号状态
function statas(){
$(".reduce img").attr("src","templates/default/images/reduce2.png");
}
function statas1(){
$(".reduce img").attr("src","templates/default/images/reduce3.png");
}
</script>