<template>
	<view class="content">
		<view class="main flex">
			<view class="main-font">新品通知</view>
			<u-switch v-model="checked" active-color="#2979ff" size="50"></u-switch>
		</view>
		<u-popup v-model="show" mode="center" border-radius="50" :closeable="true">
			<view class="popup-box">
				<view class="popup-font">长按二维码保存至本地，关注公众号即可接收消息</view>
				<view class="ewm"><image @longtap="bc_code" src="../../static/img/add.png" mode=""></image></view>
			</view>
		</u-popup>
	</view>
</template>

<script>
export default {
	data() {
		return {
			checked: false,
			show: true
		};
	},
	onLoad() {
		this.open();
	},
	onShow() {},
	onReachBottom() {},
	onReady() {},
	methods: {
		change(status) {
			console.log(status);
			this.open();
		},
		open() {
			this.show = true;
		},
		close() {
			this.show = false;
		},
		bc_code() {
			let that = this;
			console.log('保存二维码', this.backImg);
			uni.downloadFile({
				//获得二维码的临时地址
				url: this.backImg,
				success: res => {
					//console.log('获取url',res)
					if (res.statusCode == 200) {
						uni.saveImageToPhotosAlbum({
							filePath: res.tempFilePath, //传入临时地址
							success() {
								that.$api.msg('保存成功'); //封装的提示
							},
							fail() {
								that.$api.msg('保存失败');
							}
						});
					}
				}
			});
		}
	}
};
</script>

<style lang="scss">
page,
.content {
	min-height: 100%;
	height: auto;
}
.main {
	padding: 40rpx;
	.main-font {
		font-size: 30rpx;
		font-family: PingFang SC;
		font-weight: 800;
		color: #000000;
	}
}
.popup-box {
	width: 470rpx;
	padding: 86rpx 40rpx 40rpx;
	position: relative;
	.popup-font {
		font-size: 32rpx;
		font-weight: 800;
		font-family: PingFang SC;
		color: #000000;
	}
	.ewm {
		margin: 20rpx auto;
		width: 390rpx;
		height: 390rpx;
		image {
			width: 100%;
			height: 100%;
		}
	}
}
</style>
