setting.vue 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <!-- 设置 -->
  2. <template>
  3. <view class="setting">
  4. <u-cell-group :border="false" :title-style="{'color': '#333333', 'font-size': '24rpx'}">
  5. <u-cell-item icon="" title="退出登录" @click=" logoutModal = true"/>
  6. <u-cell-item icon="" title="版本信息" :arrow="false" :value="`当前版本${ config.version },已更新`"/>
  7. </u-cell-group>
  8. <!-- 退出登录提示框 -->
  9. <u-modal
  10. v-model="logoutModal"
  11. width="70%"
  12. @confirm="logout"
  13. content="您确认退出登录吗?"
  14. :show-cancel-button="true"
  15. />
  16. </view>
  17. </template>
  18. <script>
  19. export default {
  20. name: 'Setting',
  21. data() {
  22. return {
  23. // 登出提示框
  24. logoutModal: false
  25. }
  26. },
  27. methods: {
  28. /**
  29. * 退出登录
  30. */
  31. logout() {
  32. this.$u.api.logoutApi().then(res => {
  33. if (res.code === 200) {
  34. this.$u.vuex('vuex_hasLogin', false);
  35. this.$u.vuex('vuex_token', '');
  36. this.$u.vuex('vuex_user', '');
  37. this.$u.route('/pages/phoneLogin/phoneLogin');
  38. } else {
  39. uni.showToast({
  40. title: res.msg,
  41. icon: 'error'
  42. })
  43. }
  44. }).catch(() => {
  45. uni.showToast({
  46. title: '退出登录失败!',
  47. icon: 'error'
  48. })
  49. })
  50. }
  51. }
  52. }
  53. </script>
  54. <style lang="scss" scoped>
  55. .setting {
  56. padding: 20rpx 30rpx;
  57. }
  58. </style>