Newer
Older
VueSharedPrinting / src / views / pay.vue
hanfei on 22 Jan 2024 4 KB han
<template>
<!--支付确认-->
  <div class="pay">
    <navbar :name="name"/>
    <div class="box">
      <div class="flex-start name">
        <img src="../assets/demo11.png" alt="">
        <span>文件 x{{selectedFile.length}}</span>
      </div>
      <div class="info flex-start">{{ parameter.specification }},{{ parameter.printingColor=='BW'?'黑白':'彩色' }},{{ parameter.printingFaces=='SINGLE'?'单面':'双面' }},{{ parameter.copies }}份</div>
    </div>
    <div class="box2 flex-between">
      <div class="flex-start price">
        <span>费用合计:</span>
        <div>¥{{ price }}</div>
      </div>
      <div class="flex-center btn" @click="skip('expense',name)">确认支付</div>
    </div>
  </div>
</template>

<script>
import navbar from "@/components/nav";
import {getPrintPrice,submitPrintingTask} from "../api/resultApi";

export default {
  name: "pay",
  components: {
    navbar
  },
  provide() {
    return {
      title: '支付',
      type: this.name
    }
  },
  data() {
    return {
      name: this.cite.modeName,
      facility: this.cite.facility,
      selectedFile: this.cite.selectedFile,
      parameter: this.cite.parameter,
      price: 0,
    }
  },
  methods: {
    async submitPrintingTask() {
      let _this = this
      let {parameter,facility,selectedFile} = _this
      let taskList = []
      selectedFile.forEach(item => {
        taskList.push({
          printType: 'DocumentPrinting',
          copies: parameter.copies,
          printDirection: 'VERTICAL',
          printingColor: parameter.printingColor,
          printingFaces: parameter.printingFaces,
          fileId: item.id,
        })
      })
      let data = {
        deviceId: facility.id,
        payMode: 'WX_NATIVE_PAY',
        taskList: taskList,
      }
      let res = await submitPrintingTask(data)
      _this.cite.orderId = res
    },
    async skip(href,name) {
      await this.submitPrintingTask()
      this.$router.push({
        name: href,
        params: {
          name: name
        }
      })
    },
    async getPrintPrice(id) {
      let _this = this
      let {parameter,facility} = _this
      let data = {
        deviceId: facility.id,
        printType: 'DocumentPrinting',
        copies: parameter.copies,
        printDirection: 'VERTICAL',
        printingColor: parameter.printingColor,
        printingFaces: parameter.printingFaces,
        fileId: id,
      }
      let res = await getPrintPrice(data)
      _this.price = parseFloat(res)+_this.price
    },
    load() {
      let {selectedFile} = this
      selectedFile.forEach(item => {
        this.getPrintPrice(item.id)
      })
    },
  },
  mounted() {
    this.load()
  }
}
</script>

<style scoped lang="less">
.pay {
  .css1 {
    width: 105.43rem;
    background: #FFFFFF;
    box-shadow: 0rem 0.31rem 0.63rem 0.06rem rgba(0,0,0,0.14);
    border-radius: 1.63rem;
    margin: 0 auto;
    padding: 0 2.69rem;
  }
  .box {
    height: 23rem;
    .css1();
    margin-bottom: 2.5rem;
    .name {
      font-size: 2.13rem;
      font-weight: bold;
      color: #323232;
      line-height: 3rem;
      padding: 3.25rem 0 2.56rem;
      img {
        width: 3.66rem;
        margin-right: 1.63rem;
      }
    }
    .info {
      width: 97.94rem;
      height: 9.44rem;
      background: #F6F6F6;
      border-radius: 1.63rem;
      font-size: 2.13rem;
      font-weight: bold;
      color: #989898;
      line-height: 3rem;
      padding: 0 3.75rem;
    }
  }
  .box2 {
    height: 12.44rem;
    .css1();
    .price {
      font-size: 2.13rem;
      font-weight: bold;
      color: #323232;
      line-height: 3rem;
      align-items: flex-end;
      div {
        font-size: 4.13rem;
        font-weight: bold;
        color: #D51919;
        line-height: 5rem;
        margin-left: 3rem;
      }
    }
    .btn {
      width: 51.13rem;
      height: 5.5rem;
      background: linear-gradient(132deg, #52A39D 0%, #A1C553 50%, #81D012 100%);
      border-radius: 1.25rem;
      font-size: 1.88rem;
      font-weight: 400;
      color: #FFFFFF;
      line-height: 2.63rem;
    }
  }
}
</style>