<template>
  <view class="ms-detail">
    <nav-bar title="编辑公司信息" color="#000"></nav-bar>
    <view class="ms-content">
      <view class="ms-title">编辑公司及品牌信息</view>
      <view class="ms-item">
        <view class="ms-item-title" @click="checkBaseMsg">
          <view class="ms-title-txt">基本信息{{filledInCount[0]}}/5</view>
          <view class="ms-title-icon">
            <image
              src="@/static/images/my/my/top-up.svg"
              mode="scaleToFill"
              class="top"
              v-if="baseMsg"
            />
            <image
              src="@/static/images/my/my/right.svg"
              mode="scaleToFill"
              class="right"
              v-else
            />
          </view>
        </view>
        <view class="ms-item-content" v-if="baseMsg">
          <view class="name-content-item">
            <view class="name-item">品牌logo</view>
            <view class="value-item">
			  <text v-if="!companyinfo.companyLogo">未添加</text>
              <image :src="companyinfo.companyLogo" mode="scaleToFill" v-else/>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
          <view class="name-content-item">
            <view class="name-item">公司名称</view>
            <view class="value-item">
			  <text v-if="!companyinfo.companyName">未添加</text>
              <text v-else>{{companyinfo.companyName}}</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
          <view class="name-content-item">
            <view class="name-item">公司全称</view>
            <view class="value-item">
              <text v-if="!companyinfo.companyAllName">未添加</text>
              <text v-else>{{companyinfo.companyAllName}}</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
          <view class="name-content-item">
            <view class="name-item">融资阶段</view>
            <view class="value-item">
			  <text v-if="!companyinfo.companyDevelop">未添加</text>
			  <text v-else>{{companyinfo.companyDevelop}}</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
          <view class="name-content-item">
            <view class="name-item">人员规模</view>
            <view class="value-item">
              <text v-if="!companyinfo.companyPeople||companyinfo.companyPeople==='0'">未添加</text>
              <text v-else>{{companyinfo.companyPeople}}</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
        </view>
      </view>
      <view class="ms-item">
        <view class="ms-item-title" @click="checkCompanyFund">
          <view class="ms-title-txt">公司福利 {{filledInCount[1]}}/2</view>
          <view class="ms-title-icon">
            <image
              src="@/static/images/my/my/top-up.svg"
              mode="scaleToFill"
              class="top"
              v-if="companyFund"
            />
            <image
              src="@/static/images/my/my/right.svg"
              mode="scaleToFill"
              class="right"
              v-else
            />
          </view>
        </view>
        <view class="ms-item-content" v-if="companyFund" @click="goCompanyMsg">
          <view class="name-content-item">
            <view class="name-item">标准工作时间</view>
            <view class="value-item">
             <text v-if="!companyinfo.workTime">未添加</text>
             <text v-else>{{companyinfo.workTime}}</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
          <view class="name-content-item">
            <view class="name-item">福利待遇</view>
            <view class="value-item"
              >
			  <text v-if="!companyinfo.welfare">未添加</text>
			  <text v-else>已添加{{companyinfo.welfare.split(',').length}}项</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
        </view>
      </view>
      <view class="ms-item">
        <view class="ms-item-title">
          <view class="ms-title-txt">公司介绍</view>
          <view class="ms-title-icon">
            <text v-if="!companyinfo.companyContent">未添加</text>
            <text v-else>已添加</text>
          </view>
        </view>
       <!-- <view class="ms-item-content" v-if="companyDetail">
          <view class="name-content-item">
            <view class="name-item">标准工作时间</view>
            <view class="value-item">
              <text>09:00-18:00</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
          <view class="name-content-item">
            <view class="name-item">福利待遇</view>
            <view class="value-item"
              ><text>已添加2项</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
        </view> -->
      </view>
      <view class="ms-item">
        <view class="ms-item-title">
          <view class="ms-title-txt">主营业务</view>
          <view class="ms-title-icon">
            <text v-if="!companyinfo.companyScope">未添加</text>
            <text v-else>已添加{{companyinfo.companyScope.split(',').length}}项</text>
          </view>
        </view>
        <!-- <view class="ms-item-content" v-if="mainWork">
          <view class="name-content-item">
            <view class="name-item">标准工作时间</view>
            <view class="value-item">
              <text>09:00-18:00</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
          <view class="name-content-item">
            <view class="name-item">福利待遇</view>
            <view class="value-item"
              ><text>已添加2项</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
        </view> -->
      </view>
      <view class="ms-item">
        <view class="ms-item-title">
          <view class="ms-title-txt">公司相册</view>
          <view class="ms-title-icon">
           <text v-if="!companyinfo.photos">未添加</text>
           <text v-else>已添加{{companyinfo.photos.split(',').length}}张</text>
          </view>
        </view>
        <!-- <view class="ms-item-content" v-if="companyImg">
          <view class="name-content-item">
            <view class="name-item">标准工作时间</view>
            <view class="value-item">
              <text>09:00-18:00</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
          <view class="name-content-item">
            <view class="name-item">福利待遇</view>
            <view class="value-item"
              ><text>已添加2项</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
        </view> -->
      </view>
      <view class="ms-item">
        <view class="ms-item-title" @click="checkPeopleDev">
          <view class="ms-title-txt">人才发展</view>
          <view class="ms-title-icon">
           <text v-if="!companyinfo.companyPeopleDevelop">未添加</text>
           <text v-else>已添加{{companyinfo.companyPeopleDevelop.split(',').length}}项</text>
          </view>
        </view>
       <!-- <view class="ms-item-content" v-if="peopleDev">
          <view class="name-content-item">
            <view class="name-item">标准工作时间</view>
            <view class="value-item">
              <text>09:00-18:00</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
          <view class="name-content-item">
            <view class="name-item">福利待遇</view>
            <view class="value-item"
              ><text>已添加2项</text>
              <u-icon name="arrow-right" color="#999" size="20"></u-icon>
            </view>
          </view>
        </view> -->
      </view>
    </view>
  </view>
