<template>
<!--pages/demandHall/platform/index.wxml-->
<view class="page">
  <view class="area-box">
    <textarea :value="content" @input="contentChange" placeholder="介入原因"></textarea>
    <view class="upload-box">
      <image src="/static/images/upload.png"></image>
    </view>
  </view>
  <view class="submit" @tap="submit">提交</view>
</view>
</template>

<script>
// pages/demandHall/platform/index.js
const util = require("../../../utils/util.js");
const app = getApp();

export default {
  data() {
    return {
      projectId: '',
      content: '',
      imgPaths: [],
      projectCode: ""
    };
  },

  components: {},
  props: {},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      projectCode: options.code
    });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {},

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
  methods: {
    contentChange(e) {
      this.setData({
        content: e.detail.value
      });
    },

    upImgs() {
      util.chooseImages2(img => {
        let imgs = this.form.imgPaths;
        imgs.push(img);
        this.setData({
          imgPaths: imgs
        });
      });
    },

    submit() {
      let data = {
        projectCode: this.projectCode,
        content: this.content,
        imgPaths: this.imgPaths
      };
      app.http('post', 'Project/applyPlatform', data).then(res => {
        if (res.data.success) {
          uni.showToast({
            title: '提交成功！',
            duration: 2000
          });
        }
      });
    }

  }
};
</script>
<style>
/* pages/demandHall/platform/index.wxss */
.page{
  width: 100%;
  height: 100vh;
  background: #EFEFEF;
  padding: 40rpx;
}
.area-box{
  width: 100%;
  background: #fff;
  padding: 32rpx;
  font-size: 32rpx;
  border-radius: 12rpx;
}
.area-box textarea{
  width: 100%;
  height: 300rpx;
  color: #707070;
  font-size: 28rpx;
}
.area-box image{
  width: 152rpx;
  height: 152rpx;
  margin-right: 12rpx;
}
.submit{
  width: 223rpx;
  height: 76rpx;
  background: linear-gradient(144deg, #FFA782 0%, #FF5100 100%);
  border-radius: 38rpx;
  font-size: 32rpx;
  color: #fff;
  line-height: 76rpx;
  text-align: center;
  margin: 90rpx auto;
}
</style>