Commit 7fa377e2 authored by 郝聪敏's avatar 郝聪敏

fix: pdf展示方式改变

parent 477e5bec
...@@ -29,3 +29,8 @@ export const updateRenewal = (policySecId, status) => { ...@@ -29,3 +29,8 @@ export const updateRenewal = (policySecId, status) => {
export const returnOnline = params => { export const returnOnline = params => {
return req.post("/third/huagui/returnOnline", params); return req.post("/third/huagui/returnOnline", params);
}; };
// 电子保单下载获取下载地址
export const getElectronicInsurance = params => {
return req.post("/policy/download/img-state", params);
};
...@@ -73,17 +73,24 @@ axios.interceptors.request.use( ...@@ -73,17 +73,24 @@ axios.interceptors.request.use(
// 响应拦截器即异常处理 // 响应拦截器即异常处理
axios.interceptors.response.use( axios.interceptors.response.use(
response => { response => {
let notifyType = "danger";
afterRequest(); afterRequest();
delete pending[response.config.url]; delete pending[response.config.url];
if (response.data.code === "0") return response.data.data; if (response.data.code === "0") return response.data.data;
// 特殊处理,下单已存在时,跳转到保单列表 // 特殊处理,下单已存在时,跳转到保单列表
if (response.config.url === "policy_order" && response.data.code === "40601") { if (response.config.url === "policy_order" && response.data.code === "40601") {
setTimeout(() => { setTimeout(() => {
router.push("/policy"); router.push("/policy");
}, 1000); }, 1000);
} }
Notify({ type: "danger", message: response.data.msg || "后端服务异常" });
// 后端返回异常信息时提出警告
if (response.data.code && response.data.msg) notifyType = "warning";
Notify({ type: notifyType, message: response.data.msg || "后端服务异常" });
return Promise.reject(response.data); return Promise.reject(response.data);
}, },
async err => { async err => {
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
</template> </template>
<script> <script>
import Collapse from "./Collapse"; import Collapse from "./Collapse";
import electronicInsuranceMixin from "../../mixin/electronicInsurance.mixin";
export default { export default {
name: "SecurityContent", name: "SecurityContent",
...@@ -69,12 +70,10 @@ export default { ...@@ -69,12 +70,10 @@ export default {
} }
} }
}, },
mixins: [electronicInsuranceMixin],
methods: { methods: {
showPdf() { showPdf() {
this.$router.push({ this.getElectronicInsurance(this.data?.policySecId);
path: "/policy/virtual-detail",
query: { policySecId: this.data.policySecId }
});
} }
}, },
computed: { computed: {
......
<template> <template>
<div class="container"> <cr-image fit="cover" :src="url" />
<pdf v-for="(item, index) in pdfNumPages" :key="index" :src="pdfUrl" :page="index + 1" />
</div>
</template> </template>
<script> <script>
import pdf from "vue-pdf";
import config from "@/config";
import { mapActions } from "vuex";
import localStorage from "@/service/localStorage";
// let CMAP_URL = "https://cdn.jsdelivr.net/npm/pdfjs-dist@2.5.207/cmaps/";
export default { export default {
name: "PolicyVirtualDetail", name: "PolicyVirtualDetail",
components: {
pdf
},
data() { data() {
return { return {
pdfUrl: "", url: ""
pdfNumPages: null
}; };
}, },
mounted() { created() {
this.pdfTask(); this.url = this.$route.query?.url;
},
methods: {
...mapActions(["setIsLoading"]),
pdfTask() {
const token = localStorage.get("mongoToken");
const policySecId = this.$route.query?.policySecId;
if (!policySecId || !token) this.$router.back();
const url = `${
config.basicHost
}policy/download?token=${token}&policySecId=${encodeURIComponent(policySecId)}`;
this.pdfUrl = pdf.createLoadingTask({ url });
this.pdfUrl.promise
.then(pdf => {
this.pdfNumPages = pdf.numPages;
this.setIsLoading(false);
})
.catch(err => {
console.error("err", err);
});
}
} }
}; };
</script> </script>
......
import { getElectronicInsurance } from "@/api/policy";
export default {
methods: {
async getElectronicInsurance(policySecId) {
if (!policySecId) {
this.$notify({ type: "warning", message: "保单不存在" });
return;
}
const url = await getElectronicInsurance({ policySecId });
this.$router.push({
path: "/policy/virtual-detail",
query: { url }
});
}
}
};
...@@ -79,6 +79,7 @@ import { getPolicyList } from "@/api/policy"; ...@@ -79,6 +79,7 @@ import { getPolicyList } from "@/api/policy";
import settings from "@/api/settings"; import settings from "@/api/settings";
import policyStatusMixin from "../mixin/policyStatus.mixin"; import policyStatusMixin from "../mixin/policyStatus.mixin";
import detailPayMixin from "@/views/Goods/Detail/modules/detailPay.mixin"; import detailPayMixin from "@/views/Goods/Detail/modules/detailPay.mixin";
import electronicInsurance from "../mixin/electronicInsurance.mixin";
// SELF(1, "本人"), // SELF(1, "本人"),
// PARENT(2, "父母"), // PARENT(2, "父母"),
...@@ -88,7 +89,7 @@ const relations = [-1, 1, 2, 3, 4]; ...@@ -88,7 +89,7 @@ const relations = [-1, 1, 2, 3, 4];
export default { export default {
name: "InsuranceRecommend", name: "InsuranceRecommend",
mixins: [policyStatusMixin, detailPayMixin], mixins: [policyStatusMixin, detailPayMixin, electronicInsurance],
props: { props: {
type: { type: {
type: Number, type: Number,
...@@ -136,10 +137,7 @@ export default { ...@@ -136,10 +137,7 @@ export default {
query: { id: item.id, type: item.itype } query: { id: item.id, type: item.itype }
}); });
} else if (text === "电子保单") { } else if (text === "电子保单") {
this.$router.push({ this.getElectronicInsurance(item.policySecId);
path: "/policy/virtual-detail",
query: { policySecId: item.policySecId }
});
} else if (text === "去支付") { } else if (text === "去支付") {
this.orderInfo = { this.orderInfo = {
payOrderNo: item?.payInfo?.payOrderNo, payOrderNo: item?.payInfo?.payOrderNo,
......
@import "../../style/index.less"; @import "../../style/index.less";
.user { .user {
&::after {
content: "";
display: block;
height: 80px;
}
width: 100%; width: 100%;
overflow: hidden; overflow: hidden;
background-color: @user-background-color; background-color: @user-background-color;
...@@ -296,7 +303,6 @@ ...@@ -296,7 +303,6 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
align-items: center; align-items: center;
padding: 0 130px 82.92px;
font-size: 0; font-size: 0;
&-svg { &-svg {
margin-bottom: 8px; margin-bottom: 8px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment