裂变星小程序-25.03.04
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123 lines
2.9 KiB

  1. <template>
  2. <uv-popup ref="loginPopup"
  3. mode="center"
  4. :round="20"
  5. :closeable="false"
  6. :maskClick="false"
  7. :closeOnClickOverlay="false"
  8. :customStyle="{backgroundColor: '#fff', padding: 0}"
  9. overlayOpacity="0.8">
  10. <view class="login-card">
  11. <view class="login-title">登录后即可查看分享内容</view>
  12. <view class="login-content">
  13. <button class="login-btn" @click="handleLogin">
  14. 微信一键登录
  15. </button>
  16. </view>
  17. </view>
  18. </uv-popup>
  19. </template>
  20. <script>
  21. export default {
  22. data(){
  23. return {
  24. }
  25. },
  26. methods: {
  27. open(){
  28. this.$refs.loginPopup.open()
  29. },
  30. close(){
  31. this.$refs.loginPopup.close()
  32. },
  33. // 处理登录
  34. handleLogin() {
  35. uni.showLoading({
  36. title: '登录中...'
  37. })
  38. uni.login({
  39. success : (res) => {
  40. if (res.errMsg != "login:ok") {
  41. return
  42. }
  43. let data = {
  44. code: res.code,
  45. }
  46. if (uni.getStorageSync('shareId')) {
  47. data.shareId = uni.getStorageSync('shareId')
  48. }
  49. if (uni.getStorageSync('id')) {
  50. data.id = uni.getStorageSync('id')
  51. }
  52. if (uni.getStorageSync('state')) {
  53. data.state = uni.getStorageSync('state')
  54. }
  55. this.$api('wxLogin', data, res => {
  56. uni.hideLoading()
  57. if (res.code != 200) {
  58. this.close()
  59. return
  60. }
  61. uni.setStorageSync('token', res.result.token)
  62. this.$store.commit('getUserInfo')
  63. this.close()
  64. this.$emit('login')
  65. })
  66. }
  67. })
  68. },
  69. }
  70. }
  71. </script>
  72. <style lang="scss" scoped>
  73. .login-card {
  74. width: 600rpx;
  75. padding: 40rpx;
  76. text-align: center;
  77. .login-title {
  78. font-size: 32rpx;
  79. font-weight: bold;
  80. color: #333;
  81. margin-bottom: 40rpx;
  82. }
  83. .login-content {
  84. .login-image {
  85. width: 300rpx;
  86. height: 300rpx;
  87. margin-bottom: 40rpx;
  88. }
  89. .login-btn {
  90. display: flex;
  91. align-items: center;
  92. justify-content: center;
  93. margin: 0 auto;
  94. width: 80%;
  95. height: 88rpx;
  96. background: #07C160;
  97. color: #fff;
  98. border-radius: 44rpx;
  99. font-size: 32rpx;
  100. .wechat-icon {
  101. width: 48rpx;
  102. height: 48rpx;
  103. margin-right: 10rpx;
  104. }
  105. }
  106. }
  107. }
  108. </style>