<template>
  <view class="company">
    <nav-bar title="公司认证" color="#000"></nav-bar>
    <view class="company-content">
      <view class="company-title">上传公司营业执照</view>
      <view class="company-desc">请上传“{{companyName}}”的营业执照</view>
      <view class="company-btn">修改公司</view>
      <view class="upload-img">
      <u-upload :action="action" :max-size="5 * 1024 * 1024" max-count="1" class="upload" ref="uUpload" width="452" height="322"></u-upload>
      </view>
      <view class="warning-title">注意事项</view>
      <view class="warning-desc">1.拍摄与所填公司一致的营业执照上传</view>
      <view class="warning-desc">2.最新下发的营业执照</view>
      <view class="warning-desc">3.营业执照信息和公章清晰可辨</view>
    </view>
    <view class="bottom-btn" @click="goUnderReview">确认并提交</view>
  </view>
</template>
<script>
import navBar from "@/components/nav-bar/index.vue";
import configdata from '../../common/config.js'
export default {
  data() {
    return {
      address: "",
      addressDetail: "",
	  companyName:"",
	  companyId:"",
	  action:configdata.APIHOST1 + '/alioss/upload',
	  lists: []
    };
  },
  components: {
    navBar,
  },
  onLoad(options) {
  	// 接收上个页面传递的公司名称参数
  	if (options.companyName) {
		
  		this.companyName = decodeURIComponent(options.companyName);
  		console.log('接收的公司名称：', this.companyName);
  	}
	if (options.companyId) {
		this.companyId = options.companyId;
		console.log('接收的公司ID：', this.companyId);
	}
  	
  },
  	onReady() {
		// 得到整个组件对象，内部图片列表变量为"lists"
		this.lists = this.$refs.uUpload.lists;
  		},
  methods: {
    goUnderReview(){
		console.log(this.lists[0].response.data)
		var url=this.lists[0].response.data
		const data = {
			companyLogo: url, //logo
			companyId: this.companyId, //ID
		};
		// 调用接口提交
		uni.showLoading({
			title: "提交中..."
		});
		this.$Request.postJson("/app/company/updateCompany", data)
			.then((res) => {
				uni.hideLoading();
				if (res.code === 0) {
					uni.showToast({
						title: "提交成功",
						icon: "success"
					});
				    uni.navigateTo({ url: '/package/jobIntention/underReview' })
		
		
				} else {
					uni.showToast({
						title: res.msg || "提交失败",
						icon: "none"
					});
				}
			})
			.catch((err) => {
				uni.hideLoading();
				console.error("提交失败：", err);
				uni.showToast({
					title: "网络异常",
					icon: "none"
				});
			});
		
		
  
    }
  },
};
</script>
<style scoped lang="scss">
.company {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  font-family: DM Sans;
  .company-content {
    flex: 1;
    padding: 40rpx;
    box-sizing: border-box;
    overflow: hidden;
    overflow-y: auto;
    .company-title {
      color: #333;
      font-size: 40rpx;
      font-weight: 600;
      margin-bottom: 20rpx;
    }
    .company-desc {
      color: rgba(102, 102, 102, 1);
      font-family: DM Sans;
      font-size: 24rpx;
      font-weight: 400;
      line-height: 32rpx;
    }
    .company-btn {
      color: #016bf6;
      font-family: DM Sans;
      font-size: 24rpx;
      font-weight: 400;
      line-height: 32rpx;
      margin-top: 20rpx;
    }
    .upload-img {
      width: 100%;
      height: 388rpx;
      background: #fce9dc;
      display: flex;
      justify-content: center;
      align-items: center;
      margin-top: 20rpx;
    }
    .warning-title {
      color: #1f2c37;
      font-family: DM Sans;
      font-size: 28rpx;
      font-weight: 500;
      margin-top: 20rpx;

    }
    .warning-desc {
      color: #666666;
      font-family: DM Sans;
      font-size: 24rpx;
      font-weight: 400;
      margin-top: 20rpx;
    }
  }
  .bottom-btn {
    border-radius: 999px;
    background: #016bf6;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    color: rgba(255, 255, 255, 1);
    font-family: DM Sans;
    font-size: 32rpx;
    font-weight: 400;
    padding: 16rpx 32rpx;
    box-sizing: border-box;
    margin: 20rpx;
    margin-bottom: 110rpx;
  }
}
</style>
