51 lines
1.3 KiB
Vue
51 lines
1.3 KiB
Vue
<!-- 印章申请 -->
|
|
<template>
|
|
<view class="previewTestStyle" @click="preview">{{fileName}}</view>
|
|
</template>
|
|
|
|
<script setup>
|
|
import config from '@/utils/config.js'
|
|
import { ref, onMounted } from 'vue';
|
|
const props = defineProps({
|
|
url:{ type: String, default: "" },
|
|
name:{ type: String, default: "" },
|
|
filePath:{ type: String, default: "" },
|
|
})
|
|
const fileName = ref("");
|
|
onMounted(() => {
|
|
console.log('props.url',props.url)
|
|
console.log('props.name',props.name)
|
|
console.log('props.filePath',props.filePath)
|
|
let arrs = props.filePath.length>0? props.filePath.split("/"):[];
|
|
fileName.value =props.name!=""?props.name:arrs[arrs.length-1];
|
|
console.log('fileName.value',fileName.value)
|
|
})
|
|
const preview=()=>{
|
|
let baseUrl = config.baseUrl.split('/api')[0];
|
|
let url0 = props.url!=""?props.url : baseUrl + props.filePath;
|
|
let urls = [];
|
|
urls.push(url0)
|
|
console.log('url0',url0)
|
|
if (url0.indexOf('jpg')>-1||url0.indexOf('png')>-1||url0.indexOf('jpeg')>-1) {
|
|
uni.previewImage({
|
|
urls: urls,
|
|
fail: function(err) {
|
|
uni.showToast({
|
|
title: "预览失败",
|
|
icon: "none"
|
|
})
|
|
}
|
|
})
|
|
} else {
|
|
window.open(url0, '_blank');
|
|
}
|
|
}
|
|
</script>
|
|
<style scoped>
|
|
.previewTestStyle{
|
|
color: blue;
|
|
width: 100%;
|
|
display: inline-block;
|
|
}
|
|
</style>
|