accredit.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. `
  2. <!DOCTYPE html>
  3. <html>
  4. <head>
  5. <meta charset="utf-8">
  6. <meta name="viewport"
  7. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, minimal-ui">
  8. <meta name="screen-orientation" content="portrait" />
  9. <meta name="apple-mobile-web-app-capable" content="yes">
  10. <meta name="format-detection" content="telephone=no">
  11. <meta name="full-screen" content="yes">
  12. <meta name="x5-fullscreen" content="true">
  13. <script src="./js/jweixin-1.0.0.js"></script>
  14. <script src="./js/axios.min.js"></script>
  15. <title>正在授权请稍后</title>
  16. <style type="text/css">
  17. html,
  18. body {
  19. height: 100%;
  20. }
  21. html {
  22. font-size: calc(100vw/7.5);
  23. }
  24. .object {
  25. -moz-border-radius: 50% 50% 50% 50%;
  26. -webkit-border-radius: 50% 50% 50% 50%;
  27. border-radius: 50% 50% 50% 50%;
  28. position: absolute;
  29. border-left: 0.05rem solid #fff;
  30. border-right: 0.05rem solid #fff;
  31. border-top: 0.05rem solid transparent;
  32. border-bottom: 0.05rem solid transparent;
  33. -webkit-animation: animate 2s infinite;
  34. animation: animate 2s infinite;
  35. }
  36. #object_one {
  37. left: 1.25rem;
  38. top: 0.65rem;
  39. width: 0.5rem;
  40. height: 0.5rem;
  41. }
  42. #object_two {
  43. left: 1.15rem;
  44. top: 0.55rem;
  45. width: 0.7rem;
  46. height: 0.7rem;
  47. -webkit-animation-delay: 0.1s;
  48. animation-delay: 0.1s;
  49. }
  50. #object_three {
  51. left: 1.05rem;
  52. top: 0.45rem;
  53. width: 0.9rem;
  54. height: 0.9rem;
  55. -webkit-animation-delay: 0.2s;
  56. animation-delay: 0.2s;
  57. }
  58. #object_four {
  59. left: 0.95rem;
  60. top: 0.35rem;
  61. width: 1.1rem;
  62. height: 1.1rem;
  63. -webkit-animation-delay: 0.3s;
  64. animation-delay: 0.3s;
  65. }
  66. @-webkit-keyframes animate {
  67. 50% {
  68. -ms-transform: rotate(180deg);
  69. -webkit-transform: rotate(180deg);
  70. transform: rotate(180deg);
  71. }
  72. 100% {
  73. -ms-transform: rotate(0deg);
  74. -webkit-transform: rotate(0deg);
  75. transform: rotate(0deg);
  76. }
  77. }
  78. @keyframes animate {
  79. 50% {
  80. -ms-transform: rotate(180deg);
  81. -webkit-transform: rotate(180deg);
  82. transform: rotate(180deg);
  83. }
  84. 100% {
  85. -ms-transform: rotate(0deg);
  86. -webkit-transform: rotate(0deg);
  87. transform: rotate(0deg);
  88. }
  89. }
  90. </style>
  91. <body>
  92. <div class="spinner-box" style="z-index: 1000;
  93. width:100%;
  94. height: 100%;
  95. position: absolute;
  96. top:0;
  97. left: 0;">
  98. <div id="loading-center-absolute" style="position: absolute;
  99. left: 50%;
  100. top: 40%;
  101. height: 2.5rem;
  102. width: 3rem;
  103. border-radius:0.2rem;
  104. background:rgba(0,0,0,0.7);
  105. margin-top: -1rem;
  106. margin-left: -1.5rem;">
  107. <div class="object" id="object_four"></div>
  108. <div class="object" id="object_three"></div>
  109. <div class="object" id="object_two"></div>
  110. <div class="object" id="object_one"></div>
  111. <p style="color:#fff;
  112. text-align:center;
  113. font-size:0.35rem;
  114. font-weight: 700;
  115. height:1rem;
  116. line-height:1rem;
  117. margin-top:1.5rem;">加载中</p>
  118. </div>
  119. </div>
  120. <script>
  121. function getUrlParam(name, explode, url) {
  122. var param = window.location.search.substr(1);
  123. if (url) {
  124. if (explode) {
  125. param = url.substr(url.indexOf(explode) + 1);
  126. } else {
  127. param = url.substr(url.indexOf('?') + 1);
  128. }
  129. } else {
  130. if (explode) {
  131. param = window.location.href.substr(window.location.href.indexOf(explode) + 1);
  132. }
  133. }
  134. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
  135. var r = param.match(reg);
  136. if (r != null) return unescape(r[2]);
  137. return '';
  138. }
  139. if (!getUrlParam("code")) {
  140. // 未携带code时获取agent_id
  141. let agent_id = getUrlParam("agent_id");
  142. localStorage.setItem("agent_id", agent_id);
  143. //获取appId接口
  144. axios.get("http://zhejiangmiliangxiansheng.zjmlxs.com/wxsite/index/wxConfig", {
  145. params: {
  146. 'agent_id': agent_id
  147. }
  148. }).then(function(response) {
  149. if (response.data.code == 1) {
  150. if (localStorage.getItem("appid") == response.data.data.app_id) {
  151. if (!localStorage.getItem("openid") || localStorage.getItem("openid") == null || localStorage.getItem(
  152. "openid") == "undefined") {
  153. // 获取微信code
  154. window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + localStorage
  155. .getItem("appid") + "&redirect_uri=" + location.href +
  156. "&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect";
  157. } else {
  158. // 定向到项目H5页面
  159. window.location.href = "http://zhejiangmiliangxiansheng.zjmlxs.com/H5/index.html#/skip?skipType=home";
  160. }
  161. } else {
  162. localStorage.setItem("appid", response.data.data.app_id);
  163. localStorage.removeItem("token");
  164. localStorage.removeItem("openid");
  165. // 获取微信code
  166. window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + localStorage
  167. .getItem("appid") + "&redirect_uri=" + location.href +
  168. "&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect";
  169. }
  170. } else {
  171. alert(response.data.msg)
  172. }
  173. }).catch(function(error) {
  174. alert(error)
  175. });
  176. } else {
  177. // 携带code时必然为微信跳转回来的地址
  178. let code = getUrlParam("code");
  179. // 获取openId接口
  180. axios.get("http://zhejiangmiliangxiansheng.zjmlxs.com/wxsite/index/getWxInfo", {
  181. params: {
  182. 'code': code,
  183. 'agent_id': localStorage.getItem("agent_id")
  184. }
  185. }).then(function(response) {
  186. if (response.data.code == 1) {
  187. localStorage.setItem("token", response.data.data.token);
  188. localStorage.setItem("openid", response.data.data.openid);
  189. //定向到 项目H5页面
  190. window.location.href = "http://zhejiangmiliangxiansheng.zjmlxs.com/H5/index.html#/skip?skipType=home";
  191. } else {
  192. //重新获取微信code
  193. alert(response.data.msg)
  194. window.location.href = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + localStorage.getItem(
  195. "appid") + "&redirect_uri=" + location.href +
  196. "&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect";
  197. }
  198. }).catch(function(error) {
  199. alert(error)
  200. });
  201. }
  202. </script>
  203. </body>
  204. </html>