Login.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  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. watch: {},
  44. created() {
  45. this.getTKByUnionid();
  46. },
  47. methods: {
  48. WxLoginCtl() {
  49. // this.$router.push({
  50. // path: "/aikmt/Redirect_uri",
  51. // query: {
  52. // unionid: "oPHg8wXraekgH5YKVHvD3H7Ujynw"
  53. // }
  54. // });
  55. },
  56. async getTKByUnionid() {
  57. if (window.location.href.indexOf("unionid") >= 0) {
  58. // 如果url中包含unionid,则保存到store中
  59. let unionid = window.location.href.split("?")[1];
  60. unionid = unionid.substring(8);
  61. let WxCode = unionid;
  62. this.WxCode = WxCode;
  63. localStorage.setItem("unionid", this.WxCode);
  64. console.log("获取unionid" + this.WxCode);
  65. this.$store.dispatch("UnionidLogin", {
  66. unionid: this.WxCode
  67. });
  68. }
  69. if (window.location.href.indexOf("code") >= 0) {
  70. // 如果url中包含code,则保存到store中
  71. let code = window.location.href.split("?")[1];
  72. code = code.substring(5, code.indexOf("&"));
  73. let WxCode = code;
  74. this.WxCode = WxCode;
  75. console.log("获取Code" + this.WxCode);
  76. this.$store.dispatch("GET_TOKEN", {
  77. code: this.WxCode
  78. });
  79. // 清除重定向url中参数ocde,
  80. window.history.replaceState({}, "", `${location.pathname}`);
  81. console.log(location.pathname);
  82. }
  83. return;
  84. }
  85. },
  86. mounted() {
  87. var obj = new WxLogin({
  88. self_redirect: false,
  89. id: "login_container",
  90. appid: "wxd18ca9555a939281",
  91. scope: "snsapi_login",
  92. redirect_uri: encodeURIComponent(
  93. "https://kmt.sharingschool.com/aijia/manager/index.html"
  94. ),
  95. state: "",
  96. style: "width: 250px",
  97. href: ""
  98. });
  99. }
  100. };
  101. </script>
  102. <style lang="stylus" scoped>
  103. @import '../style/index.styl';
  104. .login-content{
  105. display: flex;
  106. -webkit-box-pack: justify;
  107. -ms-flex-pack: justify;
  108. justify-content: space-between;
  109. -webkit-box-align: center;
  110. -ms-flex-align: center;
  111. align-items: center;
  112. }
  113. .login
  114. position fixed
  115. top 0
  116. left 0
  117. width 100%
  118. height 100%
  119. min-width 650px
  120. &-paper
  121. position absolute
  122. top 0
  123. left 0
  124. width 100%
  125. height 100%
  126. img
  127. width 100%
  128. height 100%
  129. object-fit cover
  130. &-content
  131. position absolute
  132. top 10%
  133. left 15%
  134. width 70%
  135. height 80%
  136. background $color-bg-white
  137. border-radius 4px
  138. box-shadow()
  139. flex-row-between()
  140. .img
  141. margin 10% 0% 10% 10%
  142. flex 6
  143. img
  144. width 100%
  145. height 100%
  146. object-fit cover
  147. .section
  148. margin 10%
  149. flex 4
  150. text-align center
  151. &-icon
  152. width 50%
  153. object-fit cover
  154. &-text
  155. color $color-text-green
  156. font-size $font-size-l
  157. margin 5%
  158. &-qrcode
  159. box-shadow()
  160. padding 10px
  161. @media (min-width: 0px) and (max-width: 960px) {
  162. .img {
  163. display none
  164. }
  165. }
  166. </style>