<template>
	<view class="box">
		<view class="content">


			<view class="leftTitle2" style="padding: 24rpx 0; border-bottom: 1rpx solid #EEEEEE;">原服务门店信息</view>

			<view class="shopBg">
				<view class="leftTitle2">{{oldStoreName}}</view>
				<view class="addrressBg">
					<image src="../../static/img/icon_coordinate.png" mode="" style="width: 22rpx; height: 30rpx;">
					</image>
					<view style="color: #999999; font-size: 24rpx; margin-left: 20rpx;">{{oldStoreAddress}}</view>
				</view>
			</view>
		</view>

		<view class="content">
			<view class="viewBg">
				<image src="../../static/img/icon_xinghao.png" mode="" style="width: 14rpx; height: 14rpx;"></image>
				<view class="leftTitle">更换门店</view>
					<view class="blackColor width70" :class="{grayColor: store==''}" @click="storeChange">{{store?store:'请选择'}}</view>
			
				<image src="../../static/img/rightArrow.png" mode="" style="width: 13rpx; height: 23rpx;"></image>


			</view>

		</view>


		<view class="content">
			<view class="viewBg" style="border-bottom: 1rpx solid #EEEEEE;">
				<image src="../../static/img/icon_xinghao.png" mode="" style="width: 14rpx; height: 14rpx;"></image>
				<view class="leftTitle">更换原因</view>
				<picker :value="firstIndex" class="width70" mode="selector" :range="reasonArray" range-key="contents"
					@change="reasonChange">
					<view class="blackColor" :class="{grayColor: firstIndex==null}">
						{{firstIndex == null ? '请选择' : reasonArray[firstIndex].contents}}
					</view>
				</picker>

				<image src="../../static/img/rightArrow.png" mode="" style="width: 13rpx; height: 23rpx;"></image>


			</view>

			<view class="viewBg">

				<view class="leftTitle">补充描述</view>

				<textarea placeholder-style="color:#999999" placeholder="选填，请输入补充描述" v-model="exeContent"
					class="textareaCont" maxlength="-1" auto-height="true" @confirm="feedDone" />

			</view>
		</view>

		<view class="bottom">
			<view class="shoreDz" @click="submit">提交</view>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				sheetId:'',
				oldStoreName: '',
				oldStoreAddress: '',
				store: '',
				storeId:'',
				reasonArray: [],
				reasonId: '',
				firstIndex: null,
				exeContent: '',
			}
		},
		onLoad(opt) {
			this.sheetId = opt.sheetId;
			this.oldStoreName = opt.oldStoreName;
			this.oldStoreAddress = opt.oldStoreAddress;
			this.getChangeData();
			console.log(this.sheetId);
		},
		onShow() {
			let storeMes = uni.getStorageSync('changeStore')
			this.storeId = storeMes.shopId
			this.store = storeMes.shopName
		},
		methods: {
			submit() {
				if (this.store == '') {
					uni.showToast({
						title: '请选择更换门店',
						icon: 'none',
						duration: 2000,
					});
					return;
				}
				if (this.reasonId == '') {
					uni.showToast({
						title: '请选择更换原因',
						icon: 'none',
						duration: 2000,
					});
					return;
				}
				

				uni.showLoading({});

				this.$http('worldKeepCar/orderChangeShop/applyChangeShop', {
					sheetId: this.sheetId,
					applyReasonId: this.reasonId,
					applyReason: this.reasonArray[this.firstIndex].contents,
					
					reasonComment: this.exeContent,
					newShopID: this.storeId,
					newShopName: this.store,

				}, 'POST').then(res => {
					uni.hideLoading();
					if (res.code == 0) {
						uni.showToast({
							title: '提交成功',
							icon: 'none',
							duration: 2000,
						});
						uni.removeStorageSync('changeStore')
						
						setTimeout(function() {
							uni.navigateBack({

							})
						}, 2000);
					}



				})
			},
			getChangeData() {
				uni.showLoading({
					title: '加载中'
				})
				let url = 'worldKeepCar/orderChangeShop/refuseReasonList',
					params = {
						type: 1,

					}
				this.$http(url, params, 'GET').then(res => {

					uni.hideLoading();


					this.reasonArray = res.data


				})
			},
			feedDone(e) {
				this.exeContent = e.target.value

			},
			storeChange(e) {
				uni.navigateTo({
					
					url:'../module/orderShop?fromChangeStore=true'
				}) 
			},
			reasonChange(e) {
				this.firstIndex = e.target.value
				this.reasonId = this.reasonArray[this.firstIndex].id
			}
		}
	}
</script>

<style scoped>
	.box {
		min-height: 100vh;
		background: #F4F5F7;
		padding-top: 20rpx;
	}

	.content {
		background-color: #FFFFFF;
		border-radius: 10rpx;
		margin: 20rpx 24rpx;
		padding: 0 20rpx;
	}

	.shopBg {
		padding: 30rpx 0;
	}

	.addrressBg {
		padding-top: 12rpx;
		display: flex;
		align-items: center;
	}

	.viewBg {
		display: flex;
		align-items: center;
		padding: 30rpx 0;
	}

	.width70 {
		width: 70%;
	}

	.leftTitle2 {
		color: #333333;
		font-size: 28rpx;

	}

	.leftTitle {
		color: #333333;
		font-size: 28rpx;
		width: 130rpx;
		margin-right: 50rpx;
	}

	.blackColor {
		color: #333333;
		font-size: 28rpx;
	}

	.grayColor {
		color: #999999;
		font-size: 28rpx;
	}

	.textareaCont {

		width: 70%;
		font-size: 28rpx;
		color: #333333;

	}

	.bottom {
		width: 750rpx;
		height: 120rpx;
		background: #FFFFFF;
		box-shadow: 0px -4px 8px 0px rgba(153, 153, 153, 0.08);
		position: fixed;
		left: 0;
		bottom: 0;
		display: flex;
		justify-content: space-around;
	}

	.shoreDz {
		width: 702rpx;
		height: 74rpx;

		background: linear-gradient(135deg, #FD5300 0%, #FF270A 100%);
		border-radius: 37rpx;
		text-align: center;
		line-height: 74rpx;
		color: #FFFFFF;
		font-size: 30rpx;
		margin-top: 24rpx;
	}
</style>
