<template>
  <div class="mine">
    <div class="left">
      <div class="user-info">
        <div class="user-img"><img :src="userInfo.avatar_url"
               alt=""></div>
        <div class="user-span">
          <div class="name">昵称：<span>{{userInfo.nickname}}</span></div>
          <div class="sex">性别：<span>{{userInfo.sex}}</span></div>
          <div class="age">肤龄：<span>{{userInfo.age}}</span></div>
          <div class="skin-type">肤质：<span>{{userInfo.skin}}</span></div>
        </div>
      </div>
      <div class="user-record">
        <div class="fraction">
          <div class="title">肌肤得分</div>
          <div class="num">{{userInfo.score}}分</div>
        </div>
        <div class="status">
          <div class="title">皮肤状态</div>
          <div class="tips">{{userInfo.skin_status}}</div>
        </div>
        <div class="times">
          <div class="title">上传检测时间</div>
          <div class="ts">{{userInfo.check_time}}</div>
        </div>
      </div>
      <div class="summary">
        <div class="left-title">皮肤总结</div>
        <div class="summary-list">
          <div class="summary-info"
               v-for="item,index in detail_list"
               :key="index">
            <div class="result">
              <div class="result-left">
                <div class="title">{{item.name}}：</div>
                <div class="tips">{{item.main_item.name}}{{item.main_item.num}}</div>
              </div>
              <div class="right min-size">
                <div v-for="value,i in item.items"
                     :key="i">{{value.name}}：{{value.num}}个</div>
              </div>
            </div>
            <div class="bottom-tips">
              <span>{{item.suggest}}</span>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="right">
      <div class="lable">
        <div class="lable-title">
          面诊标签
        </div>
        <div class="lable-list">
          <div v-for="(item,index) in lableList"
               :key="index"
               :class="['lable-info', tags.indexOf(item)>-1?'active':'']">
            {{item}}
          </div>
          <div class="add-lable">
            +
          </div>
        </div>
        <div class="lable-title">
          备注
        </div>
        <div class="remarks">
          <el-input type="textarea"
                    autosize
                    resize="none"
                    placeholder="多行输入"
                    v-model="remarks">
          </el-input>
        </div>
      </div>
      <div class="programme">
        <div class="tab">
          <div class="tab-title">执行方案</div>
          <div class="add"
               @click="isPupop=true">新增</div>
        </div>
        <div class="programme-list">
          <div :class="['programme-info',item.onSelect?'programme-active':'']"
               v-for="(item,index) in programmeList"
               :key="index"
               @click="onOperation(index)">
            <div class="programme-left">
              <div class="programme-img"><img :src="item.cover_url"
                     alt=""></div>
              <div class="programme-tips">
                <div class="tips-title">{{item.name|ellipsis(9)}}</div>
                <div class="tips-title">{{item.desc|ellipsis(9)}}</div>
                <div class="tips-title">仪器：<span>{{item.device_name|ellipsis(9)}}</span></div>
              </div>
            </div>
            <div class="programme-right">
              <div class="frequency">执行频率：<span>{{item.frequency}}</span></div>
              <div class="duration">持续时长：<span>{{item.duration}}</span></div>
            </div>
            <div class="operation"
                 v-if="item.onSelect">
              <div class="edit">编辑</div>
              <div class="delete">删除</div>
            </div>
          </div>
        </div>
      </div>
      <div class="submit"
           @click="onSubmit">保存</div>
    </div>
    <mine-pupop :show="isPupop">
      <div class="block">
        <div class="delete-pupop"
             @click="isPupop=false"><img src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/icon/slices/delete.png"
               alt=""></div>
        <div class="pupop-title">
          选择执行方案
        </div>
        <el-select v-model="projectInfo"
                   placeholder="请选择项目"
                   class="project-select"
                   size="mini">
          <el-option v-for="item in projectList"
                     :key="item.id"
                     :label="item.name"
                     :value="item.id">
          </el-option>
        </el-select>
        <div class="frequency">
          <div>执行频率：</div>
          <el-select v-model="weekInfo"
                     class="week-select"
                     size="mini">
            <el-option v-for="item in weekList"
                       :key="item.value"
                       :label="item.label"
                       :value="item.value">
            </el-option>
          </el-select>
          <div>周</div>
          <el-select v-model="timesInfo"
                     class="times-select"
                     size="mini">
            <el-option v-for="item in timesList"
                       :key="item.value"
                       :label="item.label"
                       :value="item.value">
            </el-option>
          </el-select>
          <div>次</div>
        </div>
        <div class="submit-frequency"
             @click="submitFrequency">确定</div>
      </div>
    </mine-pupop>
  </div>
</template>

<script>
import minePupop from '../../../components/minePupop/index.vue'
import api from '../../../server/home'

