You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

178 lines
5.2 KiB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
  1. var domino, window, document, location, Vue, VueRouter, navigator, axios, Promise, GoUseCall, GoUse, GoUseRegistered,
  2. govueId, useRoute, goUseCallCache, $, jQuery, GoParam;
  3. navigator = {
  4. userAgent: "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36"
  5. };
  6. var wx = {
  7. request: function (c) {
  8. var url = c["url"];
  9. var data = c["data"];
  10. var header = c["header"];
  11. var method = c["method"];
  12. var dataType = c["dataType"];
  13. var responseType = c["responseType"];
  14. var success = c["success"];
  15. var fail = c["fail"];
  16. var complete = c["complete"];
  17. // console.log("request");
  18. // console.log(url);
  19. var isHost = url.indexOf("http://") > -1 || url.indexOf("https://") > -1;
  20. var isAbs = (url[0] == '/');
  21. if (!isHost) {
  22. if (!isAbs) {
  23. url = location.pathname + "/" + url
  24. }
  25. url = location.host + "/" + url;
  26. for (; url.indexOf("//") > -1;) {
  27. url = url.replace("//", "/")
  28. }
  29. url = location.protocol + "//" + url
  30. }
  31. // console.log("url",url);
  32. var result = GoRequest({
  33. url: url,
  34. data: data,
  35. method: method,
  36. });
  37. result = JSON.parse(result);
  38. var statusCode = result["statusCode"];
  39. var data = result["data"];
  40. if (dataType == "json") {
  41. data = JSON.parse(data)
  42. }
  43. success({
  44. data: data,
  45. statusCode: statusCode,
  46. });
  47. }
  48. };
  49. /**
  50. * 获取页面Id
  51. * @return {string}
  52. */
  53. function GetGoVueId() {
  54. var id = "";
  55. if (document.getElementsByTagName("html").length > 0) {
  56. id = document.getElementsByTagName("html")[0].getAttribute("gv-id")
  57. }
  58. return id;
  59. }
  60. /**
  61. * 执行内联的javascript
  62. */
  63. function RunInlineCode() {
  64. var jsInline = document.getElementsByTagName("script");
  65. var jsInlineFiles = [];
  66. for (var i = jsInline.length - 1; i >= 0; i--) {
  67. var isGoVueSrc = jsInline[i].hasAttribute("gv-src");
  68. var isGoVueCommon = jsInline[i].hasAttribute("gv-common");
  69. if (isGoVueSrc) {
  70. var res = {};
  71. var file = jsInline[i].getAttribute("src");
  72. if (jsInline[i].hasAttribute("src") && file != "") {
  73. res["file"] = file
  74. }
  75. if (jsInline[i].text && jsInline[i].text != "") {
  76. res["src"] = jsInline[i].text;
  77. }
  78. if (res["file"] || res["src"]) {
  79. jsInlineFiles.unshift(res);
  80. }
  81. if (isGoVueCommon){
  82. jsInline[i].removeAttribute("gv-src");
  83. jsInline[i].removeAttribute("gv-common");
  84. }else{
  85. jsInline[i].remove();
  86. }
  87. }
  88. }
  89. for (var i in jsInlineFiles) {
  90. if (jsInlineFiles[i]["file"]) {
  91. GoRunCodeByFile(jsInlineFiles[i]["file"]);
  92. }
  93. if (jsInlineFiles[i]["src"]) {
  94. eval(jsInlineFiles[i]["src"]);
  95. }
  96. }
  97. }
  98. /**
  99. * 载入页面传入的参数
  100. */
  101. function LoadGoParam() {
  102. GoParam = jQuery.deparam(GoQuery);
  103. }
  104. /**
  105. * 忽略标签操作
  106. */
  107. var GoVueIgnore = function () {
  108. var gv_ignore_tag_map = {};
  109. var gv_ignore_class_map = {};
  110. var gv_ignore_len = 0;
  111. var gv_ignore_class_len = 0;
  112. /**
  113. * 忽略前置
  114. */
  115. this.ignore = function () {
  116. var gv_ignore = document.getElementsByTagName("gv-ignore");
  117. gv_ignore_len = gv_ignore.length;
  118. for (var i = gv_ignore_len - 1; i >= 0; i--) {
  119. gv_ignore_tag_map[i] = gv_ignore[i].innerHTML;
  120. gv_ignore[i].outerHTML = "<gv-ignore-" + i + "></gv-ignore-" + i + ">";
  121. }
  122. var gv_ignore_class = document.getElementsByClassName("gv-ignore");
  123. gv_ignore_class_len = gv_ignore_class.length;
  124. for (var i = 0; i < gv_ignore_class_len; i++) {
  125. if (!gv_ignore_class_map[i]) {
  126. gv_ignore_class_map[i] = {};
  127. }
  128. var a = gv_ignore_class[i].attributes;
  129. var len = gv_ignore_class[i].attributes.length;
  130. for (var k = len - 1; k >= 0; k--) {
  131. gv_ignore_class_map[i][a.item(k).name] = a.item(k).value;
  132. gv_ignore_class[i].removeAttribute(a.item(k).name);
  133. }
  134. gv_ignore_class[i].setAttribute("class", "gv-ignore-" + i)
  135. }
  136. };
  137. /**
  138. * 恢复忽略内容等待渲染
  139. */
  140. this.restore = function () {
  141. var gv_restore, i, k, j;
  142. for (i = 0; i < gv_ignore_len; i++) {
  143. gv_restore = document.getElementsByTagName("gv-ignore-" + i);
  144. for (k = 0; k < gv_restore.length; k++) {
  145. gv_restore[k].innerHTML = gv_ignore_tag_map[i];
  146. }
  147. }
  148. for (i = 0; i < gv_ignore_class_len; i++) {
  149. gv_restore = document.getElementsByClassName("gv-ignore-" + i);
  150. for (k = 0; k < gv_restore.length; k++) {
  151. for (j in gv_ignore_class_map[i]) {
  152. gv_restore[k].setAttribute(j, gv_ignore_class_map[i][j]);
  153. }
  154. }
  155. }
  156. }
  157. };