更新记录
1.0.0(2022-11-04)
下载此版本
1.基于市场插件改进的海报
平台兼容性
uni-app
Vue2 |
Vue3 |
Chrome |
Safari |
app-vue |
app-nvue |
Android |
iOS |
鸿蒙 |
√ |
- |
- |
- |
√ |
- |
- |
- |
- |
微信小程序 |
支付宝小程序 |
抖音小程序 |
百度小程序 |
快手小程序 |
京东小程序 |
鸿蒙元服务 |
QQ小程序 |
飞书小程序 |
快应用-华为 |
快应用-联盟 |
√ |
- |
- |
- |
- |
- |
- |
- |
- |
- |
- |
其他
HTML结构
复制代码<template>
<view class="poster">
<shareImages ref="canvas" :canvasWidth="canvasWidth"
:canvasHeight="canvasHeight"
:goodsTitle="goodsTitle"
:qrSize="qrSize"
:qrUrl="qrUrl"
@success="shareSuccess">
</shareImages>
<view class="button">
<button :disabled="canvasImages == '' ? false : true" type="primary"
@click="createsShareImage">生成海报</button>
<button :disabled="canvasImages != '' ? false : true" @click="previewHandle">预览海报</button>
</view>
<view class="" @click="saveImg">
保存
</view>
</view>
</template>
<style lang="less" scoped>
.poster{
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
background-color: rgba(0, 0, 0, 0.5);
.button{
position: absolute;
bottom: 100rpx;
}
}
</style>
引入组件
复制代码import shareImages from '@/components/poster/shareImages.vue'
注册组件
复制代码export default {
components: {
shareImages
},
data() {
return {
canvasImages: '',
canvasWidth: 600,
canvasHeight: 864,
goodsTitle: '我是这张图片的标题我是这张图片的标题我是这张图片的标',
qrSize: 100,
qrUrl: '我要吃饭了',
}
},
methods: {
createsShareImage() {
this.$refs.canvas.canvasCreate();
},
previewHandle() {
uni.previewImage({
urls: [this.canvasImages],
});
},
shareSuccess(e) {
this.canvasImages = e
console.log(e);
},
onShareAppMessage(res) {
return {
title: 'canvas图片分享',
path: this.canvasImages
}
},
saveImg() {
uni.downloadFile({
url: this.canvasImages,
success: (res) => {
console.log(res)
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: () => {
uni.showToast({
title: "保存成功!",
});
},
fail: () => {
uni.showToast({
title: "保存失败",
});
},
});
},
});
}
}
}