提交 5842f90d authored 作者: 龙菲's avatar 龙菲

修复文物图片加载失败问题;修复点赞后无法更新的问题

上级 6c241513
...@@ -95,7 +95,7 @@ ...@@ -95,7 +95,7 @@
</template> </template>
<script> <script>
import { mapGetters } from "vuex"; import { mapGetters, mapActions } from "vuex";
import { debounce, formatNum } from "@/utils/index"; import { debounce, formatNum } from "@/utils/index";
export default { export default {
name: "ReaderOperations", name: "ReaderOperations",
...@@ -131,67 +131,81 @@ export default { ...@@ -131,67 +131,81 @@ export default {
}, },
computed: { computed: {
...mapGetters(["token", "showLoginDialog"]), ...mapGetters(["token", "showLoginDialog"]),
isCulturalRelic() {
if (!this.sourceType) {
return;
}
return this.sourceType == "biz_cultural_relic";
},
isExhibiton() {
if (!this.sourceType) {
return;
}
return this.sourceType == "biz_exhibition";
},
}, },
methods: { methods: {
handleCollect: debounce(function () { ...mapActions("user", ["toggleCollect", "toggleLike"]),
handleCollect: debounce(async function () {
if (this.token) { if (this.token) {
let sourceId; let sourceId;
let title; let title;
if (this.sourceType == "biz_cultural_relic") { if (this.isCulturalRelic) {
sourceId = this.info.crId; const { crId, name } = this.info;
title = this.info.name; sourceId = crId;
} else if (this.sourceType == "biz_exhibition") { title = name;
sourceId = this.info.exhibitionId; } else if (this.isExhibiton) {
title = this.info.title; const { exhibitionId, title } = this.info;
sourceId = exhibitionId;
title = title;
} }
const params = { const params = {
sourceType: this.sourceType, sourceType: this.sourceType,
sourceId, sourceId,
title, title,
}; };
this.$store.dispatch("user/toggleCollect", params).then(() => {
if (!this.info.collectCountStatus) { try {
// 点赞 await this.toggleCollect(params);
this.$message.success("已收藏!"); const msg = this.info.collectCountStatus
} else { ? "已取消收藏!"
this.$message.success("已取消收藏!"); : "已收藏!";
} this.$message.success(msg);
setTimeout(() => { const id = this.info.crId || this.info.exhibitionId;
this.$emit("reload", this.info.crId || this.info.exhibitionId); this.$emit("reload", id);
}, 300); } catch (error) {
}); this.$message.error("操作失败:" + error);
} else { }
this.loginDialogVisible = true;
} }
}), }),
// 点赞 // 点赞
handleLike: debounce(function () { handleLike: debounce(async function () {
if (this.token) { if (this.token) {
let sourceId; let sourceId;
let title; let title;
if (this.sourceType == "biz_cultural_relic") { if (this.isCulturalRelic) {
sourceId = this.info.crId; const { crId, name } = this.info;
title = this.info.name; sourceId = crId;
} else if (this.sourceType == "biz_exhibition") { title = name;
sourceId = this.info.exhibitionId; } else if (this.isExhibiton) {
title = this.info.title; const { exhibitionId, title } = this.info;
sourceId = exhibitionId;
title = title;
} }
const params = { const params = {
sourceType: this.sourceType, sourceType: this.sourceType,
sourceId, sourceId,
title, title,
}; };
this.$store.dispatch("user/toggleLike", params).then(() => { try {
if (!this.info.loveCountStatus) { await this.toggleLike(params);
// 点赞 const msg = this.info.loveCountStatus ? "已取消点赞!" : "已点赞!";
this.$message.success("已点赞!"); this.$message.success(msg);
} else { const id = this.info.crId || this.info.exhibitionId;
this.$message.success("已取消点赞!"); this.$emit("reload", id);
} } catch (error) {
setTimeout(() => { this.$message.error("操作失败:" + error);
this.$emit("reload", this.info.crId || this.info.exhibitionId); }
}, 300);
});
} else { } else {
this.loginDialogVisible = true; this.loginDialogVisible = true;
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<!-- online_3d_viewer --> <!-- online_3d_viewer -->
<div <div
class="online_3d_viewer" class="online_3d_viewer"
model="/static/3d/yshl.FBX" :model="url"
:backgroundcolor="backgroundcolor" :backgroundcolor="backgroundcolor"
></div> ></div>
</template> </template>
......
...@@ -188,7 +188,7 @@ const routes = [ ...@@ -188,7 +188,7 @@ const routes = [
import("@/views/3d/index.vue"), import("@/views/3d/index.vue"),
}, },
{ {
path: "/3d/:id", path: "/3dDetail",
name: "3dDetail", name: "3dDetail",
component: () => component: () =>
import("@/views/3d/detail.vue"), import("@/views/3d/detail.vue"),
......
...@@ -3,7 +3,7 @@ const getDefaultState = () => { ...@@ -3,7 +3,7 @@ const getDefaultState = () => {
curPath: null, curPath: null,
navBarFixed: false, navBarFixed: false,
showLoginDialog: null, showLoginDialog: null,
navbarHeight:null, navbarHeight: null,
navbarStyle: '1',//1-默认蓝色;2-中国风;3-红色 navbarStyle: '1',//1-默认蓝色;2-中国风;3-红色
} }
} }
......
...@@ -61,7 +61,7 @@ const actions = { ...@@ -61,7 +61,7 @@ const actions = {
setUserInfo(data) setUserInfo(data)
resolve(response) resolve(response)
} }
// else{ // else{
// console.log('222',response); // console.log('222',response);
// resolve(response) // resolve(response)
......
import axios from 'axios' import axios from 'axios'
import { import {
MessageBox,
Message,
Loading Loading
} from 'element-ui' } from 'element-ui'
import store from '@/store'
import messageup from './resetMessage' import messageup from './resetMessage'
import { import {
getToken getToken,
removeToken,
removeUserInfo
} from '@/utils/auth' } from '@/utils/auth'
console.log('process.env', process.env); import store from '@/store'
// create an axios instance
const service = axios.create({ const service = axios.create({
baseURL: process.env.VUE_APP_BASE_API, baseURL: process.env.VUE_APP_BASE_API,
timeout: 1000 * 10, timeout: 1000 * 10,
...@@ -42,9 +40,10 @@ service.interceptors.request.use( ...@@ -42,9 +40,10 @@ service.interceptors.request.use(
} }
) )
// response interceptor // response interceptor
service.interceptors.response.use( service.interceptors.response.use(
response => { async response => {
num-- num--
if (num === 0) { if (num === 0) {
setTimeout(() => { setTimeout(() => {
...@@ -52,30 +51,39 @@ service.interceptors.response.use( ...@@ -52,30 +51,39 @@ service.interceptors.response.use(
}, 500); }, 500);
} }
const res = response.data const res = response.data
if (response.config.url === '/sys/getVerify') { // 验证码接口
const isVerify = response.config.url === '/sys/getVerify'
// 组织机构树接口
const isSysRegionTree = response.config.url === '/sysRegion/tree'
// 先处理一些不需要经过拦截器的或者单独处理的
if (isVerify) {
return res return res
} }
if (isSysRegionTree) {
if (response.config.url === '/sysRegion/tree') {
let arr = res.data let arr = res.data
if (arr && arr.length > 0) { if (arr && arr.length > 0) {
if (arr[0].code === '520000000000' && arr.length === 1) { if (arr[0].code === '520000000000' && arr.length === 1) {
arr = arr[0].children arr = arr[0].children
} }
} }
res.data = arr res.data = arr
return res return res
} }
// debugger
// if the custom code is not 20000, it is judged as an error.
if (res.code !== 0) { if (res.code !== 0) {
messageup({ messageup({
type: 'error', type: 'error',
showClose: true, showClose: true,
message: res.msg || 'Error' message: res.msg || 'Error'
}) })
// 401001l令牌过期,此时调用logout依旧显示令牌过期,因此直接Remove用户信息
const isExpired = res.code === 401001
if (isExpired) {
removeToken()
removeUserInfo()
commit('RESET_STATE')
location.reload()
store.commit('app/OPEN_LOGIN_DIALOG', true)
}
return Promise.reject(res.msg || 'Error') return Promise.reject(res.msg || 'Error')
} else { } else {
return res return res
......
<template> <template>
<div class="container-3d"> <div class="container-3d">
<Viewer3d backgroundcolor="linear(0, 0, 0,40%)" /> <Viewer3d
backgroundcolor="linear(0, 0, 0,40%)"
:url="file3dUrl"
v-if="file3dUrl"
/>
<div class="left-text"> <div class="left-text">
<div>多彩贵州</div> <div>多彩贵州</div>
<div>博物<br />盛筵</div> <div>博物<br />盛筵</div>
...@@ -93,7 +97,10 @@ export default { ...@@ -93,7 +97,10 @@ export default {
}; };
}, },
mounted() { mounted() {
console.log(this.$router); const { file3dUrl } = this.$route.query;
if (file3dUrl) {
this.file3dUrl = file3dUrl;
}
}, },
methods: { methods: {
handleChangeButton(item) { handleChangeButton(item) {
......
...@@ -122,8 +122,16 @@ export default { ...@@ -122,8 +122,16 @@ export default {
}, },
methods: { methods: {
handleOpen3d(item) { handleOpen3d(item) {
const newPage = this.$router.resolve({ path: "/3d/" + item }); const path = "/3dDetail";
window.open(newPage.href, "_blank"); const { file3dUrl } = item;
if (file3dUrl) {
const query = {
file3dUrl: encodeURI(file3dUrl),
};
this.$bizCommon.openNewPage(path, query);
} else {
this.$message.error("3d文件为空或无效!");
}
}, },
}, },
}; };
......
...@@ -71,12 +71,17 @@ export default { ...@@ -71,12 +71,17 @@ export default {
getPropValue(prop) { getPropValue(prop) {
return this.detail[prop] || "暂无"; return this.detail[prop] || "暂无";
}, },
loadDetail() { loadDetail(id) {
this.$emit("loadDetail"); this.$emit("loadDetail", id);
}, },
handleTo3D() { handleTo3D() {
const { file3dUrl, url3d } = this.detail; const { file3dUrl, url3d } = this.detail;
if (file3dUrl) { if (file3dUrl) {
const path = "/3dDetail";
const query = {
file3dUrl: encodeURI(file3dUrl),
};
this.$bizCommon.openNewPage(path, query);
return; return;
} }
if (url3d) { if (url3d) {
...@@ -106,6 +111,9 @@ export default { ...@@ -106,6 +111,9 @@ export default {
margin-right: 8px; margin-right: 8px;
} }
} }
.view-3d {
cursor: pointer;
}
.basic-info { .basic-info {
color: #333; color: #333;
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
<div class="imgs"> <div class="imgs">
<div class="common-title">文物图片</div> <div class="common-title">文物图片</div>
<swiper :options="swiperOption" ref="imgSwiper"> <swiper :options="swiperOption" ref="imgSwiper">
<swiper-slide v-for="(item, i) in detail.imagesVo" :key="i"> <swiper-slide v-for="(item, i) in imagesVo" :key="i">
<div <div
title="点击查看大图" title="点击查看大图"
class="img-container" class="img-container"
@click.stop="handelPreviewImages(detail.imagesVo, i)" @click.stop="handelPreviewImages(imagesVo, i)"
> >
<img :src="$getFullUrl(item.middleUrl || item.url)" alt="" /> <img :src="$getFullUrl(item.middleUrl || item.url)" alt="" />
<div class="search" title="搜索类似图片"> <div class="search" title="搜索类似图片">
...@@ -44,12 +44,29 @@ export default { ...@@ -44,12 +44,29 @@ export default {
default: () => ({}), default: () => ({}),
}, },
}, },
computed: {
imagesVo() {
if (!this.detail.imagesVo) {
return;
}
if (this.detail.imagesVo.length > 0) {
return this.detail.imagesVo;
} else {
return [
{
pressUrl: this.detail.faceImagePressUrl,
url: this.detail.faceImageUrl,
middleUrl: this.detail.faceImageMiddleUrl,
},
];
}
},
},
data() { data() {
return { return {
swiperOption: imgSwiperOption, swiperOption: imgSwiperOption,
}; };
}, },
mounted() {},
methods: { methods: {
handelPreviewImages(items, index) { handelPreviewImages(items, index) {
this.imgList = items.map((item) => this.$getFullUrl(item.url)); this.imgList = items.map((item) => this.$getFullUrl(item.url));
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论