applets-login.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <template>
  2. <view>
  3. <!-- 登录弹窗 -->
  4. <view class="loginMask" v-if="loginPopupShow" @click="closePopup"></view>
  5. <view class="loginPopup" v-if="loginPopupShow">
  6. <view class="loginBox">
  7. <image class="logo" :src="base.logoUrl"></image>
  8. <view class="platformName">{{ base.platformName }}</view>
  9. <view class="description" v-if="base.description">{{ base.description }}</view>
  10. </view>
  11. <button class="main-bg-color" type="primary" hover-class="active" open-type="getUserInfo" @getuserinfo="onAuthorization">授权登录</button>
  12. </view>
  13. </view>
  14. </template>
  15. <script>
  16. import { mapState, mapMutations } from 'vuex';
  17. import base from '@/config/baseUrl';
  18. // #ifdef MP-WEIXIN
  19. import { getUserInfo } from '@/config/login';
  20. // #endif
  21. let clear;
  22. export default {
  23. data() {
  24. return {
  25. base: base
  26. };
  27. },
  28. computed: {
  29. ...mapState(['userInfo', 'loginPopupShow'])
  30. },
  31. methods: {
  32. ...mapMutations(['setUserInfo', 'setLoginPopupShow']),
  33. //授权登录
  34. onAuthorization: function(e) {
  35. if (e.detail.errMsg == 'getUserInfo:ok') {
  36. var userInfo = e.detail;
  37. this.setLoginPopupShow(false);
  38. getUserInfo(userInfo, 'authorized');
  39. }
  40. },
  41. closeLogin() {
  42. if (this.loginPopupShow && this.userInfo.token) {
  43. this.setLoginPopupShow(false);
  44. }
  45. },
  46. //关闭弹窗
  47. closePopup() {
  48. this.setLoginPopupShow(false);
  49. }
  50. }
  51. };
  52. </script>
  53. <style scoped>
  54. .loginMask {
  55. position: fixed;
  56. top: 0upx;
  57. left: 0upx;
  58. right: 0upx;
  59. bottom: 0upx;
  60. background-color: rgba(0, 0, 0, 0.4);
  61. z-index: 10;
  62. }
  63. .loginPopup {
  64. position: fixed;
  65. top: 50%;
  66. left: 50%;
  67. transform: translateX(-50%) translateY(-50%);
  68. width: 500upx;
  69. background-color: #fff;
  70. border-radius: 20upx;
  71. overflow: hidden;
  72. z-index: 11;
  73. }
  74. .loginPopup .loginBox {
  75. padding: 30upx 15upx 40upx 15upx;
  76. display: flex;
  77. flex-direction: column;
  78. align-items: center;
  79. }
  80. .loginPopup .loginBox .logo {
  81. width: 160upx;
  82. height: 160upx;
  83. border-radius: 20%;
  84. }
  85. .loginPopup .loginBox .platformName {
  86. font-size: 24upx;
  87. color: #999;
  88. margin-top: 10upx;
  89. }
  90. .loginPopup .loginBox .description {
  91. margin-top: 15upx;
  92. font-size: 30upx;
  93. color: #333;
  94. }
  95. .loginPopup button {
  96. border-radius: 0upx;
  97. }
  98. .loginPopup .active {
  99. opacity: 0.8;
  100. }
  101. </style>