</template>
<script>
import navBar from "@/components/nav-bar/index.vue";

export default {
  data() {
    return {
      baseMsg: false,
      companyFund: false,
      companyDetail: false,
      mainWork: false,
      companyImg: false,
      peopleDev: false,
	  companyinfo:{}
    };
  },
  components: {
    navBar,
  },
  onLoad() {
  	this.getcompanystatus()
  },
  computed: {
  	filledInCount() {
  		let arr = [0,0]
		if(this.companyinfo.companyLogo) arr[0]+=1
		if(this.companyinfo.companyName) arr[0]+=1
		if(this.companyinfo.companyAllName) arr[0]+=1
		if(this.companyinfo.companyDevelop) arr[0]+=1
		if(this.companyinfo.companyPeople&&this.companyinfo.companyPeople!=='0') arr[0]+=1
		
		if(this.companyinfo.workTime) arr[1]+=1
		if(this.companyinfo.welfare) arr[1]+=1
		
		return arr 
  	}
  },
  methods: {
    checkBaseMsg() {
      this.baseMsg = !this.baseMsg;
    },
    checkCompanyFund() {
      this.companyFund = !this.companyFund;
    },
    checkCompanyDetail() {
      this.companyDetail = !this.companyDetail;
    },
    checkMainWork() {
      this.mainWork = !this.mainWork;
    },
    checkCompanyImg() {
      this.companyImg = !this.companyImg;
    },
    checkPeopleDev() {
      this.peopleDev = !this.peopleDev;
    },
    goCompanyMsg(){
        uni.navigateTo({ url: '/my/renzheng/companyMsg' })
    },
	// 查询用户企业状态
	getcompanystatus() {
		this.$Request.get("/app/company/selectCompanyByUserId", "")
			.then((res) => {
				if (res.code != 0) {
					uni.showToast({
						title: res.msg || "查询状态失败",
						icon: "none"
					});
					return;
				}
				this.companyinfo = res.data || {};
				console.log("查询用户企业状态", this.companyinfo)
			})
			.catch((err) => {
				console.error("查询失败：", err);
				uni.showToast({
					title: "网络异常",
					icon: "none"
				});
			});
	},
  },
};
</script>
<style scoped lang="scss">
.ms-detail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  .ms-content {
    flex: 1;
    width: 100%;
    padding: 40rpx;
    box-sizing: border-box;
    overflow: hidden;
    overflow-y: auto;
    .ms-title {
      color: rgba(51, 51, 51, 1);
      font-family: DM Sans;
      font-size: 48rpx;
      font-weight: 700;
      line-height: 60rpx;
    }
    .ms-item {
      .ms-item-title {
        color: rgba(31, 44, 55, 1);
        font-family: DM Sans;
        font-size: 28rpx;
        font-weight: 500;
        line-height: 44rpx;
        text-align: left;
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-top: 20rpx;
        margin-bottom: 16rpx;
        .ms-title-txt {
        }
        .ms-title-icon {
          color: rgba(153, 153, 153, 1);
          font-family: DM Sans;
          font-size: 24rpx;
          font-weight: 400;
          line-height: 32rpx;
          .top {
            width: 28rpx;
            height: 18rpx;
            margin-left: 8rpx;
          }
          .right {
            width: 18rpx;
            height: 28rpx;
            margin-left: 8rpx;
          }
        }
      }
      .ms-item-content {
        box-sizing: border-box;
        border: 1rpx solid rgba(227, 231, 236, 1);
        border-radius: 12rpx;
        background: rgba(255, 255, 255, 1);
        padding: 36rpx;
        .name-content-item {
          display: flex;
          justify-content: space-between;
          align-items: center;
          padding: 9rpx 0;
          box-sizing: border-box;
          .name-item {
            color: rgba(153, 153, 153, 1);
            font-family: DM Sans;
            font-size: 24rpx;
            font-weight: 400;
            line-height: 32rpx;
          }
          .value-item {
            display: flex;
            justify-content: center;
            align-items: center;
            color: rgba(153, 153, 153, 1);
            font-family: DM Sans;
            font-size: 24rpx;
            font-weight: 400;
            line-height: 32rpx;
            letter-spacing: 0%;
            text {
              margin-right: 8rpx;
            }
            image {
              width: 50rpx;
              height: 50rpx;
              border-radius: 50%;
              margin-right: 8rpx;
              background: linear-gradient(
                90deg,
                rgba(13, 39, 247, 1),
                rgba(19, 193, 234, 1) 100%
              );
            }
          }
        }
      }
    }
  }
}
</style>
