personal.vue 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="personal page-bg-color">
  3. <view class="personal-header">
  4. <u-avatar :src="require('@/static/logo.png')" size="large"></u-avatar>
  5. <view class="personal-header-info">
  6. <text class="personal-header-info-name">{{userInfo.displayName || '-'}}</text>
  7. <text class="u-tips-color">{{userInfo.displayName || '-'}}</text>
  8. </view>
  9. <u-icon size="40" name="edit-pen"></u-icon>
  10. </view>
  11. <view class="u-m-t-20">
  12. <u-cell-group>
  13. <u-cell-item icon="weixin-fill" title="绑定微信" @click="weiBind"></u-cell-item>
  14. </u-cell-group>
  15. </view>
  16. <view class="u-m-t-80">
  17. <u-button type="error" @click="logout">退出登录</u-button>
  18. </view>
  19. <u-top-tips ref="uTips"></u-top-tips>
  20. </view>
  21. </template>
  22. <script>
  23. export default {
  24. data() {
  25. return {
  26. userInfo: JSON.parse(uni.getStorageSync('userInfo') || '{}')
  27. }
  28. },
  29. methods: {
  30. logout() {
  31. const that = this
  32. that.$dibootApi.post('/h5/logout').then(() => {
  33. that.$tip(that.$refs.uTips, '退出成功!').then(() => {
  34. uni.clearStorageSync()
  35. let timer = setTimeout(() => {
  36. clearTimeout(timer)
  37. uni.reLaunch({
  38. url: '/pages/login/index'
  39. });
  40. }, 0)
  41. })
  42. })
  43. },
  44. //
  45. /**
  46. * 微信绑定
  47. */
  48. weiBind() {
  49. // 小程序登陆
  50. // #ifdef MP-WEIXIN
  51. this.$miniLogin.setBindWx(true).setTip(this.$refs.uToast).setUrlPath('/pages/personal/personal').go()
  52. //#endif
  53. // 微信公众号登陆
  54. // #ifdef H5
  55. this.$mpLogin.redirect(true)
  56. //#endif
  57. }
  58. },
  59. }
  60. </script>
  61. <style scoped lang="scss">
  62. .personal {
  63. padding: 24rpx 24rpx 0;
  64. &-header {
  65. display: flex;
  66. background-color: #fff;
  67. padding: 40rpx;
  68. border-radius: 20rpx;
  69. margin-bottom: 40rpx;
  70. &-info {
  71. flex: 1;
  72. display: flex;
  73. flex-direction: column;
  74. justify-content: space-around;
  75. margin-left: 40rpx;
  76. &-name {
  77. font-weight: bold;
  78. font-size: 32rpx;
  79. }
  80. }
  81. }
  82. }
  83. </style>