Exemplo n.º 1
0
 editAction: function () {
   var $item        = this.$('.item');
   var $subBtn      = this.$('.sub-btn');
   var $checkBox    = this.$('.checkbox');
   var status       = this.model.get('editStatus');
   var $itemContent = this.$('.item-content'), checkHtml;
   if ( status ) {
     $item.addClass('weui_cells_checkbox');
     // 这里循环生成html,为了获得不同的for--id值
     // 过程比较复杂,大致为:先生成选择框label,然后把itemContent移到里面去
     // 移到里面去是为了能够点击每个item的时候都能选中input框
     // 这里面的操作全部为DOM操作,性能较低
     for (var i = 0,len = $itemContent.length; i < len; i++) {
       checkHtml = T.compile(U.checkHtml)({index:i});
       $(checkHtml).insertBefore( $itemContent[i] );
       var $label = this.$('label');
       $($label[i]).append( $itemContent[i] );
     }
     $checkBox = this.$('.checkbox');
     $subBtn.addClass("animate");
   } else {
     // 当取消编辑时,需要把移入到content中的checkbox移动到外面来
     // 暂时没有想到更好的方法去实现
     $item.removeClass('weui_cells_checkbox');
     $subBtn.removeClass("animate");
     for (var j = 0, length = $itemContent.length; j < length; j++) {
       $($itemContent[j]).insertAfter($checkBox[j]);
     }
     $checkBox.remove();
   }
 },
Exemplo n.º 2
0
 _removeItem: function ( deleteList ) {
   if ( !deleteList && deleteList.length === 0 ) return;
   var deleteItem = [];
   var $item = this.$(".item");
   for (var i = 0, len = deleteList.length; i < len; i++) {
     for (var j = 0, length = $item.length; j < length; j++) {
       if ( $($item[j]).data('sku_id') == deleteList[i] ) {
         $( $item[j] ).remove();
       }
     }
   }
 },
Exemplo n.º 3
0
 ele.parents().each(function ( i, v ) {
   var $item = $(v);
   if ( $item.hasClass('item')) {
     skuId = $item.data('sku_id');
     return skuId;
   }
 });
Exemplo n.º 4
0
 checkOn: function ( e ) {
   var $target = $( e.target );
   // 手机端会先触发label,然后在触发input,这里过滤掉label
   if ( $target[0].nodeName.toLowerCase() == 'label' ) return;
   var isChecked = $target.prop('checked');
   var action = isChecked ? 'add' : 'sub';
   var skuId = this._getSkuId( $target );
   this.model.updateNum( action, skuId );
 },
Exemplo n.º 5
0
 switchCate: function ( e ) {
   var status = this.model.get('cateStatus');
   var $cate = this.$('.category');
   var $list = $cate.find('.list');
   var $target = $(e.target);
   if ( $target.hasClass('cur') ) {
     this.updateCate( $target );
   }
   $list.toggleClass('active');
   this._changeIconStatus();
 },
Exemplo n.º 6
0
 $(window).on('scroll.coupon', function() {
     var $this = $(this);
     clearTimeout(timer);
     timer = setTimeout(function() {
         var scrollTop = $this.scrollTop();
         var height = $this.height();
         var scrollHeight = document.body.scrollHeight;
         if (scrollTop + height + 10 > scrollHeight) {
             self.showNextPage();
         }
     }, 100);
 });
Exemplo n.º 7
0
 actConfirmSelect: function( e ) {
     var that = this;
     var $target = $(e.target);
     if ( $target.hasClass('conflict') ) {
         Confirm.show('当前优惠券与订单折扣不能同时使用,确认使用优惠券?', function() {
             that.selectCoupon( $target );
         }, function() {
             that.$mod.find('input[ name= "couponRadio" ]').prop('checked', false);
             $oldChoice.prop('checked', true);
         });
     } else {
         that.selectCoupon( $target );
     }
 },
Exemplo n.º 8
0
 edit: function ( e ) {
   var $target = $(e.target);
   var editable = this.model.get('editable');
   var editStatus = this.model.get('editStatus');
   if ( editable ) {
     this._changeHeader( editable, $target );
     this.model.changeEditStatus();
     this.model.set('checkedNum', 0);
   }
   // 如果editable为false,且editStatus为true,则也需要完成
   if ( !editable && editStatus ) {
     this._changeHeader( editStatus, $target );
   }
 },
Exemplo n.º 9
0
 $(window).on('scroll.collect', function() {
   var $this = $(this);
   clearTimeout(that.timer);
   that.timer = setTimeout(function() {
     var scrollTop = $this.scrollTop();
     var height = $this.height();
     var scrollHeight = document.body.scrollHeight;
     if (scrollTop + height + 10 > scrollHeight) {
       if ( !that.isEnd ) {
         Loading.show('数据加载中...');
         that.model.getList({catid: that.catId, pn: that.model.pn + 12});
       }
     }
   }, 100);
 });
Exemplo n.º 10
0
    initialize: function ( options ) {
        artTpl.helper('desc_filter', filters.desc_filter);
        artTpl.helper('value_filter', filters.value_filter);
        artTpl.helper('date_filter', filters.date_filter);

        if( options ){
            this.model = new Model(options);
        }else {
            this.model = new Model();
        }
        //渲染容器
        $(document.body).append( this.$el );

        this.listenTo( this.model, 'sync', this.render );
        this.listenTo( this.model, 'change:currentCoupon', this.appendItem );

        if ( options && options.id ) {
            this.model.getList( true, options.id );
        } else {
            this.model.getList();
        }
        this.bindEvents();
    },
Exemplo n.º 11
0
 unbindEvent: function() {
     $(window).off('.coupon');
 }
Exemplo n.º 12
0
 close: function () {
   $('window').off('.collect');
 }
Exemplo n.º 13
0
 renderUI: function () {
   $(document.body).append( this.$el.html( U.ui /* 此处没有加载数据,可不用compile */) );
 },