<template>
<!--pages/demandHall/contact/index.wxml-->
<view class="contact-page">
  <view class="company-card-box acea-row-nowrap">
    <image :src="needsDetail.enterprise.enterpriseLogo" class="company-logo"></image>
    <view class="info">
      <view class="n-title-box acea-row row-between row-middle">
        <view class="line1">{{needsDetail.title}}</view>
      </view>
      <view class="n-tags acea-row">
        <view class="n-tag-item">{{needsDetail.cname}}</view>
      </view>
      <view class="price">需求预算<text class="n-title-a">{{needsDetail.capital}}</text></view>
    </view>
  </view>
  <view class="tips acea-row row-middle">
    <view class="t-icon">!</view>
    <text>请明确您可提供的资源！</text>
  </view>
  <view class="area-box">
    <textarea placeholder="请输入您的资源信息" :value="content" @input="inpChange"></textarea>
  </view>
  <view class="submit-btn" @tap="submit">提交申请</view>
</view>
</template>

<script>
const app = getApp();

export default {
  data() {
    return {
      active: null,
      needsDetail: {},
      needsList: [],
      content: ''
    };
  },
  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    // console.log(options)
    let data = JSON.parse(decodeURIComponent(options.detail));
    this.setData({
      needsDetail: data
    });
    // console.log(this.needsDetail);
    this.getList();
  },
  methods: {
    needItemClick(e) {
      let id = e.currentTarget.dataset.id;
      this.setData({
        active: e.currentTarget.dataset.id
      });
    },

    inpChange(e) {
      console.log(e);
      this.setData({
        content: e.detail.value
      });
    },

    getList() {
      app.http('post', 'Resources/listMyResourcesPublish', {
        resourceType: 1
      }).then(res => {
        if (res.data.success) {
          res.data.data.content.length > 0 ? this.setData({
            active: res.data.data.content[0].id
          }) : this.setData({
            active: null
          });
          this.setData({
            needsList: res.data.data.content
          });
        }
      });
    },

    submit() {
      if (this.content == '' && this.demandId == null) {
        uni.showToast({
          title: '请填写您的申请内容！',
          icon: 'none'
        });
        return;
      }

      let data = {
        resourceId: this.needsDetail.id,
        // demandId: this.needsDetail.id,
        content: this.content
      };
      app.http('post', 'Communicate/create', data).then(res => {
        if (res.data.success) {
          uni.showToast({
            title: '提交成功！',
            duration: 2000
          });
          setTimeout(() => {
            uni.navigateBack({
              delta: 1
            });
          }, 2000);
        }
      });
    }

  }
};
</script>
<style>
/* pages/demandHall/contact/index.wxss */
.contact-page{
  width: 100%;
  min-height: 100vh;
  padding: 40rpx;
  background: #EFEFEF;
}
.company-card-box {
  width: 100%;
  height: 210rpx;
  padding: 30rpx 12rpx;
  background: #FFFFFF;
  box-shadow: 0rpx 6rpx 12rpx rgba(0, 0, 0, 0.16);
  border-radius: 12rpx;
}
.info{
  width: 70%;
}
.company-logo{
  width: 150rpx;
  height: 150rpx;
  margin-right: 20rpx;
}
.company-name{
  font-size: 36rpx;
  line-height: 56rpx;
  font-weight: 500;
  color: #1D1D1D;
}
.slogan{
  font-size: 24rpx;
  line-height: 34rpx;
  color: #666;
  margin: 4rpx 0 12rpx;
}
.tags-box{
  margin: 6rpx 0 10rpx;
}
.tag-item{
  width: 112rpx;
  height: 36rpx;
  display: inline-block;
  line-height: 36rpx;
  text-align: center;
  font-size: 20rpx;
  background: #292929;
  color: #fff;
  border-radius: 8rpx;
  margin-right: 8rpx;
}
.tips{
  margin: 32rpx 0;
  font-size: 24rpx;
  color: #1D1D1D;
}
.t-icon{
  width: 28rpx;
  height: 28rpx;
  border-radius: 50%;
  border: 1px solid #1D1D1D;
  text-align: center;
  line-height: 25rpx;
  color: #1D1D1D;
  font-size: 24rpx;
  font-weight: bold;
  margin-right: 10rpx;
}
.needs-list{
  width: 100%;
}
.need-item{
  width: 100%;
  padding: 20rpx 0 0;
  background: #FFFFFF;
  box-shadow: 0rpx 6rpx 12rpx rgba(0, 0, 0, 0.16);
  border-radius: 12rpx;
  margin-bottom: 32rpx;
}
.n-title{
  width: 100%;
  padding: 18rpx 26rpx;
  border-bottom: 2rpx solid #E2E2E2;
  font-size: 24rpx;
  color: #979797;
  font-weight: 500;
}
.dot{
  width: 28rpx;
  height: 28rpx;
  border: 2rpx solid #979797;
  border-radius: 50%;
  margin-right: 6rpx;
}
.n-title-a .dot{
  position: relative;
  border-color: #292929;
}
.n-title-a .dot::before{
  content: '';
  display: inline-block;
  width: 20rpx;
  height: 20rpx;
  border-radius: 50%;
  border-color: #292929;
  background: #292929;
  position: absolute;
  top: 2rpx;
  left: 2rpx;
}
.n-title-a{
  color: #292929;
}
.price{
  font-size: 28rpx;
  color: #707070;
  margin-top: 20rpx;
}
.n-title-box{
  /* padding: 0 26rpx; */
  font-size: 28rpx;
  color: #1D1D1D;
  margin: 16rpx 0 8rpx;
}
.colO{
  color: #FF5100;
  font-size: 500;                                    
}
.n-tags{
  /* padding: 0 26rpx; */
}
.n-tag-item{
  width: 112rpx;
  height: 36rpx;
  line-height: 34rpx;
  text-align: center;
  border: 1rpx solid #FFAA00;
  color: #FFAA00;
  border-radius: 4rpx;
  margin-right: 8rpx;
  font-size: 24rpx;
}
.bgG{
  border: 1rpx solid #3A9EFA;
  color: #3A9EFA;
}
.bgO{
  border: 1rpx solid #FC9367;
  color: #FC9367;
}
.area-box{
  width: 100%;
  height: 900rpx;
  padding: 42rpx 24rpx;
  background: #fff;
  border-radius: 12rpx;
}
.area-box textarea{
  width: 100%;
  height: 50%;
}
.submit-btn{
  width: 240rpx;
  height: 88rpx;
  line-height: 88rpx;
  text-align: center;
  background: #000;
  border-radius: 12rpx;
  font-size: 32rpx;
  color: #fff;
  /* margin: 32rpx auto; */
  position: absolute;
  bottom: 80rpx;
  left: 50%;
  margin-left: -120rpx;
}
</style>