set.vue 2.4 KB

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