123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- {include file="../application/h5/view/wx_book_dinner/header.html"}
- <div class="weui_cells weui_cells_checkbox">
- {foreach $data as $key => $value}
- <label class="weui_cell weui_check_label" for="s{$key}" id='cartId'>
- <div class="weui_cell_hd">
- <input type="checkbox" class="weui_check" name="checkbox" id="s{$key}" checked="checked">
- <i class="weui_icon_checked"></i>
- </div>
- <div class="weui_cell_bd weui_cell_primary">
- <p>{$value.name}</p>
- </div>
- <div style="font-size: 0px;" class="weui_cell_ft">
- <a href="javascript:;" class="weui-number weui-number-sub needsclick">-</a>
- <input pattern="[0-9]*" class="weui-number-input" style="width: 50px;" data-id="{$value.cart_id}" value="{$value.count}" data-min="0" data-max="100" data-step="1" onchange="changevaule(this);">
- <a href="javascript:;" class="weui-number weui-number-plus needsclick">+</a>
- </div>
- <div class="weui_cell_ft" style="display: none;"> 0 </div>
- </label>
- {/foreach}
- </div>
- {if $cartCount>0}
- <div class="weui-flex weui-list-btm" style="margin-bottom: 60px;">
- <div class="weui-flex-item" id="submitorder"><a href="javascript:count_order();" class="weui_btn weui_btn_warn">去结算</a></div>
- <!-- <div class="weui-flex-item"><a href="/WXBookDinner/BuildOrderAndPay" class="weui_btn weui_btn_warn">去结算新</a></div> -->
- </div>
- {else}
- <div class="weui_msg" style="display: block; opacity: 1;">
- <div class="weui_icon_area"><i class="weui_icon_msg weui_icon_info"></i></div>
- <div class="weui_text_area">
- <h2 class="weui_msg_title"></h2>
- <p class="weui_msg_desc">购物车里什么也没有</p>
- </div>
- <div class="weui_opr_area">
- <p class="weui_btn_area">
- <a href="{:url('index')}" class="weui_btn bg-blue-b">现在去挑选商品</a>
- </p>
- </div>
- <div class="weui_extra_area">
-
- </div>
- </div>
- {/if}
- <script type="text/javascript">
- function upDownOperation(element)
- {
- var _input = element.parent().find('input'),
- _value = _input.val(),
- _step = _input.attr('data-step') || 1;
- //检测当前操作的元素是否有disabled,有则去除
- element.hasClass('disabled') && element.removeClass('disabled');
- //检测当前操作的元素是否是操作的添加按钮(.input-num-up)‘是’ 则为加操作,‘否’ 则为减操作
- if ( element.hasClass('weui-number-plus') )
- {
- var _new_value = parseInt( parseFloat(_value) + parseFloat(_step) ),
- _max = _input.attr('data-max') || false,
- _down = element.parent().find('.weui-number-sub');
- //若执行‘加’操作且‘减’按钮存在class='disabled'的话,则移除‘减’操作按钮的class 'disabled'
- _down.hasClass('disabled') && _down.removeClass('disabled');
- if (_max && _new_value >= _max) {
- _new_value = _max;
- element.addClass('disabled');
- }
- _input.val( _new_value );
- changevaule(_input);
- } else {
- var _new_value = parseInt( parseFloat(_value) - parseFloat(_step) ),
- _min = _input.attr('data-min') || false,
- _up = element.parent().find('.weui-number-plus');
- //若执行‘减’操作且‘加’按钮存在class='disabled'的话,则移除‘加’操作按钮的class 'disabled'
- _up.hasClass('disabled') && _up.removeClass('disabled');
- if (_min && _new_value <= _min) {
- _new_value = _min;
- element.addClass('disabled');
- }
- _input.val( _new_value );
- changevaule(_input);
- //如果减到0了,就移除这个
- if(_new_value<=0){
- element.closest('#cartId').remove();
- // alert(JSON.stringify(it));
- // it.parent().remove(it);
- }
- }
- }
- $('.weui-number-plus').click(function(e){
- console.log(111);
- cancelBubble($(this));
- upDownOperation( $(this) );
- return false;
- });
- $('.weui-number-sub').click(function(e){
- cancelBubble($(this));
- upDownOperation( $(this) );
- return false;
- });
- function cancelBubble(e) {
- var evt = e ? e : window.event;
- if (evt.stopPropagation) { //W3C
- evt.stopPropagation();
- }else { //IE
- evt.cancelBubble = true;
- }
- }
- </script>
- <script type="text/javascript">
- function changevaule(self) {
- var _new_value = $(self).val();
- var DinnerCartId = $(self).attr('data-id');
- get_data('updateCart?id='+DinnerCartId+'&num='+_new_value,function(result){
- if(result.code==0){
- $('#badgecart').html(result.data.count);
- if(result.data.count>0){
- $('#badgecart').show();
- $('#submitorder').show();
- }else{
- $('#submitorder').hide();
- $('#badgecart').hide();
- window.location.href = 'cart';
- }
- }else{
- $.alert(result.message);
- }
- });
- }
- function count_order(){
- var Ids = '';
- $('.weui_cell').each(function(index, item){
- if($(item).find('.weui_check').prop("checked")){
- var DinnerCartId = $(item).find('.weui-number-input').attr('data-id');
- if(index>0){
- Ids +=',';
- }
- Ids +=DinnerCartId;
- }
- });
- if(Ids==''){
- $.alert('没有选择订单');
- }
- var url = 'submitorder?orders='+Ids;
- window.location.href = url;
- }
- </script>
|