Commit b8dc2ecb8d0e57835348931c07c4779c8ed3e1b8
1 parent
c0f275b0
保存图片
Showing
2 changed files
with
70 additions
and
0 deletions
src/pages/test.vue
0 → 100644
| 1 | +<template> | ||
| 2 | + <div class="test"> | ||
| 3 | + <img @touchstart="gtouchstart()" @touchmove="gtouchmove()" @touchend="gtouchend()" style="width: 100%" src="https://wjj.ys2.cnliveimg.com/769/shop/img/2020/01/06/5e12f2ead41bb.jpg"/> | ||
| 4 | + <div id="captureId" class="capture" v-show="firstFlag"> | ||
| 5 | + </div> | ||
| 6 | + <img :src="dataURL" alt="" v-show="!firstFlag"/> | ||
| 7 | + <!--<div style="width:100%; height: 50px; line-height: 50px; background-color: #000; font-size: 18px;color: #ffffff;text-align: center;">--> | ||
| 8 | + <!--<!–保存图片–>--> | ||
| 9 | + <!--</div>--> | ||
| 10 | + </div> | ||
| 11 | +</template> | ||
| 12 | +<script> | ||
| 13 | + import html2canvas from 'html2canvas'; | ||
| 14 | + export default { | ||
| 15 | + data () { | ||
| 16 | + return { | ||
| 17 | + dataURL:'https://wjj.ys2.cnliveimg.com/769/shop/img/2020/01/06/5e12f31607200.jpg', | ||
| 18 | + firstFlag:true, | ||
| 19 | + timeOutEvent:0 | ||
| 20 | + }; | ||
| 21 | + }, | ||
| 22 | + mounted(){ | ||
| 23 | + | ||
| 24 | + }, | ||
| 25 | + methods: { | ||
| 26 | + onimg(){ | ||
| 27 | + document.documentElement.style.webkitUserSelect='none'; | ||
| 28 | + document.documentElement.style.webkitTouchCallout='none'; | ||
| 29 | + }, | ||
| 30 | + //js | ||
| 31 | + gtouchstart () { | ||
| 32 | + // 开始触摸 | ||
| 33 | + this.timeOutEvent = setTimeout(() => { | ||
| 34 | + // 长按3秒 | ||
| 35 | + this.timeOutEvent = 0 | ||
| 36 | + if(this.isiPhone.value){ | ||
| 37 | + window.webkit.messageHandlers.CNDSCheckAllowVisitPhotoAlbumHandler.postMessage({body: {}}); | ||
| 38 | + }else { | ||
| 39 | + if (window.obj && window.obj.CNDSCheckAllowVisitPhotoAlbumHandler) { | ||
| 40 | + // 调取相册 | ||
| 41 | + window.obj.CNDSCheckAllowVisitPhotoAlbumHandler(); | ||
| 42 | + } | ||
| 43 | + } | ||
| 44 | + }, 3000) | ||
| 45 | + }, | ||
| 46 | + gtouchmove () { | ||
| 47 | + // 看具体需求 | ||
| 48 | + // clearTimeout(this.timeOutEvent) | ||
| 49 | + // this.timeOutEvent = 0 | ||
| 50 | + }, | ||
| 51 | + gtouchend () { | ||
| 52 | + clearTimeout(this.timeOutEvent) | ||
| 53 | + this.timeOutEvent = 0 | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + } | ||
| 57 | +</script> | ||
| 58 | +<style lang='less' scoped> | ||
| 59 | +</style> |
src/router/index.js
| @@ -37,6 +37,17 @@ const router = new Router({ | @@ -37,6 +37,17 @@ const router = new Router({ | ||
| 37 | meta: { | 37 | meta: { |
| 38 | requireAuth: false | 38 | requireAuth: false |
| 39 | } | 39 | } |
| 40 | + }, | ||
| 41 | + { | ||
| 42 | + // test | ||
| 43 | + path: "/test", | ||
| 44 | + name: "test", | ||
| 45 | + component: resolve => { | ||
| 46 | + require(["@/pages/test"], resolve); | ||
| 47 | + }, | ||
| 48 | + meta: { | ||
| 49 | + requireAuth: false | ||
| 50 | + } | ||
| 40 | } | 51 | } |
| 41 | ] | 52 | ] |
| 42 | }, | 53 | }, |