Login.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <div class="bodyImg">
  3. <div class="container">
  4. <div class="log-paper">
  5. <img src="../assets/img/Land_sbg.png">
  6. </div>
  7. <div class="log-container">
  8. <img class="log-icon" src="../assets/img/log.png">
  9. <div class="log-text">欢迎登陆私塾家在线人员管理后台</div>
  10. <div @click="WxLoginCtl" class="log-qrcode">
  11. <div id="login_container"></div>
  12. <!-- <img class="log-qrcode-image" src="../assets/img/ssj_qrcode.png"> -->
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. </template>
  18. <script>
  19. // import { mapActions } from "vuex";
  20. // import wx from 'weixin-js-sdk'
  21. // import $ from 'jquery'
  22. export default {
  23. name: "login",
  24. data() {
  25. return {};
  26. },
  27. watch: {},
  28. created() {
  29. this.getTKByUnionid();
  30. },
  31. methods: {
  32. WxLoginCtl() {
  33. // this.$router.push({
  34. // path: "/aikmt/Redirect_uri",
  35. // query: {
  36. // unionid: "oPHg8wXraekgH5YKVHvD3H7Ujynw"
  37. // }
  38. // });
  39. },
  40. async getTKByUnionid() {
  41. if (window.location.href.indexOf("unionid") >= 0) {
  42. // 如果url中包含unionid,则保存到store中
  43. let unionid = window.location.href.split("?")[1];
  44. unionid = unionid.substring(8);
  45. let WxCode = unionid;
  46. this.WxCode = WxCode;
  47. localStorage.setItem("unionid", this.WxCode);
  48. console.log("获取unionid" + this.WxCode);
  49. this.$store.dispatch("UnionidLogin", {
  50. unionid: this.WxCode
  51. });
  52. }
  53. if (window.location.href.indexOf("code") >= 0) {
  54. // 如果url中包含code,则保存到store中
  55. let code = window.location.href.split("?")[1];
  56. code = code.substring(5, code.indexOf("&"));
  57. let WxCode = code;
  58. this.WxCode = WxCode;
  59. console.log("获取Code" + this.WxCode);
  60. this.$store.dispatch("GET_TOKEN", {
  61. code: this.WxCode
  62. });
  63. // 清除重定向url中参数ocde,
  64. window.history.replaceState({}, "", `${location.pathname}`);
  65. console.log(location.pathname)
  66. }
  67. return
  68. }
  69. },
  70. mounted() {
  71. var obj = new WxLogin({
  72. self_redirect: false,
  73. id: "login_container",
  74. appid: "wxd18ca9555a939281",
  75. scope: "snsapi_login",
  76. redirect_uri: encodeURIComponent(
  77. "https://kmt.sharingschool.com/aijia/manager/index.html"
  78. ),
  79. state: "",
  80. style: "width: 250px",
  81. href: ""
  82. });
  83. }
  84. };
  85. </script>
  86. <style scoped>
  87. body {
  88. background-image: url(../assets/img/Land_bg.png);
  89. background-size: 100% auto;
  90. }
  91. .bodyImg{
  92. background-image: url(../assets/img/Land_bg.png);
  93. background-size: 100% auto;
  94. min-height: 1024px!important;
  95. }
  96. .container {
  97. max-height: 70%;
  98. position: absolute;
  99. top: 50%;
  100. left: 50%;
  101. -webkit-transform: translate(-50%, -50%);
  102. -moz-transform: translate(-50%, -50%);
  103. -ms-transform: translate(-50%, -50%);
  104. -o-transform: translate(-50%, -50%);
  105. transform: translate(-50%, -50%);
  106. max-width: 70%;
  107. background: #ffffff;
  108. -webkit-box-shadow: 0 0 20px 0 rgba(50, 103, 0, 0.2);
  109. -webkit-border-radius: 4px;
  110. box-shadow: 0 0 20px 0 rgba(50, 103, 0, 0.2);
  111. border-radius: 4px;
  112. padding: 5%;
  113. }
  114. .log-paper {
  115. width: 45%;
  116. margin-right: 5%;
  117. float: left;
  118. }
  119. .log-paper img {
  120. width: 90%;
  121. }
  122. .log-container {
  123. width: 50%;
  124. margin-left: 5%;
  125. float: right;
  126. text-align: center;
  127. }
  128. .log-icon {
  129. width: 40%;
  130. }
  131. .log-text {
  132. font-size: 1.8em;
  133. color: #52cc60;
  134. margin: 0.5rem auto;
  135. }
  136. .log-qrcode {
  137. width: 70%;
  138. background: #ffffff;
  139. -webkit-box-shadow: 0 2px 10px 0 rgba(157, 166, 195, 0.3);
  140. box-shadow: 0 2px 10px 0 rgba(157, 166, 195, 0.3);
  141. padding: 10%;
  142. margin: 5% 10%;
  143. }
  144. .log-qrcode-image {
  145. width: 100%;
  146. }
  147. *,
  148. ::after,
  149. ::before {
  150. box-sizing: content-box;
  151. }
  152. .log-qrcode-text {
  153. margin-top: 1.5rem;
  154. font-size: 1em;
  155. color: #808080;
  156. }
  157. @media (min-width: 0px) and (max-width: 767px) {
  158. .container {
  159. width: 750px;
  160. }
  161. .log-paper {
  162. width: 0%;
  163. }
  164. .log-container {
  165. width: 100%;
  166. }
  167. }
  168. @media (min-width: 768px) and (max-width: 991px) {
  169. .container {
  170. width: 750px;
  171. }
  172. .log-paper {
  173. width: 45%;
  174. margin-top: 5%;
  175. }
  176. .log-container {
  177. width: 40%;
  178. }
  179. }
  180. @media (min-width: 992px) {
  181. .container {
  182. width: 970px;
  183. }
  184. .log-paper {
  185. width: 45%;
  186. }
  187. .log-container {
  188. width: 40%;
  189. }
  190. }
  191. @media (min-width: 1200px) {
  192. .container {
  193. width: 1170px;
  194. }
  195. }
  196. body {
  197. background: #f6f7fb;
  198. -webkit-font-smoothing: subpixel-antialiased;
  199. }
  200. .color-green {
  201. color: #52cc60 !important;
  202. }
  203. .color-purple {
  204. color: #612d00 !important;
  205. }
  206. .fontweight {
  207. font-weight: bold;
  208. }
  209. .text-indent {
  210. text-indent: 2.6rem;
  211. }
  212. .nodata {
  213. text-align: center;
  214. padding: 250px 20px !important;
  215. }
  216. .nodata p {
  217. padding-top: 50px;
  218. font-size: 18px;
  219. color: #65b800;
  220. }
  221. /* 适应1366 */
  222. /* @media screen and (max-width: 1366px) {
  223. .isShow1 {
  224. display: none;
  225. }
  226. .isShow2 {
  227. display: block;
  228. }
  229. .isShow3 {
  230. display: none;
  231. }
  232. .isShow4 {
  233. display: block;
  234. }
  235. } */
  236. </style>