<template>
  <view class="flex-col page">
    <view class="flex-col group_4">
      <view class="flex-col group_5">
        <view class="flex-row equal-division">
          <view class="equal-division-item flex-col items-center">
            <image
              src="@/static/icon/tianxie1.png"
              class="image_6"
            />
            <text class="text_2">填写信息</text>
          </view>
          <view class="equal-division-item flex-col items-center">
            <image
              src="@/static/icon/tianxie2.png"
              class="image_6"
            />
            <text class="text_2">藏品寄送</text>
          </view>
          <view class="equal-division-item flex-col items-center">
            <image
              src="@/static/icon/tianxie3.png"
              class="image_6"
            />
            <text class="text_2">评级</text>
          </view>
        </view>
        <view class="justify-between group_9">
          <view class="section_2"> </view>
          <view class="section_3"> </view>
        </view>
      </view>
      <view class="flex-col section_4" @click="$url('/packages/address/address?is_select=1')">
		 <view v-if="$isRight(address)">
			  <view class="justify-between">
			    <view class="flex-row">
			      <text class="text_6">{{ address.name }}</text>
			      <text class="text_7">{{ address.tel }}</text>
			    </view>
			    <image
			      src="@/static/icon/rightArrow.png"
			      class="image_10 image_11"
			    />
			  </view>
			  <text class="text_8">{{ address.desc }}</text>
		  </view>
		  <!-- 没有选择地址时 -->
		  <view v-else>
			  <view class="justify-between">
			    <view class="flex-row">
			      <text class="lf-font-32">点击选择收货地址</text>
			    </view>
			    <image
			      src="@/static/icon/rightArrow.png"
			      class="image_10 image_11"
			    />
			  </view>
		  </view>
      </view>
      <view class="flex-col section_5">
        <view class="justify-between">
          <text class="text_9">送评人信息</text>
          <!-- <view class="flex-row group_13">
            <text>编辑</text>
            <image
              src="@/static/icon/rightArrow.png"
              class="image_10"
            />
          </view> -->
        </view>
        <view class="flex-row group_14">
          <text class="text_11">送评人：</text>
          <!-- <text class="text_12">送评人</text> -->
		  <u-input v-model="sonpingInfo.name" placeholder="请输入送评人"></u-input>
        </view>
        <view class="flex-row group_15">
          <text class="text_13">手机号：</text>
          <!-- <text class="text_14">18266785384</text> -->
		  <u-input v-model="sonpingInfo.phone" placeholder="请输入送评人手机号" type="number" maxlength="11"></u-input>
        </view>
        <view class="flex-row group_16">
          <text class="text_15">数量：</text>
          <!-- <text class="text_16">3</text> -->
		  <u-input v-model="sonpingInfo.number" placeholder="请输入送评数量" type="number"></u-input>
        </view>
        <view class="justify-between group_17" @click="pickerShow(true)">
          <view class="flex-row group_18">
            <text class="text_17">是否快评：</text>
            <text class="text_18">(价格翻倍)</text>
          </view>
		  
		  <view class="pick-panel">
			  <view>
				  {{columnsData[columnsIndex].title}}
			  </view>
			  <image
			    src="@/static/icon/rightArrow.png"
			    class="image_10 image_11 rote90"
			  />
		  </view>
		
	
		  <!-- <u-switch v-model="isQuickReview" activeColor="#e7a23f"></u-switch> -->
		  
        </view>
		<view class="flex-col group_19" v-if="columnsIndex!=0">
			<view class="fast_desc">
				{{columnsData[columnsIndex].desc}}
			</view>
		</view>
        <view class="flex-col group_19">
          <text>打包照片</text>
          <view class="flex-row equal-division_1">
			<u-upload
				:fileList="fileList"
				name="1"
				multiple
				:maxCount="4"
				:previewFullImage="true"
				@afterRead="afterRead"
				@delete="deletePic"
			></u-upload>
          </view>
        </view>
        <view class="flex-col group_20">
          <text class="text_20">备注</text>
		  <u-textarea v-model="remarks" placeholder="请输入备注" :height="100" class="textarea" :count="true"></u-textarea>
        </view>
		<view class="flex-row group_15">
		  <text class="text_11">优惠券：</text>
		  <u-input @change="checkCoupon" v-model="coupon" placeholder="非必填,请输入优惠券码"></u-input>
		</view>
        <view class="flex-col group_21">
          <view class="flex-col items-center button" @click="next">
            <text>寄送藏品</text>
          </view>
          <view class="section_6"> </view>
        </view>
      </view>
    </view>
		  <u-picker :show="show" :columns="columns" immediateChange="true" @cancel="pickerShow(false)" @confirm="confirmPicker"></u-picker>
  </view>
</template>

