Commit 010378fb authored by 郝聪敏's avatar 郝聪敏

Merge branch 'feature/update_pdf' into 'master'

fix: pdf展示方式改变

See merge request !194
parents 477e5bec 7fa377e2
......@@ -29,3 +29,8 @@ export const updateRenewal = (policySecId, status) => {
export const 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(
// 响应拦截器即异常处理
axios.interceptors.response.use(
response => {
let notifyType = "danger";
afterRequest();
delete pending[response.config.url];
if (response.data.code === "0") return response.data.data;
// 特殊处理,下单已存在时,跳转到保单列表
if (response.config.url === "policy_order" && response.data.code === "40601") {
setTimeout(() => {
router.push("/policy");
}, 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);
},
async err => {
......
......@@ -46,6 +46,7 @@
</template>
<script>
import Collapse from "./Collapse";
import electronicInsuranceMixin from "../../mixin/electronicInsurance.mixin";
export default {
name: "SecurityContent",
......@@ -69,12 +70,10 @@ export default {
}
}
},
mixins: [electronicInsuranceMixin],
methods: {
showPdf() {
this.$router.push({
path: "/policy/virtual-detail",
query: { policySecId: this.data.policySecId }
});
this.getElectronicInsurance(this.data?.policySecId);
}
},
computed: {
......
<template>
<div class="container">
<pdf v-for="(item, index) in pdfNumPages" :key="index" :src="pdfUrl" :page="index + 1" />
</div>
<cr-image fit="cover" :src="url" />
</template>
<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 {
name: "PolicyVirtualDetail",
components: {
pdf
},
data() {
return {
pdfUrl: "",
pdfNumPages: null
url: ""
};
},
mounted() {
this.pdfTask();
},
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);
});
}
created() {
this.url = this.$route.query?.url;
}
};
</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";
import settings from "@/api/settings";
import policyStatusMixin from "../mixin/policyStatus.mixin";
import detailPayMixin from "@/views/Goods/Detail/modules/detailPay.mixin";
import electronicInsurance from "../mixin/electronicInsurance.mixin";
// SELF(1, "本人"),
// PARENT(2, "父母"),
......@@ -88,7 +89,7 @@ const relations = [-1, 1, 2, 3, 4];
export default {
name: "InsuranceRecommend",
mixins: [policyStatusMixin, detailPayMixin],
mixins: [policyStatusMixin, detailPayMixin, electronicInsurance],
props: {
type: {
type: Number,
......@@ -136,10 +137,7 @@ export default {
query: { id: item.id, type: item.itype }
});
} else if (text === "电子保单") {
this.$router.push({
path: "/policy/virtual-detail",
query: { policySecId: item.policySecId }
});
this.getElectronicInsurance(item.policySecId);
} else if (text === "去支付") {
this.orderInfo = {
payOrderNo: item?.payInfo?.payOrderNo,
......
@import "../../style/index.less";
.user {
&::after {
content: "";
display: block;
height: 80px;
}
width: 100%;
overflow: hidden;
background-color: @user-background-color;
......@@ -296,7 +303,6 @@
display: flex;
flex-direction: column;
align-items: center;
padding: 0 130px 82.92px;
font-size: 0;
&-svg {
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