珠宝小程序前端代码
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.

122 lines
2.8 KiB

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