作者 lihan
1 个管道 的构建 通过 耗费 0 秒

修改bug阶段

... ... @@ -172,6 +172,11 @@ class CenterController extends HomeBaseController
upload();
}
public function upload2()
{
upload2();
}
public function orderList()
{
$order = new OrderModel;
... ...
... ... @@ -209,13 +209,13 @@
return param;
}
function previewImage(file) {
var MAXWIDTH =60;
var MAXHEIGHT =77;
var MAXWIDTH = 60;
var MAXHEIGHT = 77;
var div = document.getElementById('preview');
if(file.files && file.files[0]) {
if (file.files && file.files[0]) {
div.innerHTML = '<img id=imghead onclick=$("#previewImg").click()>';
var img = document.getElementById('imghead');
img.onload = function() {
img.onload = function () {
var rect = clacImgZoomParam(MAXWIDTH, MAXHEIGHT, img.offsetWidth, img.offsetHeight);
img.width = rect.width;
img.height = rect.height;
... ... @@ -223,13 +223,13 @@
//img.style.marginTop = rect.top + 'px';
}
var reader = new FileReader();
reader.onload = function(evt) {
reader.onload = function (evt) {
src = evt.target.result;
console.log(src);
var text='';
text+=' <div class="pushimg">' +
var text = '';
text += ' <div class="pushimg">' +
'<p class="enter_photo">' +
'<img src="'+src+'" alt="">' +
'<img src="' + src + '" alt="">' +
'</p>' +
'<p class="cancel">' +
'<img src="__INDEX__/img/cancel.png" alt="">' +
... ... @@ -239,7 +239,7 @@
$(".addimg").append(text);
img.src='__INDEX__/img/tianjia@2x.png';
img.src = '__INDEX__/img/tianjia@2x.png';
}
reader.readAsDataURL(file.files[0]);
} else //兼容IE
... ... @@ -255,56 +255,37 @@
div.innerHTML = "<div id=divhead style='width:" + rect.width + "px;height:" + rect.height + "px;margin-top:" + rect.top + "px;" + sFilter + src + "\"'></div>";
}
$(this).attr("src","__INDEX__/img/tianjia@2x.png");
var len=$(".enter_photo");
$(this).attr("src", "__INDEX__/img/tianjia@2x.png");
var len = $(".enter_photo");
console.log(len.length)
if(len==3){
$("#preview").css("display","none")
if (len == 3) {
$("#preview").css("display", "none")
}
//删除图片
console.log($(".addimg"))
$(".addimg").on("click",".cancel",function(){
$(".addimg").on("click", ".cancel", function () {
$(this).parent(".pushimg").remove()
})
// var formData = new FormData();
// var fileM = document.querySelector("#previewImg");
// console.log(fileM)
// var fileObj = fileM.files[0];
// console.log(fileObj);
// formData.append("files", fileObj);
// $.ajax({
// url: 'http://hula.wx.bronet.cn/index.php/MyComment/upload',
// type: 'POST',
// data: formData,
// async: false,
// cache: false,
// contentType: false,
// processData: false,
// success: function(res) {
// console.log(res);
// pic = res.data;
// console.log(pic);
// imgurl.push(pic);
// console.log(imgurl)
// var text = '';
// text += '<div class="evaluate_pic_item" style="float:left">' +
// '<img src="' + pic + '" class="delimg"/>' +
// '<div class="icon">' +
// '<img src="../img/cancel.png" />' +
// '</div>' +
// '</div>'
// $(".addimg").append(text);
// if(imgurl.length == 3) {
// $(".imgone").css("display", "none");
// }
// $("#imghead").attr("src","../img/3@2x.png");
// },
// error: function() {
//
// }
// });
var formData = new FormData();
var fileM = document.querySelector("#previewImg");
console.log(fileM)
var fileObj = fileM.files[0];
console.log(fileObj);
formData.append("files", fileObj);
$.ajax({
url: "{:url('user/Center/upload2')}",
type: 'POST',
data: formData,
async: false,
cache: false,
contentType: false,
processData: false,
success: function (data) {
console.log(data);
}
});
}
$(".publish").click(function () {
... ... @@ -312,7 +293,7 @@
url:"",
data:{
file1:'',
fiel2:'',
file2:'',
},
type:"POST",
dataType:"JSON",
... ...
... ... @@ -1882,4 +1882,31 @@ function upload()
}
}
}
function upload2()
{
$request = request();
if ($request->isAjax()) {
$file = request()->file('file');
$info = $file->move(ROOT_PATH . 'public' . DS . 'upload/portal/comment');
if ($info) {
// 成功上传后 获取上传信息
// 输出 jpg
//echo $info->getExtension();
// 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
$save = cmf_get_image_url('portal/comment/' . $info->getSaveName());
// 输出 42a79759f284b767dfcb2a0197904287.jpg
//echo $info->getFilename();
//更新头像
//原始头像
echo json_encode(['msg' => 'ok', 'data' => $save]);
exit();
} else {
// 上传失败获取错误信息
echo $file->getError();
exit();
}
}
}
\ No newline at end of file
... ...