set.vue 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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/address')"></uni-list-item>
  6. </uni-list>
  7. <uni-list class="margin-t-20" v-if="new_version != ''">
  8. <uni-list-item title="检查更新" @click="updates()">
  9. <template slot="right">
  10. 当前版本{{ new_version }}
  11. </template>
  12. </uni-list-item>
  13. </uni-list>
  14. <view class="list-cell log-out-btn" @click="toLogout"><text class="cell-tit">退出登录</text></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, version } from '@/api/set.js';
  21. import { mapMutations } from 'vuex';
  22. // #ifdef APP-PLUS
  23. import { getUpApp } from '@/utils/upApp.js';
  24. // #endif
  25. export default {
  26. components: {
  27. uniList,
  28. uniListItem
  29. },
  30. data() {
  31. return {
  32. new_version: ''
  33. };
  34. },
  35. onShow() {
  36. const obj = this;
  37. //#ifdef APP-PLUS
  38. plus.runtime.getProperty(plus.runtime.appid, function(wgtinfo) {
  39. // 获取当前系统
  40. obj.new_version = wgtinfo.version;
  41. console.log(wgtinfo.version, '123456');
  42. });
  43. //#endif
  44. },
  45. methods: {
  46. ...mapMutations('user', ['logout']),
  47. navTo(url) {
  48. uni.navigateTo({
  49. url: url
  50. });
  51. },
  52. updates() {
  53. const obj = this;
  54. version().then(({ data }) => {
  55. if (data.version_code == obj.new_version) {
  56. obj.$api.msg('已经是最新版本了');
  57. } else {
  58. getUpApp();
  59. }
  60. });
  61. },
  62. //退出登录
  63. toLogout() {
  64. let obj = this;
  65. uni.showModal({
  66. content: '确定要退出登录么',
  67. success: e => {
  68. if (e.confirm) {
  69. logout({})
  70. .then(e => {
  71. uni.navigateBack();
  72. })
  73. .catch(e => {
  74. console.log(e);
  75. });
  76. obj.logout();
  77. }
  78. }
  79. });
  80. },
  81. //switch切换触发方法
  82. switchChange(e) {
  83. console.log(e);
  84. let statusTip = e.value ? '打开' : '关闭';
  85. this.$api.msg(`${statusTip}消息推送`);
  86. }
  87. }
  88. };
  89. </script>
  90. <style lang="scss">
  91. page {
  92. background: $page-color-base;
  93. }
  94. .list-cell {
  95. display: flex;
  96. align-items: baseline;
  97. padding: 20rpx $page-row-spacing;
  98. line-height: 60rpx;
  99. position: relative;
  100. background: #fff;
  101. justify-content: center;
  102. &.log-out-btn {
  103. margin-top: 40rpx;
  104. .cell-tit {
  105. color: $uni-color-primary;
  106. text-align: center;
  107. margin-right: 0;
  108. }
  109. }
  110. .cell-tit {
  111. flex: 1;
  112. font-size: $font-base + 2rpx;
  113. color: $font-color-dark;
  114. margin-right: 10rpx;
  115. }
  116. .cell-tip {
  117. font-size: $font-base;
  118. color: $font-color-light;
  119. }
  120. switch {
  121. transform: translateX(16rpx) scale(0.84);
  122. }
  123. }
  124. </style>