Login.vue 4.7 KB

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