【银保app】添加水印公共js并调用获取代理人信息接口

This commit is contained in:
liu.xiaofeng@ebiz-digits.com
2022-11-30 16:15:35 +08:00
parent 53d8d671cd
commit 851f70b689
3 changed files with 78 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
// warterMark.js
'use strict'
let watermark = {}
let setWatermark = (str, str1) => {
let id = '1.23452384164.123412415'
if (document.getElementById(id) !== null) {
document.body.removeChild(document.getElementById(id))
}
let can = document.createElement('canvas')// 创建一个画布
can.width = 350 // 设置宽度
can.height = 150 // 高度
let cans = can.getContext('2d')
cans.rotate(-25 * Math.PI / 180) // 水印旋转角度 0 水平
cans.font = '14px Vedana' // 字体大小
cans.fillStyle = '#000' // 水印的颜色
cans.textAlign = 'left' // 设置文本内容的当前对齐方式
cans.textBaseline = 'Middle' // 设置在绘制文本时使用的当前文本基线
cans.globalAlpha = 0.1 // 透明度
cans.fillText(str, can.width / 4.5, can.height / 1) // 在画布上绘制填色的文本输出的文本开始绘制文本的X坐标位置开始绘制文本的Y坐标位置
cans.fillText(str1, can.width / 3, can.height / 2.5) // 根据需求可添加多行水印在方法中添加str1
let div = document.createElement('div')
div.id = id
div.style.pointerEvents = 'none'
div.style.top = '100px'
div.style.left = '0px'
div.style.position = 'fixed'
div.style.zIndex = '100000'
div.style.width = document.documentElement.clientWidth - 30 + 'px'
div.style.height = document.documentElement.clientHeight + 'px'
div.style.background = 'url(' + can.toDataURL('image/png') + ') left top repeat'
document.body.appendChild(div)
return id
}
// 该方法只允许调用一次
watermark.set = (str,str1) => {
let id = setWatermark(str,str1)
setInterval(() => {
if (document.getElementById(id) === null) {
id = setWatermark(str,str1)
}
}, 500)
window.onresize = () => {
setWatermark(str,str1)
}
}
export default watermark

View File

@@ -21,6 +21,8 @@
<script> <script>
import { YBpolicyDetail } from '@/api/YB_APP/index' import { YBpolicyDetail } from '@/api/YB_APP/index'
import warterMark from "@/assets/js/utils/warterMark.js"
import { getAgentInfo } from '@/api/ebiz/my/my.js'
export default { export default {
name: 'policyDetail', name: 'policyDetail',
components: {}, components: {},
@@ -31,11 +33,20 @@ export default {
} }
}, },
mounted() { mounted() {
this.getAgentInfo()
this.policyNo = this.$route.query.policyNo this.policyNo = this.$route.query.policyNo
console.log(this.policyNo, 'avc') console.log(this.policyNo, 'avc')
this.YBpolicyDetail() this.YBpolicyDetail()
}, },
methods: { methods: {
getAgentInfo(){
getAgentInfo({}).then(res=>{
if(res.result == 0){
console.log('123')
warterMark.set(res.name+res.jobNo,"")
}
})
},
YBpolicyDetail() { YBpolicyDetail() {
let params = { let params = {
policyNo: this.policyNo policyNo: this.policyNo

View File

@@ -5,6 +5,7 @@
<van-search shape="round" v-model="findValue" placeholder="请输入保单号" /> <van-search shape="round" v-model="findValue" placeholder="请输入保单号" />
<button class="searchButton" @click="keywordSearch(findValue)">搜索</button> <button class="searchButton" @click="keywordSearch(findValue)">搜索</button>
</div> </div>
<!-- <div style="width:100%;height:1000px;background:rgba(0, 0, 0, 0.2);"></div> -->
<!-- 右侧搜索按钮 --> <!-- 右侧搜索按钮 -->
@@ -120,6 +121,8 @@ import { Button, Search } from 'vant'
import { ref } from 'vue' import { ref } from 'vue'
import utils from '@/assets/js/utils/date-utils' import utils from '@/assets/js/utils/date-utils'
import { YBpolicyListAgent } from '@/api/YB_APP/index' import { YBpolicyListAgent } from '@/api/YB_APP/index'
import warterMark from "@/assets/js/utils/warterMark.js"
import { getAgentInfo } from '@/api/ebiz/my/my.js'
export default { export default {
name: 'policyList', name: 'policyList',
@@ -182,6 +185,8 @@ export default {
}, 500) }, 500)
}, },
mounted() { mounted() {
this.getAgentInfo()
this.YBpolicyListAgent() this.YBpolicyListAgent()
// 筛选按钮的点击事件 // 筛选按钮的点击事件
window.appCallBack = this.appCallBack window.appCallBack = this.appCallBack
@@ -190,6 +195,14 @@ export default {
}, },
methods: { methods: {
getAgentInfo(){
getAgentInfo({}).then(res=>{
if(res.result == 0){
console.log('123')
warterMark.set(res.name+res.jobNo,"")
}
})
},
appCallBack(data, flag) { appCallBack(data, flag) {
// 筛选按钮的点击事件 // 筛选按钮的点击事件
this.showSideBar = true this.showSideBar = true