美文网首页
上传图片

上传图片

作者: ml66 | 来源:发表于2016-09-06 16:09 被阅读0次
            //拍照上传
            function cameraOpen() {
               //回调方法
                uexCamera.cbOpen = function(opId, dataType, data) {
                    if (maxImg != 0) {
                        filefrom += "," + data;
                    } else {
                        filefrom += data;
                    }
                    var img = filefrom.split(",");
                    var imgList = "";
                    maxImg = 0
                    maxSelect = 5
                    for (var i in img) {
                        imgList += '<div class="ub-img uwh-adph umar-r-20" style="float:left;background-image:url(' + img[i] + ')"  onclick="deleteImg(\'' + img[i] + '\')"></div>'
                        maxImg++;
                        maxSelect--;
                    }
                    if (maxImg == 5) {
                        $('#tianzige').addClass("uhide")
                    }
                    $('#userimg').html(imgList)
                }
               //打开相机
                uexCamera.open();
            }
            //相册上传
            function imagePick() {
                //回调方法
                uexImage.onPickerClosed = function(data) {
                    console.log(data)
                    appcan.logs('onPickerClosed:' + data);
                    if (data == "") {
                        return;
                    }
                    var data = JSON.parse(data);
    
                    if (data.isCancelled == true) {
                        return;
                    }
                    for (var i = data.data.length - 1; i >= 0; i--) {
                        if (maxImg != 0) {
                            filefrom += "," + data.data[i];
                        } else {
                            filefrom += data.data[i];
                        }
                        maxImg++;
                    }
    
                    var img = filefrom.split(",");
                    var imgList = "";
                    maxImg = 0
                    maxSelect = 5
                    for (var i in img) {
                        imgList += '<div class=" ub-img uwh-adph umar-r-20" style="float:left;background-image:url(' + img[i] + ')"  onclick="deleteImg(\'' + img[i] + '\')"></div>'
                        maxImg++;
                        maxSelect--;
                    }
                    if (maxImg == 5) {
                        $('#tianzige').addClass("uhide")
                    }
                    $('#userimg').html(imgList)
                }
                var data = JSON.stringify({
                    min : 1,
                    max : maxSelect
                })
                //打开相册
                uexImage.openPicker(data);
            }
    

    相关文章

      网友评论

          本文标题:上传图片

          本文链接:https://www.haomeiwen.com/subject/chbdettx.html