<template>
  <view class="page">
    <u-navbar
      title="任务审核"
      back-icon-color="#FFFFFF"
      title-color="#FFFFFF"
      leftText="返回"
      :autoBack="true"
      :placeholder="true"
    />
    <view class="view-forms">
      <uni-forms
        ref="valiForm"
        :rules="rules"
        :modelValue="valiFormData"
        label-position="top"
      >
        <view>
          <view class="item-header">
            <view class="title">事件标题</view>
            <view class="icon">*</view>
          </view>
          <view class="checkbox-rudio">
            <uni-data-checkbox
              mode="button"
              v-model="valiFormData.sex"
              :localdata="sexs"
            />
          </view>
        </view>
        <view>
          <view class="item-header">
            <view class="title">处理前照片</view>
            <view class="icon">*</view>
          </view>
          <view>
            <view class="img-box">
              <img
                @click="previewImage(index)"
                v-for="(image, index) in imageList"
                :key="index"
                :src="image"
              />
            </view>
          </view>
        </view>
        <view>
          <view class="item-header">
            <view class="title">处理后照片</view>
            <view class="icon">*</view>
          </view>

          <view>
            <u-checkbox-group @change="checkboxGroupChange">
              <view class="img-boxs">
                <view
                  class="img-item"
                  v-for="(item, index) in list"
                  :key="index"
                >
                  <img :src="item.text" />
                  <u-checkbox
                    class="cu-checkbox"
                    @change="
                      (e) => {
                        item.checked = e;
                      }
                    "
                    v-model="item.checked"
                    :name="item.name"
                    :activeColor="'#32b78b'"
                    shape="circle"
                  />
                  <view :class="item.checked ? 'text-tag-a' : 'text-tag'">
                    <text :class="item.checked ? 'text-a' : 'text-c'">{{
                      item.checked ? "已标记" : "标记"
                    }}</text>
                  </view>
                </view>
              </view>
            </u-checkbox-group>
          </view>
        </view>
        <view>
          <view class="item-header">
            <view class="title">标记后照片</view>
            <view class="icon">*</view>
          </view>
          <view>
            <view class="img-box">
              <img
                @click="previewImage(index)"
                v-for="(image, index) in imageList"
                :key="index"
                :src="image"
              />
            </view>
          </view>
        </view>
        <view>
          <view class="item-header">
            <view class="title">语音说明</view>
            <view class="icon">*</view>
          </view>
          <view class="view-voice">
            <view class="voice-btn">
              <view class="icon-voice"></view>
              按住开始说话
            </view>
            <view class="voice-list">
              <view class="voice-item">
                <view class="item-left" style="width: 260rpx">
                  <view>13秒</view>
                  <view class="icon-sound"></view>
                </view>
                <view class="btn-del">删除</view>
              </view>

              <view class="voice-item">
                <view class="item-left" style="width: 460rpx">
                  <view>20秒</view>
                  <view class="icon-sound"></view>
                </view>
                <view class="btn-del">删除</view>
              </view>
            </view>
          </view>
        </view>
        <view>
          <view class="item-header">
            <view class="title">文字说明</view>
            <view class="icon">*</view>
          </view>
          <view>
            <uni-easyinput
              type="textarea"
              v-model="valiFormData.introduction"
              placeholder="请输入内容"
            />
          </view>
        </view>
      </uni-forms>
    </view>

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

