123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- <template>
- <view class="main">
- <view class="list" v-for="(item, index) in menuList" :key="index" @click="toCommon(item.route)">
- <view class="left">
- <text class="title">{{item.title||'暂无'}}</text>
- </view>
- <view class="right">
- <text class="t-icon t-icon-tiaozhuan"></text>
- </view>
- </view>
- <view class="button">
- <button type="warn" v-if="user&&user.id" @click="toLogin('1')">退出登录</button>
- <button type="warn" v-else @click="toLogin('2')">登录</button>
- </view>
- </view>
- </template>
- <script>
- export default {
- components: {},
- data() {
- return {
- user: {},
- menuList: [{
- title: "账号信息",
- route: "pagesMy/account/basic",
- },
- {
- title: "修改密码",
- route: "pagesMy/account/password",
- }
- ],
- }
- },
- onLoad: async function(e) {
- const that = this;
- await that.searchToken();
- },
- methods: {
- // 用户信息
- searchToken() {
- const that = this;
- try {
- const res = uni.getStorageSync('token');
- if (res) {
- const user = that.$jwt(res);
- that.$set(that, `user`, user);
- }
- } catch (e) {}
- },
- // 公共跳转
- toCommon(e) {
- uni.navigateTo({
- url: `/${e}`
- })
- },
- // 登录或注销
- toLogin(type) {
- if (type == '1') {
- uni.showModal({
- title: '提示',
- content: '确定要退出登录?',
- success: function(res) {
- if (res.confirm) {
- try {
- uni.removeStorageSync('token');
- } catch (e) {}
- uni.navigateBack({
- delta: 1
- })
- } else if (res.cancel) {
- console.log('用户点击取消');
- }
- }
- });
- } else {
- uni.reLaunch({
- url: `/pagesHome/login/index`
- })
- }
- },
- }
- }
- </script>
- <style lang="scss" scoped>
- .main {
- .list {
- display: flex;
- justify-content: space-between;
- padding: 3vw 2vw;
- border-bottom: 1px solid var(--f9Color);
- .left {
- display: flex;
- align-items: center;
- .title {
- margin: 0 0 0 5px;
- display: inline-block;
- font-size: var(--font14Size);
- }
- }
- .right {
- .t-icon {
- width: var(--font14Size) !important;
- height: var(--font14Size) !important;
- color: var(--f99Color) !important;
- }
- }
- }
- .button {
- margin: 3vw;
- text-align: center;
- .button {}
- }
- }
- </style>
|