|
|
@@ -1,5 +1,5 @@
|
|
|
<template>
|
|
|
- <div>
|
|
|
+ <div v-if="!permissionDenied">
|
|
|
<el-row class="movie-list">
|
|
|
<el-col :md="24">
|
|
|
<el-card :if="!user" :body-style="{ padding: '0px' }" class="card">
|
|
|
@@ -67,15 +67,19 @@
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</div>
|
|
|
+ <div v-else>
|
|
|
+ <permission-denied-card :text-object="textObject"/>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+import PermissionDeniedCard from '@/components/card/PermissionDeniedCard'
|
|
|
import { followUser, getUserInfo, unfollowUser } from "@/api/user";
|
|
|
import { getAlbum, collectImage } from "@/api/image";
|
|
|
|
|
|
export default {
|
|
|
name: 'ImagePage',
|
|
|
- components: {},
|
|
|
+ components: { PermissionDeniedCard },
|
|
|
data() {
|
|
|
return {
|
|
|
// 屏幕宽度, 为了控制分页条的大小
|
|
|
@@ -88,23 +92,44 @@ export default {
|
|
|
},
|
|
|
data: null,
|
|
|
dataList: [],
|
|
|
+ permissionDenied: false,
|
|
|
+ textObject: {
|
|
|
+ content: '相册',
|
|
|
+ route: '/image'
|
|
|
+ },
|
|
|
}
|
|
|
},
|
|
|
created() {
|
|
|
const albumId = this.$route.params.albumId
|
|
|
- getAlbum(albumId).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- const resData = res.data
|
|
|
- document.title = '相册 - ' + resData.albumName
|
|
|
+ getAlbum(albumId).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ const respData = resp.data
|
|
|
+ document.title = '相册 - ' + respData.albumName
|
|
|
|
|
|
- this.data = resData
|
|
|
- this.userId = resData.userId
|
|
|
- getUserInfo(this.userId).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
- this.user = res.data
|
|
|
+ this.data = respData
|
|
|
+ this.userId = respData.userId
|
|
|
+ getUserInfo(this.userId).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
+ this.user = resp.data
|
|
|
+ } else {
|
|
|
+ this.$notify.error({
|
|
|
+ message: resp.msg,
|
|
|
+ type: 'warning',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
}
|
|
|
})
|
|
|
+ } else if (resp.code === 2) {
|
|
|
+ this.$router.push('/404')
|
|
|
+ } else {
|
|
|
+ this.permissionDenied = true
|
|
|
}
|
|
|
+ }).catch(error => {
|
|
|
+ this.$notify.error({
|
|
|
+ message: error.message,
|
|
|
+ type: 'error',
|
|
|
+ duration: 3000
|
|
|
+ })
|
|
|
})
|
|
|
},
|
|
|
mounted() {
|
|
|
@@ -119,15 +144,15 @@ export default {
|
|
|
methods: {
|
|
|
followUser(userId) {
|
|
|
if (this.followButton.text === '关注') {
|
|
|
- followUser(userId).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
+ followUser(userId).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
this.followButton.text = '已关注'
|
|
|
this.followButton.icon = 'el-icon-check'
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
- unfollowUser(userId).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
+ unfollowUser(userId).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
this.followButton.text = '关注'
|
|
|
this.followButton.icon = 'el-icon-plus'
|
|
|
}
|
|
|
@@ -155,11 +180,12 @@ export default {
|
|
|
},
|
|
|
collectItem(image) {
|
|
|
const jsonData = {}
|
|
|
+ jsonData.contentType = 1001
|
|
|
jsonData.contentId = image.imageFileId
|
|
|
if (image.collected) {
|
|
|
- jsonData.collect = false
|
|
|
- collectImage(jsonData).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
+ jsonData.collected = false
|
|
|
+ collectImage(jsonData).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
this.$notify({
|
|
|
title: '取消收藏图片',
|
|
|
type: 'info',
|
|
|
@@ -169,9 +195,9 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
- jsonData.collect = true
|
|
|
- collectImage(jsonData).then(res => {
|
|
|
- if (res.code === 0) {
|
|
|
+ jsonData.collected = true
|
|
|
+ collectImage(jsonData).then(resp => {
|
|
|
+ if (resp.code === 0) {
|
|
|
this.$notify({
|
|
|
title: '图片已收藏',
|
|
|
type: 'info',
|