<script>
export default {
  data() {
    return {
      list: [
        {
          name: "apple",
          text: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao-small.jpg",
          checked: false,
          disabled: false,
        },
        {
          name: "banner",
          text: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao-small.jpg",
          checked: false,
          disabled: false,
        },
        {
          name: "orange",
          text: "https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/shuijiao-small.jpg",
          checked: false,
          disabled: false,
        },
      ],
      checked: false,
      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",
      ],

      // 单选数据源
      sexs: [
        {
          text: "通过",
          value: 0,
        },
        {
          text: "不通过",
          value: 1,
        },
      ],
      // 校验表单数据
      valiFormData: {
        name: "",
        age: "",
        sex: "",
        introduction: "",
        checkbox1: [],
      },
      // 校验规则
      rules: {
        introduction: {
          rules: [
            {
              required: true,
            },
          ],
        },
      },
    };
  },
  computed: {},
  onLoad() {},
  onReady() {},
  methods: {
    // 选中某个复选框时，由checkbox时触发
    checkboxChange(e) {
      //console.log(e);
    },
    // 选中任一checkbox时，由checkbox-group触发
    checkboxGroupChange(e) {
      // console.log(e);
    },

    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;
    }
    .img-boxs {
      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-item {
        position: relative;
        object-fit: cover;
        margin: 16rpx 0;
        display: flex;
        flex-direction: column;
        img {
          width: 200rpx;
          height: 200rpx;
        }

        .cu-checkbox {
          position: absolute;
          top: 0;
        }

        .text-tag {
          text-align: center;
          padding: 22rpx 0 0 0;

          .text-c {
            border: 1rpx solid #367bef;
            background: #ffffff;
            border-radius: 8rpx;
            padding: 9rpx 37rpx;
            font-size: 28rpx;
            font-family: PingFang SC-Regular, PingFang SC;
            color: #367bef;
            letter-spacing: 6rpx;
          }
        }

        .text-tag-a {
          text-align: center;
          padding: 22rpx 0 0 0;

          .text-a {
            border: 1rpx solid #367bef;
            background: #367bef;
            border-radius: 8rpx;
            padding: 9rpx 37rpx;
            font-size: 28rpx;
            font-family: PingFang SC-Regular, PingFang SC;
            color: #ffffff;
            letter-spacing: 6rpx;
          }
        }
      }
    }
    .item-header {
      display: flex;
      .title {
        font-size: 30rpx;
        font-family: PingFang SC-Bold, PingFang SC;
        // font-weight: bold;
        color: #2e2f31;
        background-image: url("@/static/images/umale/icon_ind.png");
        background-size: 100% 50%;
        background-position: bottom;
        background-repeat: no-repeat;
      }

      .icon {
        font-size: 30rpx;
        font-family: PingFang SC-Bold, PingFang SC;
        font-weight: bold;
        color: #fe3434;
      }
    }

    /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;
    }

    .checkbox-rudio /deep/ .uni-data-checklist .checklist-group {
      display: flex;

      & :nth-child(odd) {
        margin-right: 15rpx;
      }

      & :nth-child(even) {
        margin-left: 15rpx;
        margin-right: 0;
      }

      .checklist-box {
        flex: 1;
        background: #ffffff;
        box-shadow: 0rpx 0rpx 20rpx 1rpx rgba(57, 118, 241, 0.06);
        border-radius: 16rpx;
        border: 2rpx solid #dce3ec;

        .checklist-content {
          padding: 32rpx;

          justify-content: center;
        }

        .radio__inner {
          position: absolute;
          top: 12rpx;
          left: 0;
        }
      }
    }

    // 选中
    .checkbox-rudio
      /deep/
      .uni-data-checklist
      .checklist-group
      .checklist-box.is--button.is-checked {
      border-color: #32b78b;
      background-color: rgba(50, 183, 139, 0.05);
      .checklist-text {
        color: #32b78b;
      }

      .radio__inner {
        border-color: #32b78b;
        background-color: #32b78b;
        padding-left: 10rpx;
        padding-bottom: 10rpx;

        .radio__inner-icon {
          background-color: transparent;
        }

        .radio__inner-icon::before {
          content: "\2713"; /* 使用 Unicode 字符编码表示勾号 */
          color: #ffffff; /* 勾号的颜色 */
          font-size: 24rpx; /* 勾号的大小 */
        }
      }
    }

    .view-voice {
      margin-top: 16rpx;
      .voice-btn {
        padding: 23rpx 0;
        text-align: center;
        background: #ffffff;
        box-shadow: 0rpx 0rpx 20rpx 1rpx rgba(57, 118, 241, 0.06);
        border-radius: 16rpx;
        font-size: 38rpx;
        font-family: PingFang SC-Regular, PingFang SC;
        color: #2e2f31;
        letter-spacing: 10rpx;

        .icon-voice {
          width: 50rpx;
          height: 46rpx;
          position: absolute;
          margin-left: 25rpx;
          background-image: url("@/static/images/umale/voice.png");
          background-size: 100% 100%;
          background-repeat: no-repeat;
        }
      }

      .voice-list {
        margin-top: 20rpx;

        .voice-item {
          display: flex;
          margin: 16rpx 0;
          .item-left {
            display: flex;
            justify-content: space-between;
            align-items: center;
            box-shadow: 0rpx 0rpx 20rpx 1rpx rgba(57, 118, 241, 0.06);
            border-radius: 8rpx 8rpx 8rpx 8rpx;
            padding: 10rpx 19rpx 10rpx 33rpx;
            background: #ffffff;

            .icon-sound {
              width: 27rpx;
              height: 27rpx;
              background-image: url("@/static/images/umale/sound.png");
              background-size: 100% 100%;
              background-repeat: no-repeat;
            }
          }

          .btn-del {
            margin-left: 20rpx;
            background: #f8404c;
            font-size: 28rpx;
            font-family: PingFang SC-Regular, PingFang SC;
            color: #ffffff;
            letter-spacing: 10rpx;
            border-radius: 16rpx;
            padding: 7rpx 26rpx;
            display: flex;
            align-items: center;
          }
        }
      }
    }
  }
  .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>
