<template> <!--支付确认--> <div class="pay"> <navbar :name="name" /> <div :class="['box', { 'vertical-box-width': isVertical }]"> <div class="flex-start name"> <img src="../assets/demo11.png" alt="" /> <span>文件 x{{ selectedFile.length }}</span> </div> <div :class="['info', 'flex-start', { 'vertical-box-width0': isVertical }]"> {{ parameter.specification }},{{ parameter.printingColor == 'BW' ? '黑白' : '彩色' }},{{ parameter.printingFaces == 'SINGLE' ? '单面' : '双面' }},{{ parameter.copies }}份 </div> </div> <div :class="['box2', 'flex-between', { 'vertical-box-btn': isVertical }]"> <div class="flex-start price" v-if="price != ''"> <span>费用合计:</span> <div>¥{{ price }}</div> </div> <span v-else>文件正在处理中,请稍后!</span> <div class="flex-center btn" @click="skip('expense', name)">确认支付</div> </div> </div> </template> <script> import navbar from '@/components/nav' import { getPrintPrice } from '../api/resultApi' import alert from "@/utils/alert"; // 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: '', num: 0, isVertical: false } }, 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', payMode: 'WX_JS_PAY', taskList: taskList } _this.cite.printData = data // let res = await submitPrintingTask(data) // _this.cite.orderId = res }, async skip(href, name) { if (this.num > 0) { this.cite.state = { name: '加载中,请稍后!', sta: true } return } 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).catch(error => {alert(error,this)}) if (_this.price == '') { _this.price = 0 } _this.price = (parseFloat(res * 1000) + _this.price * 1000) / 1000 _this.num = _this.num - 1 }, load() { let { selectedFile } = this this.num = selectedFile.length selectedFile.forEach(item => { this.getPrintPrice(item.id) }) } }, created() { this.isVertical = this.cite.isVertical }, mounted() { this.price = '' 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; } } } .vertical-box-width { width: 87% !important; } .vertical-box-width0 { width: auto !important; } .vertical-box-btn { width: 87% !important; height: 14.44rem !important; padding: 2rem 2.69rem !important; flex-direction: column !important; } </style>