<script>
	import { dispose } from '@/common/directoss.js';
	import { checkAgentCode } from '@/service/index.js';
	
  export default {
    data() {
      return {
		  address: {},
		  isQuickReview: 0,
		  sonpingInfo: {
			  name: '',
			  phone: '',
			  number: ''
		  },
		  fileList: [],
		  remarks: '',
		  rateIndex: 0,
		  coupon: '',
		  show:false,
		  columns:[],
		  columnsData:null,
		  columnsIndex:0,
		  couponStatus:true,
		  couponTimer:null,
	  };
    },
	// computed:{
	// 	columns:()=>{
	// 		return ['1','2'];
	// 	},
	// },
	onLoad(options){
		this.rateIndex = options.rate_index || 0;
		let d = uni.getStorageSync('qxk_sysinfo')
		if(d){
			let options = d.fast_options
			this.columnsData = options.filter((item)=>{
				if(this.rateIndex == 3){
					if(item.id == 0 || item.id == 4){
						return item;
					}
				}else{
					if(item.id <=3){
						return item;
					}
				}
			});
			
			let texts = this.columnsData.map((item)=>{
				return item.title
			})
			//t = [...t,...texts];
			this.columns.push(texts)
			
		}
	},
	methods: {
		checkCoupon(event){
			if(this.couponTimer){
				clearTimeout(this.couponTimer);
			}
			this.couponTimer = setTimeout(async () => {
				let res = await checkAgentCode(event);
				if(res.code > 0){
					this.couponStatus = false;
					uni.showToast({
						title:res.msg,
					});
				}else{
					this.couponStatus = true;
				}
			},500);
		},
		async afterRead(event){
			let imageList = await dispose(event.file);
			this.fileList.push(...imageList);
			console.log("上传完成后的图片---------", this.fileList)
		},
		deletePic(event){
			this.fileList.splice(event.index, 1);
		},
		pickerShow(v){
			this.show = v
		},
		confirmPicker(e){
			console.log("confirmPicker",e)
			this.columnsIndex = e.indexs[0]
			this.isQuickReview = this.columnsData[this.columnsIndex].id
			//e.
			this.pickerShow(false)
		},
		next(){
			let sonpingInfo = this.sonpingInfo;
			if(!this.$isRight(this.address)) return this.$msg('请选择收货地址');
			if(!sonpingInfo.name) return this.$msg('请填写送评人信息');
			if(!sonpingInfo.phone) return this.$msg('请填写送评人手机号');
			if(!sonpingInfo.number) return this.$msg('请填写送评数量');
			if(this.couponStatus == false){
				this.coupon = '';
			}
			this.$url('/pages/write/distribution');
		}
	}
  };
</script>

