<template>
	<view class="recycling">
		<view class="recycling-hd">
			<image src="@/static/news/recyling-banner-01.png"></image>
		</view>
		<view class="recycling-bd">
			<view class="tab">
				<view class="a">
					<view class="item" @click="tabItem(0)"></view>
					<view class="item" @click="tabItem(1)"></view>
					<view class="item" @click="tabItem(2)"></view>
				</view>
				<view class="b">
					<image v-if="tabIndex == 0" src="@/static/news/icon-recyling-tab-01.png"></image>
					<image v-if="tabIndex == 1" src="@/static/news/icon-recyling-tab-02.png"></image>
					<image v-if="tabIndex == 2" src="@/static/news/icon-recyling-tab-03.png"></image>
				</view>
			</view>
			<view class="goods">
				<view class="a">
					<image src="@/static/news/icon-mall.jpg"></image>{{storeInfo.shop_name}}
				</view>
				<view class="b">
					<view class="l">
						<image class="pic" :src="storeInfo.logo_url"></image>
						<view class="info">
							<view class="tel">{{storeInfo.linkman}}{{storeInfo.phone}}</view>
							<view class="address">{{storeInfo.address}}</view>
							<view class="time">营业时间：{{storeInfo.shop_hours}}</view>
						</view>
						<view class="do">
							<view class="tel" @click="openPage(1,storeInfo.phone)">
								<image src="@/static/news/tel.png"></image>电话
							</view>
							<view class="tel" @click="openPage(2)">
								<image src="@/static/news/address.png"></image>导航
							</view>
						</view>
					</view>
					<view class="r">
						<image class="pic" :src="info.recovery_image"></image>
						<view class="info">
							<view class="tel">{{info.recovery_name}}</view>
							<view class="price">免支付预约</view>
						</view>
						<view class="num">
							x1
						</view>
					</view>
				</view>
			</view>
			<view class="form">
				<view class="item">
					<view class="a">品牌</view>
					<view class="b">
						<input class="box" type="text" v-model="brand" placeholder="品牌" />
					</view>
				</view>
				<view class="item">
					<view class="a">型号</view>
					<view class="b">
						<input class="box" type="text" v-model="model" placeholder="型号" />
					</view>
				</view>
				<view class="item">
					<view class="a">服务时间</view>
					<view class="b" @click="openPage(3)">
						<view class="select" :class="server_time?'select-on':''">{{server_time?server_time:(tabIndex <= 1?'请选择预约到店时间':'请选择预计寄出商品的时间')}}</view>
						<u-icon style="margin-left: 10rpx;" name="arrow-right"></u-icon>
					</view>
				</view>
				<view class="item">
					<view class="a">联系人</view>
					<view class="b">
						<input class="box1" v-model="username" type="text" placeholder="联系人姓名" />
						<view class="radio">
							<u-radio-group v-model="radioValue" active-color="red">
								<u-radio name="先生">先生</u-radio>
								<u-radio name="女士">女士</u-radio>
							</u-radio-group>
						</view>
					</view>
				</view>
				<view class="item">
					<view class="a">联系电话</view>
					<view class="b">
						<input class="box" type="number" v-model="mobile" placeholder="联系人手机号码" />
					</view>
				</view>
				<view class="item" v-if="tabIndex == 2">
					<view class="a">联系人微信</view>
					<view class="b">
						<input class="box" v-model="wx_account" type="text" placeholder="联系人微信号码" />
					</view>
				</view>
				<view class="item" v-if="tabIndex == 2">
					<view class="a">发件地址</view>
					<view class="b">
						<picker @change="changeRegion" mode="region">
							<view class="select" :class="region.length>0?'select-on':''">
							{{
								region.length > 0?region[0]+region[1]+region[2]:'请选择所在人城市'
							}}</view>
						</picker>
					</view>
				</view>
				<view class="item" v-if="tabIndex == 2">
					<view class="a">门牌号</view>
					<view class="b">
						<input class="box" type="text" placeholder="例：12幢1单元102室" />
					</view>
				</view>
				<view class="item">
					<view class="a">期待卖价</view>
					<view class="b">
						<input class="box" v-model="expect_price" type="number" placeholder="请输入您期待的售卖价格（元）" />
					</view>
				</view>
				<view class="photo" v-if="tabIndex != 0">
					<u-upload :action="url" :header="header" @on-uploaded="success" width="160" height="160" :file-list="fileList" :custom-btn="true" max-count="8">
						<template v-slot:addBtn>
							<view class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
								<image src="/static/news/icon-upload.png"></image>
								<view class="1">上传图片</view>
								<view class="1">1/8</view>
							</view>
						</template>
					</u-upload>
				</view>
				<view class="remark">
					<view class="name">备注 ：</view>
					<view class="xu">
						<view class="li" @click="openPage(5,'可提前来')">可提前来</view>
						<view class="li" @click="openPage(5,'来之前打电话')">来之前打电话</view>
						<view class="li" @click="openPage(5,'请尽快联系我')">请尽快联系我</view>
					</view>
					<view class="content">
						<u-input v-model="remake" height="260" type="textarea" placeholder="请输入您的留言，最多可留言100字" :border="true" />
					</view>
				</view>
			</view>
		</view>
		<view class="recycling-fd">
			<view class="a">免支付预购</view>
			<view class="b" @click="openPage(4)">提交订单</view>
		</view>
		<!-- 时间选择器 -->
		<u-picker mode="time" :params="params" v-model="show" confirm-color="#FE483B" :show-time-tag="false" @confirm="confirm"></u-picker>
	</view>
