<template>
  <div style="background: #f3f4f8; overflow: hidden;">
    <tips />

    <course-model
      v-if="mypreViewData && mypreViewData.isShowMusicCourseForPay"
      :isShowSalePrice="isShowSalePrice"
      :courseViewType="courseViewType"
      :courseShowInfo="courseShowInfo"
      :remissionCourseFeeStatus="remissionCourseFeeStatus"
      :courseInfo="courseInfo"
      :trainSmallBg="trainSmallBg"
      :serviceValidDate="serviceValidDate"
      :cloudTeacherFee="cloudTeacherFee"
      :chargeTypeName="chargeTypeName"
      :memberCoursePrice="memberCoursePrice"
      :memberCourseShowFlag="memberCourseShowFlag"
      @onCourseChange="onCheckItem"
      @onQuestions="onQuestions"
    />

    <member
      v-if="
        toolsPackage &&
          toolsPackage.length > 0 &&
          mypreViewData &&
          mypreViewData.isShowMemberForPay
      "
      :isShowSalePrice="isShowSalePrice"
      :toolsPackage="toolsPackage"
      :isGiveAccessories="isGiveAccessories"
      :accessStatus="accessOries.length > 0"
      @onCheckItem="onCheckItem"
    />

    <instrument-model
      :isShowSalePrice="isShowSalePrice"
      :instrumentResultList="instrumentResultList"
      :buyMaintenance="buyMaintenance"
      :trainSmallBg="trainSmallBg"
      :courseViewType="courseViewType"
      :toolsPackage="toolsPackage"
      :organId="organId"
      @instrumentF="onCheckItem"
      @onQuestions="onQuestions"
    />

    <div
      class="courseModel"
      style="margin-top: 12px;"
      v-if="
        instrumentRepair &&
          instrumentRepair.length > 0 &&
          mypreViewData &&
          mypreViewData.isShowMusicInsuranceForPay
      "
    >
      <h2 class="titles">
        <img :src="trainSmallBg" />
        <span>乐器保养</span>
      </h2>
      <!-- 可选课程信息集合 -->
      <div class="section">
        <el-row class="title-row">
          <el-col :span="isShowSalePrice ? 9 : 14">服务项目</el-col>
          <!-- 原价 -->
          <el-col :span="5" style="text-align: right;">时间</el-col>
          <el-col :span="5" style="text-align: right;">原价</el-col>
          <el-col :span="5" style="text-align: right;" v-if="isShowSalePrice"
            >售价</el-col
          >
        </el-row>
        <el-row
          class="option-row"
          v-for="(item, index) in instrumentRepair"
          :key="index"
          @click.native="onCheckItem(item)"
        >
          <el-col :span="isShowSalePrice ? 9 : 14">
            <i
              class="check_default"
              :class="[
                item.isStatus ? 'check_active' : '',
                item.optionalFlag ? 'disabled' : '',
                item.noSelect ? 'noSelect' : ''
              ]"
            ></i>
            {{ item.name }}
          </el-col>
          <el-col :span="5">
            <span style="color: #AAA; font-size: 12px;"
              >{{ item.num }}(年)</span
            >
          </el-col>
          <el-col :span="5">
            <del style="color: #AAA; font-size: 12px;"
              >￥{{ item.originalAmount | moneyFormat }}</del
            >
          </el-col>
          <el-col :span="5" v-if="isShowSalePrice">
            <span style="color: #1A1A1A"
              >￥{{ item.actualAmount | moneyFormat }}</span
            >
          </el-col>
        </el-row>
      </div>
    </div>

    <accessories
      :isShowSalePrice="isShowSalePrice"
      :trainSmallBg="trainSmallBg"
      :accessOries="accessOries"
      :isGiveAccessories="giveAccessoriesStatus"
      @onAuxiliarie="onCheckItem"
    />
    <activity
      v-if="
        activityList &&
          activityList.length > 0 &&
          mypreViewData &&
          mypreViewData.isShowVipCourseForPay
      "
      :isShowSalePrice="isShowSalePrice"
      :trainSmallBg="trainSmallBg"
      :activityList="activityList"
      @onCheckItem="onCheckItem"
    />

    <!-- <div class="buy">
      <div class="price">
        <p class="oldprice">
          <del class="text">原价</del>
          <del style="font-size: 13px"
            >￥{{ orderInfo.marketPrice | moneyFormat }}</del
          >
        </p>
        <p class="now_price">
          <span class="text">仅需支付</span>
          <span style="font-weight: bold">￥{{ needPrice | moneyFormat }}</span>
        </p>
      </div>

      <a class="btn-submit">购买</a>
    </div> -->
  </div>
