12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250 |
- <template>
- <el-dialog
- title="添加观影人"
- :visible.sync="dialogVisible"
- width="90%"
- :before-close="handleClose">
- <div
- v-loading="loading"
- :element-loading-text="loadingText"
- element-loading-spinner="el-icon-loading"
- element-loading-background="rgba(0, 0, 0, 0.8)"
- class="increase-viewers-box">
- <div class="increase-viewers-info">
- <el-table
- :data="viewerList"
- border
- style="width: 100%">
- <el-table-column
- label="序号"
- type="index"
- width="50">
- </el-table-column>
- <el-table-column
- label="姓名"
- width="180">
- <template slot-scope="scope">
- <div>
- <span v-if="actionIndex != scope.row.id">{{ scope.row.name }}</span>
- <el-input size="mini" v-else v-model="tableForm.name" placeholder="请输入姓名"></el-input>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- label="身份证号"
- width="250">
- <template slot-scope="scope">
- <div>
- <span v-if="actionIndex != scope.row.id">{{ scope.row.idcard }}</span>
- <el-input
- size="mini"
- v-else
- v-model="tableForm.idcard"
- placeholder="请输入身份证号"
- clearable
- style="width: 230px;"
- @keyup.enter.native="handleQuery"
- >
- <el-button slot="append" :loading="idcardLoading" size="mini" type="primary" @click="readCert">{{ idcardLoading ? '识别中':'识别' }}</el-button>
- </el-input>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- label="座位类型">
- <template slot-scope="scope">
- <span>{{ scope.row.seatTypeName }}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="date"
- label="座位号">
- <template slot-scope="scope">
- <span>{{ scope.row.seatName }}</span>
- </template>
- </el-table-column>
- <el-table-column
- prop="date"
- label="价格(元)">
- <template slot-scope="scope">
- <span>{{ scope.row.salePrice }}</span>
- </template>
- </el-table-column>
- <el-table-column
- label="人员类别"
- width="140">
- <template slot-scope="scope">
- <div>
- <dict-tag v-if="actionIndex != scope.row.id" :options="dict.type.personnel_type" :value="scope.row.identity"/>
- <el-select
- size="mini"
- v-else
- v-model="tableForm.identity"
- placeholder="请选择人员类别"
- clearable
- style="width: 100%"
- >
- <el-option
- v-for="dict in dict.type.personnel_type"
- :key="dict.value"
- :label="dict.label"
- :value="dict.value"
- />
- </el-select>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- label="应收金额(元)">
- <template slot-scope="scope">
- <span v-if="(scope.$index!=0 && oneMany ==1 && personnelNum != 0)">{{ scope.row.realPrice }}</span>
- <div v-else>
- <span v-if="actionIndex != scope.row.id">{{ scope.row.realPrice }}</span>
- <el-input-number size="mini" style="width: 120px;" v-else v-model="tableForm.realPrice" controls-position="right" label="请输入应收金额(元)"></el-input-number>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- label="备注"
- width="180">
- <template slot-scope="scope">
- <div>
- <span v-if="actionIndex != scope.row.id">{{ scope.row.remark }}</span>
- <el-input size="mini" v-else v-model="tableForm.remark" placeholder="请输入备注"></el-input>
- </div>
- </template>
- </el-table-column>
- <el-table-column
- label="操作"
- width="80"
- >
- <template slot-scope="scope" v-if="(scope.$index != 0 && oneMany!=2) || scope.$index == 0">
- <el-button
- size="mini"
- type="success"
- :loading="factorAuthLoading"
- v-if="actionIndex == scope.row.id"
- @click="handleSeva(scope.$index, scope.row)">{{ factorAuthLoading ? '保存中....' : '保存' }}</el-button>
- <el-button
- :disabled="!!actionIndex"
- size="mini"
- type="primary"
- v-if="actionIndex != scope.row.id"
- @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
- <!-- <el-button
- size="mini"
- type="danger"
- @click="handleDelete(scope.$index, scope.row)">删除</el-button> -->
- </template>
- </el-table-column>
- </el-table>
- </div>
- <div style="padding: 10px 0 20px;">合计:累计观影人员{{ viewerList.length }}人,应收总额¥{{ moneyAll }}(元)</div>
- <div>
- <el-form
- :model="ruleForm"
- :rules="rules"
- ref="ruleForm11"
- label-width="120px"
- class="demo-ruleForm"
- size="mini"
- >
-
- <div style="display: flex;">
- <el-form-item label="用户来源 :" prop="source">
- <el-radio-group @input="selectMarketTeamBySourceFun" v-model="ruleForm.source">
- <el-radio label="7">窗口</el-radio>
- <el-radio label="10">美团</el-radio>
- <el-radio label="11">携程</el-radio>
- <el-radio label="13">抖音</el-radio>
- <el-radio label="14">猫眼</el-radio>
- <el-radio label="18">大麦</el-radio>
- <el-radio label="19">飞猪</el-radio>
- <!-- <el-radio label="15">去哪儿</el-radio> -->
- <el-radio label="16">其他</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label-width="60px" v-if="ruleForm.source && ruleForm.source == 16" label="备注 :" prop="sourceRemark">
- <el-input style="width: 200px;" v-model="ruleForm.sourceRemark"></el-input>
- </el-form-item>
- </div>
- <el-form-item v-if="ruleForm.source && ruleForm.source != 7" label="核销码/订单码" prop="orderIdOrQrCode">
- <el-input style="width: 400px;" type="textarea" :rows="2" v-model="ruleForm.orderIdOrQrCode"></el-input>
- </el-form-item>
- <el-form-item label="支付方式 :" prop="paymentType">
- <el-radio-group v-model="ruleForm.paymentType">
- <el-radio label="1">扫码</el-radio>
- <el-radio label="2">现金</el-radio>
- <!-- <el-radio v-if="['10','11','13','14','18','19'].includes(ruleForm.source)" label="3">对公支付</el-radio> -->
- <el-radio v-if="['10','11','13','14','18','19'].includes(ruleForm.source)" label="4">账户余额({{ balance }})</el-radio>
- <el-radio v-if="['10','11','13','14','18','19'].includes(ruleForm.source)" label="5">授信余额({{ grantQuota }})</el-radio>
- </el-radio-group>
- </el-form-item>
- <el-form-item label="应收金额 :">
- ¥{{ moneyAll }}元
- </el-form-item>
- <!-- <el-form-item label="找零计算(注:只用于找零不提交数据 找零金额 = 收到金额 - 实收金额)" v-if="ruleForm.paymentType == 2 || ruleForm.paymentType == 3" label-width="480px"></el-form-item> -->
- <el-form-item v-if="ruleForm.paymentType == 2 || ruleForm.paymentType == 3" label="收取现金 :" prop="realPrice_1">
- <el-input @input="setRealPrice_1" style="width: 200px;" v-model="ruleForm.realPrice_1"></el-input>
- <span>元</span>
- </el-form-item>
- <el-form-item label="找零金额 :" v-if="ruleForm.paymentType == 2">
- ¥{{ ruleForm.small }}元
- </el-form-item>
- <el-form-item v-if="ruleForm.paymentType == 2 || ruleForm.paymentType == 3" label="实收金额 :" prop="realPrice">
- <el-input @input="setRealPrice" style="width: 200px;" v-model="ruleForm.realPrice"></el-input>
- <span>元</span>
- </el-form-item>
- <el-form-item label="订单备注 :" prop="remark">
- <el-input style="width: 400px;" type="textarea" :rows="2" maxlength="200" v-model="ruleForm.remark" show-word-limit></el-input>
- </el-form-item>
- </el-form>
- </div>
- <!-- 支付过程 控制 -->
- <div v-if="payStatus" class="increase-viewers-pay-status">
- <div class="increase-viewers-pay-status-info" v-if="!loading">
- <span style="font-weight: 600;font-size: 20px;">提示</span>
- <span style="padding: 10px 0;">
- {{ payStatus==1 ? '生成订单失败!!!' :
- payStatus==2 ? '生成订单生成成功,请点击调取扫码盒子' :
- payStatus==4 ? '扫码支付失败!!!' :
- payStatus==5 ? '请出示付款码!!!' :
- payStatus==5.5 ? '扫码成功,支付中...' :
- payStatus==5.6 ? '扫码成功,支付中...' :
- payStatus==6 ? '连接扫码器失败!!!' :
- payStatus==7 ? '用户支付失败或未支付,请重新连接支付!!!' :
- payStatus==8 ? '用户支付成功,请点击打印票!!!' :
- payStatus==9 ? '支付超时!!!' :
- payStatus==10 ? '订单已关闭,请重新选择座位,再购买!!!' :
- payStatus==3 ? '现金支付记录入库失败,请重新提交' : '未知状态' }}
- </span>
- <!-- 重新生成订单 1 -->
- <div v-if="payStatus==1" style="display: flex;">
- <el-button @click="payStatus = null" type="success">修改信息</el-button>
- <el-button @click="orderInfoSubmitFun()" style="margin-left: 20px;" type="primary">重新生成订单</el-button>
- </div>
- <!-- 扫码支付 2 -->
- <el-button v-if="payStatus==2" @click="vbar_open(orderId)" type="success">扫码支付</el-button>
- <!-- 扫码支付 4 -->
- <el-button v-if="payStatus==4" @click="vbar_open(orderId)" type="success">重新扫码支付</el-button>
- <!-- 重新支付 3 -->
- <el-button v-if="payStatus==3" @click="gotoCashPayFun(orderId)" type="success">重新提交入库</el-button>
- <!-- 重新支付 6 7 -->
- <el-button v-if="payStatus==6 || payStatus==7" @click="vbar_open(orderId)" type="success">重新连接扫码支付</el-button>
- <!-- 打印 8 -->
- <div v-if="payStatus==8">
- <el-select v-model="printListId" placeholder="选择打印机">
- <el-option :label="item.deviceName" :key="item.id" :value="item.id" v-for="(item,index) in printList"></el-option>
- </el-select>
- <el-button style="margin-left: 15px" @click="print" type="success">打印门票</el-button>
- <el-button style="margin-left: 15px" @click="goTicketingCollections" type="success">跳转取票界面</el-button>
- </div>
- <!-- 支付超时 9 -->
- <div v-if="payStatus==9">
- <!-- <el-button @click="print" type="danger">取消支付</el-button> -->
- <el-button @click="orderInfoSubmitFun()" type="primary">重新扫码</el-button>
- </div>
- <!-- 订单被关闭 10 -->
- <div v-if="payStatus==10">
- <!-- <el-button @click="print" type="danger">取消支付</el-button> -->
- <el-button @click="handleClose()" type="primary">关闭</el-button>
- </div>
- </div>
- </div>
- </div>
-
- <span slot="footer" class="dialog-footer">
- <el-button @click="handleClose()">取 消</el-button>
- <el-button v-if="!orderId&&!payStatus" :loading="loading" type="primary" @click="submitForm('ruleForm11')">确定支付</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- import {
- orderInfoSubmit,
- gotoMicroPay,
- gotoCashPay,
- gotoCorporatePay,
- gotoBalancePay,
- gotoQuotaPay,
- payQuery,
- selectRegion,
- orderInfoCancel,
- factorAuth,
- selectMarketTeamBySourceApi
- } from '@/api/windowTicketSales/ticketingSales'
- import { pageList as getPrintListApi } from "@/api/device/pda";
- import { printApi } from '@/api/windowTicketSales/ticketingCollection'
- const mathM = require('mathjs')
- const https = require('https');
- const axios = require('axios');
- export default {
- dicts: ['personnel_type'],
- data() {
- return {
- loading: false,
- loadingText: '',
- dialogVisible: false,
- actionIndex: false,
- tableForm: {
- name: '', // 姓名
- mobile: '', // 电话
- idcard: '', // 身份证
- identity: '', // 观影人身份
- remark: '', // 备注信息
- salePrice: '', // 原价
- realPrice: '', // 实收金额
- seatId: '', // 座位ID
- seatName: '', // 座位名称
- seatType: '', // 座位类型
- },
- ruleForm: {
- performId: "", // 剧目ID
- retailId: "", // 分销ID
- goodsList: [], // 商品列表
- auditoriumId: "", // 演出厅ID
- performTimeId: "1", // 场次时段ID
- seatTypeId: "", // 座位类型ID
- source: '', // 订单来源
- purchaser: {},// 购票人信息
- viewerList: [], // 观影人列表
- orderIdOrQrCode: '',
- paymentType: '', // 支付方式
- small: '',// 找零
- realPrice: '', // 实收金额
- },
- viewerList: [], // 观影人列表
- rules: {
- source: [
- { required: true, message: '请选择用户来源', trigger: ['blur','change']},
- ],
- orderIdOrQrCode: [
- { required: true, message: '请输入核销码/订单码', trigger: ['blur','change']},
- ],
- paymentType: [
- { required: true, message: '请选择支付方式', trigger: ['blur','change']},
- ],
- realPrice: [
- { required: true, message: '请输入实收金额', trigger: ['blur','change']},
- ],
- sourceRemark: [
- { required: true, message: '请输入备注', trigger: ['blur','change']},
- ],
- },
- moneyAll: '',
- payment: '',
- payStatus: null, // 支付状态
- orderId: null,
- websocket_connected: false, // 是否已连接
- websocketCtrl: null,
- websocketData: null,
- idcardLoading: false,
- payTime: null, // 支付等待时间
- payTimeNum: 0,
- printListId: null,
- printList: [],
- // 身份证校验 loading
- factorAuthLoading: false,
- ifRealUser: 0, // 散客是否实名:0-否 1-是
- ifRealTeam: 0, // 团购是否实名:0否 1-是
- oneMany: 1, // 证件要求: 1一证一票,2一证多票
- personnelNum: 0, // 人员要求:0-表示不限制 其他数字表示限制人数
-
-
- balance: null, // 授信额度
- grantQuota: null, // 授信使用额度
- code: '', // 支付code
- codeTime: null // 检测是websocket是否还在连接
- };
-
- },
- methods: {
- async initData(list,params){
- try {
- this.code = ''
- this.ifRealUser = params.ifRealUser // 散客是否实名:0-否 1-是
- this.ifRealTeam = params.ifRealTeam // 团购是否实名:0否 1-是
- this.oneMany = params.oneMany // 证件要求: 1一证一票,2一证多票
- this.personnelNum = params.personnelNum // 人员要求:0-表示不限制 其他数字表示限制人数
- this.websocketClear()
- this.idcardLoading = false
- this.ruleForm = {
- performId: params.performId, // 剧目ID
- retailId: "", // 分销ID
- goodsList: [
- {
- goodsId: params.goodsId,
- salePeice: params.salePrice,
- saleNum: 1,
- }
- ], // 商品列表
- auditoriumId: params.auditoriumId, // 演出厅ID
- performTimeId: params.timeId, // 场次时段ID
- seatTypeId: params.seatTypeId, // 座位类型ID
- source: '', // 订单来源
- purchaser: {},// 购票人信息
- viewerList: [], // 观影人列表
- orderIdOrQrCode: '',
- paymentType: '', // 支付方式
- small: '',// 实收金额
- realPrice: '', // 实收金额
- remark: '', // 订单备注
- sourceRemark: '', // 来源备注
- }
- this.payStatus = null
- this.orderId = null
- this.websocket_connected = false
- this.dialogVisible = true
- this.loading = true
- this.actionIndex = null
- this.viewerList = []
- let perform = await this.selectRegionFun(params,list[0].seatTypeId)
- console.log("perform===",perform)
- // let perform = {
- // money: params.salePrice,
- // //name: params.goodsName,
- // seatTypeId: params.seatTypeId,
- // seatTypeName: params.seatTypeName,
- // }
- let listCopy = []
- let listCopy1 = []
- list.forEach((item,index)=>{
- listCopy.push({
- id: index+1,
- name: '', // 姓名
- mobile: '', // 电话
- idcard: '', // 身份证
- identity: 0, // 观影人身份
- remark: '', // 备注信息
- salePrice: this.oneMany == 2 || (this.oneMany == 1 && this.personnelNum != 0) ? index == 0 ? perform.money : 0 : perform.money, // 原价
- realPrice: this.oneMany == 2 || (this.oneMany == 1 && this.personnelNum != 0) ? index == 0 ? perform.money : 0 : perform.money, // 实收金额
- seatId: item.id, // 座位ID
- seatName: item.name?item.name:'暂无命名', // 座位名称
- seatType: perform.seatTypeId, // 座位类型
- seatTypeId: perform.seatTypeId,
- seatTypeName: perform.seatTypeName,
- })
- })
- //this.goodsList =
- this.viewerList = JSON.parse(JSON.stringify(listCopy))
- this.setMoneyAll()
-
- console.log(this.viewerList)
- this.loading = false
- this.$nextTick(()=>{
- this.$refs.ruleForm11.clearValidate()
- })
- } catch (error) {
- console.error("error====",error)
- }
-
- },
- /** 获取票务信息 */
- async selectRegionFun(params,seatTypeId){
- try {
- this.loadingText = "获取票务信息中..."
- let res = await selectRegion({
- "auditoriumId": params.auditoriumId, // 演艺厅ID
- "goodsId": params.goodsId, // 商品ID
- "performId": params.performId, // 上一界面节目ID
- "performTimeId": params.timeId, // 时段ID
- "retailId": "" // 分销ID
- })
- if(res.code == 200) {
- if(res.data.regionPriceList &&res.data.regionPriceList.length>0){
- //let obj = res.data.regionPriceList[0]
- let obj = {}
- res.data.regionPriceList.forEach((item,index)=>{
- if(seatTypeId == item.seatTypeId) {
- obj = item
- }
- })
- if(JSON.stringify(obj) != '{}'){
- this.ruleForm.performId = obj.performId
- this.ruleForm.goodsList = [
- {
- goodsId: obj.goodsId,
- salePeice: obj.salePrice,
- saleNum: 1,
- }
- ]
- this.ruleForm.auditoriumId = obj.auditoriumId
- this.ruleForm.performId = obj.performId
- this.ruleForm.performTimeId = res.data.performTimeId
- this.ruleForm.seatTypeId = obj.seatTypeId
- return {
- money: obj.salePrice,
- //name: obj.goodsName,
- seatTypeId: obj.seatTypeId,
- seatTypeName: obj.seatTypeName,
- }
- }else {
- this.$message.error('存在座位未设置价格,请选择其他票!!!');
- this.loading = false
- this.dialogVisible = false
- }
-
- }else {
- this.$message.error('存在座位未设置价格,请选择其他票!!!');
- this.loading = false
- this.dialogVisible = false
- }
- console.log("res====",res)
- }else {
- this.$message.error(res.msg);
- this.loading = false
- this.dialogVisible = false
- }
- } catch (error) {
- console.error("error=====",error)
- this.$message.error('价格查询出错');
- this.loading = false
- this.dialogVisible = false
- }
- },
- /** 取消订单 */
- async orderInfoCancelFun(type){
- // let payStatus = this.payStatus
- // this.payStatus = null
- try {
- this.loading = true
- this.loadingText = "取消订单中..."
- orderInfoCancel({
- orderId: this.orderId
- }).then((res)=>{
- if(res.code==200) {
- if(type){ // 关闭弹窗
- if(this.codeTime) {
- clearInterval(this.codeTime)
- }
- this.orderId = null
- this.payStatus = null
- this.$emit('clearDialogVisible')
- this.dialogVisible = false
- }else {
- this.payStatus = 9
- this.loading = false
- }
-
- }else {
-
- }
- }).catch(()=>{
- this.$message.error('订单关闭失败!!!');
- })
- } catch (error) {
-
- }
- },
- /** 退出窗口 */
- handleClose(done) {
- // if(this.payStatus==8) {
- // this.$message.error('请daying');
- // return
- // }
- this.$confirm('确认关闭?')
- .then(_ => {
- if(this.orderId){
- document.removeEventListener('keydown',this.keydownAdd);
- this.orderInfoCancelFun(true)
- }else {
- this.dialogVisible = false
- }
- })
- .catch(_ => {});
- },
- /** 保存个人信息 */
- handleSeva(index, row) {
- if(!this.tableForm.name){
- this.$message.error('请输入姓名!!!');
- return
- }
- if(!this.tableForm.idcard){
- this.$message.error('请输入身份证号!!!');
- return
- }
- if(this.tableForm.identity && this.tableForm.identity != 0){
- if(!this.tableForm.remark){
- this.$message.error('请输入备注!!!');
- return
- }
- }
-
- //this.factorAuthFun(index,this.tableForm)
- if(this.oneMany == 2 && index==0) {
- this.$set(this.viewerList,index,JSON.parse(JSON.stringify(this.tableForm)))
- let list = JSON.parse(JSON.stringify(this.viewerList))
- list.forEach((item,index)=>{
- item.name = this.tableForm.name
- item.idcard = this.tableForm.idcard
- })
- this.viewerList = list
- }else {
- this.$set(this.viewerList,index,JSON.parse(JSON.stringify(this.tableForm)))
- }
- this.actionIndex = null
- this.setMoneyAll()
- },
- /** 校验 身份证 */
- async factorAuthFun(index, obj){
- try {
- this.factorAuthLoading = true
- let res = await factorAuth({
- "name": obj.name,
- "idcard": obj.idcard
- })
- if(res.code == 200){
- this.factorAuthLoading = false
- if(res.data.status != 1) {
- this.$message.error(res.data.errReason);
- }else {
- this.$set(this.viewerList,index,JSON.parse(JSON.stringify(this.tableForm)))
- this.actionIndex = null
- this.setMoneyAll()
- }
- }else {
- this.$message.error(res.msg);
- this.factorAuthLoading = false
- }
- } catch (error) {
- this.$message.error(error);
- this.factorAuthLoading = false
- }
- },
- handleEdit(index, row) {
- this.actionIndex = row.id
- this.tableForm = JSON.parse(JSON.stringify(row))
-
- console.log(index, row);
- },
- handleDelete(index, row) {
- console.log(index, row);
- },
- setMoneyAll(){
- let moneyAll = 0
- this.viewerList.forEach((item,index) => {
- console.log("item.realPrice====",item.realPrice)
- if(item.realPrice && !isNaN(Number(item.realPrice))) {
- moneyAll = mathM.format(Number(moneyAll) + Number(item.realPrice),10)
- }
- })
- console.log("dsfsfdsf",moneyAll)
- this.moneyAll = moneyAll? moneyAll: ''
- this.$set(this.ruleForm,'realPrice',this.moneyAll)
- },
- setRealPrice(value) {
- // if(value && !isNaN(value)) {
- // this.$set(this.ruleForm,'small',mathM.format(Number(value) - Number(this.moneyAll),10) )
- // }
- if(this.ruleForm.realPrice_1 && !isNaN(this.ruleForm.realPrice_1) && value && !isNaN(value)) {
- this.$set(this.ruleForm,'small',mathM.format(Number(this.ruleForm.realPrice_1) - Number(value),10) )
- }
- },
- setRealPrice_1(value) {
- if(this.ruleForm.realPrice && !isNaN(this.ruleForm.realPrice) && value && !isNaN(value)) {
- this.$set(this.ruleForm,'small',mathM.format(Number(value) - Number(this.ruleForm.realPrice),10) )
- }
- },
- /** 检查是否存在空值 */
- checkViewerList() {
- let flog = false
- for(let i = 0; i < this.viewerList.length; i++){
- let obj = this.viewerList[i]
- if(!obj.name){
- this.$message.error('请填写观影人姓名!!!');
- flog = true
- break;
- }
- if(!obj.idcard){
- this.$message.error('请填写观影人身份证号!!!');
- flog = true
- break;
- }
- if(obj.identity && obj.identity != 0){
- if(!obj.remark){
- this.$message.error('请填写观影人备注!!!');
- flog = true
- break;
- }
- }
- }
- if(this.actionIndex){
- this.$message.error('请先保存观影影人信息!!!');
- flog = true
- }
- return flog
- },
- submitForm(formName) {
- this.$refs[formName].validate((valid) => {
- if (valid) {
- if(this.ruleForm.paymentType == 4 && (!this.balance||this.balance<=0||this.balance < this.moneyAll)) {
- this.$message.error('团队账户余额不足!!!');
- return
- }
- if(this.ruleForm.paymentType == 5 && (!this.grantQuota||this.grantQuota<=0||this.grantQuota < this.moneyAll)) {
- this.$message.error('团队授信余额不足!!!');
- return
- }
- if(!this.checkViewerList()){
- this.orderInfoSubmitFun()
- }
- } else {
- console.log('error submit!!');
- return false;
- }
- });
- },
- resetForm(formName) {
- this.$refs[formName].resetFields();
- },
- /** 生成订单 */
- async orderInfoSubmitFun(){
- this.loading = true
- try {
- this.orderId = null
- this.loadingText = "生成订单中..."
- let res = await orderInfoSubmit({
- ...this.ruleForm,
- viewerList: this.viewerList
- })
- if(res.code == 200){
- this.orderId = res.data.orderId
- if(this.ruleForm.paymentType == 2) {
- this.gotoCashPayFun(this.orderId)
- }else if(this.ruleForm.paymentType == 3) { // 对公支付
- this.gotoCorporatePayFun(this.orderId)
- }else if(this.ruleForm.paymentType == 4){ // 账户余额
- this.gotoBalancePayFun(this.orderId)
- }else if(this.ruleForm.paymentType == 5){ // 授信余额
- this.gotoQuotaPayFun(this.orderId)
- }else {
- // 扫码支付
- this.loading = false
- this.payStatus = 2
- }
- }else{
- this.$message.error('生成订单失败!!!');
- this.loading = false
- this.payStatus = 1
- }
- } catch (error) {
- this.$message.error('生成订单失败!!!');
- this.loading = false
- this.payStatus = 1
- }
- },
-
- /** 调取 订单支付码支付 */
- async gotoMicroPayFun(orderId,code){
- this.loading = true
- try {
- this.loadingText = "订单支付中..."
- this.payStatus = ''
- let res = await gotoMicroPay({
- "orderId": orderId, // 订单编号-提交订单返回
- "authCode": code // 微信扫码支付-支付码
- })
- if(res.code == 200){
- this.payTimeNum = 0
- this.websocketClear()
- if(this.payTime){
- clearInterval(this.payTime)
- }
- this.payTime = setInterval(()=>{
- this.payQueryFun(this.orderId)
- },1500)
- }else{
- this.$message.error('支付失败!!!');
- this.payStatus = ''
- this.loading = false
- this.payStatus = 6
- }
- } catch (error) {
- this.$message.error('支付失败!!!');
- this.loading = false
- this.payStatus = 6
- }
- },
- /** 对公支付 */
- async gotoCorporatePayFun(orderId) {
- this.loading = true
- try {
- this.loadingText = "订单入库中..."
- let res = await gotoCorporatePay({
- "orderId": orderId, // 订单编号-提交订单返回
- "payAmount": this.ruleForm.realPrice
- })
- if(res.code == 200){
- if(this.payTime){
- clearInterval(this.payTime)
- }
- this.payTimeNum = 0
- this.payTime = setInterval(()=>{
- this.payQueryFun(this.orderId)
- },1000)
- }else{
- this.$message.error('订单入库中失败!!!');
- this.loading = false
- this.payStatus = 3
- }
- } catch (error) {
- this.$message.error('订单入库中失败!!!');
- this.loading = false
- this.payStatus = 3
- }
- },
- /** 授信额度支付 */
- async gotoQuotaPayFun(orderId) {
- this.loading = true
- try {
- this.loadingText = "订单入库中..."
- let res = await gotoQuotaPay({
- "orderId": orderId, // 订单编号-提交订单返回
- })
- if(res.code == 200){
- if(this.payTime){
- clearInterval(this.payTime)
- }
- this.payTimeNum = 0
- this.payTime = setInterval(()=>{
- this.payQueryFun(this.orderId)
- },1000)
- }else{
- this.$message.error('订单入库中失败!!!');
- this.loading = false
- this.payStatus = 3
- }
- } catch (error) {
- this.$message.error('订单入库中失败!!!');
- this.loading = false
- this.payStatus = 3
- }
- },
- /** 余额支付 */
- async gotoBalancePayFun(orderId) {
- this.loading = true
- try {
- this.loadingText = "订单入库中..."
- let res = await gotoBalancePay({
- "orderId": orderId, // 订单编号-提交订单返回
- })
- if(res.code == 200){
- if(this.payTime){
- clearInterval(this.payTime)
- }
- this.payTimeNum = 0
- this.payTime = setInterval(()=>{
- this.payQueryFun(this.orderId)
- },1000)
- }else{
- this.$message.error('订单入库中失败!!!');
- this.loading = false
- this.payStatus = 3
- }
- } catch (error) {
- this.$message.error('订单入库中失败!!!');
- this.loading = false
- this.payStatus = 3
- }
- },
- /** 订单现金支付 */
- async gotoCashPayFun(orderId){
- this.loading = true
- try {
- this.loadingText = "订单入库中..."
- let res = await gotoCashPay({
- "orderId": orderId, // 订单编号-提交订单返回
- "payAmount": this.ruleForm.realPrice
- })
- if(res.code == 200){
- if(this.payTime){
- clearInterval(this.payTime)
- }
- this.payTimeNum = 0
- this.payTime = setInterval(()=>{
- this.payQueryFun(this.orderId)
- },1000)
- }else{
- this.$message.error('订单入库中失败!!!');
- this.loading = false
- this.payStatus = 3
- }
- } catch (error) {
- this.$message.error('订单入库中失败!!!');
- this.loading = false
- this.payStatus = 3
- }
- },
- // 跳转取票界面
- goTicketingCollections(){
- this.$router.push({
- path:"/windowTicketSales/ticketingCollections",
- query:{
- orderId: this.orderId
- }
- })
- },
- /** 查看支付 状态 */
- async payQueryFun(orderId){
- this.loading = true
-
- try {
- this.payTimeNum = this.payTimeNum + 1
- if(this.payTimeNum==15){
- if(this.payTime){
- clearInterval(this.payTime)
- }
- this.orderInfoCancelFun()
- return
- }
- if(this.ruleForm.paymentType == 2){
- this.loadingText = "订单入库中..."
- }else {
- this.loadingText = "订单支付中..."
- }
- this.payStatus = ''
- let res = await payQuery({
- orderId: orderId
- })
- if(res.code == 200){
- if(res.data) {
- if(res.data.payStatus == 0) {
- if(this.payTime){
- clearInterval(this.payTime)
- }
- if(this.ruleForm.paymentType == 2){
- this.$message.error('"订单入库中失败"');
- this.loading = false
- this.payStatus = 3
- }else {
- if(res.data.orderStatus == 9 || res.data.orderStatus == 4 || res.data.orderStatus == 5){
- this.$message.error('订单已关闭,请重新选择座位,再购买!!!');
- this.loading = false
- this.payStatus = 10
- }else {
- this.$message.error('用户未支付!!!');
- this.loading = false
- this.payStatus = 7
- }
- }
-
- }else if(res.data.payStatus == 1) {
- if(this.payTime){
- clearInterval(this.payTime)
- }
- if(this.ruleForm.paymentType == 2){
- this.$message({
- message: '订单入库成功',
- type: 'success'
- });
- this.loading = false
- // this.payStatus = 8
- // this.getPrintListApi()
- this.goTicketingCollections()
-
- }else {
- this.$message({
- message: '用户已支付成功,请打印门票',
- type: 'success'
- });
- // 开始 打印
- this.loading = false
- // this.payStatus = 8
- // this.getPrintListApi()
- this.goTicketingCollections()
- }
- this.dialogVisible = false
-
- }else if(res.data.payStatus == 2) {
- }else if(res.data.payStatus == 3) {
- if(this.payTime){
- clearInterval(this.payTime)
- }
- if(this.ruleForm.paymentType == 2){
- this.$message.error('"订单入库中失败"');
- this.loading = false
- this.payStatus = 3
- }else {
- if(res.data.orderStatus == 9 || res.data.orderStatus == 4 || res.data.orderStatus == 5){
- this.$message.error('订单已关闭,请重新选择座位,再购买!!!');
- this.loading = false
- this.payStatus = 10
- }else {
- this.$message.error('用户支付失败!!!');
- this.loading = false
- this.payStatus = 7
- }
- }
- }else if(res.data.payStatus == 4) {
- if(this.payTime){
- clearInterval(this.payTime)
- }
-
- if(this.ruleForm.paymentType == 2){
- this.$message.error('"订单入库中失败"');
- this.loading = false
- this.payStatus = 3
- }else {
- if(res.data.orderStatus == 9 || res.data.orderStatus == 4 || res.data.orderStatus == 5){
- this.$message.error('订单已关闭,请重新选择座位,再购买!!!');
- this.loading = false
- this.payStatus = 10
- }else {
- this.$message.error('支付退款!!!');
- this.loading = false
- this.payStatus = 7
- }
- }
-
- }
- }
-
- }else{
- this.$message.error('支付失败!!!');
- this.loading = false
- this.payStatus = 7
- }
-
- } catch (error) {
- this.$message.error('支付失败!!!');
- this.loading = false
- this.payStatus = 7
- }
- },
- /** 连接VBarServer */
- vbar_open() {
- this.loading = true
- this.loadingText = "连接扫码盒子中!!!"
- this.payStatus = null
- this.code = ''
- this.websocketClear()
- this.payStatus = 5 // 连接成功
- document.addEventListener('keydown',this.keydownAdd);
- this.loading = false
- },
- /** 连接结果 */
- websocket_open_state(message){
- console.log("连接结果 ===== ",message)
- this.codeTime = setInterval(()=>{
- console.log("检测是否连接")
- if(this.websocketData.readyState != WebSocket.OPEN) {
- this.payStatus = 6
- }
- },3000)
- //document.getElementById('wsocket').value = "已连接";
- },
- // 拼接字符串
- keydownAdd(e){
- console.log("e=====",e)
- console.log("this.code=====",this.code)
- if( this.payStatus == 5 && e.key != 'Enter') {
- this.code = this.code + e.key
- }
- if( e.key == 'Enter') {
- document.removeEventListener('keydown',this.keydownAdd);
- let codeCopy = this.code
- this.payStatus == 5.5
- this.code = ''
- this.gotoMicroPayFun(this.orderId,codeCopy)
- }
- },
- //接收扫码完整结果处理
- websocket_decode(code){
- console.log("orderId=========",this.orderId )
- console.log("code=========",code)
- if(this.orderId && this.payStatus == 5.5 && regex.test(code) ) {
- this.payStatus = 5.6 // 支付中
- let codeCopy = code.replace("%%%", "").replace("%%%", "")
- this.gotoMicroPayFun(this.orderId,codeCopy)
- }else if(!code){
- this.payStatus = 5
- this.code = ''
- }
- },
- /** 关闭通讯 */
- websocketClear(){
- document.removeEventListener('keydown',this.keydownAdd);
- },
- /** 读取身份证 */
- readCert(){
- this.idcardLoading = true
- var result = "";
- try {
- let xmlHttp = new XMLHttpRequest();
- let Protocol = window.location.protocol.split(':')[0];
- //获取当前协议,并且分割字符串,得到http或者https
- if (Protocol === 'https'){
- //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
- xmlHttp.open("POST", "http://127.0.0.1:18889/api/readCert?ReadSN=" + 0, false); //readCert读卡,生成正反面仿复印件
- }else {
- //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
- xmlHttp.open("POST", "http://127.0.0.1:18889/api/readCert?ReadSN=" + 0, false); //readCert读卡,生成正反面仿复印件
- }
- //发送请求
- xmlHttp.send();
- if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
- result = xmlHttp.responseText;
- xmlHttp.readyState = 1;
- }
- } catch (e) {
- console.error("e====",e)
- }
- let obj = JSON.parse(result)
- if(obj.resultContent && obj.resultContent.certNumber){
- this.$set(this.tableForm,"idcard",obj.resultContent.certNumber)
- this.$set(this.tableForm,"name",obj.resultContent.partyName)
- }else {
- this.$message.error('读取失败!!!');
- }
-
- this.idcardLoading = false
- //return result;
- console.log(result,obj)
- },
- /** 查询打印机列表 */
- getPrintListApi() {
- getPrintListApi({deviceType:5,pageNum: 1,
- pageSize: 999,})
- .then(response => {
- this.printList = response.data.rows;
- }).catch((error)=>{
- console.log("error===",error)
- }
- );
- },
- // 打印
- async print(list = []){
- if(!this.printListId) {
- this.$message.error('请选择打印机!!');
- return
- }
- this.loading = true
- this.loadingText = '打印中...'
- this.payStatus = ''
- try {
- let res = await printApi({
- orderId: this.orderId,
- source: 2,
- deviceId: this.printListId
- })
- if(res.code == 200) {
- let url = res.data.linkIp
- let printInfo = res.data.printInfo
- this.connectPrint(url,printInfo)
- }else {
- throw new Error(res)
- }
- } catch (error) {
- this.loading = false
- this.payStatus = 8
- console.error("error=====",error)
- }
-
- },
- /** 连接打印机 */
- connectPrint(url,data){
- // 创建忽略 SSL 的 axios 实例
- const ignoreSSL = axios.create({
- httpsAgent: new https.Agent({
- rejectUnauthorized: false
- }),
- withCredentials: true, // 跨域请求时发送Cookie
- timeout: 60000, // 请求超时
- headers: {
- "Content-Type": "application/json; charset=UTF-8;"
- }
- });
- ignoreSSL.post(url,
- { ...data }
- ).then(()=>{
- this.dialogVisible = false
- this.loading = false
- }).catch(()=>{
- this.loading = false
- this.payStatus = 8
- // this.dialogVisible = false
- // this.loading = false
- })
- // 在 axios 请求时,选择性忽略 SSL
- // const agent = new https.Agent({
- // rejectUnauthorized: false
- // });
- // axios.post(
- // url,
- // { httpsAgent: agent,...data }
- // ).then(()=>{
- // this.dialogVisible = false
- // this.loading = false
- // })
- // .catch(()=>{
- // this.dialogVisible = false
- // this.loading = false
- // })
- },
- /** 获取授信余额和账户余额 */
- async selectMarketTeamBySourceFun(value) {
- console.log("value===",value)
- try {
- if(!['10','11','13','14','18','19'].includes(value)) return
- let res = await selectMarketTeamBySourceApi({
- source: value
- })
- this.balance = res.data.balance
- if(res.data.grantQuota && res.data.grantUsed) {
- this.grantQuota = res.data.grantQuota - res.data.grantUsed
- }else if(res.data.grantQuota) {
- this.grantQuota = res.data.grantQuota
- }else {
- this.grantQuota = 0
- }
-
- } catch (error) {
- this.balance = null
- this.grantQuota = null
- }
- }
- },
- beforeDestroy() {
- // 组件销毁前执行的代码
- console.log('组件即将销毁');
- document.removeEventListener('keydown',this.keydownAdd);
- },
- }
- </script>
- <style scoped lang="scss">
- .increase-viewers-box {
- width: 100%;
- height: calc( 100vh - 250px );
- box-sizing: border-box;
- overflow: hidden;
- overflow-y: auto;
- position: relative;
- }
- .increase-viewers-pay-status {
- width: 100%;
- height: 100%;
- position: absolute;
- z-index: 999;
- background-color: rgba(0,0,0,0.3);
- top: 0;
- left: 0;
- .increase-viewers-pay-status-info {
- width: 100%;
- height: 100%;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- color: #fff;
- }
- }
- </style>
|