</template>
<script>
	import Config from '@/core/config'
	export default{
		data(){
			return {
				info: {},
				type: 1,
				radioValue: "男士",
				server_time: "",
				tabIndex: 0,
				fileList: [],
				image_ids: [],
				express_no: "",
				express_id: "",
				shipping_address: "",
				house_number: "",
				wx_account: "",
				model: "",
				brand: "",
				remake: "",
				expect_price: "",
				mobile: "",
				username: "",
				params: {
					year: true,
					month: true,
					day: true,
					hour: true,
					minute: true,
					second: true
				},
				show: false,
				storeInfo: {},
				region: [],
				header: {
					'Storeid': uni.getStorageSync('Store').storeInfo.store_id
					'AccessToken': uni.getStorageSync('AccessToken')
					'platform': "MP-WEIXIN",
				},
				
				url: Config.get('apiUrl')+'user/upload'
			}
		},
		onLoad(o) {
			this.tabIndex = o.tabIndex;
			this.info = uni.getStorageSync("getInfo")
			this.storeInfo = uni.getStorageSync("storeHsInfo")
			this.type = o.type;
			
		},
		methods: {
			success(e) {
				console.log(e)
			},
			beforeUpload(e,list){
				console.log(list)
				for(i = 0; i<list.length;i++){
					uni.uploadFile({
						name: 'file',
						header: {
							
						},
						url: ,
						filePath: list[i].url,
						success: (upRes) => {
							let end = JSON.parse(upRes.data);
							console.log(end)
							// that.userInfo.avatar = end.data.path
							// that.userInfo.avatar1 = end.data.url
						},
						fail: (err) => {
							console.log("toUpload err",err)
							console.log(err)
						}
					});
				}
				
			},
			uploadImage() {
				const that = this
				uni.chooseImage({
					count: 1,
					sizeType: ["original"], //可以指定是原图还是压缩图，默认二者都有
					sourceType: ["album", "camera"],
					success: (res) => {
						console.log(res.tempFilePaths[0])
						
					},
					fail(err){
						console.log("fail",err)
					}
				});
			},
			tabItem(i) {
				this.tabIndex = i
			},
			confirm(e){
				this.server_time = e.year+"-"+e.month+'-'+e.day+" "+e.hour+"-"+e.minute+'-'+e.second
			},
			changeRegion(e) {
				this.region = e.detail.value
			},
			openPage(i,msg){
				if(i == 1){
					uni.makePhoneCall({
						phoneNumber: msg
					})
				}else if(i == 2){
					uni.openLocation({
						latitude: this.storeInfo.latitude,
						longitude:  this.storeInfo.longitude,
						complete: function (res) {
							console.log(res);
						}
					});
				}else if(i == 3){
					this.show = true
					// uni.navigateTo({
					// 	url: "/pages/news/recycling/timer"
					// })
				}else if(i == 4) {
					uni.redirectTo({
						url: "/pages/news/recycling/order"
					})
				}
			},
		}
	}
