login.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <template>
  2. <view class="login-container">
  3. <view class="wechatapp">
  4. <view class="header">
  5. <open-data class="" type="userAvatarUrl"></open-data>
  6. </view>
  7. </view>
  8. <view class="auth-title">申请获取以下权限</view>
  9. <view class="auth-subtitle">获得你的公开信息(昵称、头像等)</view>
  10. <view class="login-btn">
  11. <!-- #ifdef MP-WEIXIN -->
  12. <button class="btn-normal" @click="getUserInfo">授权登录</button>
  13. <!-- #endif -->
  14. </view>
  15. <view class="no-login-btn">
  16. <button class="btn-normal" @click="onNotLogin">暂不登录</button>
  17. </view>
  18. </view>
  19. </template>
  20. <script>
  21. export default {
  22. data() {
  23. return {
  24. background: '',
  25. listData: [],
  26. invitation_id: 0
  27. }
  28. },
  29. onLoad(e) {
  30. this.invitation_id = uni.getStorageSync('invitation_id') ? uni.getStorageSync('invitation_id') : 0;
  31. },
  32. methods: {
  33. onNotLogin: function() {
  34. uni.switchTab({
  35. url: '/pages/index/index'
  36. })
  37. },
  38. getUserInfo: function() {
  39. let self = this;
  40. wx.getUserProfile({
  41. lang: 'zh_CN',
  42. desc: '用于完善会员资料',
  43. success: (res) => {
  44. if (res.errMsg !== 'getUserProfile:ok') {
  45. return false;
  46. }
  47. uni.showLoading({
  48. title: "正在登录",
  49. mask: true
  50. });
  51. // 执行微信登录
  52. wx.login({
  53. success(res_login) {
  54. // 发送用户信息
  55. self._post('user.userweb/login', {
  56. code: res_login.code
  57. }, res => {
  58. console.log('res', res)
  59. if(res.code == 1){
  60. uni.navigateTo({
  61. url: '/pages/login/applet?openid=' + res.data.openid
  62. })
  63. uni.hideLoading()
  64. }
  65. })
  66. }
  67. });
  68. }
  69. });
  70. },
  71. },
  72. }
  73. </script>
  74. <style>
  75. .login-container {
  76. padding: 30rpx;
  77. }
  78. .wechatapp {
  79. padding: 80rpx 0 48rpx;
  80. border-bottom: 1rpx solid #e3e3e3;
  81. margin-bottom: 72rpx;
  82. text-align: center;
  83. }
  84. .wechatapp .header {
  85. width: 190rpx;
  86. height: 190rpx;
  87. border: 2px solid #fff;
  88. margin: 0rpx auto 0;
  89. border-radius: 50%;
  90. overflow: hidden;
  91. box-shadow: 1px 0px 5px rgba(50, 50, 50, 0.3);
  92. }
  93. .auth-title {
  94. color: #585858;
  95. font-size: 34rpx;
  96. margin-bottom: 40rpx;
  97. }
  98. .auth-subtitle {
  99. color: #888;
  100. margin-bottom: 88rpx;
  101. font-size: 28rpx;
  102. }
  103. .login-btn {
  104. padding: 0 20rpx;
  105. }
  106. .login-btn button {
  107. height: 88rpx;
  108. line-height: 88rpx;
  109. background: #04be01;
  110. color: #fff;
  111. font-size: 30rpx;
  112. border-radius: 999rpx;
  113. text-align: center;
  114. }
  115. .no-login-btn {
  116. margin-top: 20rpx;
  117. padding: 0 20rpx;
  118. }
  119. .no-login-btn button {
  120. height: 88rpx;
  121. line-height: 88rpx;
  122. background: #dfdfdf;
  123. color: #fff;
  124. font-size: 30rpx;
  125. border-radius: 999rpx;
  126. text-align: center;
  127. }
  128. </style>