lib.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. function upload_mc_a_icon() {
  2. var upfile = $("#upload_mc_a_icon")[0].files[0];
  3. if (in_login < 1) {
  4. alert("请先登录");
  5. return false;
  6. }
  7. if (upfile.size > 1048576) {
  8. alert("图标不能大于1M");
  9. return false;
  10. }
  11. var fd = new FormData();
  12. fd.append("webview", upfile);
  13. var a_icon_xhr = new XMLHttpRequest();
  14. a_icon_xhr.open("post", in_path + "webview/ajax");
  15. a_icon_xhr.onload = complete_mc_a_icon;
  16. a_icon_xhr.onerror = failed_mc_a_icon;
  17. a_icon_xhr.upload.onprogress = progress_mc_a_icon;
  18. a_icon_xhr.send(fd);
  19. }
  20. function progress_mc_a_icon(evt) {
  21. var per = Math.round(evt.loaded / evt.total * 100);
  22. $("#tips_mc_a_icon").text(per + "%");
  23. if (per > 99) {
  24. $("#tips_mc_a_icon").text("请稍等...");
  25. }
  26. }
  27. function complete_mc_a_icon(evt) {
  28. var response = evt.target.responseText;
  29. if (response == "return_0") {
  30. alert("文件不规范");
  31. } else {
  32. $("#preview_mc_a_icon").html('<img width="100" height="100" src="' + in_path + "data/tmp/" + response + '">');
  33. }
  34. }
  35. function failed_mc_a_icon() {
  36. alert("上传异常");
  37. }
  38. var id = '';
  39. function mobile_config() {
  40. if (in_login < 1) {
  41. alert("请先登录后再操作!");
  42. return;
  43. }
  44. if ($("#mc_title").val() == "") {
  45. $("#mc_title").focus();
  46. return;
  47. }
  48. if ($("#mc_url").val() == "") {
  49. $("#mc_url").focus();
  50. return;
  51. }
  52. if ($("#preview_mc_a_icon img").length < 1) {
  53. alert("请上传应用图标!");
  54. return;
  55. }
  56. $(".mc-btn").attr("disabled", "disabled").text("生成中...");
  57. var data = {
  58. id: $('input[name=id]').val(),
  59. title: escape($("#mc_title").val()),
  60. url: $("#mc_url").val(),
  61. aicon: $("#preview_mc_a_icon img")[0].src,
  62. period: $('ul.period>li.active').attr('data-id'),
  63. bid: $("#in_bid").val(),
  64. version: $("#version").val(),
  65. FullScreen: $('input[name=FullScreen]:checked').val(),
  66. IsRemovable: $('input[name=IsRemovable]:checked').val(),
  67. IsRemovURL: $('input[name=IsRemovURL]:checked').val()
  68. }
  69. ;
  70. $.post(in_path + "webview/ajax/mobileconfig", data, function (ret) {
  71. if (ret.code == -1) {
  72. alert("请先登录");
  73. } else if (ret.code == -2) {
  74. alert("余额不足", function () {
  75. window.location.href = "/index/item_price?type=1";
  76. });
  77. } else if (ret.code == -3) {
  78. alert("未进行实名认证或认证审核中!");
  79. } else if (ret.code == -4) {
  80. alert("应用容量不足!请升级VIP!", function () {
  81. window.location.href = "/index/item_price?type=2";
  82. });
  83. } else if (ret.data) {
  84. // $('.ng-binding').eq(0).hide().siblings().show();
  85. id = ret.data.id;
  86. window.location.href = "/index/webview_log?id=" + ret.data.id;
  87. }
  88. }, 'json');
  89. }
  90. function createHtml() {
  91. if (id) {
  92. var url = "/index/webview/createHtml?id=" + id;
  93. location.href = url;
  94. // window.open();
  95. } else {
  96. alert('请完成封装后下载此文件');
  97. }
  98. }
  99. function downloadFile() {
  100. var url = "/index/webview/download?id=" + id;
  101. location.href = url;
  102. }
  103. function publish() {
  104. location.href = "/webview/ajax/pub?id=" + id;
  105. }