当前位置: 首页 > news >正文

【uniapp】微信小程序 , 海报轮播图弹窗,点击海报保存到本地,长按海报图片分享,收藏或保存

在这里插入图片描述
uivew 2.0
uniapp 海报画板 DCloud 插件市场

第一步,下载插件并导入HbuilderX

第二步,文件内 引入 海报组件

<template><painter ref="haibaorefs"></painter>
<template>
<script>import painter from '@/components/painter.vue'export default {components: {painter},methods: {// 点击打开海报弹窗clickFun(){this.$refs.haibaorefs.open();}}
}
<script>

第三步,子组件 海报 源码, components/painter.vue 文件内容

<template><!-- 弹窗 --><u-popup :show="goodsshow" mode="center" round='26rpx' z-index='10076' bgColor='transparent' @close="goodsclose"><view class="popupbox"><view class="swiperbox"><swiper class="swiper" :indicator-dots="false" :autoplay="false" :circular="true" skip-hidden-item-layoutprevious-margin='35rpx'next-margin='35rpx'@change="swiperChange"><swiper-item v-for="(item,i) in list" :key="i"><view class="" v-if="item.coverimg"><image :src="item.coverimg" mode="" class="swiperImg"  show-menu-by-longpress></image></view><l-painterv-else@success='successFun($event,i)'isCanvasToTempFilePathpath-type="url"css="width: 600rpx;height:900rpx; box-sizing: border-box;  position: relative;"><l-painter-image :src="item.image"css="width: 600rpx;height:900rpx;border-radius: 20rpx;object-fit: cover;"/><l-painter-view css="position: absolute; bottom: 40rpx; right: 40rpx; background: #fff;  padding:10rpx 8rpx;border-radius: 10rpx; "><l-painter-image :src="erweima"css="width: 146rpx;height:143rpx;object-fit: cover;"/></l-painter-view></l-painter></swiper-item></swiper></view><view class="btnbox" @click="saveFun()"><!-- <view class="btn btn1" @click="goodsshow = false">长按识别分享海报</view> --><view class="btn btn2">保存到本地</view></view></view></u-popup>
</template><script>export default {components: {},props: {// list: {//   type: Array,//   default: null// }},data() {return {goodsshow: false,current: 0,list: [{image: 'https://m.360buyimg.com/babel/jfs/t1/196317/32/13733/288158/60f4ea39E6fb378ed/d69205b1a8ed3c97.jpg',coverimg:'', // 海报生成图片的临时地址id: 11},{image: 'https://m.360buyimg.com/babel/jfs/t1/196317/32/13733/288158/60f4ea39E6fb378ed/d69205b1a8ed3c97.jpg',coverimg:'',id: 11},{image: require('@/static/img/1.jpg'),coverimg:'',id: 11},],erweima: require('@/static/img/1.jpg')}},mounted() {},methods: {open(){this.goodsshow = true;},goodsclose() {this.goodsshow = false;},swiperChange(e) {this.current = e.detail.current;},// 接收海报临时路径successFun(e,i){console.log('接收海报临时路径',e,i)uni.getSavedFileList({success: function (res) {console.log(res.fileList);}});this.list.forEach((item,index) => {if(index == i){item.coverimg = e;}});},// 保存到本地saveFun(){let that = this;console.log(that.list[that.current].coverimg,'保存图片的临时路径和下标',this.current)uni.saveImageToPhotosAlbum({filePath: that.list[that.current].coverimg,success: function () {console.log('save success');uni.$u.toast('海报已保存到相册')}});},// 跳转navTo(url) {uni.navigateTo({url: url})},},}
</script><style lang='scss' scoped>swiper-item {/* 	display: flex;justify-content: center;align-items: center; */}.popupbox {display: flex;justify-content: center;align-items: center;flex-direction: column;.swiperbox {background-color: transparent;width: 750rpx;height: 900rpx;box-sizing: border-box;.swiper {width: 750rpx;height: 900rpx;overflow: hidden;border-radius: 20rpx;box-sizing: border-box;.swiperImg {width: 600rpx;height: 900rpx;border-radius: 20rpx;}}}.btnbox {margin: 50rpx auto 0;.btn {width: 315px;height: 96rpx;line-height: 96rpx;text-align: center;border-radius: 48rpx;font-size: 32rpx;font-weight: 500;}.btn2 {background: linear-gradient(177deg, #F2582F, #E1200B);color: #ffffff;}}}
</style>
http://www.lryc.cn/news/141827.html

相关文章:

  • SpringBoot与前端交互遇到的一些问题
  • Maven介绍与配置+IDEA集成Maven+使用Maven命令
  • 毕业设计题目源码-毕业论文参考
  • SSH报错-Terminal shell path: C:\WINDOWS\System32\cmd.exe 此时不应有
  • Docker 轻量级可视化工具Portainer
  • 站点平台技术架构
  • 一个以太坊合约的漏洞分析-重入攻击
  • 测试先行:探索测试驱动开发的深层价值
  • 如何用Dockerfile部署LAMP架构
  • 基于量子粒子群算法(QPSO)优化LSTM的风电、负荷等时间序列预测算法(Matlab代码实现)
  • SQL Server软件安装包分享(附安装教程)
  • 基于Django的博客管理系统
  • windows系统依赖环境一键安装
  • centos7安装nacos
  • 【python】python智能停车场数据分析(代码+数据集)【独一无二】
  • 如何使用Redis来防止穿透、击穿和雪崩问题
  • 以getPositionList为例,查找接口函数定义及接口数据格式定义
  • 一生一芯8——在github上添加ssh key
  • 2023年6月电子学会Python等级考试试卷(一级)答案解析
  • ppt如何转pdf文档?用这个方法可将ppt转pdf
  • Hope.money:新兴DeFi项目如何重新定义稳定币生态的未来?
  • 使用 S3 生命周期精确管理对象生命周期
  • RocketMQ零拷贝原理
  • HTML <tbody> 标签
  • 4.22 TCP 四次挥手,可以变成三次吗?
  • 鲁棒性简述
  • 复习leetcode
  • 从聚类(Clustering)到异常检测(Anomaly Detection):常用无监督学习方法的优缺点
  • git仓库提交流程
  • 层叠上下文、层叠顺序