Нет описания

portrait_head.js 2.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. mui.init();
  2. var a = localStorage.getItem('token')
  3. //图片裁剪
  4. var o = $(".image-crop > img");
  5. $(o).cropper({
  6. aspectRatio: 4 / 3,
  7. resizable: true,
  8. dragCrop: true,
  9. preview: ".img-preview",
  10. done: function() {}
  11. });
  12. var r = $("#inputImage");
  13. if(window.FileReader) {
  14. r.change(function() {
  15. $('.progress-bar').css('width', '0%');
  16. $('.progress-bar').text('0%');
  17. var e, i = new FileReader,
  18. t = this.files;
  19. if(t.length && (e = t[0], /^image\/\w+$/.test(e.type))) {
  20. i.readAsDataURL(e);
  21. i.onload = function() {
  22. r.val("");
  23. o.cropper("reset", !0).cropper("replace", this.result);
  24. }
  25. } else {
  26. layer.msg("请选择图片文件");
  27. }
  28. });
  29. $("#setDrag").click(function() {
  30. o.cropper("setDragMode", "crop");
  31. var img = o.cropper("getCroppedCanvas").toDataURL('image/png');
  32. $.post(huayi.config.callcenter_url + "web/UploadImage", {
  33. dataurl: encodeURIComponent(img),
  34. "token": $.cookie("token")
  35. }, function(result) {
  36. result = $.parseJSON(result);
  37. if(result.state.toLowerCase() == "success") {
  38. //$(".yhtx").attr("src",result.data);
  39. $("#berImg").val(result.data.imgurl);
  40. $("#aftImg").val(result.data.smallimgurl);
  41. layer.msg("上传成功");
  42. }
  43. })
  44. });
  45. $("#zoomIn").click(function() {
  46. o.cropper("zoom", .1)
  47. });
  48. $("#zoomOut").click(function() {
  49. o.cropper("zoom", -.1)
  50. });
  51. $("#rotateLeft").click(function() {
  52. o.cropper("rotate", 45)
  53. });
  54. $("#rotateRight").click(function() {
  55. o.cropper("rotate", -45)
  56. });
  57. } else {
  58. r.addClass("hide");
  59. }
  60. //常见问题
  61. document.getElementById('Question').addEventListener('tap', function() {
  62. var nwaiting = plus.nativeUI.showWaiting();
  63. webviewShow = plus.webview.create("portrait_head.html"); //后台创建webview并打开show.html
  64. webviewShow.addEventListener("loaded", function() { //注册新webview的载入完成事件
  65. nwaiting.close(); //新webview的载入完毕后关闭等待框
  66. webviewShow.show("slide-in-right", 300); //把新webview窗体显示出来,显示动画效果为速度300毫秒的右侧移入动画
  67. }, false);
  68. });