increaseViewersNew.vue 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250
  1. <template>
  2. <el-dialog
  3. title="添加观影人"
  4. :visible.sync="dialogVisible"
  5. width="90%"
  6. :before-close="handleClose">
  7. <div
  8. v-loading="loading"
  9. :element-loading-text="loadingText"
  10. element-loading-spinner="el-icon-loading"
  11. element-loading-background="rgba(0, 0, 0, 0.8)"
  12. class="increase-viewers-box">
  13. <div class="increase-viewers-info">
  14. <el-table
  15. :data="viewerList"
  16. border
  17. style="width: 100%">
  18. <el-table-column
  19. label="序号"
  20. type="index"
  21. width="50">
  22. </el-table-column>
  23. <el-table-column
  24. label="姓名"
  25. width="180">
  26. <template slot-scope="scope">
  27. <div>
  28. <span v-if="actionIndex != scope.row.id">{{ scope.row.name }}</span>
  29. <el-input size="mini" v-else v-model="tableForm.name" placeholder="请输入姓名"></el-input>
  30. </div>
  31. </template>
  32. </el-table-column>
  33. <el-table-column
  34. label="身份证号"
  35. width="250">
  36. <template slot-scope="scope">
  37. <div>
  38. <span v-if="actionIndex != scope.row.id">{{ scope.row.idcard }}</span>
  39. <el-input
  40. size="mini"
  41. v-else
  42. v-model="tableForm.idcard"
  43. placeholder="请输入身份证号"
  44. clearable
  45. style="width: 230px;"
  46. @keyup.enter.native="handleQuery"
  47. >
  48. <el-button slot="append" :loading="idcardLoading" size="mini" type="primary" @click="readCert">{{ idcardLoading ? '识别中':'识别' }}</el-button>
  49. </el-input>
  50. </div>
  51. </template>
  52. </el-table-column>
  53. <el-table-column
  54. label="座位类型">
  55. <template slot-scope="scope">
  56. <span>{{ scope.row.seatTypeName }}</span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column
  60. prop="date"
  61. label="座位号">
  62. <template slot-scope="scope">
  63. <span>{{ scope.row.seatName }}</span>
  64. </template>
  65. </el-table-column>
  66. <el-table-column
  67. prop="date"
  68. label="价格(元)">
  69. <template slot-scope="scope">
  70. <span>{{ scope.row.salePrice }}</span>
  71. </template>
  72. </el-table-column>
  73. <el-table-column
  74. label="人员类别"
  75. width="140">
  76. <template slot-scope="scope">
  77. <div>
  78. <dict-tag v-if="actionIndex != scope.row.id" :options="dict.type.personnel_type" :value="scope.row.identity"/>
  79. <el-select
  80. size="mini"
  81. v-else
  82. v-model="tableForm.identity"
  83. placeholder="请选择人员类别"
  84. clearable
  85. style="width: 100%"
  86. >
  87. <el-option
  88. v-for="dict in dict.type.personnel_type"
  89. :key="dict.value"
  90. :label="dict.label"
  91. :value="dict.value"
  92. />
  93. </el-select>
  94. </div>
  95. </template>
  96. </el-table-column>
  97. <el-table-column
  98. label="应收金额(元)">
  99. <template slot-scope="scope">
  100. <span v-if="(scope.$index!=0 && oneMany ==1 && personnelNum != 0)">{{ scope.row.realPrice }}</span>
  101. <div v-else>
  102. <span v-if="actionIndex != scope.row.id">{{ scope.row.realPrice }}</span>
  103. <el-input-number size="mini" style="width: 120px;" v-else v-model="tableForm.realPrice" controls-position="right" label="请输入应收金额(元)"></el-input-number>
  104. </div>
  105. </template>
  106. </el-table-column>
  107. <el-table-column
  108. label="备注"
  109. width="180">
  110. <template slot-scope="scope">
  111. <div>
  112. <span v-if="actionIndex != scope.row.id">{{ scope.row.remark }}</span>
  113. <el-input size="mini" v-else v-model="tableForm.remark" placeholder="请输入备注"></el-input>
  114. </div>
  115. </template>
  116. </el-table-column>
  117. <el-table-column
  118. label="操作"
  119. width="80"
  120. >
  121. <template slot-scope="scope" v-if="(scope.$index != 0 && oneMany!=2) || scope.$index == 0">
  122. <el-button
  123. size="mini"
  124. type="success"
  125. :loading="factorAuthLoading"
  126. v-if="actionIndex == scope.row.id"
  127. @click="handleSeva(scope.$index, scope.row)">{{ factorAuthLoading ? '保存中....' : '保存' }}</el-button>
  128. <el-button
  129. :disabled="!!actionIndex"
  130. size="mini"
  131. type="primary"
  132. v-if="actionIndex != scope.row.id"
  133. @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
  134. <!-- <el-button
  135. size="mini"
  136. type="danger"
  137. @click="handleDelete(scope.$index, scope.row)">删除</el-button> -->
  138. </template>
  139. </el-table-column>
  140. </el-table>
  141. </div>
  142. <div style="padding: 10px 0 20px;">合计:累计观影人员{{ viewerList.length }}人,应收总额¥{{ moneyAll }}(元)</div>
  143. <div>
  144. <el-form
  145. :model="ruleForm"
  146. :rules="rules"
  147. ref="ruleForm11"
  148. label-width="120px"
  149. class="demo-ruleForm"
  150. size="mini"
  151. >
  152. <div style="display: flex;">
  153. <el-form-item label="用户来源 :" prop="source">
  154. <el-radio-group @input="selectMarketTeamBySourceFun" v-model="ruleForm.source">
  155. <el-radio label="7">窗口</el-radio>
  156. <el-radio label="10">美团</el-radio>
  157. <el-radio label="11">携程</el-radio>
  158. <el-radio label="13">抖音</el-radio>
  159. <el-radio label="14">猫眼</el-radio>
  160. <el-radio label="18">大麦</el-radio>
  161. <el-radio label="19">飞猪</el-radio>
  162. <!-- <el-radio label="15">去哪儿</el-radio> -->
  163. <el-radio label="16">其他</el-radio>
  164. </el-radio-group>
  165. </el-form-item>
  166. <el-form-item label-width="60px" v-if="ruleForm.source && ruleForm.source == 16" label="备注 :" prop="sourceRemark">
  167. <el-input style="width: 200px;" v-model="ruleForm.sourceRemark"></el-input>
  168. </el-form-item>
  169. </div>
  170. <el-form-item v-if="ruleForm.source && ruleForm.source != 7" label="核销码/订单码" prop="orderIdOrQrCode">
  171. <el-input style="width: 400px;" type="textarea" :rows="2" v-model="ruleForm.orderIdOrQrCode"></el-input>
  172. </el-form-item>
  173. <el-form-item label="支付方式 :" prop="paymentType">
  174. <el-radio-group v-model="ruleForm.paymentType">
  175. <el-radio label="1">扫码</el-radio>
  176. <el-radio label="2">现金</el-radio>
  177. <!-- <el-radio v-if="['10','11','13','14','18','19'].includes(ruleForm.source)" label="3">对公支付</el-radio> -->
  178. <el-radio v-if="['10','11','13','14','18','19'].includes(ruleForm.source)" label="4">账户余额({{ balance }})</el-radio>
  179. <el-radio v-if="['10','11','13','14','18','19'].includes(ruleForm.source)" label="5">授信余额({{ grantQuota }})</el-radio>
  180. </el-radio-group>
  181. </el-form-item>
  182. <el-form-item label="应收金额 :">
  183. ¥{{ moneyAll }}元
  184. </el-form-item>
  185. <!-- <el-form-item label="找零计算(注:只用于找零不提交数据 找零金额 = 收到金额 - 实收金额)" v-if="ruleForm.paymentType == 2 || ruleForm.paymentType == 3" label-width="480px"></el-form-item> -->
  186. <el-form-item v-if="ruleForm.paymentType == 2 || ruleForm.paymentType == 3" label="收取现金 :" prop="realPrice_1">
  187. <el-input @input="setRealPrice_1" style="width: 200px;" v-model="ruleForm.realPrice_1"></el-input>
  188. <span>元</span>
  189. </el-form-item>
  190. <el-form-item label="找零金额 :" v-if="ruleForm.paymentType == 2">
  191. ¥{{ ruleForm.small }}元
  192. </el-form-item>
  193. <el-form-item v-if="ruleForm.paymentType == 2 || ruleForm.paymentType == 3" label="实收金额 :" prop="realPrice">
  194. <el-input @input="setRealPrice" style="width: 200px;" v-model="ruleForm.realPrice"></el-input>
  195. <span>元</span>
  196. </el-form-item>
  197. <el-form-item label="订单备注 :" prop="remark">
  198. <el-input style="width: 400px;" type="textarea" :rows="2" maxlength="200" v-model="ruleForm.remark" show-word-limit></el-input>
  199. </el-form-item>
  200. </el-form>
  201. </div>
  202. <!-- 支付过程 控制 -->
  203. <div v-if="payStatus" class="increase-viewers-pay-status">
  204. <div class="increase-viewers-pay-status-info" v-if="!loading">
  205. <span style="font-weight: 600;font-size: 20px;">提示</span>
  206. <span style="padding: 10px 0;">
  207. {{ payStatus==1 ? '生成订单失败!!!' :
  208. payStatus==2 ? '生成订单生成成功,请点击调取扫码盒子' :
  209. payStatus==4 ? '扫码支付失败!!!' :
  210. payStatus==5 ? '请出示付款码!!!' :
  211. payStatus==5.5 ? '扫码成功,支付中...' :
  212. payStatus==5.6 ? '扫码成功,支付中...' :
  213. payStatus==6 ? '连接扫码器失败!!!' :
  214. payStatus==7 ? '用户支付失败或未支付,请重新连接支付!!!' :
  215. payStatus==8 ? '用户支付成功,请点击打印票!!!' :
  216. payStatus==9 ? '支付超时!!!' :
  217. payStatus==10 ? '订单已关闭,请重新选择座位,再购买!!!' :
  218. payStatus==3 ? '现金支付记录入库失败,请重新提交' : '未知状态' }}
  219. </span>
  220. <!-- 重新生成订单 1 -->
  221. <div v-if="payStatus==1" style="display: flex;">
  222. <el-button @click="payStatus = null" type="success">修改信息</el-button>
  223. <el-button @click="orderInfoSubmitFun()" style="margin-left: 20px;" type="primary">重新生成订单</el-button>
  224. </div>
  225. <!-- 扫码支付 2 -->
  226. <el-button v-if="payStatus==2" @click="vbar_open(orderId)" type="success">扫码支付</el-button>
  227. <!-- 扫码支付 4 -->
  228. <el-button v-if="payStatus==4" @click="vbar_open(orderId)" type="success">重新扫码支付</el-button>
  229. <!-- 重新支付 3 -->
  230. <el-button v-if="payStatus==3" @click="gotoCashPayFun(orderId)" type="success">重新提交入库</el-button>
  231. <!-- 重新支付 6 7 -->
  232. <el-button v-if="payStatus==6 || payStatus==7" @click="vbar_open(orderId)" type="success">重新连接扫码支付</el-button>
  233. <!-- 打印 8 -->
  234. <div v-if="payStatus==8">
  235. <el-select v-model="printListId" placeholder="选择打印机">
  236. <el-option :label="item.deviceName" :key="item.id" :value="item.id" v-for="(item,index) in printList"></el-option>
  237. </el-select>
  238. <el-button style="margin-left: 15px" @click="print" type="success">打印门票</el-button>
  239. <el-button style="margin-left: 15px" @click="goTicketingCollections" type="success">跳转取票界面</el-button>
  240. </div>
  241. <!-- 支付超时 9 -->
  242. <div v-if="payStatus==9">
  243. <!-- <el-button @click="print" type="danger">取消支付</el-button> -->
  244. <el-button @click="orderInfoSubmitFun()" type="primary">重新扫码</el-button>
  245. </div>
  246. <!-- 订单被关闭 10 -->
  247. <div v-if="payStatus==10">
  248. <!-- <el-button @click="print" type="danger">取消支付</el-button> -->
  249. <el-button @click="handleClose()" type="primary">关闭</el-button>
  250. </div>
  251. </div>
  252. </div>
  253. </div>
  254. <span slot="footer" class="dialog-footer">
  255. <el-button @click="handleClose()">取 消</el-button>
  256. <el-button v-if="!orderId&&!payStatus" :loading="loading" type="primary" @click="submitForm('ruleForm11')">确定支付</el-button>
  257. </span>
  258. </el-dialog>
  259. </template>
  260. <script>
  261. import {
  262. orderInfoSubmit,
  263. gotoMicroPay,
  264. gotoCashPay,
  265. gotoCorporatePay,
  266. gotoBalancePay,
  267. gotoQuotaPay,
  268. payQuery,
  269. selectRegion,
  270. orderInfoCancel,
  271. factorAuth,
  272. selectMarketTeamBySourceApi
  273. } from '@/api/windowTicketSales/ticketingSales'
  274. import { pageList as getPrintListApi } from "@/api/device/pda";
  275. import { printApi } from '@/api/windowTicketSales/ticketingCollection'
  276. const mathM = require('mathjs')
  277. const https = require('https');
  278. const axios = require('axios');
  279. export default {
  280. dicts: ['personnel_type'],
  281. data() {
  282. return {
  283. loading: false,
  284. loadingText: '',
  285. dialogVisible: false,
  286. actionIndex: false,
  287. tableForm: {
  288. name: '', // 姓名
  289. mobile: '', // 电话
  290. idcard: '', // 身份证
  291. identity: '', // 观影人身份
  292. remark: '', // 备注信息
  293. salePrice: '', // 原价
  294. realPrice: '', // 实收金额
  295. seatId: '', // 座位ID
  296. seatName: '', // 座位名称
  297. seatType: '', // 座位类型
  298. },
  299. ruleForm: {
  300. performId: "", // 剧目ID
  301. retailId: "", // 分销ID
  302. goodsList: [], // 商品列表
  303. auditoriumId: "", // 演出厅ID
  304. performTimeId: "1", // 场次时段ID
  305. seatTypeId: "", // 座位类型ID
  306. source: '', // 订单来源
  307. purchaser: {},// 购票人信息
  308. viewerList: [], // 观影人列表
  309. orderIdOrQrCode: '',
  310. paymentType: '', // 支付方式
  311. small: '',// 找零
  312. realPrice: '', // 实收金额
  313. },
  314. viewerList: [], // 观影人列表
  315. rules: {
  316. source: [
  317. { required: true, message: '请选择用户来源', trigger: ['blur','change']},
  318. ],
  319. orderIdOrQrCode: [
  320. { required: true, message: '请输入核销码/订单码', trigger: ['blur','change']},
  321. ],
  322. paymentType: [
  323. { required: true, message: '请选择支付方式', trigger: ['blur','change']},
  324. ],
  325. realPrice: [
  326. { required: true, message: '请输入实收金额', trigger: ['blur','change']},
  327. ],
  328. sourceRemark: [
  329. { required: true, message: '请输入备注', trigger: ['blur','change']},
  330. ],
  331. },
  332. moneyAll: '',
  333. payment: '',
  334. payStatus: null, // 支付状态
  335. orderId: null,
  336. websocket_connected: false, // 是否已连接
  337. websocketCtrl: null,
  338. websocketData: null,
  339. idcardLoading: false,
  340. payTime: null, // 支付等待时间
  341. payTimeNum: 0,
  342. printListId: null,
  343. printList: [],
  344. // 身份证校验 loading
  345. factorAuthLoading: false,
  346. ifRealUser: 0, // 散客是否实名:0-否 1-是
  347. ifRealTeam: 0, // 团购是否实名:0否 1-是
  348. oneMany: 1, // 证件要求: 1一证一票,2一证多票
  349. personnelNum: 0, // 人员要求:0-表示不限制 其他数字表示限制人数
  350. balance: null, // 授信额度
  351. grantQuota: null, // 授信使用额度
  352. code: '', // 支付code
  353. codeTime: null // 检测是websocket是否还在连接
  354. };
  355. },
  356. methods: {
  357. async initData(list,params){
  358. try {
  359. this.code = ''
  360. this.ifRealUser = params.ifRealUser // 散客是否实名:0-否 1-是
  361. this.ifRealTeam = params.ifRealTeam // 团购是否实名:0否 1-是
  362. this.oneMany = params.oneMany // 证件要求: 1一证一票,2一证多票
  363. this.personnelNum = params.personnelNum // 人员要求:0-表示不限制 其他数字表示限制人数
  364. this.websocketClear()
  365. this.idcardLoading = false
  366. this.ruleForm = {
  367. performId: params.performId, // 剧目ID
  368. retailId: "", // 分销ID
  369. goodsList: [
  370. {
  371. goodsId: params.goodsId,
  372. salePeice: params.salePrice,
  373. saleNum: 1,
  374. }
  375. ], // 商品列表
  376. auditoriumId: params.auditoriumId, // 演出厅ID
  377. performTimeId: params.timeId, // 场次时段ID
  378. seatTypeId: params.seatTypeId, // 座位类型ID
  379. source: '', // 订单来源
  380. purchaser: {},// 购票人信息
  381. viewerList: [], // 观影人列表
  382. orderIdOrQrCode: '',
  383. paymentType: '', // 支付方式
  384. small: '',// 实收金额
  385. realPrice: '', // 实收金额
  386. remark: '', // 订单备注
  387. sourceRemark: '', // 来源备注
  388. }
  389. this.payStatus = null
  390. this.orderId = null
  391. this.websocket_connected = false
  392. this.dialogVisible = true
  393. this.loading = true
  394. this.actionIndex = null
  395. this.viewerList = []
  396. let perform = await this.selectRegionFun(params,list[0].seatTypeId)
  397. console.log("perform===",perform)
  398. // let perform = {
  399. // money: params.salePrice,
  400. // //name: params.goodsName,
  401. // seatTypeId: params.seatTypeId,
  402. // seatTypeName: params.seatTypeName,
  403. // }
  404. let listCopy = []
  405. let listCopy1 = []
  406. list.forEach((item,index)=>{
  407. listCopy.push({
  408. id: index+1,
  409. name: '', // 姓名
  410. mobile: '', // 电话
  411. idcard: '', // 身份证
  412. identity: 0, // 观影人身份
  413. remark: '', // 备注信息
  414. salePrice: this.oneMany == 2 || (this.oneMany == 1 && this.personnelNum != 0) ? index == 0 ? perform.money : 0 : perform.money, // 原价
  415. realPrice: this.oneMany == 2 || (this.oneMany == 1 && this.personnelNum != 0) ? index == 0 ? perform.money : 0 : perform.money, // 实收金额
  416. seatId: item.id, // 座位ID
  417. seatName: item.name?item.name:'暂无命名', // 座位名称
  418. seatType: perform.seatTypeId, // 座位类型
  419. seatTypeId: perform.seatTypeId,
  420. seatTypeName: perform.seatTypeName,
  421. })
  422. })
  423. //this.goodsList =
  424. this.viewerList = JSON.parse(JSON.stringify(listCopy))
  425. this.setMoneyAll()
  426. console.log(this.viewerList)
  427. this.loading = false
  428. this.$nextTick(()=>{
  429. this.$refs.ruleForm11.clearValidate()
  430. })
  431. } catch (error) {
  432. console.error("error====",error)
  433. }
  434. },
  435. /** 获取票务信息 */
  436. async selectRegionFun(params,seatTypeId){
  437. try {
  438. this.loadingText = "获取票务信息中..."
  439. let res = await selectRegion({
  440. "auditoriumId": params.auditoriumId, // 演艺厅ID
  441. "goodsId": params.goodsId, // 商品ID
  442. "performId": params.performId, // 上一界面节目ID
  443. "performTimeId": params.timeId, // 时段ID
  444. "retailId": "" // 分销ID
  445. })
  446. if(res.code == 200) {
  447. if(res.data.regionPriceList &&res.data.regionPriceList.length>0){
  448. //let obj = res.data.regionPriceList[0]
  449. let obj = {}
  450. res.data.regionPriceList.forEach((item,index)=>{
  451. if(seatTypeId == item.seatTypeId) {
  452. obj = item
  453. }
  454. })
  455. if(JSON.stringify(obj) != '{}'){
  456. this.ruleForm.performId = obj.performId
  457. this.ruleForm.goodsList = [
  458. {
  459. goodsId: obj.goodsId,
  460. salePeice: obj.salePrice,
  461. saleNum: 1,
  462. }
  463. ]
  464. this.ruleForm.auditoriumId = obj.auditoriumId
  465. this.ruleForm.performId = obj.performId
  466. this.ruleForm.performTimeId = res.data.performTimeId
  467. this.ruleForm.seatTypeId = obj.seatTypeId
  468. return {
  469. money: obj.salePrice,
  470. //name: obj.goodsName,
  471. seatTypeId: obj.seatTypeId,
  472. seatTypeName: obj.seatTypeName,
  473. }
  474. }else {
  475. this.$message.error('存在座位未设置价格,请选择其他票!!!');
  476. this.loading = false
  477. this.dialogVisible = false
  478. }
  479. }else {
  480. this.$message.error('存在座位未设置价格,请选择其他票!!!');
  481. this.loading = false
  482. this.dialogVisible = false
  483. }
  484. console.log("res====",res)
  485. }else {
  486. this.$message.error(res.msg);
  487. this.loading = false
  488. this.dialogVisible = false
  489. }
  490. } catch (error) {
  491. console.error("error=====",error)
  492. this.$message.error('价格查询出错');
  493. this.loading = false
  494. this.dialogVisible = false
  495. }
  496. },
  497. /** 取消订单 */
  498. async orderInfoCancelFun(type){
  499. // let payStatus = this.payStatus
  500. // this.payStatus = null
  501. try {
  502. this.loading = true
  503. this.loadingText = "取消订单中..."
  504. orderInfoCancel({
  505. orderId: this.orderId
  506. }).then((res)=>{
  507. if(res.code==200) {
  508. if(type){ // 关闭弹窗
  509. if(this.codeTime) {
  510. clearInterval(this.codeTime)
  511. }
  512. this.orderId = null
  513. this.payStatus = null
  514. this.$emit('clearDialogVisible')
  515. this.dialogVisible = false
  516. }else {
  517. this.payStatus = 9
  518. this.loading = false
  519. }
  520. }else {
  521. }
  522. }).catch(()=>{
  523. this.$message.error('订单关闭失败!!!');
  524. })
  525. } catch (error) {
  526. }
  527. },
  528. /** 退出窗口 */
  529. handleClose(done) {
  530. // if(this.payStatus==8) {
  531. // this.$message.error('请daying');
  532. // return
  533. // }
  534. this.$confirm('确认关闭?')
  535. .then(_ => {
  536. if(this.orderId){
  537. document.removeEventListener('keydown',this.keydownAdd);
  538. this.orderInfoCancelFun(true)
  539. }else {
  540. this.dialogVisible = false
  541. }
  542. })
  543. .catch(_ => {});
  544. },
  545. /** 保存个人信息 */
  546. handleSeva(index, row) {
  547. if(!this.tableForm.name){
  548. this.$message.error('请输入姓名!!!');
  549. return
  550. }
  551. if(!this.tableForm.idcard){
  552. this.$message.error('请输入身份证号!!!');
  553. return
  554. }
  555. if(this.tableForm.identity && this.tableForm.identity != 0){
  556. if(!this.tableForm.remark){
  557. this.$message.error('请输入备注!!!');
  558. return
  559. }
  560. }
  561. //this.factorAuthFun(index,this.tableForm)
  562. if(this.oneMany == 2 && index==0) {
  563. this.$set(this.viewerList,index,JSON.parse(JSON.stringify(this.tableForm)))
  564. let list = JSON.parse(JSON.stringify(this.viewerList))
  565. list.forEach((item,index)=>{
  566. item.name = this.tableForm.name
  567. item.idcard = this.tableForm.idcard
  568. })
  569. this.viewerList = list
  570. }else {
  571. this.$set(this.viewerList,index,JSON.parse(JSON.stringify(this.tableForm)))
  572. }
  573. this.actionIndex = null
  574. this.setMoneyAll()
  575. },
  576. /** 校验 身份证 */
  577. async factorAuthFun(index, obj){
  578. try {
  579. this.factorAuthLoading = true
  580. let res = await factorAuth({
  581. "name": obj.name,
  582. "idcard": obj.idcard
  583. })
  584. if(res.code == 200){
  585. this.factorAuthLoading = false
  586. if(res.data.status != 1) {
  587. this.$message.error(res.data.errReason);
  588. }else {
  589. this.$set(this.viewerList,index,JSON.parse(JSON.stringify(this.tableForm)))
  590. this.actionIndex = null
  591. this.setMoneyAll()
  592. }
  593. }else {
  594. this.$message.error(res.msg);
  595. this.factorAuthLoading = false
  596. }
  597. } catch (error) {
  598. this.$message.error(error);
  599. this.factorAuthLoading = false
  600. }
  601. },
  602. handleEdit(index, row) {
  603. this.actionIndex = row.id
  604. this.tableForm = JSON.parse(JSON.stringify(row))
  605. console.log(index, row);
  606. },
  607. handleDelete(index, row) {
  608. console.log(index, row);
  609. },
  610. setMoneyAll(){
  611. let moneyAll = 0
  612. this.viewerList.forEach((item,index) => {
  613. console.log("item.realPrice====",item.realPrice)
  614. if(item.realPrice && !isNaN(Number(item.realPrice))) {
  615. moneyAll = mathM.format(Number(moneyAll) + Number(item.realPrice),10)
  616. }
  617. })
  618. console.log("dsfsfdsf",moneyAll)
  619. this.moneyAll = moneyAll? moneyAll: ''
  620. this.$set(this.ruleForm,'realPrice',this.moneyAll)
  621. },
  622. setRealPrice(value) {
  623. // if(value && !isNaN(value)) {
  624. // this.$set(this.ruleForm,'small',mathM.format(Number(value) - Number(this.moneyAll),10) )
  625. // }
  626. if(this.ruleForm.realPrice_1 && !isNaN(this.ruleForm.realPrice_1) && value && !isNaN(value)) {
  627. this.$set(this.ruleForm,'small',mathM.format(Number(this.ruleForm.realPrice_1) - Number(value),10) )
  628. }
  629. },
  630. setRealPrice_1(value) {
  631. if(this.ruleForm.realPrice && !isNaN(this.ruleForm.realPrice) && value && !isNaN(value)) {
  632. this.$set(this.ruleForm,'small',mathM.format(Number(value) - Number(this.ruleForm.realPrice),10) )
  633. }
  634. },
  635. /** 检查是否存在空值 */
  636. checkViewerList() {
  637. let flog = false
  638. for(let i = 0; i < this.viewerList.length; i++){
  639. let obj = this.viewerList[i]
  640. if(!obj.name){
  641. this.$message.error('请填写观影人姓名!!!');
  642. flog = true
  643. break;
  644. }
  645. if(!obj.idcard){
  646. this.$message.error('请填写观影人身份证号!!!');
  647. flog = true
  648. break;
  649. }
  650. if(obj.identity && obj.identity != 0){
  651. if(!obj.remark){
  652. this.$message.error('请填写观影人备注!!!');
  653. flog = true
  654. break;
  655. }
  656. }
  657. }
  658. if(this.actionIndex){
  659. this.$message.error('请先保存观影影人信息!!!');
  660. flog = true
  661. }
  662. return flog
  663. },
  664. submitForm(formName) {
  665. this.$refs[formName].validate((valid) => {
  666. if (valid) {
  667. if(this.ruleForm.paymentType == 4 && (!this.balance||this.balance<=0||this.balance < this.moneyAll)) {
  668. this.$message.error('团队账户余额不足!!!');
  669. return
  670. }
  671. if(this.ruleForm.paymentType == 5 && (!this.grantQuota||this.grantQuota<=0||this.grantQuota < this.moneyAll)) {
  672. this.$message.error('团队授信余额不足!!!');
  673. return
  674. }
  675. if(!this.checkViewerList()){
  676. this.orderInfoSubmitFun()
  677. }
  678. } else {
  679. console.log('error submit!!');
  680. return false;
  681. }
  682. });
  683. },
  684. resetForm(formName) {
  685. this.$refs[formName].resetFields();
  686. },
  687. /** 生成订单 */
  688. async orderInfoSubmitFun(){
  689. this.loading = true
  690. try {
  691. this.orderId = null
  692. this.loadingText = "生成订单中..."
  693. let res = await orderInfoSubmit({
  694. ...this.ruleForm,
  695. viewerList: this.viewerList
  696. })
  697. if(res.code == 200){
  698. this.orderId = res.data.orderId
  699. if(this.ruleForm.paymentType == 2) {
  700. this.gotoCashPayFun(this.orderId)
  701. }else if(this.ruleForm.paymentType == 3) { // 对公支付
  702. this.gotoCorporatePayFun(this.orderId)
  703. }else if(this.ruleForm.paymentType == 4){ // 账户余额
  704. this.gotoBalancePayFun(this.orderId)
  705. }else if(this.ruleForm.paymentType == 5){ // 授信余额
  706. this.gotoQuotaPayFun(this.orderId)
  707. }else {
  708. // 扫码支付
  709. this.loading = false
  710. this.payStatus = 2
  711. }
  712. }else{
  713. this.$message.error('生成订单失败!!!');
  714. this.loading = false
  715. this.payStatus = 1
  716. }
  717. } catch (error) {
  718. this.$message.error('生成订单失败!!!');
  719. this.loading = false
  720. this.payStatus = 1
  721. }
  722. },
  723. /** 调取 订单支付码支付 */
  724. async gotoMicroPayFun(orderId,code){
  725. this.loading = true
  726. try {
  727. this.loadingText = "订单支付中..."
  728. this.payStatus = ''
  729. let res = await gotoMicroPay({
  730. "orderId": orderId, // 订单编号-提交订单返回
  731. "authCode": code // 微信扫码支付-支付码
  732. })
  733. if(res.code == 200){
  734. this.payTimeNum = 0
  735. this.websocketClear()
  736. if(this.payTime){
  737. clearInterval(this.payTime)
  738. }
  739. this.payTime = setInterval(()=>{
  740. this.payQueryFun(this.orderId)
  741. },1500)
  742. }else{
  743. this.$message.error('支付失败!!!');
  744. this.payStatus = ''
  745. this.loading = false
  746. this.payStatus = 6
  747. }
  748. } catch (error) {
  749. this.$message.error('支付失败!!!');
  750. this.loading = false
  751. this.payStatus = 6
  752. }
  753. },
  754. /** 对公支付 */
  755. async gotoCorporatePayFun(orderId) {
  756. this.loading = true
  757. try {
  758. this.loadingText = "订单入库中..."
  759. let res = await gotoCorporatePay({
  760. "orderId": orderId, // 订单编号-提交订单返回
  761. "payAmount": this.ruleForm.realPrice
  762. })
  763. if(res.code == 200){
  764. if(this.payTime){
  765. clearInterval(this.payTime)
  766. }
  767. this.payTimeNum = 0
  768. this.payTime = setInterval(()=>{
  769. this.payQueryFun(this.orderId)
  770. },1000)
  771. }else{
  772. this.$message.error('订单入库中失败!!!');
  773. this.loading = false
  774. this.payStatus = 3
  775. }
  776. } catch (error) {
  777. this.$message.error('订单入库中失败!!!');
  778. this.loading = false
  779. this.payStatus = 3
  780. }
  781. },
  782. /** 授信额度支付 */
  783. async gotoQuotaPayFun(orderId) {
  784. this.loading = true
  785. try {
  786. this.loadingText = "订单入库中..."
  787. let res = await gotoQuotaPay({
  788. "orderId": orderId, // 订单编号-提交订单返回
  789. })
  790. if(res.code == 200){
  791. if(this.payTime){
  792. clearInterval(this.payTime)
  793. }
  794. this.payTimeNum = 0
  795. this.payTime = setInterval(()=>{
  796. this.payQueryFun(this.orderId)
  797. },1000)
  798. }else{
  799. this.$message.error('订单入库中失败!!!');
  800. this.loading = false
  801. this.payStatus = 3
  802. }
  803. } catch (error) {
  804. this.$message.error('订单入库中失败!!!');
  805. this.loading = false
  806. this.payStatus = 3
  807. }
  808. },
  809. /** 余额支付 */
  810. async gotoBalancePayFun(orderId) {
  811. this.loading = true
  812. try {
  813. this.loadingText = "订单入库中..."
  814. let res = await gotoBalancePay({
  815. "orderId": orderId, // 订单编号-提交订单返回
  816. })
  817. if(res.code == 200){
  818. if(this.payTime){
  819. clearInterval(this.payTime)
  820. }
  821. this.payTimeNum = 0
  822. this.payTime = setInterval(()=>{
  823. this.payQueryFun(this.orderId)
  824. },1000)
  825. }else{
  826. this.$message.error('订单入库中失败!!!');
  827. this.loading = false
  828. this.payStatus = 3
  829. }
  830. } catch (error) {
  831. this.$message.error('订单入库中失败!!!');
  832. this.loading = false
  833. this.payStatus = 3
  834. }
  835. },
  836. /** 订单现金支付 */
  837. async gotoCashPayFun(orderId){
  838. this.loading = true
  839. try {
  840. this.loadingText = "订单入库中..."
  841. let res = await gotoCashPay({
  842. "orderId": orderId, // 订单编号-提交订单返回
  843. "payAmount": this.ruleForm.realPrice
  844. })
  845. if(res.code == 200){
  846. if(this.payTime){
  847. clearInterval(this.payTime)
  848. }
  849. this.payTimeNum = 0
  850. this.payTime = setInterval(()=>{
  851. this.payQueryFun(this.orderId)
  852. },1000)
  853. }else{
  854. this.$message.error('订单入库中失败!!!');
  855. this.loading = false
  856. this.payStatus = 3
  857. }
  858. } catch (error) {
  859. this.$message.error('订单入库中失败!!!');
  860. this.loading = false
  861. this.payStatus = 3
  862. }
  863. },
  864. // 跳转取票界面
  865. goTicketingCollections(){
  866. this.$router.push({
  867. path:"/windowTicketSales/ticketingCollections",
  868. query:{
  869. orderId: this.orderId
  870. }
  871. })
  872. },
  873. /** 查看支付 状态 */
  874. async payQueryFun(orderId){
  875. this.loading = true
  876. try {
  877. this.payTimeNum = this.payTimeNum + 1
  878. if(this.payTimeNum==15){
  879. if(this.payTime){
  880. clearInterval(this.payTime)
  881. }
  882. this.orderInfoCancelFun()
  883. return
  884. }
  885. if(this.ruleForm.paymentType == 2){
  886. this.loadingText = "订单入库中..."
  887. }else {
  888. this.loadingText = "订单支付中..."
  889. }
  890. this.payStatus = ''
  891. let res = await payQuery({
  892. orderId: orderId
  893. })
  894. if(res.code == 200){
  895. if(res.data) {
  896. if(res.data.payStatus == 0) {
  897. if(this.payTime){
  898. clearInterval(this.payTime)
  899. }
  900. if(this.ruleForm.paymentType == 2){
  901. this.$message.error('"订单入库中失败"');
  902. this.loading = false
  903. this.payStatus = 3
  904. }else {
  905. if(res.data.orderStatus == 9 || res.data.orderStatus == 4 || res.data.orderStatus == 5){
  906. this.$message.error('订单已关闭,请重新选择座位,再购买!!!');
  907. this.loading = false
  908. this.payStatus = 10
  909. }else {
  910. this.$message.error('用户未支付!!!');
  911. this.loading = false
  912. this.payStatus = 7
  913. }
  914. }
  915. }else if(res.data.payStatus == 1) {
  916. if(this.payTime){
  917. clearInterval(this.payTime)
  918. }
  919. if(this.ruleForm.paymentType == 2){
  920. this.$message({
  921. message: '订单入库成功',
  922. type: 'success'
  923. });
  924. this.loading = false
  925. // this.payStatus = 8
  926. // this.getPrintListApi()
  927. this.goTicketingCollections()
  928. }else {
  929. this.$message({
  930. message: '用户已支付成功,请打印门票',
  931. type: 'success'
  932. });
  933. // 开始 打印
  934. this.loading = false
  935. // this.payStatus = 8
  936. // this.getPrintListApi()
  937. this.goTicketingCollections()
  938. }
  939. this.dialogVisible = false
  940. }else if(res.data.payStatus == 2) {
  941. }else if(res.data.payStatus == 3) {
  942. if(this.payTime){
  943. clearInterval(this.payTime)
  944. }
  945. if(this.ruleForm.paymentType == 2){
  946. this.$message.error('"订单入库中失败"');
  947. this.loading = false
  948. this.payStatus = 3
  949. }else {
  950. if(res.data.orderStatus == 9 || res.data.orderStatus == 4 || res.data.orderStatus == 5){
  951. this.$message.error('订单已关闭,请重新选择座位,再购买!!!');
  952. this.loading = false
  953. this.payStatus = 10
  954. }else {
  955. this.$message.error('用户支付失败!!!');
  956. this.loading = false
  957. this.payStatus = 7
  958. }
  959. }
  960. }else if(res.data.payStatus == 4) {
  961. if(this.payTime){
  962. clearInterval(this.payTime)
  963. }
  964. if(this.ruleForm.paymentType == 2){
  965. this.$message.error('"订单入库中失败"');
  966. this.loading = false
  967. this.payStatus = 3
  968. }else {
  969. if(res.data.orderStatus == 9 || res.data.orderStatus == 4 || res.data.orderStatus == 5){
  970. this.$message.error('订单已关闭,请重新选择座位,再购买!!!');
  971. this.loading = false
  972. this.payStatus = 10
  973. }else {
  974. this.$message.error('支付退款!!!');
  975. this.loading = false
  976. this.payStatus = 7
  977. }
  978. }
  979. }
  980. }
  981. }else{
  982. this.$message.error('支付失败!!!');
  983. this.loading = false
  984. this.payStatus = 7
  985. }
  986. } catch (error) {
  987. this.$message.error('支付失败!!!');
  988. this.loading = false
  989. this.payStatus = 7
  990. }
  991. },
  992. /** 连接VBarServer */
  993. vbar_open() {
  994. this.loading = true
  995. this.loadingText = "连接扫码盒子中!!!"
  996. this.payStatus = null
  997. this.code = ''
  998. this.websocketClear()
  999. this.payStatus = 5 // 连接成功
  1000. document.addEventListener('keydown',this.keydownAdd);
  1001. this.loading = false
  1002. },
  1003. /** 连接结果 */
  1004. websocket_open_state(message){
  1005. console.log("连接结果 ===== ",message)
  1006. this.codeTime = setInterval(()=>{
  1007. console.log("检测是否连接")
  1008. if(this.websocketData.readyState != WebSocket.OPEN) {
  1009. this.payStatus = 6
  1010. }
  1011. },3000)
  1012. //document.getElementById('wsocket').value = "已连接";
  1013. },
  1014. // 拼接字符串
  1015. keydownAdd(e){
  1016. console.log("e=====",e)
  1017. console.log("this.code=====",this.code)
  1018. if( this.payStatus == 5 && e.key != 'Enter') {
  1019. this.code = this.code + e.key
  1020. }
  1021. if( e.key == 'Enter') {
  1022. document.removeEventListener('keydown',this.keydownAdd);
  1023. let codeCopy = this.code
  1024. this.payStatus == 5.5
  1025. this.code = ''
  1026. this.gotoMicroPayFun(this.orderId,codeCopy)
  1027. }
  1028. },
  1029. //接收扫码完整结果处理
  1030. websocket_decode(code){
  1031. console.log("orderId=========",this.orderId )
  1032. console.log("code=========",code)
  1033. if(this.orderId && this.payStatus == 5.5 && regex.test(code) ) {
  1034. this.payStatus = 5.6 // 支付中
  1035. let codeCopy = code.replace("%%%", "").replace("%%%", "")
  1036. this.gotoMicroPayFun(this.orderId,codeCopy)
  1037. }else if(!code){
  1038. this.payStatus = 5
  1039. this.code = ''
  1040. }
  1041. },
  1042. /** 关闭通讯 */
  1043. websocketClear(){
  1044. document.removeEventListener('keydown',this.keydownAdd);
  1045. },
  1046. /** 读取身份证 */
  1047. readCert(){
  1048. this.idcardLoading = true
  1049. var result = "";
  1050. try {
  1051. let xmlHttp = new XMLHttpRequest();
  1052. let Protocol = window.location.protocol.split(':')[0];
  1053. //获取当前协议,并且分割字符串,得到http或者https
  1054. if (Protocol === 'https'){
  1055. //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
  1056. xmlHttp.open("POST", "http://127.0.0.1:18889/api/readCert?ReadSN=" + 0, false); //readCert读卡,生成正反面仿复印件
  1057. }else {
  1058. //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
  1059. xmlHttp.open("POST", "http://127.0.0.1:18889/api/readCert?ReadSN=" + 0, false); //readCert读卡,生成正反面仿复印件
  1060. }
  1061. //发送请求
  1062. xmlHttp.send();
  1063. if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
  1064. result = xmlHttp.responseText;
  1065. xmlHttp.readyState = 1;
  1066. }
  1067. } catch (e) {
  1068. console.error("e====",e)
  1069. }
  1070. let obj = JSON.parse(result)
  1071. if(obj.resultContent && obj.resultContent.certNumber){
  1072. this.$set(this.tableForm,"idcard",obj.resultContent.certNumber)
  1073. this.$set(this.tableForm,"name",obj.resultContent.partyName)
  1074. }else {
  1075. this.$message.error('读取失败!!!');
  1076. }
  1077. this.idcardLoading = false
  1078. //return result;
  1079. console.log(result,obj)
  1080. },
  1081. /** 查询打印机列表 */
  1082. getPrintListApi() {
  1083. getPrintListApi({deviceType:5,pageNum: 1,
  1084. pageSize: 999,})
  1085. .then(response => {
  1086. this.printList = response.data.rows;
  1087. }).catch((error)=>{
  1088. console.log("error===",error)
  1089. }
  1090. );
  1091. },
  1092. // 打印
  1093. async print(list = []){
  1094. if(!this.printListId) {
  1095. this.$message.error('请选择打印机!!');
  1096. return
  1097. }
  1098. this.loading = true
  1099. this.loadingText = '打印中...'
  1100. this.payStatus = ''
  1101. try {
  1102. let res = await printApi({
  1103. orderId: this.orderId,
  1104. source: 2,
  1105. deviceId: this.printListId
  1106. })
  1107. if(res.code == 200) {
  1108. let url = res.data.linkIp
  1109. let printInfo = res.data.printInfo
  1110. this.connectPrint(url,printInfo)
  1111. }else {
  1112. throw new Error(res)
  1113. }
  1114. } catch (error) {
  1115. this.loading = false
  1116. this.payStatus = 8
  1117. console.error("error=====",error)
  1118. }
  1119. },
  1120. /** 连接打印机 */
  1121. connectPrint(url,data){
  1122. // 创建忽略 SSL 的 axios 实例
  1123. const ignoreSSL = axios.create({
  1124. httpsAgent: new https.Agent({
  1125. rejectUnauthorized: false
  1126. }),
  1127. withCredentials: true, // 跨域请求时发送Cookie
  1128. timeout: 60000, // 请求超时
  1129. headers: {
  1130. "Content-Type": "application/json; charset=UTF-8;"
  1131. }
  1132. });
  1133. ignoreSSL.post(url,
  1134. { ...data }
  1135. ).then(()=>{
  1136. this.dialogVisible = false
  1137. this.loading = false
  1138. }).catch(()=>{
  1139. this.loading = false
  1140. this.payStatus = 8
  1141. // this.dialogVisible = false
  1142. // this.loading = false
  1143. })
  1144. // 在 axios 请求时,选择性忽略 SSL
  1145. // const agent = new https.Agent({
  1146. // rejectUnauthorized: false
  1147. // });
  1148. // axios.post(
  1149. // url,
  1150. // { httpsAgent: agent,...data }
  1151. // ).then(()=>{
  1152. // this.dialogVisible = false
  1153. // this.loading = false
  1154. // })
  1155. // .catch(()=>{
  1156. // this.dialogVisible = false
  1157. // this.loading = false
  1158. // })
  1159. },
  1160. /** 获取授信余额和账户余额 */
  1161. async selectMarketTeamBySourceFun(value) {
  1162. console.log("value===",value)
  1163. try {
  1164. if(!['10','11','13','14','18','19'].includes(value)) return
  1165. let res = await selectMarketTeamBySourceApi({
  1166. source: value
  1167. })
  1168. this.balance = res.data.balance
  1169. if(res.data.grantQuota && res.data.grantUsed) {
  1170. this.grantQuota = res.data.grantQuota - res.data.grantUsed
  1171. }else if(res.data.grantQuota) {
  1172. this.grantQuota = res.data.grantQuota
  1173. }else {
  1174. this.grantQuota = 0
  1175. }
  1176. } catch (error) {
  1177. this.balance = null
  1178. this.grantQuota = null
  1179. }
  1180. }
  1181. },
  1182. beforeDestroy() {
  1183. // 组件销毁前执行的代码
  1184. console.log('组件即将销毁');
  1185. document.removeEventListener('keydown',this.keydownAdd);
  1186. },
  1187. }
  1188. </script>
  1189. <style scoped lang="scss">
  1190. .increase-viewers-box {
  1191. width: 100%;
  1192. height: calc( 100vh - 250px );
  1193. box-sizing: border-box;
  1194. overflow: hidden;
  1195. overflow-y: auto;
  1196. position: relative;
  1197. }
  1198. .increase-viewers-pay-status {
  1199. width: 100%;
  1200. height: 100%;
  1201. position: absolute;
  1202. z-index: 999;
  1203. background-color: rgba(0,0,0,0.3);
  1204. top: 0;
  1205. left: 0;
  1206. .increase-viewers-pay-status-info {
  1207. width: 100%;
  1208. height: 100%;
  1209. display: flex;
  1210. flex-direction: column;
  1211. justify-content: center;
  1212. align-items: center;
  1213. color: #fff;
  1214. }
  1215. }
  1216. </style>