| | |
| | | <view class="action-btn"> |
| | | <button @click="handleLogin" class="login-btn cu-btn block bg-blue lg round">登录</button> |
| | | </view> |
| | | <view class="wechat-login" @click="handleWechatLogin"> |
| | | <view class="wechat-btn"> |
| | | <image class="wechat-icon" src="/static/icons/profile.png"></image> |
| | | <text class="wechat-text">微信一键登录</text> |
| | | </view> |
| | | </view> |
| | | |
| | | <view class="xieyi text-center"> |
| | | <text class="text-grey1">登录即代表同意</text> |
| | |
| | | this.$modal.loading("登录中,请耐心等待...") |
| | | this.pwdLogin() |
| | | } |
| | | }, |
| | | // 微信登录方法 |
| | | async handleWechatLogin() { |
| | | // #ifdef MP-WEIXIN |
| | | // 微信小程序登录 |
| | | uni.login({ |
| | | provider: 'weixin', |
| | | success: (loginRes) => { |
| | | console.log('微信登录成功', loginRes); |
| | | // 获取用户信息 |
| | | uni.getUserInfo({ |
| | | provider: 'weixin', |
| | | success: (infoRes) => { |
| | | console.log('用户信息获取成功', infoRes); |
| | | // 跳转到微信登录确认页面 |
| | | this.$tab.navigateTo(`/pages/login/wechat?userInfo=${encodeURIComponent(JSON.stringify(infoRes.userInfo))}`); |
| | | }, |
| | | fail: (error) => { |
| | | console.error('获取用户信息失败', error); |
| | | this.$modal.msgError("获取微信用户信息失败"); |
| | | } |
| | | }); |
| | | }, |
| | | fail: (error) => { |
| | | console.error('微信登录失败', error); |
| | | this.$modal.msgError("微信登录失败"); |
| | | } |
| | | }); |
| | | // #endif |
| | | |
| | | // #ifndef MP-WEIXIN |
| | | // H5或其他平台提示 |
| | | this.$modal.msgError("请在微信客户端中使用微信登录功能"); |
| | | // #endif |
| | | }, |
| | | // 密码登录 |
| | | async pwdLogin() { |
| | |
| | | .login-btn { |
| | | height: 90rpx; |
| | | font-size: 32rpx; |
| | | } |
| | | } |
| | | |
| | | .wechat-login { |
| | | margin: 20rpx 0; |
| | | |
| | | .wechat-btn { |
| | | display: flex; |
| | | align-items: center; |
| | | justify-content: center; |
| | | background-color: #07c160; |
| | | height: 90rpx; |
| | | border-radius: 20px; |
| | | |
| | | .wechat-icon { |
| | | width: 40rpx; |
| | | height: 40rpx; |
| | | margin-right: 10rpx; |
| | | } |
| | | |
| | | .wechat-text { |
| | | color: white; |
| | | font-size: 32rpx; |
| | | } |
| | | } |
| | | } |
| | | |