|
|
|
@ -266,21 +266,17 @@ var _default = { |
|
|
|
headImage: '/static/默认头像.png', |
|
|
|
collectionNum: 5, |
|
|
|
score: 41 |
|
|
|
} |
|
|
|
}, |
|
|
|
isLogin: false |
|
|
|
}; |
|
|
|
}, |
|
|
|
computed: { |
|
|
|
isLogin: function isLogin() { |
|
|
|
return uni.getStorageSync('token'); |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
navigateTo: function navigateTo(page) { |
|
|
|
console.log('导航到:', page); |
|
|
|
// 根据不同页面进行导航
|
|
|
|
switch (page) { |
|
|
|
case 'profile': |
|
|
|
if (this.isLogin) { |
|
|
|
if (uni.getStorageSync('token')) { |
|
|
|
uni.navigateTo({ |
|
|
|
url: '/subPages/my/myProfile' |
|
|
|
}); |
|
|
|
@ -331,6 +327,7 @@ var _default = { |
|
|
|
} |
|
|
|
}, |
|
|
|
logout: function logout() { |
|
|
|
var _this = this; |
|
|
|
uni.showModal({ |
|
|
|
title: '提示', |
|
|
|
content: '确定要退出登录吗?', |
|
|
|
@ -338,10 +335,12 @@ var _default = { |
|
|
|
if (res.confirm) { |
|
|
|
// 清除用户信息
|
|
|
|
uni.removeStorageSync('token'); |
|
|
|
_this.isLogin = false; |
|
|
|
uni.showToast({ |
|
|
|
title: '已退出登录', |
|
|
|
icon: 'success' |
|
|
|
}); |
|
|
|
|
|
|
|
// 跳转到登录页面
|
|
|
|
setTimeout(function () { |
|
|
|
uni.reLaunch({ |
|
|
|
@ -353,7 +352,7 @@ var _default = { |
|
|
|
}); |
|
|
|
}, |
|
|
|
getUser: function getUser() { |
|
|
|
var _this = this; |
|
|
|
var _this2 = this; |
|
|
|
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee() { |
|
|
|
var res; |
|
|
|
return _regenerator.default.wrap(function _callee$(_context) { |
|
|
|
@ -365,14 +364,14 @@ var _default = { |
|
|
|
break; |
|
|
|
} |
|
|
|
_context.next = 3; |
|
|
|
return _this.$api.user.queryUser(); |
|
|
|
return _this2.$api.user.queryUser(); |
|
|
|
case 3: |
|
|
|
res = _context.sent; |
|
|
|
_this.userInfo = res === null || res === void 0 ? void 0 : res.result; |
|
|
|
_this2.userInfo = res === null || res === void 0 ? void 0 : res.result; |
|
|
|
_context.next = 8; |
|
|
|
break; |
|
|
|
case 7: |
|
|
|
_this.userInfo = { |
|
|
|
_this2.userInfo = { |
|
|
|
nickName: '未登录', |
|
|
|
headImage: '/static/默认头像.png', |
|
|
|
collectionNum: '0', |
|
|
|
@ -389,16 +388,17 @@ var _default = { |
|
|
|
}, |
|
|
|
onShow: function onShow() { |
|
|
|
this.getUser(); |
|
|
|
this.isLogin = uni.getStorageSync('token') ? true : false; |
|
|
|
}, |
|
|
|
onPullDownRefresh: function onPullDownRefresh() { |
|
|
|
var _this2 = this; |
|
|
|
var _this3 = this; |
|
|
|
return (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() { |
|
|
|
return _regenerator.default.wrap(function _callee2$(_context2) { |
|
|
|
while (1) { |
|
|
|
switch (_context2.prev = _context2.next) { |
|
|
|
case 0: |
|
|
|
_context2.next = 2; |
|
|
|
return _this2.getUser(); |
|
|
|
return _this3.getUser(); |
|
|
|
case 2: |
|
|
|
uni.stopPullDownRefresh(); |
|
|
|
case 3: |
|
|
|
|