set.vue 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <template>
  2. <view class="container">
  3. <uni-list>
  4. <uni-list-item title="个人资料" @click="navTo('/pages/set/userinfo')"></uni-list-item>
  5. <uni-list-item title="收货地址" @click="navTo('/pages/set/address')"></uni-list-item>
  6. </uni-list>
  7. <view class="list-cell log-out-btn" @click="toLogout"><text class="cell-tit">退出登录</text></view>
  8. </view>
  9. </template>
  10. <script>
  11. import uniList from '@/components/uni-list/uni-list.vue';
  12. import uniListItem from '@/components/uni-list-item/uni-list-item.vue';
  13. import { logout } from '@/api/set.js';
  14. import { mapMutations } from 'vuex';
  15. export default {
  16. components: {
  17. uniList,
  18. uniListItem
  19. },
  20. data() {
  21. return {};
  22. },
  23. methods: {
  24. ...mapMutations('user', ['logout']),
  25. navTo(url) {
  26. uni.navigateTo({
  27. url: url
  28. });
  29. },
  30. //退出登录
  31. toLogout() {
  32. let obj = this;
  33. uni.showModal({
  34. content: '确定要退出登录么',
  35. success: e => {
  36. if (e.confirm) {
  37. logout({})
  38. .then(e => {
  39. uni.navigateBack();
  40. })
  41. .catch(e => {
  42. console.log(e);
  43. });
  44. obj.logout();
  45. }
  46. }
  47. });
  48. },
  49. //switch切换触发方法
  50. switchChange(e) {
  51. console.log(e);
  52. let statusTip = e.value ? '打开' : '关闭';
  53. this.$api.msg(`${statusTip}消息推送`);
  54. }
  55. }
  56. };
  57. </script>
  58. <style lang="scss">
  59. page {
  60. background: $page-color-base;
  61. }
  62. .list-cell {
  63. display: flex;
  64. align-items: baseline;
  65. padding: 20rpx $page-row-spacing;
  66. line-height: 60rpx;
  67. position: relative;
  68. background: #fff;
  69. justify-content: center;
  70. &.log-out-btn {
  71. margin-top: 40rpx;
  72. .cell-tit {
  73. color: #d7a465;
  74. text-align: center;
  75. margin-right: 0;
  76. }
  77. }
  78. .cell-tit {
  79. flex: 1;
  80. font-size: $font-base + 2rpx;
  81. color: $font-color-dark;
  82. margin-right: 10rpx;
  83. }
  84. .cell-tip {
  85. font-size: $font-base;
  86. color: $font-color-light;
  87. }
  88. switch {
  89. transform: translateX(16rpx) scale(0.84);
  90. }
  91. }
  92. </style>