123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- <template>
- <div class="actionSheet">
- <img :src="url" alt="" @click="md" class="qr" />
- </div>
- </template>
- <script>
- // @ is an alias to /src
- // let sT = 0;
- export default {
- name: "Applyreal",
- data() {
- return {
- // url: "http://192.168.31.196:8080/qr.png",
- url: "http://djweb.smcic.net/img/qr.png",
- load: {},
- };
- },
- mounted() {
- document.title = "车险";
- },
- computed: {},
- methods: {
- md() {
- console.log("---");
- // this.download({
- // savePath: this.url,
- // });
- this.downimg(this.url);
- },
- downimg(url) {
- let img = new Image();
- img.src = url;
- img.onload = function (ev) {
- console.log(ev)
- // 组装a标签
- // let elink = document.createElement("a");
- // // 设置下载文件名
- // elink.download = Date.now() + ".png";
- // elink.style.display = "none";
- // elink.href = URL.createObjectURL(this.response);
- // document.body.appendChild(elink);
- // elink.click();
- // document.body.removeChild(elink);
- };
- },
- download(row) {
- // download
- this.load[row.savePath] = true;
- let xhttp,
- that = this;
- if (window.XMLHttpRequest) xhttp = new XMLHttpRequest();
- else xhttp = new window.ActiveXObject("Microsoft.XMLHTTP");
- xhttp.responseType = "blob";
- xhttp.open("GET", row.savePath, true);
- console.log(xhttp);
- xhttp.send();
- xhttp.addEventListener(
- "progress",
- res => {
- console.log(res, (res.loaded / res.total) * 100);
- that.load[row.savePath] =
- ((res.loaded / res.total) * 100).toFixed(0) - 0;
- },
- false
- );
- xhttp.onreadystatechange = function () {
- if (this.readyState != 4 || this.status != 200) return;
- // 组装a标签
- let elink = document.createElement("a");
- // 设置下载文件名
- elink.download = Date.now() + ".png";
- elink.style.display = "none";
- elink.href = URL.createObjectURL(this.response);
- document.body.appendChild(elink);
- elink.click();
- document.body.removeChild(elink);
- delete that.load[row.savePath];
- };
- },
- },
- beforeUnmount: function () {},
- components: {},
- };
- </script>
- <style>
- .actionSheet {
- background-image: url("http://djweb.smcic.net/img/cx.png");
- background-size: 100% 100%;
- width: 100vw;
- height: 100vh;
- position: relative;
- }
- .actionSheet .qr {
- position: absolute;
- top: 50%;
- width: 100%;
- transform: translateY(-60%);
- }
- </style>
|