<style lang="scss" scoped>

</style>
<template>
    <div>
          <div
            class="rounded-borders bg-white q-py-md"
            style="width: 300px"
            :style="{
              width:$q.platform.is.mobile
                  ? 'unset'
                  : '300px',
              position:$q.platform.is.mobile?'unset':'sticky',
              top:$q.platform.is.mobile?'unset':'50px',
            }"
          >
            <!-- <div class="text-subtitle1 text-weight-bolder">付款明細</div> -->
            <!-- <q-separator color="grey-2" class="q-my-md"/> -->
              <!-- <hr
                style="border: none; border-top: 1px dashed #eee !important"
                class="bg-transparent q-mb-sm"
              /> -->
              <div class="row q-mb-sm items-center">
                <div class="q-mr-lg">總金額</div>
                <div class="text-subtitle2 text-weight-bolder">
                  CNY {{sumPrice }}
                </div>
              </div>
              <hr style="border:none;" class="bg-transparent q-mb-sm" />
              <div class="row q-mb-sm items-center" v-if="MailingState==2&&MailingMoney>0">
                <div class="q-mr-lg">邮寄费</div>
                <div
                  class="text-subtitle2 text-weight-bolder text-grey-6"
                >
                  CNY  {{ MailingMoney }}
                </div>
              </div>
              <div class="row q-mb-sm items-center">
                <div class="q-mr-lg">優惠金額</div>
                <div
                  class="text-subtitle2 text-weight-bolder text-teal"
                  v-if="DiscountsMoney > 0"
                >
                  CNY - {{ DiscountsMoney }}
                </div>
                <div class="text-grey-5" v-else>暫無優惠</div>
              </div>
              <!-- <div class="row q-mb-sm items-center">
                <div class="col">支付金額</div>
                <div class="text-h6 text-weight-bolder text-primary product-price">
                  CNY {{ Money }}
                </div>
              </div> -->
            </div>
          </div>
    </div>
</template>
<script>
export default {
    props: {
        orderInfo: {
            type: Object,
            default: () => ({})
        }
    },
    data() {
      return {
        details: null,
      sumPrice: 0,//总金额
      DiscountsMoney: 0,//优惠金额
      Money: 0, // 支付金額
      MailingMoney: 0, // 邮寄费
      MailingState: '',//邮寄状态 1自取 2邮寄
      }
    },
    mounted() {
        this.getData()
        this.getOrder()
    },
    methods: {
      // 获取商品详情
      getData() {
        this.$q.loading.show();
        this.apipost("b2c_get_GetTicketCouponsDetail",
        { CouponsId: this.orderInfo.GoodsId },
          (r) => {
            if (r.data.resultCode == 1) {
              this.details = r.data.data;
            } else {
              this.$q.notify({
                type: "negative",
                message: r.data.message,
                position: "top",
                timeout: 2000, // 以毫秒为单位; 0意味着没有超时
              });
            }
            this.$q.loading.hide();
          },
          null
        );
      },
    getOrder() {
      // http://dev.api.oytour.com/#/home/project/inside/api/detail?groupID=703&childGroupID=710&apiID=4256&projectName=REBORN&projectID=2
      this.$q.loading.show();
      this.apipost(
        "ticket_post_GetSaleTicketOrderInfo",
        { OrderId: this.orderInfo.ErpOrderId },
        (r) => {
          if (r.data.resultCode == 1) {
            this.dataList = r.data.data;
            const {DiscountsMoney,MailingMoney,MailingState,Money} = r.data.data;
            
      // sumPrice: 0,//总金额
      // DiscountsMoney: 0,//优惠金额
      // Money: 0, // 支付金額
      // MailingMoney: 0, // 邮寄费
      // MailingState: '',//邮寄状态 1自取 2邮寄
            this.Money = Money;
            this.DiscountsMoney = DiscountsMoney
            this.MailingMoney = MailingMoney;
            this.MailingState = MailingState;
            this.sumPrice = Money + MailingMoney + DiscountsMoney
            this.sumPrice = this.moneyFormat(this.sumPrice, 2)
            this.Money = this.moneyFormat(this.Money, 2)
            this.DiscountsMoney = this.moneyFormat(this.DiscountsMoney, 2)
            this.MailingMoney = this.moneyFormat(this.MailingMoney, 2)
          } else {
            this.$q.notify({
              type: "negative",
              message: r.data.message,
              position: "top",
              timeout: 2000, // 以毫秒为单位; 0意味着没有超时
            });
          }
          this.$q.loading.hide();
        },
        null
      );
    
    },
    emitAddress() {
      const {PlaceList} = this.dataList
            PlaceList.findItem(item => item.id === this.id)
            this.$emit('address', this.dataList)
    }
    }
}
</script>