|
提示脚本错误是什么意思 是代码哪段有问题么?
define(function(require) {
var $ = require("jquery");
var justep = require("$UI/system/lib/justep");
var Baas = require("$UI/demo/baas/baas");
var Model = function() {
this.callParent();
};
Model.prototype.uploadImage = function(imageURI) {
var me = this;
var options = new FileUploadOptions();
options.fileKey = "fileAddPic";// 用于设置参数
options.fileName = imageURI.substr(imageURI.lastIndexOf('/') + 1);
// 如果是图片格式,就用image/jpeg,其他文件格式上官网查API
options.mimeType = "image/jpeg";
// 这里的uri根据自己的需求设定,是一个接收上传图片的地址
var uri = encodeURI("http://10.71.84.211:8080/baas/uploadImage?userID=admin&action=upLoadImage");
options.chunkedMode = false;
var params = new Object();
params.id = "1";
params.name = "test";
options.params = params;
var ft = new FileTransfer();
function success(result) {
navigator.notification.progressStop();
me.button1Click(options.fileName);
}
function fail(message) {
alert("失败:" + JSON.stringify(message));
}
// 上传回调
ft.onprogress = showUploadingProgress;
navigator.notification.progressStart("", "当前上传进度");
ft.upload(imageURI, uri, success, fail, options);
};
// 显示上传进度
function showUploadingProgress(progressEvt) {
if (progressEvt.lengthComputable) {
navigator.notification.progressValue(Math.round((progressEvt.loaded / progressEvt.total) * 100));
}
}
Model.prototype.a1Click = function(event) {
event.currentTarget.parentNode.remove();
};
Model.prototype.button3Click = function(event) {
this.comp("popOver2").show();
};
Model.prototype.image1Click = function(event) {
var me = this;
window.closeP = function() {
me.closeP();
};
var src = event.currentTarget.currentSrc;
var img = $("<a href='javascript:closeP()' style='position: absolute;top:10px;'>关闭</a><img src='" + src + "'/>");
$(".img_content").contents().remove();
justep.Bind.addNodes(this.getElementByXid("div2"), img);
this.comp("popOver1").show();
// this.comp("windowDialog1").open({
// src : "$UI/uploadImage/viewImage.w",
// data : img
// })
};
Model.prototype.closeP = function() {
this.comp("popOver1").hide();
};
// 拍照
Model.prototype.button9Click = function(event) {
this.picSource(50, 1);
};
// 从相册选择
Model.prototype.button10Click = function(event) {
this.picSource(25, 2);
};
Model.prototype.picSource = function(quality, source) {
var me = this;
this.comp("popOver2").hide();
function onSuccess(imageURI) {
me.uploadImage(imageURI);
}
function onFail(message) {
return message;
}
navigator.camera.getPicture(onSuccess, onFail, {
quality : quality,
sourceType : source
});
};
Model.prototype.button1Click = function(fileName) {
var src = "http://10.71.84.211:8080/baas/uploadImage?action=showImage&name=" + fileName;
var imglist = $("<li> <a href=\"javascript:void(0)\" data-bind=\"event:{clickmodel._callModelFn.bind($model, 'a1Click\')}\" class='button_a icon-android-close'></a><img class='imgStyle' src='"
+ src + "' data-bind=\"event:{clickmodel._callModelFn.bind($model, 'image1Click\')}\"></img></li>");
justep.Bind.addNodes(this.getElementByXid("imglist"), imglist, this.getElementByXid("b_add"));
};
return Model;
}); |
|