|
@ -13,11 +13,18 @@ |
|
|
|
|
|
|
|
|
<canvas id="myCanvas" type="2d" canvas-id="firstCanvas1"></canvas> |
|
|
<canvas id="myCanvas" type="2d" canvas-id="firstCanvas1"></canvas> |
|
|
|
|
|
|
|
|
|
|
|
<view class="btn" |
|
|
|
|
|
v-if="imagePath" |
|
|
|
|
|
@click="preservationImg(imagePath)"> |
|
|
|
|
|
保存到相册 |
|
|
|
|
|
</view> |
|
|
|
|
|
|
|
|
</view> |
|
|
</view> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
<script> |
|
|
import { mapState } from 'vuex' |
|
|
import { mapState } from 'vuex' |
|
|
|
|
|
import index from '../../uni_modules/uv-ui-tools' |
|
|
export default { |
|
|
export default { |
|
|
name: 'Promotion', |
|
|
name: 'Promotion', |
|
|
computed: { |
|
|
computed: { |
|
@ -30,6 +37,7 @@ |
|
|
baseUrl: 'https://image.hhlm1688.com/', |
|
|
baseUrl: 'https://image.hhlm1688.com/', |
|
|
canvas: {}, |
|
|
canvas: {}, |
|
|
imagePath: '', |
|
|
imagePath: '', |
|
|
|
|
|
index : 0, |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
onShow() { |
|
|
onShow() { |
|
@ -98,6 +106,7 @@ |
|
|
const coderImage = canvas.createImage() |
|
|
const coderImage = canvas.createImage() |
|
|
coderImage.src = this.baseUrl + this.url |
|
|
coderImage.src = this.baseUrl + this.url |
|
|
|
|
|
|
|
|
|
|
|
let size = 0; |
|
|
|
|
|
|
|
|
bgImage.onload = () => { |
|
|
bgImage.onload = () => { |
|
|
canvas.width = bgImage.width |
|
|
canvas.width = bgImage.width |
|
@ -105,19 +114,24 @@ |
|
|
ctx.drawImage(bgImage, |
|
|
ctx.drawImage(bgImage, |
|
|
0, 0, bgImage.width, bgImage.height) |
|
|
0, 0, bgImage.width, bgImage.height) |
|
|
|
|
|
|
|
|
let size = Math.floor(canvas.width / 3) |
|
|
|
|
|
|
|
|
|
|
|
coderImage.onload = () => { |
|
|
|
|
|
ctx.drawImage(coderImage, |
|
|
|
|
|
canvas.width / 2 - (size / 2), canvas.height * 0.6, size, size) |
|
|
|
|
|
this.canvasToTempFilePath() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
size = Math.floor(canvas.width / 3) |
|
|
|
|
|
this.canvasToTempFilePath() |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
coderImage.onload = () => { |
|
|
|
|
|
ctx.drawImage(coderImage, |
|
|
|
|
|
canvas.width / 2 - (size / 2), canvas.height * 0.6, size, size) |
|
|
|
|
|
this.canvasToTempFilePath() |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
}) |
|
|
}) |
|
|
|
|
|
|
|
|
}, |
|
|
}, |
|
|
canvasToTempFilePath(){ |
|
|
canvasToTempFilePath(){ |
|
|
|
|
|
this.index++ |
|
|
|
|
|
if(this.index < 2){ |
|
|
|
|
|
return |
|
|
|
|
|
} |
|
|
// 绘制完成后存储路径 |
|
|
// 绘制完成后存储路径 |
|
|
setTimeout(() => { |
|
|
setTimeout(() => { |
|
|
wx.canvasToTempFilePath({ |
|
|
wx.canvasToTempFilePath({ |
|
@ -179,7 +193,7 @@ |
|
|
} |
|
|
} |
|
|
.image{ |
|
|
.image{ |
|
|
width: 100%; |
|
|
width: 100%; |
|
|
height: calc(100vh - 200rpx); |
|
|
|
|
|
|
|
|
height: calc(100vh - 300rpx); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#myCanvas { |
|
|
#myCanvas { |
|
@ -194,4 +208,19 @@ |
|
|
background-color: rgba(255, 255, 255, 1); |
|
|
background-color: rgba(255, 255, 255, 1); |
|
|
text-align: center; |
|
|
text-align: center; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
.btn{ |
|
|
|
|
|
position: fixed; |
|
|
|
|
|
// top: 58vh; |
|
|
|
|
|
bottom: 0; |
|
|
|
|
|
margin: 0; |
|
|
|
|
|
width: 750rpx; |
|
|
|
|
|
height: 100rpx; |
|
|
|
|
|
padding: 0; |
|
|
|
|
|
display: flex; |
|
|
|
|
|
justify-content: center; |
|
|
|
|
|
align-items: center; |
|
|
|
|
|
background-color: #fff; |
|
|
|
|
|
color: $uni-color; |
|
|
|
|
|
} |
|
|
</style> |
|
|
</style> |