123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131 |
- <template>
- <view class="content">
- <view class="one">
- <view class="list" v-for="(item, index) in list" :key="index" @click="toCommon(item.route)">
- <view class="left">
- <text class="title">{{item.title}}</text>
- </view>
- <view class="right">
- <text class="iconfont icon-dayuhao"></text>
- </view>
- </view>
- </view>
- <view class="two">
- <button class="button" type="primary" @click="toExit">退出登录</button>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- user: {},
- list: [{
- title: '账号详情',
- route: 'pagesMy/account/info'
- },
- {
- title: '修改密码',
- route: 'pagesMy/account/update'
- }
- ]
- }
- },
- async onLoad() {
- const that = this;
- await that.searchToken();
- },
- methods: {
- async searchToken() {
- const that = this;
- uni.getStorage({
- key: 'token',
- success: function(res) {
- that.$set(that, `user`, res.data);
- },
- fail: function(err) {
- uni.showToast({
- title: err.errmsg,
- icon: 'error',
- duration: 2000
- });
- }
- })
- },
- // 公共跳转
- toCommon(e) {
- const that = this;
- if (that.user && that.user._id) {
- uni.navigateTo({
- url: `/${e}`
- })
- } else {
- uni.navigateTo({
- url: `/pages/login/index`
- })
- }
- },
- // 退出登录
- toExit() {
- uni.removeStorage({
- key: 'token',
- success: function(res) {
- let url = `/pages/index/index`;
- uni.reLaunch({
- url
- })
- }
- });
- },
- }
- }
- </script>
- <style lang="scss">
- .content {
- display: flex;
- flex-direction: column;
- padding: 2vw;
- }
- .one {
- .list {
- margin: 2vw 0 0 0;
- background-color: var(--f1Color);
- display: flex;
- justify-content: space-between;
- padding: 3vw;
- border-bottom: 1px solid var(--f9Color);
- .left {
- display: flex;
- align-items: center;
- font-size: var(--font12Size);
- .title {
- display: inline-block;
- font-size: var(--font12Size);
- }
- }
- .right {
- display: flex;
- align-items: center;
- font-size: var(--font12Size);
- color: var(--f99Color);
- }
- }
- }
- .two {
- margin: 2vw 0 0 0;
- background-color: var(--f1Color);
- .button {
- background-color: var(--f3CColor);
- color: var(--mainColor);
- font-size: var(--font14Size);
- }
- }
- </style>
|