set.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <template>
  2. <view class="container">
  3. <view class="row b-b flex">
  4. <text class="tit">头像</text>
  5. <image :src="userInfo.avatar"></image>
  6. </view>
  7. <view class="row b-b flex">
  8. <text class="tit">昵称</text>
  9. <input class="input" v-model="userInfo.nickname" type="text" disabled="true" placeholder-class="placeholder" />
  10. </view>
  11. <view class="row b-b flex">
  12. <text class="tit">ID</text>
  13. <input class="input" v-model="userInfo.uid" type="text" disabled="true" placeholder-class="placeholder" />
  14. </view>
  15. <view class="row b-b flex">
  16. <text class="tit">用户账号</text>
  17. <input class="input" v-model="userInfo.account" type="number" disabled="true" placeholder-class="placeholder" />
  18. </view>
  19. <view class="submit-box">
  20. <view class="submit" @click="toLogout">退出登录</view>
  21. </view>
  22. </view>
  23. </template>
  24. <script>
  25. import uniList from '@/components/uni-list/uni-list.vue';
  26. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  27. import { mapState, mapMutations } from 'vuex';
  28. import { logout } from '@/api/set.js';
  29. export default {
  30. components: {
  31. uniList,
  32. uniListItem
  33. },
  34. data() {
  35. return {
  36. // nickName:'李淡淡',
  37. // id:'HFBNXISN',
  38. // account:'13745262356',
  39. userInfo:'',
  40. };
  41. },
  42. onLoad() {
  43. this.userInfo = uni.getStorageSync('userInfo') || '';
  44. },
  45. methods: {
  46. ...mapMutations('user',['logout']),
  47. //退出登录
  48. toLogout() {
  49. let obj = this;
  50. uni.showModal({
  51. content: '确定要退出登录么',
  52. success: e => {
  53. if (e.confirm) {
  54. logout({}).then(e => {
  55. obj.logout();
  56. uni.navigateTo({
  57. url:'/pages/public/login'
  58. })
  59. })
  60. .catch(e => {
  61. console.log(e);
  62. });
  63. }
  64. }
  65. });
  66. },
  67. }
  68. };
  69. </script>
  70. <style lang="scss">
  71. page {
  72. min-height: 100%;
  73. .container{
  74. height: 100%;
  75. }
  76. }
  77. .row {
  78. padding: 42rpx 25rpx;
  79. font-size: 30rpx;
  80. color: #333333;
  81. image{
  82. width: 80rpx;
  83. height: 80rpx;
  84. border-radius: 50%;
  85. }
  86. .input {
  87. text-align: right;
  88. color: #333333;
  89. }
  90. }
  91. .submit-box{
  92. padding: 157rpx 95rpx;
  93. .submit{
  94. background-color: #5771DF;
  95. color: #FFFFFF;
  96. text-align: center;
  97. padding:26rpx 0rpx;
  98. border-radius: 50rpx;
  99. }
  100. }
  101. </style>