<template>
  <view class="page">
    <u-navbar
      title="处理结果上报"
      back-icon-color="#FFFFFF"
      title-color="#FFFFFF"
      leftText="返回"
      :autoBack="true"
      :placeholder="true"
    >
      <view class="u-nav-slot" slot="right" @click="clickNavRight">
        <text>申请延期</text>
      </view>
    </u-navbar>
    <view class="view-forms">
      <uni-forms
        ref="valiForm"
        :rules="rules"
        :modelValue="valiFormData"
        label-position="top"
      >
        <uni-forms-item label="处理前照片" name="">
          <view class="img-box">
            <img
              @click="previewImage(index)"
              v-for="(image, index) in imageList"
              :key="index"
              :src="image"
            />
          </view>
        </uni-forms-item>
        <uni-forms-item label="处理后照片" name="">
          <uni-file-picker
            class="uni-file-picker"
            ref="filePicker"
            limit="9"
            title=""
            styleType="bottom"
          ></uni-file-picker>
        </uni-forms-item>
        <uni-forms-item label="处理说明" name="">
          <uni-easyinput
            type="textarea"
            v-model="valiFormData.introduction"
            placeholder="请输入内容"
          />
        </uni-forms-item>
      </uni-forms>
    </view>

    <view class="footer">
      <button class="btn-add" @click="submit('valiForm')">提交</button>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      imageList: [
        "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao-small.jpg",
        "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao-small.jpg",
        "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao-small.jpg",
      ],
      // 校验表单数据
      valiFormData: {
        name: "",
        age: "",
        introduction: "",
      },
      // 校验规则
      rules: {
        name: {
          rules: [
            {
              required: true,
            },
          ],
        },
        age: {
          rules: [
            {
              required: true,
            },
          ],
        },
      },
    };
  },
  computed: {},
  onLoad() {},
  onReady() {},
  methods: {
    previewImage(index) {
      uni.previewImage({
        urls: this.imageList,
        current: index,
        indicator: this.currentIndicator,
        loop: this.isLoop,
      });
    },
    changeSelect(e) {},
    submit(ref) {
      this.$refs[ref]
        .validate()
        .then((res) => {
          console.log("success", res);
          uni.showToast({
            title: `校验通过`,
          });
        })
        .catch((err) => {
          console.log("err", err);
        });
    },
  },
};
</script>

<style lang="scss" scoped>
.page {
  .u-nav-slot {
    text {
      font-size: 32rpx;
      font-family: PingFang SC;
      font-weight: bold;
      color: #367bef;
    }
  }

  .view-forms {
    padding: 30rpx 20rpx 240rpx 20rpx;

    .img-box {
      width: 100%;
      height: auto;
      margin: 16rpx auto;
      display: flex;
      flex-direction: row;
      flex-wrap: wrap;
      justify-content: space-between;
      background: #ffffff;
      box-shadow: 0rpx 0rpx 20rpx 1rpx rgba(57, 118, 241, 0.06);
      padding: 30rpx;
    }
    .img-box > img {
      width: 200rpx;
      height: 200rpx;
      object-fit: cover;
      margin: 16rpx 0;
    }
    .img-box:after {
      content: "";
      display: block;
      width: 200rpx;
    }
    /deep/ .uni-forms-item {
      margin-bottom: 15rpx;
    }
    /deep/.uni-forms-item__label {
      background-image: url("@/static/images/umale/icon_ind.png");
      background-size: 100% 100%;
      background-position: bottom;
      background-repeat: no-repeat;
      height: auto;
      margin-top: 26rpx;
      & > text {
        line-height: 0;
      }
      & > text {
        font-size: 30rpx;
        font-family: PingFang SC-Bold, PingFang SC;
        // font-weight: bold;
        color: #2e2f31;
        white-space: nowrap;
      }

      & > .is-required {
        color: #dd524d;
        font-weight: bold;
      }
    }

    /deep/ .uni-easyinput {
      margin-top: 19rpx;
      background: #ffffff;
      box-shadow: 0rpx 0rpx 20rpx 1rpx rgba(57, 118, 241, 0.06);
      border-radius: 16rpx;
    }

    /deep/ .uni-stat-box {
      margin-top: 19rpx;
      background: #ffffff;
      box-shadow: 0rpx 0rpx 20rpx 1rpx rgba(57, 118, 241, 0.06);
      border-radius: 16rpx;
    }

    .uni-file-picker {
      margin-top: 16rpx;
      background-color: #ffffff;
      padding: 29rpx;
      box-shadow: 0rpx 0rpx 20rpx 1rpx rgba(57, 118, 241, 0.06);
      border-radius: 16rpx;
    }
  }
  .footer {
    position: fixed;
    bottom: 0;
    z-index: 1;
    width: 100%;
    background: #ffffff;
    border: 1px solid #dce3ec;
    padding: 18rpx 28rpx 60rpx 28rpx;
    .btn-add {
      font-size: 36rpx;
      font-family: PingFang SC-Medium, PingFang SC;
      height: 88rpx;
      background: linear-gradient(90deg, #3976f1 0%, #3ca0f6 100%);
      border-radius: 16rpx;
      color: #ffffff;
    }
  }
}
</style>