export default {
  components: { minePupop },
  data () {
    return {
      userInfo: {
      },
      //皮肤总结
      detail_list: [],
      //面部标签
      lableList: [],
      //后台默认的标签
      tags: [],
      //执行方案
      programmeList: [
        {
          frequency: '1周1次',
          duration: '28天'
        }, {
          frequency: '1周1次',
          duration: '28天'
        }, {
          frequency: '1周1次',
          duration: '28天'
        },
      ],
      //项目列表
      projectList: [{
        value: '选项1',
        label: '黄金糕'
      }, {
        value: '选项2',
        label: '双皮奶'
      }, {
        value: '选项3',
        label: '蚵仔煎'
      }, {
        value: '选项4',
        label: '龙须面'
      }, {
        value: '选项5',
        label: '北京烤鸭'
      }],
      //周期
      weekList: [
        {
          value: '选项1',
          label: '1'
        },
        {
          value: '选项2',
          label: '2'
        },
      ],
      //次数
      timesList: [
        {
          value: '选项1',
          label: '1'
        },
        {
          value: '选项2',
          label: '2'
        },
      ],
      timesInfo: '',//次数
      projectInfo: '',//项目
      projectId: '',//项目id
      weekInfo: '',//周次
      programmeIndex: '',
      remarks: '',//备注
      isPupop: false,
      id: 0
    };
  },
  computed: {

  },
  watch: {},

  methods: {
    getSkinInfo () {
      api.getSkinInfo({ id: this.id }).then(res => {
        this.userInfo = res.data.user
        this.detail_list = res.data.detail_list
        this.lableList = res.data.tags
        this.programmeList = res.data.scheme_list
        this.remarks = res.data.remark
      })
    },
    getSkinTags () {
      api.getSkinTags().then(res => {
        this.tags = res.data.tags
      })
    },
    getProject () {
      api.getProject().then(res => {
        this.projectList = res.data.list
      })
    },
    getSkinUpdate () {
      let params = {
        remark: this.remarks,
        tags: this.lableList.toString()
      }
      api.getSkinUpdate().then(res => {

      })
    },
    onOperation (index) {
      if (this.programmeList[index].onSelect) {
        this.$set(this.programmeList[index], 'onSelect', !this.programmeList[index].onSelect)
      } else {
        this.$set(this.programmeList[index], 'onSelect', true)
      }
    },
    onSubmit () {
      this.getSkinUpdate()
    },
    submitFrequency () { },
  },

  created () {
    let id = this.$route.query.id
    this.id = id
    this.getSkinInfo()
    this.getProject()
    this.getSkinTags()
  },

  mounted () {

  },
}

</script>

