: :
HTML:
<viv> <div id = "showotherimage"> </viv> <span id = "openIdCardImg"> <span> </span> <input type = "file" id = "other_inputfile" name = "quientimg"/> </span> </viv>
.basicinfo .item {padding: .5Rem .5Rem 0 ؛ أعلى الحدود: .3REM SOLID #EEEEE ؛}. Margin-Bottom: .5rem ؛ Line-Line: 2.1rem ؛ Border-Bottom: 1px Solid #e3e3e3 ؛}. basicinfo li: last-child {border-bottom: none ؛}. خط الارتفاع: 2REM ؛}. Line-Height: 1.5rem ؛}. basicinfo .Otherpic {min-height: 3Rem ؛}. basicinfo .Otherpic .Addpic {height: 3rem ؛ خط الارتداد: 3REM ؛ حجم الخط: 3REM ؛ margin-bottom: .5Rem ؛}. basicinfo. IMG {margin: 0 .5REM .5REM 0 ؛ العرض: 3REM ؛ الارتفاع: 3REM ؛ المحاذاة الرأسية: أعلى ؛ الحدود: 1px Solid #DDD ؛}. basicinfo .yy_inputfile {position: absolute ؛ أعلى: 0 ؛ اليسار: 0 ؛ العرض: 3REM ؛ الارتفاع: 3REM ؛ Opitory: 0 ؛}. ارتفاع الخط: 1.5. }JS:
var img_arr = new array () ؛ // 相关图片 $ (page) .on ('change' ، '#other_inputfile' ، function () {$ (this) .resizeImage ({that: this ، cutwid: '' ، Quality: 0.6 ، limitwid: 710 ، success: function (data) <div style = "float:"> ' +' <img src = "' + img_arr [len] +'" + '<span sid = "' + len + '" id = "other_img _' + len + '" $ (#OpenIdCardImg '). // 删除相关图片 $ (page) .on ('click' ، '. deletedImages' ، function () {var sid = $ (this) .attr ('sid') ؛ img_arr.splice (sid ، 1) ؛ $ (this) .parent (). img = '<div style = "float: left ؛">' + '<img src = "' + img_arr [i]" $ ('#openIdCardimg'). show () ؛ * افعل شيئًا ... *} *}) * * */ $. var url = window.url || window.webkiturl ؛ var blob = url.createObjecturl (file) ؛ var base64 ؛ var img = new image () ؛ img.src = blob ؛ if (!/image /// w+/. test (obj.that.files [0] .type)) {$ .toast ("请上传图片!" ، 1000) ؛ العودة كاذبة } img.onload = function () {if (img.width <obj.limitwid) {$ .toast ('图片宽度不得小于' + obj.limitwid + 'px' ، 1000) ؛ العودة كاذبة } var that = this ؛ // 生成比例 var w ، scale ، h = that.height ؛ if (obj.cutwid == '') {w = that.width ؛ } آخر {w = obj.cutwid ؛ } مقياس = w / h ؛ h = w / scale ؛ // 生成 canvas var canvas = document.createElement ('canvas') ؛ var ctx = canvas.getContext ('2d') ؛ $ (canvas) .attr ({width: w ، height: h}) ؛ ctx.drawimage (هذا ، 0 ، 0 ، w ، h) ؛ // 生成 base64 base64 = canvas.todataurl ('Image/JPeg' ، obj.felicaly || 0.8) ؛ var result = {base64: base64} ؛ // 成功后的回调 obj.success (النتيجة) ؛ } ؛ } ؛以上就是本文的全部内容 , 希望对大家的学习有所帮助 , 也希望大家多多支持武林网。