mui.init(); var a = localStorage.getItem('token') //图片裁剪 var o = $(".image-crop > img"); $(o).cropper({ aspectRatio: 4 / 3, resizable: true, dragCrop: true, preview: ".img-preview", done: function() {} }); var r = $("#inputImage"); if(window.FileReader) { r.change(function() { $('.progress-bar').css('width', '0%'); $('.progress-bar').text('0%'); var e, i = new FileReader, t = this.files; if(t.length && (e = t[0], /^image\/\w+$/.test(e.type))) { i.readAsDataURL(e); i.onload = function() { r.val(""); o.cropper("reset", !0).cropper("replace", this.result); } } else { layer.msg("请选择图片文件"); } }); $("#setDrag").click(function() { o.cropper("setDragMode", "crop"); var img = o.cropper("getCroppedCanvas").toDataURL('image/png'); $.post(huayi.config.callcenter_url + "web/UploadImage", { dataurl: encodeURIComponent(img), "token": $.cookie("token") }, function(result) { result = $.parseJSON(result); if(result.state.toLowerCase() == "success") { //$(".yhtx").attr("src",result.data); $("#berImg").val(result.data.imgurl); $("#aftImg").val(result.data.smallimgurl); layer.msg("上传成功"); } }) }); $("#zoomIn").click(function() { o.cropper("zoom", .1) }); $("#zoomOut").click(function() { o.cropper("zoom", -.1) }); $("#rotateLeft").click(function() { o.cropper("rotate", 45) }); $("#rotateRight").click(function() { o.cropper("rotate", -45) }); } else { r.addClass("hide"); } //常见问题 document.getElementById('Question').addEventListener('tap', function() { var nwaiting = plus.nativeUI.showWaiting(); webviewShow = plus.webview.create("portrait_head.html"); //后台创建webview并打开show.html webviewShow.addEventListener("loaded", function() { //注册新webview的载入完成事件 nwaiting.close(); //新webview的载入完毕后关闭等待框 webviewShow.show("slide-in-right", 300); //把新webview窗体显示出来,显示动画效果为速度300毫秒的右侧移入动画 }, false); });