set.vue 2.6 KB

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