setting.vue 1.4 KB

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