</template>
<script>
import { permission } from "@/utils/directivePage";
import { getSubjectGoodsAndInfoPreview, getType } from "@/api/buildTeam";
import dayjs from "dayjs";
const paymentPatternType = {
  0: "按月",
  1: "按学期",
  2: "一次性"
};
import Tips from "./tips";
import courseModel from "@/views/resetTeaming/modals/courseModel";
import InstrumentModel from "./instrumentModel";
import accessories from "./accessories";
import activity from "./activity";
import member from "./member";
export default {
  props: ["subjectId", "calenderId", "preViewData"],
  components: {
    Tips,
    courseModel,
    InstrumentModel,
    accessories,
    activity,
    member
  },
  data() {
    const query = this.$route.query;
    return {
      videoStatus: false,
      trainBg: require("../../../assets/images/musicGroup/yunTrain_bg.png"),
      trainSmallBg: require("../../../assets/images/musicGroup/yunTrain_small_bg.png"),
      musicGroupId: query.id,
      organId: null,
      result: {}, // 返回结果
      instrument: {}, // 乐器类型
      baseInfo: {}, // 其它类
      money: 580,
      balance: 0, // 余额
      needPrice: 0, // 还需支付
      payType: false, // 是否余额支付
      cloudTeacherFee: 0, // 云教练费用
      cloudTeacherPlusFee: 0, // 云教练+
      orderInfo: {
        marketPrice: 0,
        amount: 0, // 现价总金额
        groupPurchasePrice: 0, // 现价
        goodsGroupIds: null,
        goodsIds: null,
        contractGoodsIds: null, // 选中所有商品ID
        couponPrice: 0, //
        musicClassFee: 0, // 课程现价
        musicMarketClassFee: 0, // 课程原价
        accessPrice: 0, // 辅件现价
        accessMarketPrice: 0, // 辅件原价
        goodsPrice: 0, // 乐器现价
        goodsMarketPrice: 0 // 乐器原价
      }, // 金额列表，金额计算
      toolsPackage: [], // 学习工具包
      instrumentRepair: [], // 乐保信息
      activityList: [], // 小班课信息
      courseInfo: [], // 课程信息
      courseShowInfo: [], // 课程信息显示用
      musicGroupSubject: null, // 基本信息
      instrumentResult: [], //乐器
      accessOries: [], // 辅件(打包)
      agreeStatus: true,
      authStatus: false,
      ids: [],
      instrumentResultList: [],
      chargeTypeId: null,
      paymentStatus: null,
      paymentPattern: null,
      serviceValidDate: null, // 服务时间
      courseShowStatus: false,
      chargeTypeList: [],
      chargeTypeName: null,
      courseViewType: 0, // 收费模式，0 课程显示，1 AMR系统 2会员
      leBaoStatus: false,
      buyMaintenance: false, // 是否开启乐保
      isClickStatus: false,
      accessStatus: false, // 是否有辅件乐保
      accessIsShowStatus: false, // 是否显示辅件 true 显示， false 不显示
      memberCoursePrice: [], // 云教练，显示赠送的课程
      memberCourseShowFlag: false, // 是否显示赠送课程
      buyCloudTeacher: false, // 是否购买云教练
      remissionCourseFeeStatus: false,
      isGiveAccessories: false, // 是否赠送辅件
      giveAccessoriesStatus: false,
      mypreViewData: {
        isShowMemberForPay: true,
        isShowMusicInsuranceForPay: true,
        isShowVipCourseForPay: true,
        isShowMusicCourseForPay: true
      },
      isShowSalePrice: true // 是否显示原价
    };
  },
  mounted() {
    this.__init();
  },
  methods: {
    async __init() {
      // 获取数据
      let params = {
        musicGroupId: this.musicGroupId,
        subjectId: this.subjectId,
        calenderId: this.calenderId
      };
      await getSubjectGoodsAndInfoPreview(params).then(res => {
        let result = res;
        if (result.code == 200) {
          let tempResult = result.data;
          this.__dataFormat(tempResult);
        }
        // 初始化计算金额
        this.calcPrice();
      });
    },
    __dataFormat(tempResult) {
      this.mypreViewData =
        this.preViewData && this.preViewData.paymentCalender
          ? JSON.parse(JSON.stringify(this.preViewData))
          : {
              isShowMemberForPay: true,
              isShowMusicInsuranceForPay: true,
              isShowVipCourseForPay: true,
              isShowMusicCourseForPay: true
            };

      this.courseViewType = tempResult.musicGroup.courseViewType || 0;
      this.isGiveAccessories =
        (tempResult.musicGroup && tempResult.musicGroup.isGiveAccessories) ||
        false; // 是否赠送辅件
      this.organId = tempResult.musicGroup.organId;
      const musicGroupStatus = tempResult.musicGroup.status;
      this.cloudTeacherFee = tempResult.cloudTeacherFee || 0;
      this.cloudTeacherPlusFee = tempResult.cloudTeacherPlusFee || 0;

      let memberCoursePrice = tempResult.memberCoursePrice || {};
      for (let i in memberCoursePrice) {
        this.memberCoursePrice.push({
          name: coursesType[i],
          price: memberCoursePrice[i]
        });
      }
      this.memberCourseShowFlag =
        tempResult.musicGroup.memberCourseShowFlag || false;

      this.paymentPattern = 2;
      if (tempResult.musicGroupPaymentCalender) {
        this.paymentPattern =
          tempResult.musicGroupPaymentCalender.paymentPattern;
        this.serviceValidDate =
          dayjs(
            tempResult.musicGroupPaymentCalender.paymentValidStartDate
          ).format("YYYY/MM/DD") +
          "~" +
          dayjs(
            tempResult.musicGroupPaymentCalender.paymentValidEndDate
          ).format("YYYY/MM/DD");
      }
      const paymentCalender =
        this.mypreViewData && this.mypreViewData.paymentCalender
          ? this.mypreViewData.paymentCalender
          : tempResult.paymentCalender || null;

      if (paymentCalender && paymentCalender.calender) {
        this.isShowSalePrice =
          paymentCalender.calender.isShowSalePrice || false;
        if (paymentCalender.calender.paymentItemShowState) {
          let obj = JSON.parse(paymentCalender.calender.paymentItemShowState);

          for (let key in obj) {
            this.mypreViewData[key] = obj[key];
          }
        }
      }

      let tempInfo =
        paymentCalender && paymentCalender.course ? paymentCalender.course : [];
      let memberPrivilegesItemList = tempResult.memberPrivilegesItemList
        ? tempResult.memberPrivilegesItemList
        : [];
      let tempMember = [];
      memberPrivilegesItemList.forEach(member => {
        if (
          member.memberPrivilegesItems &&
          member.memberPrivilegesItems.length > 0
        ) {
          member.memberPrivilegesItems.forEach(item => {
            tempMember.push(item.name);
          });
        }
      });
      // 云教练
      const member =
        paymentCalender && paymentCalender.member ? paymentCalender.member : {};

      member.isStatus = true;

      this.toolsPackage = member && !member.memberRankSettingId ? [] : [member];

      // 乐器保养
      const repair =
        paymentCalender && paymentCalender.repair ? paymentCalender.repair : {};
      repair.name = "乐器保养";
      repair.isStatus = true; // 默认不选择乐器保养

      this.instrumentRepair = Number(repair.actualAmount) ? [repair] : [];
      // 小班课
      const activity =
        paymentCalender && paymentCalender.activity
          ? paymentCalender.activity
          : [];
      activity.map(i => {
        i.isStatus = true;
      });
      this.activityList = [...activity];

      // 判断是否有课程
      if (tempInfo && tempInfo.length > 0) {
        // 默认课程都选中
        tempInfo.forEach(item => {
          // if (item && item.isStudentOptional) {
          // item.isStatus = false;
          // } else {
          item.isStatus = true;
          // }
        });
        this.courseInfo = tempInfo;
      }

      this.musicGroupSubject = tempResult.musicGroupSubjectPlan || [];
      let instrumentInfo = {};
      let tempInstrument = [];
      let musicGroupSubjectGoodsGroupList =
        this.preViewData?.payUserType == "SCHOOL" ||
        musicGroupStatus == "PROGRESS"
          ? []
          : tempResult.musicGroupSubjectGoodsGroupList;
      musicGroupSubjectGoodsGroupList?.forEach(item => {
        if (item.type == "INSTRUMENT") {
          // 获取乐器所有提供方式
          let KGPTJ = item.kitGroupPurchaseTypeJson
            ? JSON.parse(item.kitGroupPurchaseTypeJson)
            : {};
          for (let single in KGPTJ) {
            let tempItem = Object.assign({}, item); // 深拷贝
            tempItem.marketPrice = tempItem.goodsList[0].marketPrice;
            tempItem.kitType = single; // 优惠模式
            tempItem.coupon = KGPTJ[single]; // 优惠金额
            tempItem.discountPrice = tempItem.goodsList[0].discountPrice;
            if (instrumentInfo.id) {
              tempItem.isStatus = false;
              if (single == "GROUP") {
                // 团购
                if (
                  (instrumentInfo.kitType == "GROUP" &&
                    instrumentInfo.price < tempItem.price) ||
                  instrumentInfo.kitType == "LEASE" ||
                  instrumentInfo.kitType == "FREE"
                ) {
                  this.instrumentResult.forEach(instrRes => {
                    instrRes.isStatus = false;
                  });
                  tempItem.isStatus = true;
                  instrumentInfo = {
                    id: tempItem.id,
                    price: tempItem.price,
                    kitType: single,
                    groupRemissionCourseFee: tempItem.groupRemissionCourseFee
                  };
                }
              } else if (single == "LEASE") {
                // 租赁
                if (
                  instrumentInfo.kitType == "LEASE" &&
                  instrumentInfo.price < tempItem.price
                ) {
                  this.instrumentResult.forEach(instrRes => {
                    instrRes.isStatus = false;
                  });
                  tempItem.isStatus = true;
                  instrumentInfo = {
                    id: tempItem.id,
                    price: tempItem.price,
                    kitType: single,
                    groupRemissionCourseFee: tempItem.groupRemissionCourseFee
                  };
                }
              } else if (single == "FREE") {
                // 免费
                if (
                  instrumentInfo.kitType == "FREE" &&
                  instrumentInfo.price < tempItem.price
                ) {
                  this.instrumentResult.forEach(instrRes => {
                    instrRes.isStatus = false;
                  });
                  tempItem.isStatus = true;
                  instrumentInfo = {
                    id: tempItem.id,
                    price: tempItem.price,
                    kitType: single,
                    groupRemissionCourseFee: tempItem.groupRemissionCourseFee
                  };
                }
              }
            } else {
              tempItem.isStatus = true;
              instrumentInfo = {
                id: tempItem.id,
                price: tempItem.price,
                kitType: single,
                groupRemissionCourseFee: tempItem.groupRemissionCourseFee
              };
            }
            let childGoodsNameList = [];
            if (tempItem.childGoodsList && tempItem.childGoodsList.length > 0) {
              tempItem.childGoodsList.forEach(child => {
                if (child.type != "INSTRUMENT" && child.type != "OTHER") {
                  childGoodsNameList.push(child.name);
                }
              });

              tempItem.childGoodsNames = childGoodsNameList.join("、");
            }
            this.instrumentResult.push(tempItem);
            tempInstrument.push(tempItem);
          }
        } else if (item.type == "ACCESSORIES") {
          item.isStatus = true;
          this.accessOries.push(item);
        }
      });
      // 添加自备选项
      if (this.instrumentResult.length > 0) {
        let sorted = this.groupBy(tempInstrument, item => {
          return [item.kitType];
        });
        this.instrumentResultList = sorted;

        // 设置是否有减免金额
        this.instrumentGetStatus();
        this.setLeBaoStatus();
      }
      // 如果选择的是乐保，则把所有辅件价格设置为0
      this.giveAccessoriesSetStatus();

      // 初始化计算金额
      this.calcPrice();
    },
    groupBy(array, f) {
      var groups = {};
      array.forEach(function(o) {
        var group = JSON.stringify(f(o));
        groups[group] = groups[group] || [];
        groups[group].push(o);
      });
      return Object.keys(groups).map(function(group) {
        return groups[group];
      });
    },
    onQuestions(type) {
      if (type == "amr") {
        this.$alert(
          `<b>革命性的“AMR器乐练习系统”</b><br />它的诞生是基于世界上最优秀的华人管乐指导专家唐嘉宏先生的教育理念，创新开发的一种新型“音乐感官植入程序”，这个程序抛弃了传统的“数线式识谱、机械式节奏、死记式乐理”，它营造出沉浸式可变速演奏过程，采用画面与音乐刺激序列组合而成的特定场景，在趣味性挑战的反复刺激中逐步促进器乐演奏的三核心：“音质→音准→音型”，从而达成演奏各环节水准的均匀提高，产生永久性条件反射式大脑记忆，将多板块知识融会贯通，让抽象的音乐知识刻入脑海里！<br /><br /><b>本练习系统的特点：</b><br /> 1.轻松快速掌握要点，让练习者沉浸其中，远离枯燥！<br /> 2.不假思索就能瞬间唤起反射式记忆，演奏识谱不再慢吞吞！<br /> 3.真正的实践记忆，摆脱纸上谈兵，与实际演奏紧密结合！<br />4.思维+肌肉的双重强化！无缝整合复习系统！<br /> 5.每条练习都经过严谨的编曲，你以为你只是在练习旋律线？其实是整个乐团在为你伴奏！`,
          "AMR器乐练习系统",
          {
            confirmButtonText: "确定",
            dangerouslyUseHTMLString: true,
            callback: action => {}
          }
        );
      } else if (type == "instrument") {
        this.$alert(
          `<p style="text-align: justify">1.乐器保养是管乐迷针对乐团学员提供的乐器检查、保养及维修优惠特权；<br />2.该特权为包年制，从开通特权之日起365天内有效；<br />3.特权用户可享受管乐迷提供专业的高级乐器维修技师一年不低于两次下校检查乐器使用情况；<br />4.特权有效期内凭该特权绑定的乐器编号可享受保养人工费减免、非返厂维修人工费优惠等特权;<br />感谢您的信任和支持！</p>`,
          "乐器保养特权",
          {
            confirmButtonText: "确定",
            dangerouslyUseHTMLString: true,
            callback: action => {}
          }
        );
      }
    },
    onCheckItem(item, type) {
      // 默认选中不可改
      if (item.optionalFlag) return;
      // 判断乐保是否可选
      if (item.noSelect) return;
      // 如果选择的是乐器先把所有选中的取消
      if (type == "INSTRUMENT") {
        this.instrumentResultList.forEach(group => {
          group.forEach(child => {
            if (
              child.id != item.id ||
              (child.id == item.id && child.kitType != item.kitType)
            ) {
              child.isStatus = false;
            }
          });
        });
      }
      item.isStatus = !item.isStatus;
      if (type == "train") {
        // 如果选择的是乐保，则把所有辅件价格设置为0
        this.giveAccessoriesSetStatus();
      }
      // 设置是否有减免金额
      this.instrumentGetStatus();
      // 重新设置乐保状态
      this.setLeBaoStatus();
      // 重新计算金额
      this.calcPrice();
    },
    giveAccessoriesSetStatus() {
      let status = false; // 是否有选中云教练
      this.toolsPackage.forEach(item => {
        if (item.isStatus) {
          status = true;
        } else {
          status = false;
        }
      });
      this.giveAccessoriesStatus = this.isGiveAccessories && status;
    },
    instrumentGetStatus() {
      let childItem = {};
      this.instrumentResultList.forEach(group => {
        group.forEach(child => {
          if (child.isStatus) {
            childItem = child;
          }
        });
      });
      this.remissionCourseFeeStatus =
        childItem.kitType == "GROUP" && childItem.groupRemissionCourseFee == 1
          ? true
          : false;
    },
    setLeBaoStatus() {
      // 设置乐保状态
      let status = false; // 是否有选中乐器
      this.instrumentResultList.forEach(group => {
        group.forEach(item => {
          if (item.isStatus) {
            status = true;
          }
        });
      });

      this.instrumentRepair.forEach(repair => {
        if (status) {
          repair.noSelect = false;
        } else {
          repair.noSelect = true;
          repair.isStatus = false;
        }
      });
      this.$forceUpdate();
    },
    calcPrice() {
      let ids = [];
      let amount = 0,
        marketPrice = 0,
        goodsPrice = 0, // 乐器两现价
        goodsMarketPrice = 0, // 乐器原价
        goodsGroupIds = {},
        courseKeys = [],
        couponPrice = 0, // 优惠金额
        goodsIds = [],
        buyCalenderActivityId = [], // 小班课
        tempCourseFee = 0,
        musicClassFee = 0,
        tempAccessPrice = 0,
        tempAccessMarketPrice = 0,
        tempGroupRemissionCourseFee = 0, // 乐团减免费用
        contractGoodsIds = ""; // 合同所需要的商品Id （只需要乐器编号）
      // 课程
      let mgs = this.musicGroupSubject;
      let csi = this.courseInfo;
      // 加上判断是否有课程信息
      if (mgs) {
        csi.forEach(item => {
          if (item.isStatus) {
            musicClassFee += parseFloat(item.courseCurrentPrice);
            // if (this.courseViewType != 2) {
            // }
            if (item.id > 0) {
              courseKeys.push(item.id);
            }
            // 不可选的课程才会减免课程费用
            if (!item.isStudentOptional) {
              tempGroupRemissionCourseFee += parseFloat(
                item.courseCurrentPrice
              );
            }
            marketPrice += parseFloat(item.courseOriginalPrice);
            //  else {
            //   marketPrice += parseFloat(item.courseCurrentPrice);
            // }
            // if (this.courseViewType == 0 && !item.isStudentOptional) {
            //   marketPrice += parseFloat(item.courseCurrentPrice);
            // }
          }
        });
      }

      // 云教练
      const toolsPackage = this.toolsPackage;
      if (toolsPackage.length > 0) {
        toolsPackage.forEach(item => {
          if (item.isStatus) {
            this.buyCloudTeacher = true; // 临时处理，原因一条数据事要使用，如果多条数据会有问题
            marketPrice += parseFloat(item.originalAmount);
            amount += parseFloat(item.actualAmount);
          } else {
            this.buyCloudTeacher = false;
          }
        });
      }

      // 乐器
      let ir = this.instrumentResult;
      if (ir.length > 0) {
        ir.forEach(item => {
          if (item.isStatus) {
            if (item.name != "自备乐器") {
              contractGoodsIds += item.goodsIdList;
            }
            if (item.kitType == "FREE") {
              amount += 0;
              couponPrice = 0; // 优惠金额
            } else if (item.kitType == "LEASE") {
              couponPrice = item.coupon; // 优惠金额
              if (item.name != "自备乐器") {
                amount += item.depositFee;
                goodsPrice += item.depositFee;
              } else {
                amount += 0;
              }
            } else if (item.kitType == "GROUP") {
              // 团购
              if (
                this.courseViewType == 2 &&
                this.organId == 55 &&
                !this.toolsPackage[0].isStatus
              ) {
                amount += parseFloat(item.discountPrice);
                goodsPrice += parseFloat(item.discountPrice);
                couponPrice = item.coupon ? item.coupon : 0;
              } else {
                amount += parseFloat(item.price);
                goodsPrice += parseFloat(item.price);
                couponPrice = item.coupon ? item.coupon : 0;
              }
            }
            if (item.kitType == "LEASE") {
              if (item.name != "自备乐器") {
                marketPrice += parseFloat(item.marketPrice);
                goodsMarketPrice += item.depositFee;
              }
            } else {
              marketPrice += parseFloat(item.marketPrice);
              goodsMarketPrice += parseFloat(item.marketPrice);
            }
            // item.id ? goodsGroupIds[item.id] : null
            if (item.id) {
              goodsGroupIds[item.id] = item.kitType;
            }

            // 是否减免课程费用，必须团购，并且开启了减免课程费用
            if (item.kitType == "GROUP" && item.groupRemissionCourseFee == 1) {
              musicClassFee = parseFloat(
                musicClassFee - tempGroupRemissionCourseFee
              );
            }
          }
        });
      }

      // 乐器保养
      const instrumentRepair = this.instrumentRepair;
      if (instrumentRepair.length > 0) {
        instrumentRepair.forEach(item => {
          if (item.isStatus) {
            this.buyMaintenance = true;
            marketPrice += item.originalAmount;
            amount += parseFloat(item.actualAmount);
          } else {
            this.buyMaintenance = false;
          }
        });
      }

      amount += parseFloat(tempCourseFee + musicClassFee);

      // 辅件
      if (this.accessOries.length > 0) {
        this.accessOries.forEach(item => {
          //  && this.accessIsShowStatus
          if (item.isStatus) {
            tempAccessPrice += this.giveAccessoriesStatus
              ? 0
              : parseFloat(item.price);
            amount += this.giveAccessoriesStatus ? 0 : parseFloat(item.price);
            if (item.goodsList && item.goodsList.length > 0) {
              item.goodsList.forEach(childGoods => {
                tempAccessMarketPrice += parseFloat(childGoods.marketPrice);
                marketPrice += parseFloat(childGoods.marketPrice);
              });
            }
            goodsGroupIds[item.id] = "ACCESSORIES";
          }
        });
      }

      // 小班课
      const activityList = this.activityList;
      if (activityList.length > 0) {
        activityList.forEach(item => {
          if (item.isStatus) {
            buyCalenderActivityId.push(item.id);
            marketPrice += item.originalAmount;
            amount += parseFloat(item.actualAmount);
          }
        });
      }

      let tempGroupPurchasePrice = amount;
      this.payCountMoney = amount;
      // 判断减去优惠金额，是否大于0(这里有可能出现负数)

      this.ids = ids;
      this.needPrice = Number(amount.toFixed(2));
      this.orderInfo = {
        amount: Number(amount.toFixed(2)),
        marketPrice: Number(marketPrice.toFixed(2)),
        groupPurchasePrice: tempGroupPurchasePrice,
        couponPrice: couponPrice,
        goodsGroupIds: goodsGroupIds,
        goodsIds: goodsIds.join(","),
        contractGoodsIds: contractGoodsIds,
        buyCalenderActivityId,
        courseKeys: courseKeys,
        musicClassFee: musicClassFee,
        accessMarketPrice: tempAccessMarketPrice,
        accessPrice: tempAccessPrice,
        goodsPrice: goodsPrice,
        goodsMarketPrice: goodsMarketPrice
      };
    },
    permission(str) {
      return permission(str);
    }
  }
};
</script>
<style lang="less" scoped>
@import url("./signUpPayment.less");
</style>
