jquery仿淘宝商城选择商品尺寸与大小颜色功能

jquery仿淘宝商城选择商品尺寸与大小颜色功能。

相关代码:https://download.csdn.net/download/pizilii/10537694

jquery代码调用:

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
<script>
//价格json
var sys_={
    "mktprice":"13.00",
    "price":"6.80",
    "sys_attrprice":{"3_13":{"price":"6.80","mktprice":"13.00"},"3_14":{"price":"7.80","mktprice":"14.00"},"3_16":{"price":"8.80","mktprice":"15.00"},"3_17":{"price":"9.80","mktprice":"16.00"},"4_13":{"price":"6.80","mktprice":"13.00"},"4_14":{"price":"7.80","mktprice":"14.00"},"4_16":{"price":"8.80","mktprice":"15.00"},"4_17":{"price":"9.80","mktprice":"16.00"},"8_13":{"price":"6.80","mktprice":"13.00"},"8_14":{"price":"7.80","mktprice":"1400"},"8_16":{"price":"8.80","mktprice":"15.00"},"8_17":{"price":"9.80","mktprice":"16.00"},"9_13":{"price":"6.80","mktprice":"13.00"},"9_14":{"price":"7.80","mktprice":"14.00"},"9_16":{"price":"8.80","mktprice":"15.00"},"9_17":{"price":"9.80","mktprice":"16.00"},"10_13":{"price":"6.80","mktprice":"13.00"},"10_14":{"price":"7.80","mktprice":"14.00"},"10_16":{"price":"8.80","mktprice":"15.00"},"10_17":{"price":"9.80","mktprice":"16.00"},"12_13":{"price":"6.80","mktprice":"13.00"},"12_14":{"price":"7.80","mktprice":"14.00"},"12_16":{"price":"8.80","mktprice":"15.00"},"12_17":{"price":"9.80","mktprice":"16.00"}}};
//商品规格选择
$(function(){
    $(".sys_item_spec .sys_item_specpara").each(function(){
        var i=$(this);
        var p=i.find("ul>li");
        p.click(function(){
            if(!!$(this).hasClass("selected")){
                $(this).removeClass("selected");
                i.removeAttr("data-attrval");
            }else{
                $(this).addClass("selected").siblings("li").removeClass("selected");
                
            }
            getattrprice() //输出价格
        })
    })
    //获取对应属性的价格
    function getattrprice(){
        var defaultstats=true;
        var _val='';
        var _resp=
            price:".sys_item_price"
        }  //输出对应的class
        $(".sys_item_spec .sys_item_specpara").each(function(){
           
            var v=i.attr("data-attrval");
            if(!v){
                defaultstats=false;
            }else{
                _val+=_val!=""?"_":"";
               
            }
        })
        if(!!defaultstats){
            _mktprice=sys_item['sys_attrprice'][_val]['mktprice'];
            _price=sys_item['sys_attrprice'][_val]['price'];
        }else{
            _mktprice=sys_item['mktprice'];
           
        }
        //输出价格
        $(_resp.mktprice).text(_mktprice);  ///其中的math.round为截取小数点位数
        $(_resp.price).text(_price);
    }
})
</script>



没有更多推荐了,返回首页

私密
私密原因:
请选择设置私密原因
  • 广告
  • 抄袭
  • 版权
  • 政治
  • 色情
  • 无意义
  • 其他
其他原因:
120
出错啦
系统繁忙,请稍后再试

关闭