<template>
	<view>
		<div class="header">
			<div class="searchBox" :style="{ height: localHeight + 'px', paddingTop: top + 'px' }">
				<div class="searchBox_left" @click="back">
					<u-icon name="arrow-left" size="20px" color="#000"></u-icon>
				</div>
			</div>
		</div>
		<div class="swiper">
			<swiper :indicator-dots="false" :autoplay="true" :interval="3000" :duration="1000">
				<swiper-item>
					<image src="http://192.168.0.172:5500/shop_goodsImg.png"></image>
				</swiper-item>
				<swiper-item>
					<image src="http://192.168.0.172:5500/shop_goodsImg.png"></image>
				</swiper-item>
			</swiper>

			<div class="NumDot">
				1/5
			</div>
		</div>

		<div class="Money">
			<div class="MoneyMark">￥</div>25.9 <div class="MoneyUnit">/箱</div>

			<div class="oldMoney">￥45.00</div>
		</div>

		<!-- 规格 -->
		<div class="GGBox">
			<div class="GG_left">
				<div class="GG_Item" v-for="item in 9">3KG/箱</div>
			</div>
			<div class="GG_rigth">共8款<u-icon size="26rpx" name="arrow-right"></u-icon></div>
		</div>

		<div class="Tit">新疆库尔勒香梨全母梨子新鲜孕妇水果整箱小10斤精选旗舰店包邮直发</div>
		<div class="Msg">新疆库尔勒香梨全母梨子新鲜孕妇水果整箱小10斤精选旗舰店包邮直发</div>
		<div class="GoodsMsg">
			商品详情
		</div>

		<div class="Msg_Item">
			<div class="Msg_ItemTit">商品编号</div>
			<div class="Msg_ItemCon">008475709 <image src="http://192.168.0.172:5500/shop_copy.png"></image>
			</div>
		</div>
		<div class="Msg_Item">
			<div class="Msg_ItemTit">规格说明</div>
			<div class="Msg_ItemCon">23*10*10箱</div>
		</div>
		<div class="Msg_Item">
			<div class="Msg_ItemTit">商品编号</div>
			<div class="Msg_ItemCon">箱</div>
		</div>

		<div class="GoosMsg">
			<image src="http://192.168.0.172:5500/Goods_MsgImg.png" mode="widthFix"></image>
		</div>

		<!-- 底部购物车 -->
		<div class="Car">
			<div class="car_left">
				<div class="share" @click="share">
					<image src="http://192.168.0.172:5500/shop_share.png" mode="widthFix"></image>
					分享
				</div>
				<div class="cars">
					<u-badge numberType="limit" :type="type" max="99" :value="value"></u-badge>

					<image src="http://192.168.0.172:5500/shop_car.png" mode="widthFix"></image>
					购物车
				</div>
			</div>

			<div class="car_right" v-if="false">
				加入购物车
			</div>

			<div class="car_right">
				<u-number-box v-model="value">
					<view slot="minus" class="minus">
						<u-icon name="minus" size="36" bold></u-icon>
					</view>
					<text slot="input" style="width: 200rpx;text-align: center;" class="input">{{ value }}</text>
					<view slot="plus" class="plus">
						<u-icon name="plus" color="#FFFFFF" size="36" bold></u-icon>
					</view>
				</u-number-box>
			</div>
		</div>

		<!-- 分享 -->
		<div class="shadow" @click.stop="changeShadow" v-if="boxshadow1">
			<div class="shadowBox1">
				<div class="shadowBox1Item" @click="shareFriend">
					<image src="http://192.168.0.172:5500/shop_WX.png" mode="aspectFill"></image>
					微信好友
				</div>
				<div class="shadowBox1Item" @click="openSave">
					<image src="http://192.168.0.172:5500/shop_saveImg.png" mode="aspectFill"></image>
					生成海报
				</div>
			</div>
		</div>
		<!-- 海报 -->
		<div class="shadow" @click="changeShadow2" v-if="boxshadow2">
			<div class="shadowBox2">
				<div class="shadowBox_img">
					<div class="boxshadow_tit">今日商品推荐</div>
					<div class="boxshadow_img">
						<image src="http://192.168.0.172:5500/shop_share_img.png"></image>
					</div>
					<div class="line"></div>
					<div class="shadowBoxInfo">
						<div class="shadowboxInfo_left">二维码</div>
						<div class="shadowboxInfo_right">
							<div class="shadowboxInfo_right_1">正鲜生</div>
							<div class="shadowboxInfo_right_2">
								长按识别小程序 <br>
								数量有限马上抢购</div>
						</div>
					</div>
				</div>
				<div class="shadowBox_btn" @click.stop="saveImg">保存海报</div>
			</div>
		</div>

	</view>
</template>

<script>
import {
	apiArr
} from '../../../api/doorToDoor';
import {
	picUrl,
	menuButtonInfo,
	request,
	NavgateTo
} from '../../../utils';
export default {
	data() {
		return {
			top: "",
			localHeight: "",
			value: 3,
			type: "error",
			boxshadow1: false,
			boxshadow2: false
		}
	},
	methods: {
		back() {
			uni.navigateBack({
				delta: 1
			});
		},
		// 分享微信
		shareFriend() {
			this.boxshadow2 = false
			return
			// uniapp 分享微信好友
			uni.share({
				provider: 'weixin',
				type: 'link',
				scene: 'session',
				link: 'https://uniapp.dcloud.net.cn/',
				title: '商品名称',
				imageUrl: '',
				success: (res) => {
					uni.showToast({
						title: '分享成功',
						icon: 'success',
						duration: 2000
					});
					this.boxshadow1 = false
				},
				fail: (err) => {
					console.log('分享失败', err);
					this.boxshadow1 = false
				}
			});
		},
		changeShadow() {
			this.boxshadow1 = false
		},
		openSave(){
			this.boxshadow1 = false
			this.boxshadow2 = true
		},
		// 保存海报
		saveImg() {
			this.boxshadow2 = false
			// 微信小程序保存图片
			uni.downloadFile({
				url: 'http://192.168.0.172:5500/shop_share_img.png',
				success: (res) => {
					if (res.statusCode === 200) {
						uni.saveImageToPhotosAlbum({
							filePath: res.tempFilePath,
							success: (res) => {
								uni.showToast({
									title: '保存成功',
									icon: 'success',
									duration: 2000
								});
							},
							fail: (err) => {
								console.log('保存失败', err);
							}
						});
					}
				},
				fail: (err) => {
					console.log('下载失败', err);
				}
			});
		},
		changeShadow2() {
			this.boxshadow2 = false
		},

		// 点分享按钮
		share(){
			this.boxshadow1 = true
		},
	},
	onLoad(options) {
		const meun = menuButtonInfo();
		this.top = meun.top;
		this.localHeight = meun.height;
	},
	onReachBottom() {

	},
}
</script>

<style>
@import url("./index.css");
</style>