<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="info">
            <div class="name"><span>{{userInfo.nickname}}</span></div>
            <div class="sex"><img :src="gender"
                   alt=""></div>
            <div class="age"><span>{{userInfo.skin_age}}</span><span>肤龄</span></div>
          </div>
          <div class="skin-type">肤质：<span>{{userInfo.skin_type}}</span></div>
          <div class="skin-color">肤色：<span>{{userInfo.skin_color}}</span></div>
          <div class="skin-color">上传报告时间：<span>{{userInfo.check_time}}</span></div>
        </div>
      </div>
      <div class="ps">
        <div class="ps-title">
          备注
        </div>
        <div class="ps-text">{{remarks || '无' | ellipsis(20)}}</div>
      </div>
      <div class="lable">
        <div class="lable-title">
          问题标签
        </div>
        <div class="problem-lable">
          <div class="lable-text problem-text">{{problem}}</div>
        </div>
      </div>
      <div class="lable">
        <div class="lable-title">
          面部标签
        </div>
        <div class="lable-list">
          <div v-for="(item,index) in lableList"
               :key="index"
               :style='{background:item.bgcolor,borderColor:item.bdcolor}'
               class='lable-info'>
            {{item.text}}
          </div>
        </div>
      </div>
    </div>
    <div class="right">
      <div class="shop-info">
        <div class="shpo-name">
          预约店铺：
          <span>{{order_data.store_name}}</span>
        </div>
        <div class="shpo-address">
          门店地址：
          <span>{{order_data.address}}</span>
        </div>
        <div class="shpo-ts">
          美容时间：
          <span>{{order_data.order_time}}</span>
        </div>
      </div>
      <div class="project">
        <div class="project-title">
          共
          <span>{{order_data.project_num}}个</span>项目
        </div>
        <div class="project-list">
          <div class="project-info"
               v-for="(item,index) in programmeList"
               :key="index">
            <div class="project-image">
              <img :src="item.cover_url" />
            </div>
            <div class="project-content">
              <div class="title-price">
                <div class="project-tit">{{item.name}}</div>
                <div class="project-price">
                  <span class="min-size">￥</span>
                  {{item.price}}
                </div>
              </div>
              <div class="project-tips">{{item.product_names}}</div>
              <div class="project-zoom">{{item.room}}{{item.use_time}}分钟</div>
            </div>
          </div>
        </div>
      </div>
      <div class="cost">
        <div class="cost-title">
          <div>预约费用</div>
          <div>¥{{order_data.original_price}}</div>
        </div>
        <div class="cost-coupon-list">
          <div class="coupon">
            <div class="coupon-tips">
              <div class="coupon-icon">
                <img src="https://we-spa.oss-cn-shenzhen.aliyuncs.com/pad_clerk/icon/slices/couponIcon.png"
                     alt />
              </div>
              <div class="coupon-title">优惠卷</div>
              <div class="coupon-tip">已选推荐优惠</div>
            </div>
            <div class="on-icon">></div>
          </div>
          <div class="coupon-ps"
               v-for="(item,index) in coupon_list"
               :key="index">
            <div>{{item.coupon_name}}</div>
            <div class="cou-price">-¥{{item.price}}</div>
          </div>
        </div>
        <div class="over-price">
          合计：
          <span>
            <span class="min-size">￥</span>{{order_data.price}}
            <!-- <span class="min-size">.00</span> -->
          </span>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import api from "../../../server/home";
