sign2.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. inapi = '/worker/sign';
  2. incert = '/worker/cert';
  3. var api_resign = function (_status) {
  4. var _url = +"?status=" + _status + "&site=" + oauth["site"] + "&uid=" + oauth["uid"] + "&id=" + in_id;
  5. if (_status < 2) {
  6. _url += "&ssl=" + oauth["ssl"] + "&path=" + oauth["path"] + "&ipa=" + oauth["ipa"] + "&replace=" + $("#in_replace").val() + "&suo=" + $("#in_suo").val() + "&yololib=" + oauth["yololib"] + "&newname=" + $("#in_newname").val() + "&cert=" + $("#in_cert").val() + "&charset=" + oauth["charset"] + "&name=" + oauth["name"];
  7. }
  8. $.get(oauth["api"] + inapi, oauth, function (ret) {
  9. if (ret.code == 1) {
  10. _status < 2 ? sign(0) : location.reload();
  11. } else {
  12. layer.msg(ret.msg, 3, 8);
  13. }
  14. }, 'json');
  15. };
  16. var get_cert_list = function () {
  17. $.get(oauth["api"] + incert, oauth,
  18. function (ret) {
  19. if (ret.msg) {
  20. layer.msg(ret.msg, 3, 8);
  21. }
  22. if (ret.data && ret.data.list.length) {
  23. $("#in_cert").html('');
  24. $.each(ret.data.list, function (k, v) {
  25. $("#in_cert").append('<option value="' + v + '">' + v + '</option>');
  26. });
  27. } else {
  28. $("#in_cert").html('没有可用证书');
  29. }
  30. }, 'json');
  31. };
  32. function reset_sign_confirm() {
  33. $.layer({
  34. shade: [0],
  35. area: ["auto", "auto"],
  36. dialog: {
  37. msg: "确定要重置签名吗?",
  38. btns: 2,
  39. type: 4,
  40. btn: ["确定", "取消"],
  41. yes: function () {
  42. reset_sign();
  43. },
  44. no: function () {
  45. layer.msg("已取消重置", 1, 0);
  46. }
  47. }
  48. });
  49. }
  50. function reset_sign() {
  51. var xhr = new XMLHttpRequest();
  52. xhr.open("GET", in_path + "index/ajax_sign/reset?aid=" + in_id, true);
  53. xhr.onreadystatechange = function () {
  54. if (xhr.readyState == 4) {
  55. if (xhr.status == 200) {
  56. if (xhr.responseText == -1) {
  57. layer.msg("请先登录后再操作!", 3, 11);
  58. } else if (xhr.responseText == -2) {
  59. layer.msg("应用不存在或已被删除!", 3, 11);
  60. } else if (xhr.responseText == -3) {
  61. layer.msg("您不能重置别人的应用!", 3, 8);
  62. } else if (xhr.responseText == -4) {
  63. layer.msg("该应用未在进行签名!", 3, 8);
  64. } else {
  65. location.reload();
  66. }
  67. } else {
  68. layer.msg("通讯异常,请检查网络设置!", 3, 3);
  69. }
  70. }
  71. };
  72. xhr.send(null);
  73. }
  74. function sign_confirm() {
  75. $.layer({
  76. shade: [0],
  77. area: ["auto", "auto"],
  78. dialog: {
  79. //msg: '<font color="#000fff">签名将会去除下列文件名注入的签名锁 <br>功能性动态库请勿使用下列文件名注入<br>否则您注入的动态库将失效!<br> sign.data <br> sign.dylib <br> embedded.dylib<br> embedded.png <br> XXGamePlugin <br>如已注入以上名称的动态库请取消签名 <br>并修改功能文件注入名称后重新上传ipa <br>再重新签名!<br><br>确定要开始签名吗?</font>',
  80. msg: '确定要开始签名吗?',
  81. btns: 2,
  82. type: 4,
  83. btn: ["确定", "取消"],
  84. yes: function () {
  85. $("#in_cert").val() == "" ? layer.msg("请选择企业证书", 1, 0) : sign(1);
  86. },
  87. no: function () {
  88. layer.msg("已取消签名", 1, 0);
  89. }
  90. }
  91. });
  92. }
  93. function sign(_check) {
  94. if (remote > 0) {
  95. //layer.msg("不支持云存储签名!", 3, 8);
  96. //return false;
  97. }
  98. var cert = $("#cert_" + $("#in_cert").val()).text();
  99. var xhr = new XMLHttpRequest();
  100. xhr.open("GET", in_path + "index/ajax_sign/sign?check=" + _check + "&cert=" + encodeURIComponent(cert) + "&aid=" + in_id, true);
  101. xhr.onreadystatechange = function () {
  102. if (xhr.readyState == 4) {
  103. if (xhr.status == 200) {
  104. if (xhr.responseText == -1) {
  105. layer.msg("请先登录后再操作!", 3, 11);
  106. } else if (xhr.responseText == -2) {
  107. layer.msg("应用不存在或已被删除!", 3, 11);
  108. } else if (xhr.responseText == -3) {
  109. layer.msg("您不能签名别人的应用!", 3, 8);
  110. } else if (xhr.responseText == -4) {
  111. layer.msg("不能签名Android应用!", 3, 8);
  112. } else if (xhr.responseText == -5) {
  113. layer.msg("该应用未开通企业签名!", 3, 8);
  114. } else if (xhr.responseText == -6) {
  115. layer.msg("该应用补签名额不足!", 3, 8);
  116. } else if (xhr.responseText == -7) {
  117. layer.msg("该应用正在进行签名!", 3, 8);
  118. } else {
  119. _check > 0 ? api_resign(1) : location.reload();
  120. }
  121. } else {
  122. layer.msg("通讯异常,请检查网络设置!", 3, 3);
  123. }
  124. }
  125. };
  126. xhr.send(null);
  127. }
  128. function listen() {
  129. var xhr = new XMLHttpRequest();
  130. xhr.open("GET", in_path + "index/ajax_sign/listen?aid=" + in_id, true);
  131. xhr.onreadystatechange = function () {
  132. if (xhr.readyState == 4 && xhr.status == 200) {
  133. var data = eval("(" + xhr.responseText + ")");
  134. if (xhr.responseText == -1) {
  135. $("#_listen").text("请先登录后再操作!");
  136. } else if (data["status"] == 2) {
  137. api_resign(2);
  138. } else if (data["step"] == "download") {
  139. $("#_listen").text("正在解析文件,请稍等..." + data["percent"] + "%");
  140. } else if (data["step"] == "sign") {
  141. $("#_listen").text("正在进行签名,请稍等..." + data["percent"] + "%");
  142. } else if (data["step"] == "upload") {
  143. $("#_listen").text("正在进行回传,请稍等..." + data["percent"] + "%");
  144. }
  145. }
  146. };
  147. xhr.send(null);
  148. }
  149. function download() {
  150. var xhr = new XMLHttpRequest();
  151. xhr.open("GET", in_path + "index/ajax_sign/download?aid=" + in_id, true);
  152. xhr.onreadystatechange = function () {
  153. if (xhr.readyState == 4) {
  154. if (xhr.status == 200) {
  155. if (xhr.responseText == -1) {
  156. layer.msg("请先登录后再操作!", 3, 11);
  157. } else if (xhr.responseText == -2) {
  158. layer.msg("应用不存在或已被删除!", 3, 11);
  159. } else if (xhr.responseText == -3) {
  160. layer.msg("您不能下载别人的应用!", 3, 8);
  161. } else if (xhr.responseText == -4) {
  162. layer.msg("该应用暂未完成签名!", 3, 8);
  163. } else {
  164. location.href = xhr.responseText;
  165. }
  166. } else {
  167. layer.msg("通讯异常,请检查网络设置!", 3, 3);
  168. }
  169. }
  170. };
  171. xhr.send(null);
  172. }
  173. function purchase(_key) {
  174. var xhr = new XMLHttpRequest();
  175. xhr.open("GET", in_path + "index/ajax_sign/purchase?aid=" + in_id + "&key=" + _key, true);
  176. xhr.onreadystatechange = function () {
  177. if (xhr.readyState == 4) {
  178. if (xhr.status == 200) {
  179. if (xhr.responseText == -1) {
  180. layer.msg("请先登录后再操作!", 3, 11);
  181. } else if (xhr.responseText == -2) {
  182. layer.msg("应用不存在或已被删除!", 3, 11);
  183. } else if (xhr.responseText == -3) {
  184. layer.msg("密钥不正确或已被使用!", 3, 8);
  185. } else if (xhr.responseText == 1) {
  186. location.reload();
  187. }
  188. } else {
  189. layer.msg("通讯异常,请检查网络设置!", 3, 3);
  190. }
  191. }
  192. };
  193. xhr.send(null);
  194. }
  195. function tishi() {
  196. alert('签名开始后请勿切换到其他页面或刷新\n否则可能签名失败,请耐心等待!');
  197. }
  198. function tishi1() {
  199. alert('签名将会去除下列文件名注入的签名锁 \n功能性动态库请勿使用下列文件名注入\n否则您注入的动态库将失效!\n sign.data \n sign.dylib \n embedded.dylib\n embedded.png \n XXGamePlugin \n如已注入以上名称的动态库请取消签名 \n并修改功能文件注入名称后重新上传ipa \n再重新签名!');
  200. }
  201. function change(type) {
  202. var inre = $("#in_replace").val();
  203. if (type == 1) {
  204. $('#check').html('<input type="text" class="col-sm-9 linkform-control" value="*.*|*" id="in_replace" style="display:none;" readonly="true">');
  205. }
  206. if (inre == '*.*|*') {
  207. $('#check').html('<input type="text" class="col-sm-9 link" placeholder="指定特殊签名文件,默认留空!多文件以 | 隔开" id="in_replace"><br><br>');
  208. }
  209. }