1. 程式人生 > >js相關的一些東西

js相關的一些東西

1,post提交表單資料,七牛上傳圖片

    var qiniu_url = "{:C('img')}";
    var uptoken_url = "{:U('Admin/QiNiu/fuction')}";
    var thumb_list_show = $('#thumb-list-show');
    init_upLoad(uptoken_url, 'app/shop/picture_goods/','thumb-img-btn','thumb-img-area',function(url){
        var show_url = qiniu_url + url;
        var img_div = '<div class="form-group img-del-area" style="width:200px; height:150px; float:left" >'
            +'<input type="hidden" name="thumb_list" id="thumb-list" value="'+url+'" />'
            +'<img src="'+show_url+'" /><span class="img-del">關閉</span></div>';
        thumb_list_show.append(img_div);
    });
    thumb_list_show.on('click', '.img-del', function() {
        $this = $(this);
        $('#my-confirm-3').modal({
            relatedElement:this,
            onConfirm:function(){
                $this.closest('.img-del-area').remove();
            }
        });
    });

 

 var thumb_list = $('input[name="thumb_list"]');
        var thumb_div ;
        if (thumb_list.length > 0) {
            var img = new Image();
            var img_obj = {};
            $.each(thumb_list, function(index, elem) {
                var img_url = $(elem).val();
                img.src = qiniu_url + img_url;
                img_obj['url'] = img_url;
                thumb_div+='<input type="hidden" name="thumb_list[]" value="'+img_url+'|'+img.height+'|'+img.width+'" />'

            });
            $('#thumb-img').append(thumb_div);
        }
        var thumb_uuu = $('input[name="thumb_uuu"]').val();
        if(thumb_list.length == 0 && !thumb_uuu) {
            alert('至少上傳一張原圖');
            return;
        }

 

    <div class="am-g am-margin-top" id="thumb-lists-area">
              <div class="am-u-sm-2 am-text-right">縮圖(1-20張)</div>
              <div class="am-u-sm-10" id="thumb-list-show">
              </div>

                  <volist name="thumb_url" id="vo" key="vo">
                      <div class="am-u-sm-4" style="width:200px; height:200px; float:left" >
                      <img src="{:C('img_domain')}{$vo.url}"  alt="{$vo.url}"/>
                      </div>
                      <input type="hidden" id="thumb-uuu" name="thumb_uuu" value="{$vo.url}">
                  </volist>
              <div class="am-u-sm-6">
                  <div id="thumb-img-area">
                      <input type="button" id="thumb-img-btn" value="上傳圖片">
                  </div>
              </div>
          </div>

 

  <input type="hidden" name="shop_id" value="{$info.shop_id}">
  <div id="rty"  style="display:none;"></div><div id="title-img"  style="display:none;"></div><div id="thumb-img"  style="display:none;"></div>
  <input type="hidden" name="id" value="{$info.id}">

  <div class="am-margin">
    <button class="am-btn am-btn-primary am-btn-xs" id="add-shop-pic">提交儲存</button>
  </div>