<style scoped lang="css">
	.pick-panel{
		display: flex;
	}
	.rote90{
		transform: rotate(90deg);
	}
	.fast_desc{
		display:inline-block;
		width: 100%;
		height: auto;
		word-wrap: break-word;
		word-break: break-all;
		white-space: pre-wrap;
		font-size: 28rpx;
	}
  .equal-division-item {
    flex: 1 1 240rpx;
    padding: 10rpx 0;
  }
  .image_10 {
    width: 44rpx;
    height: 44rpx;
  }
  .image_6 {
    border-radius: 50%;
    width: 80rpx;
    height: 80rpx;
  }
  .equal-division-item_1 {
    margin-left: 28rpx;
    flex: 1 1 210rpx;
    border-radius: 10rpx;
    width: 210rpx;
    height: 130rpx;
  }
  .text_2 {
    margin-top: 20rpx;
  }
  .page {
    background-color: #f6f6f6;
    width: 100%;
    overflow-y: auto;
    height: 100%;
  }
  .group_4 {
    flex: 1 1 auto;
    overflow-y: auto;
  }
  .group_5 {
    padding-top: 2rpx;
    color: rgb(85, 85, 85);
    font-size: 28rpx;
    font-weight: 500;
    line-height: 40rpx;
    white-space: nowrap;
    position: relative;
  }
  .section_4 {
    margin-top: 30rpx;
    padding: 40rpx 32rpx 40rpx 40rpx;
    background-color: rgb(255, 255, 255);
  }
  .section_5 {
    margin-top: 30rpx;
    padding: 40rpx 32rpx 16rpx;
    background-color: rgb(255, 255, 255);
  }
  .equal-division {
    padding: 30rpx 14rpx;
    background-color: rgb(255, 255, 255);
  }
  .group_9 {
    width: 404rpx;
    position: absolute;
    right: 166rpx;
    top: 81rpx;
  }
  .text_8 {
    margin-top: 20rpx;
    color: rgb(51, 51, 51);
    font-size: 32rpx;
    line-height: 44rpx;
  }
  .group_14 {
    margin-top: 40rpx;
	align-items: center;
  }
  .group_15 {
    margin-top: 50rpx;
	align-items: center;
  }
  .group_16 {
    margin-top: 50rpx;
	align-items: center;
  }
  .group_17 {
    margin-top: 44rpx;
  }
  .group_19 {
    margin-top: 44rpx;
    color: rgb(119, 119, 119);
    font-size: 32rpx;
    font-weight: 500;
    line-height: 44rpx;
    white-space: nowrap;
  }
  .group_20 {
    margin-top: 50rpx;
  }
  .group_21 {
    margin-top: 50rpx;
    color: rgb(255, 255, 255);
    font-size: 32rpx;
    font-weight: 600;
    line-height: 44rpx;
    white-space: nowrap;
  }
  .section_2 {
    background-image: repeating-linear-gradient(
      90deg,
      rgb(231, 162, 63),
      rgb(231, 162, 63) 2.4691358024691357%,
      transparent 2.4691358024691357%,
      transparent 14.814814814814815%
    );
    width: 162rpx;
    height: 2rpx;
  }
  .section_3 {
    background-image: repeating-linear-gradient(
      90deg,
      rgb(195, 195, 195),
      rgb(195, 195, 195) 2.4691358024691357%,
      transparent 2.4691358024691357%,
      transparent 14.814814814814815%
    );
    width: 162rpx;
    height: 2rpx;
  }
  .image_11 {
    margin-top: 4rpx;
  }
  .text_9 {
    color: rgb(51, 51, 51);
    font-size: 36rpx;
    font-weight: 600;
    line-height: 50rpx;
    white-space: nowrap;
  }
  .group_13 {
    margin-top: 4rpx;
    color: rgb(119, 119, 119);
    font-size: 28rpx;
    font-weight: 500;
    line-height: 40rpx;
    white-space: nowrap;
  }
  .text_11 {
    color: rgb(119, 119, 119);
    font-size: 32rpx;
    font-weight: 500;
    line-height: 44rpx;
    white-space: nowrap;
  }
  .text_12 {
    margin-left: 20rpx;
    color: rgb(51, 51, 51);
    font-size: 32rpx;
    font-weight: 500;
    line-height: 44rpx;
    white-space: nowrap;
  }
  .text_13 {
    color: rgb(119, 119, 119);
    font-size: 32rpx;
    font-weight: 500;
    line-height: 44rpx;
    white-space: nowrap;
  }
  .text_14 {
    margin-left: 20rpx;
    color: rgb(51, 51, 51);
    font-size: 32rpx;
    font-weight: 500;
    line-height: 44rpx;
    white-space: nowrap;
  }
  .text_15 {
    color: rgb(119, 119, 119);
    font-size: 32rpx;
    font-weight: 500;
    line-height: 44rpx;
    white-space: nowrap;
  }
  .text_16 {
    margin-left: 52rpx;
    color: rgb(51, 51, 51);
    font-size: 32rpx;
    font-weight: 500;
    line-height: 44rpx;
    white-space: nowrap;
  }
  .group_18 {
    margin: 6rpx 0;
  }
  .switch {
    border-radius: 104rpx;
    width: 100rpx;
    height: 56rpx;
  }
  .equal-division_1 {
    margin-top: 20rpx;
  }
  .text_20 {
    color: rgb(119, 119, 119);
    font-size: 32rpx;
    font-weight: 500;
    line-height: 44rpx;
    white-space: nowrap;
  }
  .text-wrapper {
    margin-top: 20rpx;
    padding: 30rpx 0 138rpx;
    color: rgb(153, 153, 153);
    font-size: 28rpx;
    font-weight: 500;
    line-height: 40rpx;
    white-space: nowrap;
    background-color: rgb(246, 246, 246);
    border-radius: 10rpx;
  }
  .button {
    padding: 26rpx 0;
    background-color: rgb(231, 162, 63);
    border-radius: 10rpx;
  }
  .section_6 {
    margin-top: 22rpx;
    align-self: center;
    border-radius: 4rpx;
    width: 196rpx;
    height: 8rpx;
  }
  .text_6 {
    color: rgb(51, 51, 51);
    font-size: 36rpx;
    font-weight: 700;
    line-height: 50rpx;
    white-space: nowrap;
  }
  .text_7 {
    margin-left: 40rpx;
    margin-top: 4rpx;
    color: rgb(51, 51, 51);
    font-size: 32rpx;
    font-weight: 700;
    line-height: 44rpx;
    white-space: nowrap;
  }
  .text_17 {
    color: rgb(119, 119, 119);
    font-size: 32rpx;
    font-weight: 500;
    line-height: 44rpx;
    white-space: nowrap;
  }
  .text_18 {
    margin: 6rpx 0 4rpx 10rpx;
    color: rgb(231, 162, 63);
    font-size: 24rpx;
    font-weight: 500;
    line-height: 34rpx;
    white-space: nowrap;
  }
  .image_13 {
    margin-left: 0;
  }
  .text_21 {
    margin-left: 30rpx;
  }
  
  /deep/.u-textarea{
	  background-color: #f6f6f6 !important;
	  margin-top: 20rpx;
	  border-radius: 10rpx;
  }
</style>