wechat-oauth.vue 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <template>
  2. <view>
  3. <u-toast ref="uToast" />
  4. <view class="w75">
  5. <view
  6. class="f-weight-bold"
  7. style="color: #333; font-size: 42rpx; padding-top: 100rpx"
  8. >授权成功</view
  9. >
  10. <view
  11. class="f-size-32"
  12. style="color: #bbb; margin-top: 20rpx"
  13. >请重新登录</view
  14. >
  15. <button
  16. @tap="logout"
  17. class="main-color-bg text-color-white"
  18. style="border-radius: 80rpx; line-height: 100rpx;margin-top:100rpx"
  19. >
  20. 退出登录
  21. </button>
  22. </view>
  23. </view>
  24. </template>
  25. <script>
  26. export default {
  27. data() {
  28. return {
  29. form: {
  30. oldPassword: '', // 手机号
  31. password: '', // 验证码
  32. passwordConfirm: '' // 密码
  33. },
  34. openId: null
  35. };
  36. },
  37. onLoad(options) {
  38. this.openId = options.openId
  39. // 用户此时仍处于登录状态,立即调用绑定接口,而不是仅存缓存等下次密码登录才绑定
  40. if (this.openId) {
  41. uni.setStorageSync('openId', this.openId);
  42. this.$Http.bindUserAndOpenId(this.openId).then(() => {
  43. uni.removeStorageSync('openId');
  44. }).catch(err => {
  45. console.error('微信绑定失败', err);
  46. });
  47. }
  48. },
  49. methods: {
  50. // 退出登录
  51. logout() {
  52. uni.removeStorageSync('userInfo');
  53. uni.removeStorageSync('accessToken');
  54. uni.redirectTo({
  55. url: '/pages/login/login'
  56. });
  57. }
  58. }
  59. };
  60. </script>
  61. <style scoped lang="less">
  62. .input {
  63. width: 600rpx;
  64. margin: 0 auto;
  65. & > view {
  66. height: 100rpx;
  67. border-bottom: 1rpx solid #e6e6e6;
  68. }
  69. .code {
  70. height: 56rpx;
  71. line-height: 56rpx;
  72. padding: 0rpx 20rpx;
  73. background: #ffffff;
  74. border: 1rpx solid #0082ff;
  75. border-radius: 28rpx;
  76. }
  77. input {
  78. height: 100rpx;
  79. }
  80. }
  81. </style>