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

这篇具有很好参考价值的文章主要介绍了【uniapp】微信小程序 , 海报轮播图弹窗,点击海报保存到本地,长按海报图片分享,收藏或保存。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

【uniapp】微信小程序 , 海报轮播图弹窗,点击海报保存到本地,长按海报图片分享,收藏或保存,uniapp,样式集合,uni-app,微信小程序,小程序
uivew 2.0
uniapp 海报画板 DCloud 插件市场文章来源地址https://www.toymoban.com/news/detail-674725.html

第一步,下载插件并导入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-layout
				previous-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-painter
							v-else
							@success='successFun($event,i)'
							isCanvasToTempFilePath
							path-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('海报已保存到相册')
						}
					});
			},
			// 分享给好友(底部弹出)
			shareFun() {
				let that = this;
				console.log(that.list[that.current].coverimg, '保存图片的临时路径')
				uni.showShareImageMenu({
				path: that.list[that.current].coverimg,
				success: function () {
					console.log('save success');
				},
				complete:function(resres){
				console.log(resres,'不论成功失败都显示')
				 	}
				 });
			},
			// 跳转
			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>

到了这里,关于【uniapp】微信小程序 , 海报轮播图弹窗,点击海报保存到本地,长按海报图片分享,收藏或保存的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

  • 微信小程序轮播图swiper使用

    文章目录 一、swiper的作用? 二、使用步骤 1.引入库 2.读入数据 总结 小程序中创建轮播图。 微信开放文档中组件--》视图容器--》swiper将下面代码拷贝   将代码粘贴至需要轮播图的页面,并根据实际情况修改代码 这里的tabList和img是根据接口传来的数据,需要在js中定义,这

    2024年02月12日
    浏览(38)
  • 微信小程序swiper实现层叠轮播图

    在微信小程序中,需要实现展示5个,横向层叠的轮播图效果,轮播图由中间到2侧的依次缩小.如下图 使用原生小程序进行开发,没有使用Skyline模式,所以layout-type配置项也无效。所以基于swiper组件进行调整。 主要思路就是设置不同的样式,根据当前激活的项,来动态切换样式。

    2024年01月24日
    浏览(37)
  • 微信小程序中实现轮播图效果

    swiper是轮播图的外层容器,所以使用轮播图就必须使用到swiper标签。 存在默认样式: 1 width 100% 2 height 150px 只能放置在swiper组件中。表示每一个轮播项。 编译效果: 当切换机型后,就可以方向,图片的宽高与效果不一样 1.分析和升级版本,解决换机型的宽高问题 ①先找出

    2024年02月11日
    浏览(40)
  • 解决微信小程序swiper轮播图撑不满有留白 实现swiper轮播图撑满父容器

    问题 :如下图,swiper轮播图两侧会有留白,没有撑满swiper 失败的尝试 : 1.调整图片尺寸 2.设属性设置image的mode为scaleToFill 3.设置item的属性 都没能实现将图片填充满轮播图,图片会有右侧和底部两块留白 通过调试器查看到image区域很小,怀疑是image本身属性的问题 随后尝试在

    2024年04月25日
    浏览(33)
  • 微信小程序首页、界面布局、3D轮播图效果(示例二)

    使用swiper实现3D轮播图效果,自定义顶部状态栏,具体代码: 1、js代码 2、wxml代码 3、wxss代码 4、json代码 如需要下载完整版,包含监听事件、图片文件等,请前往下方链接,下载完整版,下载后直接使用微信开发者工具打开即可,下载链接为: 小程序完整版界面(示例二)

    2024年02月10日
    浏览(43)
  • 微信小程序-轮播图-九宫格布局--【开发实战(第2版)】

    微信目录集链接在此: 详细解析黑马微信小程序视频–【思维导图知识范围】 难度★✰✰✰✰ 微信小程序开发实战(第2版)入门–【开发实战(第2版)】 ★★✰✰✰ 不会导入/打开小程序的看这里:参考 微信小程序开发实战(第2版)入门–【开发实战(第2版)】 用免费

    2024年02月08日
    浏览(33)
  • 微信小程序02-轮播图实现与图片点击跳转

    在小程序01中,已经学习了如何制作底部导航栏,本节让我们一起学习如何制作轮播图,以及点击轮播图完成页面跳转。 注:(1)前期学习,我这里用的本地的图片,后期的话,会对接后端接口,动态获取数据,前期方便学习,就暂时用的本地图片。(2)关于图片跳转地址

    2024年02月16日
    浏览(48)
  • 微信小程序进阶——Flex弹性布局&轮播图&会议OA项目(首页)

    目录 一、Flex弹性布局 1.1 什么是Flex弹性布局 1.1.1 详解 1.1.2 图解  1.1.3 代码演示效果 1.2 Flex弹性布局的核心概念 1.3 Flex 弹性布局的常见属性 1.4 Flex弹性布局部分属性详解 1.4.1 flex-direction属性 1.4.2 flex-wrap属性 1.4.3 flex-flow属性 1.4.4 justify-content属性 1.4.5 align-items属性 1.4.6 

    2024年02月05日
    浏览(30)
  • 微信小程序(原生)——轮播图swiper、1秒切换、自动轮播、无缝切换

    微信小程序的轮播图制作,且图片不变形。1秒切换、自动轮播、无缝切换 index.wxml文件: index.wxss文件: 完整示意图 swiper网址:https://developers.weixin.qq.com/miniprogram/dev/component/swiper.html image网址:https://developers.weixin.qq.com/miniprogram/dev/component/image.html 图片处理方面: mode=\\\"aspectFi

    2024年02月15日
    浏览(39)
  • 解决微信小程序关于轮播图宽度无法撑满页面的问题

    没有设置轮播图内部的图片宽度为100%,导致有空余从而无法使整个轮播图宽度撑满页面   index.wxml index.css 踩坑+1

    2024年02月13日
    浏览(58)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包