</script>
<style lang="scss" scoped>
	.recycling{
		min-height: 100vh;
		background-color: #FFFFFF;
		padding-bottom: 130rpx;
		overflow: hidden;
		.slot-btn{
			width: 80px;
			height: 80px;
			background: #FFFFFF;
			border-radius: 10rpx;
			border: 1px solid #C0C0C0;
			text-align: center;
			font-size: 24rpx;
			font-weight: 500;
			color: #D1D1D1;
			image{
				width: 50rpx;
				height: 50rpx;
				margin-top: 20rpx;
			}
		}
		&-hd{
			width: 686rpx;
			height: 152rpx;
			border-radius: 8rpx;
			overflow: hidden;
			margin: 0 auto;
			margin-top: 30rpx;
			image{
				width: 100%;
				height: 100%;
			}
		}
		&-bd{
			width: 690rpx;
			min-height: 280rpx;
			overflow: hidden;
			margin: 0 auto;
			margin-top: 30rpx;
			position: relative;
			.tab{
				width: 690rpx;
				height: 280rpx;
				.b{
					width: 100%;
					height: 100%;
					display: block;
					image{
						width: 100%;
						height: 100%;
						display: block;
					}
				}
				.a{
					width: 100%;
					height: 98rpx;
					position: absolute;
					left: 0;
					top: 0;
					z-index: 2;
					display: flex;
					align-items: center;
					.item{
						flex: 1;
						height: 100%;
					}
				}
			}
			.goods{
				padding: 30rpx 35rpx;
				overflow: hidden;
				border-left: 1px solid #F1F1F1;
				border-right: 1px solid #F1F1F1;
				.a{
					display: flex;
					align-items: center;
					image{
						width: 50rpx;
						height: 50rpx;
						margin-right: 10rpx;
					}
					font-size: 28rpx;
					font-weight: 500;
					color: #000000;
				}
				.b{
					padding: 20rpx 0;
					overflow: hidden;
					.l{
						display: flex;
						align-items: center;
						overflow: hidden;
						.pic{
							width: 182rpx;
							height: 146rpx;
							border-radius: 6rpx;
							margin-right: 10rpx;
						}
						.info{
							width: 305rpx;
							margin-right: 20rpx;
							.title{
								font-size: 24rpx;
								font-weight: 400;
								color: #5C5C5C;
							}
							.address{
								font-size: 24rpx;
								font-weight: 400;
								color: #5C5C5C;
								height: 80rpx;
								line-height: 40rpx;
								overflow: hidden;
							}
							.time{
								font-size: 24rpx;
								font-weight: 400;
								color: #5C5C5C;
							}
						}
						.do{
							flex: 1;
							text-align: center;
							font-size: 20rpx;
							font-weight: 400;
							color: #989898;
							display: flex;
							align-items: center;
							justify-content: space-between;
							image{
								width: 30rpx;
								height: 30rpx;
								display: block;
								margin: 0 auto;
								margin-bottom: 20rpx;
							}
						}
					}
					.r{
						display: flex;
						align-items: flex-start;
						overflow: hidden;
						margin-top: 30rpx;
						.pic{
							width: 182rpx;
							height: 146rpx;
							border-radius: 6rpx;
							margin-right: 10rpx;
						}
						.info{
							width: 305rpx;
							margin-right: 20rpx;
							.title{
								font-size: 28rpx;
								font-weight: 400;
								color: #212121;
							}
							.price{
								font-size: 32rpx;
								font-weight: 500;
								color: #FF584D;
								margin-top: 20rpx;
							}
						}
						.num{
							flex: 1;
							text-align: center;
							font-size: 30rpx;
							font-weight: 400;
							color: #989898;
							text-align: right;
						}
					}
				}
			}
			.form {
				padding: 0 40rpx;
				overflow: hidden;
				border-left: 1px solid #F1F1F1;
				border-right: 1px solid #F1F1F1;
				border-bottom: 1px solid #F1F1F1;
				.remark{
					.name{
						font-size: 28rpx;
						font-weight: 400;
						color: #313131;
					}
					.xu{
						display: flex;
						flex-wrap: wrap;
						overflow: hidden;
						.li{
							line-height: 52rpx;
							background: #FFFFFF;
							border-radius: 6rpx;
							border: 1px solid #EDEDED;
							padding: 0 20rpx;
							margin-right: 20rpx;
							text-align: center;
							font-size: 24rpx;
							font-weight: 400;
							color: #949494;
							margin-top: 20rpx;
						}
					}
					.content{
						padding: 20rpx 0 50rpx;
						font-size: 28rpx;
						color: #212121;
					}
				}
				.photo{
					padding: 20rpx 0;
					overflow: hidden;
				}
				.item{
					padding: 20rpx 0;
					border-bottom: 1px solid #F4F4F4;
					display: flex;
					align-items: center;
					.a{
						width: 160rpx;
						font-size: 28rpx;
						font-weight: 400;
						color: #313131;
						line-height: 45rpx;
					}
					.b{
						flex: 1;
						display: flex;
						align-items: center;
						justify-content: space-between;
						.select{
							flex: 1;
							font-size: 28rpx;
							font-weight: 400;
							line-height: 45rpx;
							color: #949494;
							&-on{
								color: #212121;
							}
						}
						.box{
							flex: 1;
							font-size: 28rpx;
							color: #212121;
							line-height: 45rpx;
						}
						.box1{
							width: 160rpx;
							font-size: 28rpx;
							color: #212121;
							line-height: 45rpx;
						}
						.radio{
							display: flex;
							align-items: center;
							justify-content: flex-end;
							flex: 1;
							border-left: 1px solid #E6E6E6;
						}
					}
				}
			}
		}
		&-fd{
			width: 100%;
			height: 120rpx;
			background-color: #FFFFFF;
			padding: 25rpx 25rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			box-sizing: border-box;
			position: fixed;
			left: 0;
			bottom: 0;
			z-index: 99;
			.a{
				font-size: 28rpx;
				font-weight: 400;
				color: #727272;
			}
			.b{
				width: 502rpx;
				height: 88rpx;
				line-height: 88rpx;
				background: #FE483B;
				border-radius: 88rpx; 
				text-align: center;
				font-size: 28rpx;
				font-weight: 600;
				color: #FFFFFF;
			}
		}
	}
</style>