<style lang='less' scoped>
.mine {
  height: 100%;
  display: flex;
  .left {
    width: 318px;
    padding: 12px 12px 0 12px;
    background: #ffffff;
    box-shadow: 0px 2px 4px 0px rgba(184, 191, 198, 0.2);
    border-radius: 8px;
    font-size: 13px;
    font-family: PingFangSC-Regular, PingFang SC;
    font-weight: 400;
    color: #999999;
    line-height: 18px;
    height: 100%;
    .user-info {
      display: flex;
      align-items: center;
      .user-img {
        width: 96px;
        img {
          width: 100%;
          border-radius: 5px;
          display: block;
        }
      }
      .user-span {
        margin-left: 12px;

        span {
          color: #333333;
        }
      }
    }
    .user-record {
      margin-top: 16px;
      display: flex;
      justify-content: space-between;
      .num {
        font-size: 18px;
        font-family: OPPOSans-B, OPPOSans;
        font-weight: normal;
        color: #333333;
        line-height: 29px;
      }
      .tips {
        font-size: 13px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #333333;
        line-height: 30px;
      }
      .ts {
        font-size: 13px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #333333;
        line-height: 30px;
      }
    }
    .summary {
      .left-title {
        margin-top: 10px;
        font-size: 14px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #333333;
        line-height: 20px;
      }
      .summary-list {
        margin-top: 10px;
        height: 280px;
        overflow: scroll;
        .summary-info {
          border-radius: 4px;
          margin-bottom: 20px;
          border: 1px solid #f5f5f5;
          .result {
            padding: 10px;
            display: flex;
            justify-content: space-between;
            align-content: center;
            .result-left {
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              .title {
                font-size: 14px;

                color: #666666;
                line-height: 20px;
              }
              .tips {
                font-size: 18px;
                color: #fa7d22;
                line-height: 25px;
              }
            }
            .right {
              font-size: 12px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #666666;
              line-height: 20px;
              text-align: end;
            }
          }
          .bottom-tips {
            padding: 6px 10px;
            font-size: 10px;
            font-family: PingFang-SC-Regular, PingFang-SC;
            font-weight: 400;
            color: #333333;
            line-height: 14px;
            background: #f5f5f5;
            border-radius: 4px;
            span {
              display: block;
              zoom: 0.83;
            }
          }
        }
      }
    }
  }
  .right {
    margin-left: 18px;
    position: relative;
    flex: 1;
    .lable {
      width: 100%;
      height: 230px;
      overflow: scroll;
      padding: 12px;
      background: #ffffff;
      box-shadow: 0px 2px 4px 0px rgba(184, 191, 198, 0.2);
      border-radius: 8px;
      .lable-title {
        font-size: 14px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #333333;
        line-height: 20px;
        margin-bottom: 14px;
      }
      .lable-list {
        width: 100%;
        min-height: 105rpx;
        .lable-info {
          display: inline-block;
          padding: 0 12px;
          margin-left: 10px;
          height: 24px;
          line-height: 24px;
          border-radius: 2px;
          border: 1px solid #d6d6d6;
          margin-bottom: 10px;
        }
        .add-lable {
          display: inline-block;
          width: 27px;
          height: 24px;
          line-height: 24px;
          font-size: 12px;
          font-family: PingFang-SC-Regular, PingFang-SC;
          font-weight: 400;
          color: #333333;
          text-align: center;
          margin-left: 10px;
          border-radius: 2px;
          border: 1px solid #d6d6d6;
        }
        .active {
          background: url(https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/icon/slices/%E9%80%89%E4%B8%AD2%402x.png)
            no-repeat;
          background-size: 100% 100%;
          border: 0px solid #d6d6d6;
        }
      }
      .remarks {
        /deep/ .el-textarea__inner:focus {
          border-color: #fa852f;
        }
      }
    }
    .programme {
      margin-top: 18px;
      width: 100%;
      // height: 208px;
      background: #ffffff;
      box-shadow: 0px 2px 4px 0px rgba(184, 191, 198, 0.2);
      border-radius: 8px;
      padding: 14px 12px 0 12px;

      .tab {
        display: flex;
        align-items: center;
        justify-content: space-between;
        .tab-title {
          font-size: 14px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #333333;
          line-height: 20px;
        }
        .add {
          width: 60px;
          height: 28px;
          line-height: 28px;
          background: #fa7d22;
          border-radius: 8px;
          font-size: 14px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #ffffff;
          text-align: center;
        }
      }
      .programme-list {
        margin-top: 10px;
        height: 150px;
        overflow: scroll;
        position: relative;
        z-index: 1;
        .programme-info {
          position: relative;
          padding: 8px 10px;
          margin-bottom: 10px;
          display: flex;
          align-items: center;
          border-radius: 4px;
          border: 1px solid #f5f5f5;
          .programme-left {
            flex: 1;
            display: flex;
            .programme-img {
              width: 48px;
              img {
                width: 100%;
                display: block;
              }
            }
            .programme-tips {
              margin-left: 10px;
              font-size: 10px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #999999;
              line-height: 14px;
            }
          }
          .programme-right {
            flex: 1;
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #333333;
            line-height: 17px;
            padding-left: 125px;
            .duration {
              margin-top: 14px;
            }
          }
          .operation {
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
            top: 10px;
            z-index: 10;
            width: 44px;
            background: #ffffff;
            box-shadow: 0px 9px 28px 8px rgba(0, 0, 0, 0.05),
              0px 6px 16px 0px rgba(0, 0, 0, 0.08),
              0px 3px 6px -4px rgba(0, 0, 0, 0.12);
            border-radius: 2px;
            padding: 10px;
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #333333;
            line-height: 17px;
            .delete {
              margin-top: 20px;
            }
          }
        }
        .programme-active {
          border: 1px solid #fa852f;
        }
      }
    }
    .submit {
      margin-top: 18px;
      position: relative;
      left: 50%;
      transform: translateX(-50%);
      width: 176px;
      height: 28px;
      line-height: 28px;
      background: #fa7d22;
      border-radius: 14px;
      text-align: center;
      font-size: 14px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #ffffff;
    }
  }
  .block {
    width: 540px;
    background: #ffffff;
    border-radius: 8px;
    position: relative;
    padding: 42px;
    .delete-pupop {
      position: absolute;
      width: 32px;
      height: 32px;
      top: 5px;
      right: 5px;
      img {
        width: 100%;
        height: 100%;
        display: block;
      }
    }
    .pupop-title {
      font-size: 14px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #333333;
      line-height: 20px;
      text-align: center;
    }
    .project-select {
      margin-top: 26px;
      position: relative;
      left: 50%;
      transform: translateX(-50%);
      width: 300px;
    }
    .frequency {
      margin-top: 20px;
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #333333;
      line-height: 20px;
      .week-select {
        width: 77px;
        margin-right: 8px;
      }
      .times-select {
        width: 77px;
        margin: 0 8px 0 20px;
      }
    }
    .submit-frequency {
      position: relative;
      left: 50%;
      transform: translateX(-50%);
      margin-top: 158px;
      width: 176px;
      height: 28px;
      text-align: center;
      background: #fa7d22;
      border-radius: 14px;
      font-size: 14px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #ffffff;
      line-height: 28px;
    }
  }
}
</style>
