set.vue 2.7 KB

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