Blame view

public/js/home/orders.page.js 1.93 KB
weiqingting authored
1 2 3 4 5
/**
 * 我的订单
 * @author: xuqi<qi.xu@yoho.cn>
 * @date: 2016/2/17
 */
htoooth authored
6
var $ = require('yoho-jquery');
weiqingting authored
7
htoooth authored
8 9
require('../common');
require('./orders/order-block');
weiqingting authored
10
htoooth authored
11
// 不同订单包裹提示
weiqingting authored
12 13 14

$('.why').click(function() {
    $('#differentBag').show();
yyq authored
15
    $(this).addClass('on');
weiqingting authored
16 17 18 19 20 21 22 23
    return false;

});
$('#differentBag').click(function() {
    return false;
});
$(document).click(function() {
    $('#differentBag').hide();
yyq authored
24
    $('.why').removeClass('on');
weiqingting authored
25 26 27
});

htoooth authored
28
// 订单包裹左右切换
weiqingting authored
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
function lunBo($pre, $next, $ul, $iWidth) {
    var i = 1,
        j = 1;

    var iSpeed = 0,
        isMoving = false;

    $pre.click(function() {
        if (isMoving) {
            return;
        }

        if ($ul.css('left') === '0px') {
            iSpeed = 0;

        } else {
            iSpeed += j * $iWidth;
            isMoving = true;
        }
        $ul.stop().animate({
            left: iSpeed
        }, 300, function() {
            isMoving = false;
        });
    });
    $next.click(function() {
        var $largeLeft = $ul.parent().width() - $ul.width() + 'px';

        if (isMoving) {
            return;
        }

        if ($ul.css('left') === $largeLeft) {
            $ul.css('left', $largeLeft);
        } else {
            iSpeed += -i * $iWidth;
            isMoving = true;
        }

        $ul.stop().animate({
            left: iSpeed
        }, 300, function() {
            isMoving = false;
        });
    });
}
htoooth authored
76
// 订单分类
weiqingting authored
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
$('.bag').find('ul').each(function() {
    var $pre = $(this).parent().parent().find('.pre');
    var $next = $(this).parent().parent().find('.next');

    var $iWidth = $(this).find('li').eq(0).width();
    var $length = $(this).find('li').size();
    var $ulWidth = $iWidth * $length;

    $(this).css('width', $ulWidth);
    if ($length > 5) {
        $pre.show();
        $next.show();
        lunBo($pre, $next, $(this), $iWidth);
    } else {
        $pre.hide();
        $next.hide();
    }

});