feat: 5.22 update
This commit is contained in:
parent
736adae554
commit
6a20d18c12
@ -9,11 +9,11 @@ const DEFAULT_TIMEOUT = 15000;
|
|||||||
|
|
||||||
// 错误码定义
|
// 错误码定义
|
||||||
const ERR_CODE = {
|
const ERR_CODE = {
|
||||||
SUCCESS: 200,
|
SUCCESS: 200,
|
||||||
UNAUTHORIZED: 401,
|
UNAUTHORIZED: 401,
|
||||||
FORBIDDEN: 403,
|
FORBIDDEN: 403,
|
||||||
NOT_FOUND: 404,
|
NOT_FOUND: 404,
|
||||||
SERVER_ERROR: 500,
|
SERVER_ERROR: 500,
|
||||||
};
|
};
|
||||||
|
|
||||||
function getHeaders(contentType = 'application/json') {
|
function getHeaders(contentType = 'application/json') {
|
||||||
@ -63,6 +63,11 @@ function handleResponse(response) {
|
|||||||
* 处理 token 失效
|
* 处理 token 失效
|
||||||
*/
|
*/
|
||||||
function handleUnauthorized() {
|
function handleUnauthorized() {
|
||||||
|
// 如果 localStorage 中本来就没有 token,说明是未登录状态,不做处理
|
||||||
|
if (!localStorage.getItem('member_token')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// 清除登录状态
|
// 清除登录状态
|
||||||
localStorage.removeItem('member_token');
|
localStorage.removeItem('member_token');
|
||||||
localStorage.removeItem('member_username');
|
localStorage.removeItem('member_username');
|
||||||
|
|||||||
@ -87,6 +87,11 @@ export default {
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
getPermissions() {
|
getPermissions() {
|
||||||
|
if (!this.$isLogin()) {
|
||||||
|
// this.$showFailToast('登录状态异常,请重新登录')
|
||||||
|
// location.replace('#/Login')
|
||||||
|
return
|
||||||
|
}
|
||||||
this.$get('/v1/client/DUsersClient').then(res => {
|
this.$get('/v1/client/DUsersClient').then(res => {
|
||||||
this.PermissionsData = {
|
this.PermissionsData = {
|
||||||
id: res.data.id,
|
id: res.data.id,
|
||||||
|
|||||||
@ -310,6 +310,9 @@ const routes = [
|
|||||||
path: '/SyncAuth',
|
path: '/SyncAuth',
|
||||||
name: 'SyncAuth',
|
name: 'SyncAuth',
|
||||||
component: () => import('./views/SyncAuth.vue'),
|
component: () => import('./views/SyncAuth.vue'),
|
||||||
|
meta: {
|
||||||
|
noLogin: true,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/404',
|
path: '/404',
|
||||||
|
|||||||
@ -538,8 +538,9 @@ img {
|
|||||||
>img {
|
>img {
|
||||||
width: 16vw;
|
width: 16vw;
|
||||||
height: 16vw;
|
height: 16vw;
|
||||||
.y50;
|
border-radius: 50%;
|
||||||
margin-right: 2.933vw;
|
margin-right: 2.933vw;
|
||||||
|
object-fit: contain;
|
||||||
}
|
}
|
||||||
|
|
||||||
.text {
|
.text {
|
||||||
|
|||||||
@ -164,6 +164,12 @@ export default {
|
|||||||
location.replace('#/')
|
location.replace('#/')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (!this.$isLogin) {
|
||||||
|
this.$showFailToast?.('登录状态异常,请重新登录')
|
||||||
|
// localStorage.removeItem('member_token')
|
||||||
|
location.replace('#/Login')
|
||||||
|
return
|
||||||
|
}
|
||||||
// this.checkWxLogin();
|
// this.checkWxLogin();
|
||||||
const code = JSON.stringify(this.$route.query.code);
|
const code = JSON.stringify(this.$route.query.code);
|
||||||
if (code) {
|
if (code) {
|
||||||
|
|||||||
@ -149,7 +149,21 @@ export default {
|
|||||||
name: 'Merchant',
|
name: 'Merchant',
|
||||||
components: { ManagerPopup },
|
components: { ManagerPopup },
|
||||||
mounted() {
|
mounted() {
|
||||||
this.init()
|
this.$get('/v1/client/DUsersClient').then(res => {
|
||||||
|
this.id = res.data.id;
|
||||||
|
if (!res.data.isshop) {
|
||||||
|
this.$showFailToast('您不是商家账号!')
|
||||||
|
// localStorage.removeItem('member_token')
|
||||||
|
location.replace('#/My')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.init();
|
||||||
|
}).catch(() => {
|
||||||
|
this.$showFailToast('登录状态异常,请重新登录')
|
||||||
|
// localStorage.removeItem('member_token')
|
||||||
|
location.replace('#/Login')
|
||||||
|
})
|
||||||
|
|
||||||
window.addEventListener('showManagerPopup', this.onShowManagerPopup)
|
window.addEventListener('showManagerPopup', this.onShowManagerPopup)
|
||||||
window.addEventListener('closeManagerPopup', this.onCloseManagerPopup)
|
window.addEventListener('closeManagerPopup', this.onCloseManagerPopup)
|
||||||
},
|
},
|
||||||
@ -160,7 +174,7 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
managerPopupVisible: false,
|
managerPopupVisible: false,
|
||||||
id: this.$route.query.id,
|
id: this.$route.query.id || this.$ls.get('user_id'),
|
||||||
data: {
|
data: {
|
||||||
endTimes: new Date().toLocaleString('zh-CN', { hour12: false })
|
endTimes: new Date().toLocaleString('zh-CN', { hour12: false })
|
||||||
},
|
},
|
||||||
@ -203,5 +217,4 @@ export default {
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="less">
|
<style lang="less"></style>
|
||||||
</style>
|
|
||||||
@ -28,7 +28,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="times">
|
<div class="times">
|
||||||
<span>{{ $formatGMT(item.addtime, 'yyyy-MM-dd HH:mm:ss') }}</span>
|
<span>{{ $formatGMT(item.addtime, 'yyyy-MM-dd HH:mm:ss') }}</span>
|
||||||
<span>阅览量 {{ item.ReadCount }}</span>
|
<span>阅览量 {{ item.click }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -3,21 +3,27 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { useUserStore } from '@/stores/user'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.token)
|
if (this.token) {
|
||||||
localStorage.setItem('member_token', this.token);
|
localStorage.setItem('member_token', this.token)
|
||||||
// if (this.miniopenid)
|
const userStore = useUserStore()
|
||||||
// localStorage.setItem('miniopenid', this.miniopenid);
|
userStore.setToken(this.token)
|
||||||
if (this.target)
|
setTimeout(() => {
|
||||||
location.replace(`#/${this.target}`);
|
const target = this.target ? `/${this.target}` : '/Home'
|
||||||
else
|
// console.log(target);
|
||||||
location.replace('#/');
|
|
||||||
|
this.$router.replace(target)
|
||||||
|
}, 200)
|
||||||
|
} else {
|
||||||
|
this.$router.replace('/Home')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
token: decodeURIComponent(this.$route.query.token || ''),
|
token: decodeURIComponent(this.$route.query.token || ''),
|
||||||
// miniopenid: decodeURIComponent(this.$route.query.miniopenid || ''),
|
|
||||||
target: decodeURIComponent(this.$route.query.target || ''),
|
target: decodeURIComponent(this.$route.query.target || ''),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@ -218,10 +218,15 @@ export default {
|
|||||||
components: { ManagerPopup },
|
components: { ManagerPopup },
|
||||||
computed: {
|
computed: {
|
||||||
},
|
},
|
||||||
|
beforeRouteEnter(to, from, next) {
|
||||||
|
if (!localStorage.getItem('member_token')) {
|
||||||
|
next({ name: 'Login', query: { redirect: to.fullPath } });
|
||||||
|
} else {
|
||||||
|
next();
|
||||||
|
}
|
||||||
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.init();
|
this.init();
|
||||||
window.addEventListener('showManagerPopup', this.onShowManagerPopup)
|
|
||||||
window.addEventListener('closeManagerPopup', this.onCloseManagerPopup)
|
|
||||||
},
|
},
|
||||||
beforeUnmount() {
|
beforeUnmount() {
|
||||||
window.removeEventListener('showManagerPopup', this.onShowManagerPopup)
|
window.removeEventListener('showManagerPopup', this.onShowManagerPopup)
|
||||||
@ -250,6 +255,13 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
init() {
|
init() {
|
||||||
|
if (!this.$isLogin()) {
|
||||||
|
this.$showFailToast('登录状态异常,请重新登录')
|
||||||
|
location.replace('#/Login')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
window.addEventListener('showManagerPopup', this.onShowManagerPopup)
|
||||||
|
window.addEventListener('closeManagerPopup', this.onCloseManagerPopup)
|
||||||
Promise.all(
|
Promise.all(
|
||||||
[
|
[
|
||||||
this.$get('/v1/client/DUsersClient').then(data => {
|
this.$get('/v1/client/DUsersClient').then(data => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user