Login.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. <template>
  2. <div class="login" style=" min-width: 650px!important;">
  3. <div class="login-paper">
  4. <img src="../assets/img/Land_bg.png">
  5. </div>
  6. <div class="login-content">
  7. <div class="img">
  8. <img src="../assets/img/Land_sbg.png">
  9. </div>
  10. <div class="section">
  11. <img class="section-icon" src="../assets/img/log.png">
  12. <div class="log-text section-text">欢迎登陆私塾家在线人员管理后台</div>
  13. <div @click="WxLoginCtl" class="log-qrcode">
  14. <div class="section-qrcode" id="login_container"></div>
  15. </div>
  16. </div>
  17. </div>
  18. </div>
  19. </template>
  20. <script>
  21. export default {
  22. name: "login",
  23. data() {
  24. return {};
  25. },
  26. //监听器
  27. watch: {
  28. '$route' (to, from) { //监听路由是否变化
  29. console.log(999)
  30. location.reload()
  31. },
  32. },
  33. created() {
  34. localStorage.removeItem("accessToken")
  35. this.getTKByUnionid();
  36. },
  37. methods: {
  38. WxLoginCtl() {
  39. // this.$router.push({
  40. // path: "/aikmt/Redirect_uri",
  41. // query: {
  42. // unionid: "oPHg8wXraekgH5YKVHvD3H7Ujynw"
  43. // }
  44. // });
  45. },
  46. async getTKByUnionid() {
  47. if (window.location.href.indexOf("unionid") >= 0) {
  48. // 如果url中包含unionid,则保存到store中
  49. let unionid = window.location.href.split("?")[1];
  50. unionid = unionid.substring(8);
  51. let WxCode = unionid;
  52. this.WxCode = WxCode;
  53. localStorage.setItem("unionid", this.WxCode);
  54. console.log("获取unionid" + this.WxCode);
  55. this.$store.dispatch("UnionidLogin", {
  56. unionid: this.WxCode
  57. });
  58. }
  59. if (window.location.href.indexOf("code") >= 0) {
  60. // 如果url中包含code,则保存到store中
  61. console.log(window.location.href)
  62. let code = window.location.href.split("#/?")[1];
  63. console.log("code开始打印")
  64. console.log(code)
  65. code = code.substring(5, code.indexOf("&"));
  66. let WxCode = code;
  67. this.WxCode = WxCode;
  68. console.log("获取Code" + this.WxCode);
  69. this.$store.dispatch("GET_TOKEN", {
  70. code: this.WxCode,
  71. type:0,
  72. // type:1, //aikmt
  73. });
  74. // 清除重定向url中参数ocde,
  75. window.history.replaceState({}, "", `${location.pathname}`);
  76. console.log(location.pathname);
  77. }
  78. return;
  79. }
  80. },
  81. mounted() {
  82. var obj = new WxLogin({
  83. self_redirect: false,
  84. id: "login_container",
  85. appid: "wxd18ca9555a939281", //正式环境
  86. // appid: "wx5a83afb22813e986", //OSS正式环境
  87. // appid: "wx7fe760dc3c45794d", //实训环境
  88. // appid: "wx3d4605f43beda11a", //测试环境
  89. scope: "snsapi_login",
  90. redirect_uri: encodeURIComponent(
  91. "https://kmt.sharingschool.com/aijia/manager/index.html#/" //正式环境
  92. // "https://aikmt.sharingschool.com/manager/index.html#/" //OSS正式环境
  93. // "https://sxkmt.sharingschool.com/manager/index.html#/" //实训环境
  94. // "https://xtkmt.sharingschool.com/manager/index.html#/" //测试环境
  95. ),
  96. state: "",
  97. style: "width: 250px",
  98. href: ""
  99. });
  100. }
  101. };
  102. </script>
  103. <style lang="stylus" scoped>
  104. @import '../style/index.styl';
  105. .login-content{
  106. display: flex;
  107. -webkit-box-pack: justify;
  108. -ms-flex-pack: justify;
  109. justify-content: space-between;
  110. -webkit-box-align: center;
  111. -ms-flex-align: center;
  112. align-items: center;
  113. }
  114. .login
  115. position fixed
  116. top 0
  117. left 0
  118. width 100%
  119. height 100%
  120. min-width 650px
  121. &-paper
  122. position absolute
  123. top 0
  124. left 0
  125. width 100%
  126. height 100%
  127. img
  128. width 100%
  129. height 100%
  130. object-fit cover
  131. &-content
  132. position absolute
  133. top 10%
  134. left 15%
  135. width 70%
  136. height 80%
  137. background $color-bg-white
  138. border-radius 4px
  139. box-shadow()
  140. flex-row-between()
  141. .img
  142. margin 10% 0% 10% 10%
  143. flex 6
  144. img
  145. width 100%
  146. height 100%
  147. object-fit cover
  148. .section
  149. margin 10%
  150. flex 4
  151. text-align center
  152. &-icon
  153. width 50%
  154. object-fit cover
  155. &-text
  156. color $color-text-green
  157. font-size $font-size-l
  158. margin 5%
  159. &-qrcode
  160. box-shadow()
  161. padding 10px
  162. @media (min-width: 0px) and (max-width: 960px) {
  163. .img {
  164. display none
  165. }
  166. }
  167. </style>