social.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <template>
  2. <view class="container">
  3. <view class="auth-header">
  4. <view class="auth-logo">
  5. <u-avatar size="100" icon="github-circle-fill" fontSize="100"></u-avatar>
  6. </view>
  7. </view>
  8. <view class="auth-box">
  9. <view class="btn-group">
  10. <!-- #ifdef MP-WEIXIN -->
  11. <u-button class="auth-btn" open-type="getPhoneNumber" type="primary" @getphonenumber="getPhoneNumber">一键登录</u-button>
  12. <navigator class="reg-login-link" url="/pages/login/mobile" open-type="navigate" hover-class="none">手机号登录/注册 &gt;</navigator>
  13. <!-- #endif -->
  14. <!-- #ifndef MP-WEIXIN -->
  15. <u-button type="primary" text="手机号登录/注册" @click="handleJump"></u-button>
  16. <!-- #endif -->
  17. </view>
  18. <view class="auth-footer">
  19. <view>登录即表示同意<text class="lk-text">《用户协议》</text> 和 <text class="lk-text">《隐私政策》</text></view>
  20. </view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. export default {
  26. data() {
  27. return {}
  28. },
  29. onLoad() {},
  30. onReady() {},
  31. methods: {
  32. getPhoneNumber(e) {
  33. let phoneCode = e.detail.code
  34. if (!e.detail.code) {
  35. uni.showModal({
  36. title: '授权失败',
  37. content: '您已拒绝获取绑定手机号登录授权,可以使用其他手机号验证登录',
  38. cancelText: '知道了',
  39. confirmText: '验证登录',
  40. confirmColor: '#3C9CFFFF',
  41. success: res => {
  42. if (res.confirm) {
  43. uni.$u.route('/pages/login/mobile')
  44. } else if (res.cancel) {
  45. //console.log('用户点击取消')
  46. }
  47. }
  48. })
  49. } else {
  50. uni.login({
  51. provider: 'weixin',
  52. success: res => {
  53. this.$store.dispatch('Login', { type: 2, data: { phoneCode: phoneCode, loginCode: res.code } }).then(res => {
  54. uni.$u.toast('登录成功')
  55. setTimeout(() => {
  56. uni.switchTab({
  57. url: '/pages/user/user'
  58. })
  59. }, 300)
  60. })
  61. }
  62. })
  63. }
  64. },
  65. handleJump() {
  66. uni.$u.route('/pages/login/mobile')
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="scss" scoped>
  72. .container {
  73. height: calc(100vh - 70px);
  74. @include flex-space-between(column);
  75. }
  76. .auth-header {
  77. flex: 2;
  78. @include flex-center;
  79. .auth-logo {
  80. @include flex-center(column);
  81. }
  82. }
  83. .auth-box {
  84. @include flex-center(column);
  85. .btn-group {
  86. width: 600rpx;
  87. margin-bottom: 200rpx;
  88. .auth-btn {
  89. height: 90rpx;
  90. font-size: 32rpx;
  91. }
  92. }
  93. .reg-login-link {
  94. margin-top: 32rpx;
  95. text-align: center;
  96. color: #636363;
  97. font-size: 30rpx;
  98. }
  99. .auth-footer {
  100. font-size: 26rpx;
  101. color: #939393;
  102. .lk-text {
  103. color: $u-primary;
  104. text-decoration: $u-primary;
  105. }
  106. }
  107. }
  108. </style>