<template>
	<view class="page">
		<view class="topBody">
			<view class="header">
			</view>
			<view class="myinfo">
				<image :src="myinfo.share_img" mode="widthFix"></image>

				<view style="margin-top: 24rpx;" class="numlist">
					<view class="num" @click="saveImg">
						<image src="../../static/w3/save.png" mode="widthFix"></image>
						<view class="name">保存</view>
					</view>
				</view>


			</view>


			<view class="blankHeight"></view>
		</view>

		<!-- 提示框 -->
		<DialogBox ref="DialogBox"></DialogBox>
	</view>
</template>

<script>
	export default {
		components: {},
		data() {
			return {
				title: '',
				sel: 1,
				nodata: true,
				myinfo: {},
				list: [],
			}
		},
		onLoad() {
			// setTimeout(function() {
			// 	uni.setNavigationBarColor({
			// 		frontColor: '#ffffff',
			// 		backgroundColor: '#00000000',
			// 		animation: {
			// 			duration: 400,
			// 			timingFunc: 'easeIn'
			// 		}
			// 	})
			// }, 200);
			this.loadInfo();
		},
		onShow() {},
		methods: {
			onBack() {},
			chkSel() {
				if (this.sel == 1) {
					this.sel = 0;
				} else {
					this.sel = 1;
				}
			},
			loadInfo() {
				console.log({
					uuid: getApp().globalData.uuid,
					skey: getApp().globalData.skey
				});
				uni.request({
					url: this.$apiHost + '/Web/getinfo',
					data: {
						uuid: getApp().globalData.uuid,
						type: 'tuan'
					},
					header: {
						"content-type": "application/json", //自定义请求头信息
					},
					success: (res) => {
						console.log("----:", res.data);
						this.myinfo = res.data;
					},
					complete: (com) => {
						// uni.hideLoading();
					},
					fail: (e) => {
						console.log("----e:", e);
					}
				});
			},
			saveImg() {
				// #ifdef APP-PLUS
				let that = this;
				uni.showLoading()
				uni.downloadFile({
					url: that.myinfo.share_img,
					success: (res) => {
						if (res.statusCode === 200) {
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success: function() {
									uni.showToast({
										title: '已保存到相册'
									});
								},
								fail: function(e) {
									uni.showToast({
										icon: 'none',
										title: '保存失败'
									});
								},
								complete: function() {
									uni.hideLoading()
								}
							});
						} else {
							uni.hideLoading()
							uni.showToast({
								icon: 'none',
								title: '保存失败'
							})
						}
					},
					fail: function() {
						uni.hideLoading()
						uni.showToast({
							icon: 'none',
							title: '保存失败'
						})
					}
				})

				// #endif
			}

		}
	}
</script>

<style scoped lang="scss">
	@import 'share_img.scss';
</style>