set.vue 2.4 KB

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