set.vue 2.3 KB

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