export default {
  data () {
    return {
      userInfo: {
      },
      lableList: [],
      programmeList: {},
      scheme_list: {},
      timesInfo: "",
      projectInfo: "",
      weekInfo: "",
      programmeIndex: "",
      remarks: "",
      coupon_list: "",
      order_data: "",
      isPupop: false,
      id: "",
      problem: '',
    };
  },
  computed: {
    gender () {
      // 性别，1男，2女，0保密
      return this.userInfo.sex == 1 ?
        'https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220610/male.png' :
        'https://we-spa.oss-cn-shenzhen.aliyuncs.com/wxapp/20220610/female.png'
    }
  },
  watch: {},

  methods: {
    getOrderInfo () {
      api.getOrderInfo({ id: this.id }).then(res => {
        this.userInfo = res.data.user;
        this.order_data = res.data.order_data;
        this.problem = res.data.skin_name
        let _problem = []
        res.data.face_names.forEach(item => {
          let info = {}
          info['text'] = item
          _problem.push(info)
          console.log(_problem, '_problem');
        })
        this.lableList = _problem
        this.randomColor();
        this.programmeList = res.data.order_data.project_list;
        this.coupon_list = res.data.order_data.coupon_list;
        this.remarks = res.data.remark;
      });
    },

    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);
      }
    },
    randomColor (type) {
      let arr = [
        { background: 'rgba(244, 247, 255, 1)', border: 'rgba(85, 124, 255, 1)' },
        { background: 'rgba(245, 252, 245, 1)', border: 'rgba(66, 211, 81, 1)' },
        { background: 'rgba(254, 244, 237, 1)', border: 'rgba(250, 125, 34, 1)' },
        { background: 'rgba(249, 245, 255, 1)', border: 'rgba(136, 50, 255, 1)' },
        { background: 'rgba(255, 252, 245, 1)', border: 'rgba(204, 116, 42, 1)' },]
      this.lableList.forEach(res => {
        let color = Math.floor((Math.random() * arr.length))
        this.$set(res, 'bgcolor', arr[color].background)
        this.$set(res, 'bdcolor', arr[color].border)
      })

    },
    onSubmit () { },
    submitFrequency () { }
  },

  created () {
    let id = this.$route.query.id;
    this.id = id;
    this.getOrderInfo();
  },

  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;
    overflow: scroll;
    height: 100%;
    .user-info {
      display: flex;
      align-items: center;
      .user-img {
        width: 96px;
        img {
          width: 100%;
          display: block;
          border-radius: 6px;
        }
      }
      .user-span {
        margin-left: 12px;

        span {
          color: #333333;
        }
        .info {
          display: flex;
          justify-content: space-between;

          .name {
            font-size: 22px;
          }
          .sex {
            img {
              width: 24px;
              height: 24px;
            }
          }
          .age {
            margin-left: 13px;
            span:nth-child(1) {
              font-size: 22px;
            }
            span:nth-child(2) {
              margin-left: 4px;
              color: #999999;
            }
          }
        }
        div:nth-child(2),
        div:nth-child(3) {
          margin-bottom: 8px;
        }
      }
    }
    .user-record {
      margin-top: 16px;
      display: flex;
      justify-content: space-between;
      .num {
        font-size: 18px;
        font-family: OPPOSans-B, OPPOSans;
        font-weight: normal;
        color: #fa7d22;
        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;
      }
    }
    .lable {
      margin-top: 23px;
      width: 100%;
      overflow: scroll;
      background: #ffffff;
      .lable-title {
        font-size: 14px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #333333;
        line-height: 20px;
      }
      .problem-lable {
        flex: 1;
        overflow-y: hidden;
        width: 100%;
        font-size: 12px;
        font-family: PingFang-SC-Regular, PingFang-SC;
        font-weight: 400;
        color: #333333;
        line-height: 17px;
        display: flex;
        flex-flow: column wrap;
        list-style-type: none;
        overflow-x: scroll;
        align-items: baseline;

        .lable-text {
          margin-top: 10px;
          margin-bottom: 10px;
          height: 24px;
          line-height: 24px;
          border: 1px solid #42d351;
          padding: 0 12px;
          border-radius: 2px;
        }
        .problem-text {
          background: rgba(244, 247, 255, 1);
          border: 1px solid rgba(85, 124, 255, 1);
        }
      }
      .lable-list {
        width: 100%;
        min-height: 105rpx;
        .lable-info {
          padding: 3px 12px;
          display: inline-block;
          line-height: 17px;
          border-radius: 2px;
          border: 1px solid #d6d6d6;
          margin-top: 10px;
          margin-right: 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;
        }
      }
      .remarks {
        /deep/ .el-textarea__inner:focus {
          border-color: #fa852f;
        }
      }
    }
    .ps {
      font-size: 14px;
      font-family: PingFangSC-Medium, PingFang SC;
      font-weight: 500;
      color: #333333;
      line-height: 20px;
      margin-top: 20px;
      .ps-text {
        margin-top: 10px;
        font-size: 12px;
        font-family: PingFang-SC-Regular, PingFang-SC;
        font-weight: 400;
        color: #666666;
        line-height: 17px;
      }
    }
    .programme {
      margin-top: 20px;
      width: 100%;
      background: #ffffff;
      border-radius: 8px;

      .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;
        }
      }
      .programme-list {
        margin-top: 10px;
        position: relative;
        z-index: 1;
        .programme-info {
          position: relative;
          margin-bottom: 10px;
          border-radius: 4px;
          border: 1px solid #f5f5f5;
          display: flex;
          justify-content: space-between;
          padding: 8px 8px 8px 10px;
          align-items: center;
          .programme-left {
            display: flex;
            align-items: center;
            .programme-img {
              width: 48px;
              display: inline-block;
              img {
                width: 100%;
                display: block;
              }
            }
            .programme-tips {
              display: inline-block;
              margin-left: 10px;
              font-size: 10px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #999999;
              line-height: 14px;
              zoom: 0.83;
            }
          }
          .programme-right {
            font-size: 12px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #333333;
            line-height: 17px;
            .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;
        }
      }
    }
  }
  .right {
    margin-left: 18px;
    position: relative;
    flex: 1;
    .shop-info {
      background: #ffffff;
      box-shadow: 0px 2px 4px 0px rgba(184, 191, 198, 0.2);
      border-radius: 8px;
      padding: 12px;
      font-size: 13px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #999999;
      line-height: 28px;
      span {
        font-weight: 500;
        color: #333333;
      }
    }
    .project {
      margin-top: 18px;
      background: #ffffff;
      box-shadow: 0px 2px 4px 0px rgba(184, 191, 198, 0.2);
      border-radius: 8px;
      padding: 16px 12px 12px 12px;
      .project-title {
        font-size: 14px;
        font-family: PingFangSC-Medium, PingFang SC;
        font-weight: 500;
        color: #333333;
        line-height: 20px;
        span {
          color: #fa7d22;
        }
      }
      .project-list {
        padding-top: 10px;
        height: 130px;
        overflow: scroll;
        .project-info {
          margin-bottom: 10px;
          display: flex;
          .project-image {
            width: 60px;
            height: 60px;
            img {
              width: 100%;
              display: block;
            }
          }
          .project-content {
            flex: 1;
            margin-left: 10px;
            .title-price {
              display: flex;
              justify-content: space-between;
              font-size: 14px;
              font-family: PingFangSC-Medium, PingFang SC;
              font-weight: 500;
              color: #292929;
              line-height: 22px;
            }
            .project-tips {
              font-size: 12px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #999999;
              line-height: 18px;
            }
            .project-zoom {
              font-size: 12px;
              font-family: PingFangSC-Regular, PingFang SC;
              font-weight: 400;
              color: #fa7d22;
              line-height: 18px;
            }
          }
        }
      }
    }
    .cost {
      height: 186px;
      overflow: scroll;
      background: #ffffff;
      border-radius: 8px;
      margin-top: 18px;
      padding: 10px 19px 11px 12px;
      font-size: 14px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #333333;
      line-height: 20px;
      .cost-coupon-list {
        height: 110px;
        overflow: scroll;
        border-bottom: 1px solid #f9f9f9;
      }
      .cost-title {
        display: flex;
        justify-content: space-between;
      }
      .coupon {
        margin-top: 10px;
        display: flex;
        justify-content: space-between;
        .coupon-tips {
          display: flex;
          align-items: center;
          .coupon-icon {
            width: 16px;
            img {
              width: 100%;
              display: block;
            }
          }
          .coupon-title {
            margin-left: 3px;
          }
          .coupon-tip {
            margin-left: 10px;
            background: #ffefeb;
            border-radius: 4px;
            border: 1px solid #ff3007;
            font-size: 10px;
            font-family: PingFangSC-Regular, PingFang SC;
            font-weight: 400;
            color: #ff3007;
            line-height: 14px;
            padding: 2px 6px;
            zoom: 0.83;
          }
        }
      }
      .coupon-ps {
        margin-left: -6px;
        margin-top: 11px;
        display: flex;
        justify-content: space-between;
        font-size: 12px;
        font-family: PingFangSC-Regular, PingFang SC;
        font-weight: 400;
        color: #333333;
        line-height: 17px;
        .cou-price {
          font-weight: 500;
          color: #ff3007;
        }
      }
      .over-price {
        margin-top: 14px;
        text-align: right;
      }
    }
  }
}
</style>
