|
@@ -15,7 +15,7 @@ import {
|
|
|
showLoadingToast,
|
|
|
showSuccessToast
|
|
|
} from 'vant'
|
|
|
-import { computed, defineComponent, onMounted, reactive, TransitionGroup, ref } from 'vue'
|
|
|
+import { computed, defineComponent, onMounted, reactive, TransitionGroup, ref, nextTick } from 'vue'
|
|
|
import { useRoute } from 'vue-router'
|
|
|
import styles from './index.module.less'
|
|
|
import iconImage from '../images/icon-photo-default.png'
|
|
@@ -100,10 +100,11 @@ export default defineComponent({
|
|
|
}
|
|
|
const imgTobase64 = (_img: any) => {
|
|
|
const _canvas = document.createElement('canvas')
|
|
|
- _canvas.width = _img.offsetWidth
|
|
|
- _canvas.height = _img.offsetHeight
|
|
|
+ _canvas.width = _img.width
|
|
|
+ _canvas.height = _img.height
|
|
|
const ctx = _canvas.getContext('2d')
|
|
|
ctx?.drawImage(_img, 0, 0, _canvas.width, _canvas.height)
|
|
|
+ // console.log(_img, _canvas)
|
|
|
return _canvas.toDataURL('image/png')
|
|
|
}
|
|
|
const saveImg = async () => {
|
|
@@ -116,8 +117,8 @@ export default defineComponent({
|
|
|
const _img = document.createElement('img')
|
|
|
_img.crossOrigin = 'anonymous'
|
|
|
_img.onload = async () => {
|
|
|
+ // console.log("🚀 ~ base64:", base64)
|
|
|
const base64 = imgTobase64(_img)
|
|
|
- console.log("🚀 ~ base64:", base64)
|
|
|
try {
|
|
|
const res = await promisefiyPostMessage({
|
|
|
api: 'savePicture',
|
|
@@ -194,6 +195,14 @@ export default defineComponent({
|
|
|
onChange={(index: number) => (data.downIndex = index)}
|
|
|
>
|
|
|
{{
|
|
|
+ image: ({ src }) => (
|
|
|
+ <img
|
|
|
+ crossorigin="anonymous"
|
|
|
+ src={src}
|
|
|
+ class="van-image__img"
|
|
|
+ style="object-fit: contain;"
|
|
|
+ />
|
|
|
+ ),
|
|
|
cover: () => (
|
|
|
<div class={styles.downBtn} onClick={() => saveImg()}>
|
|
|
<img src={iconDown} />
|