increaseViewers.vue 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063
  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>{{ scope.row.realPrice }}</span> -->
  101. <div>
  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">
  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 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="15">去哪儿</el-radio> -->
  161. <el-radio label="16">其他</el-radio>
  162. </el-radio-group>
  163. </el-form-item>
  164. <el-form-item label-width="60px" v-if="ruleForm.source && ruleForm.source == 16" label="备注 :" prop="sourceRemark">
  165. <el-input style="width: 200px;" v-model="ruleForm.sourceRemark"></el-input>
  166. </el-form-item>
  167. </div>
  168. <el-form-item v-if="ruleForm.source && ruleForm.source != 7" label="核销码/订单码" prop="orderIdOrQrCode">
  169. <el-input style="width: 400px;" type="textarea" :rows="2" v-model="ruleForm.orderIdOrQrCode"></el-input>
  170. </el-form-item>
  171. <el-form-item label="支付方式 :" prop="paymentType">
  172. <el-radio-group v-model="ruleForm.paymentType">
  173. <el-radio label="1">扫码</el-radio>
  174. <el-radio label="2">现金</el-radio>
  175. <el-radio v-if="['10','11','13','14'].includes(ruleForm.source)" label="3">对公支付</el-radio>
  176. </el-radio-group>
  177. </el-form-item>
  178. <el-form-item label="应付金额 :">
  179. ¥{{ moneyAll }}元
  180. </el-form-item>
  181. <el-form-item v-if="ruleForm.paymentType == 2 || ruleForm.paymentType == 3" label="实付金额 :" prop="realPrice">
  182. <el-input @input="setRealPrice" style="width: 200px;" v-model="ruleForm.realPrice"></el-input>
  183. </el-form-item>
  184. <el-form-item label="找零金额 :" v-if="ruleForm.paymentType == 2">
  185. ¥{{ ruleForm.small }}元
  186. </el-form-item>
  187. <el-form-item label="订单备注 :" prop="remark">
  188. <el-input style="width: 400px;" type="textarea" :rows="2" maxlength="200" v-model="ruleForm.remark" show-word-limit></el-input>
  189. </el-form-item>
  190. </el-form>
  191. </div>
  192. <!-- 支付过程 控制 -->
  193. <div v-if="payStatus" class="increase-viewers-pay-status">
  194. <div class="increase-viewers-pay-status-info" v-if="!loading">
  195. <span style="font-weight: 600;font-size: 20px;">提示</span>
  196. <span style="padding: 10px 0;">
  197. {{ payStatus==1 ? '生成订单失败!!!' :
  198. payStatus==2 ? '生成订单生成成功,请点击调取扫码盒子' :
  199. payStatus==4 ? '扫码支付失败!!!' :
  200. payStatus==5 ? '请出示付款码!!!' :
  201. payStatus==6 ? '连接扫码器失败!!!' :
  202. payStatus==7 ? '用户支付失败或未支付,请重新连接支付!!!' :
  203. payStatus==8 ? '用户支付成功,请点击打印票!!!' :
  204. payStatus==9 ? '支付超时!!!' :
  205. payStatus==3 ? '现金支付记录入库失败,请重新提交' : '未知状态' }}
  206. </span>
  207. <!-- 重新生成订单 1 -->
  208. <div v-if="payStatus==1" style="display: flex;">
  209. <el-button @click="payStatus = null" type="success">修改信息</el-button>
  210. <el-button @click="orderInfoSubmitFun()" style="margin-left: 20px;" type="primary">重新生成订单</el-button>
  211. </div>
  212. <!-- 扫码支付 2 -->
  213. <el-button v-if="payStatus==2" @click="vbar_open(orderId)" type="success">扫码支付</el-button>
  214. <!-- 扫码支付 4 -->
  215. <el-button v-if="payStatus==4" @click="vbar_open(orderId)" type="success">重新扫码支付</el-button>
  216. <!-- 重新支付 3 -->
  217. <el-button v-if="payStatus==3" @click="gotoCashPayFun(orderId)" type="success">重新提交入库</el-button>
  218. <!-- 重新支付 6 7 -->
  219. <el-button v-if="payStatus==6 || payStatus==7" @click="vbar_open(orderId)" type="success">重新连接扫码支付</el-button>
  220. <!-- 打印 8 -->
  221. <div v-if="payStatus==8">
  222. <el-select v-model="printListId" placeholder="选择打印机">
  223. <el-option :label="item.deviceName" :key="item.id" :value="item.id" v-for="(item,index) in printList"></el-option>
  224. </el-select>
  225. <el-button style="margin-left: 15px" @click="print" type="success">打印门票</el-button>
  226. <el-button style="margin-left: 15px" @click="goTicketingCollections" type="success">跳转取票界面</el-button>
  227. </div>
  228. <!-- 支付超时 9 -->
  229. <div v-if="payStatus==9">
  230. <!-- <el-button @click="print" type="danger">取消支付</el-button> -->
  231. <el-button @click="orderInfoSubmitFun()" type="primary">重新扫码</el-button>
  232. </div>
  233. </div>
  234. </div>
  235. </div>
  236. <span slot="footer" class="dialog-footer">
  237. <el-button @click="handleClose()">取 消</el-button>
  238. <el-button v-if="!orderId&&!payStatus" :loading="loading" type="primary" @click="submitForm('ruleForm11')">确定支付</el-button>
  239. </span>
  240. </el-dialog>
  241. </template>
  242. <script>
  243. import {
  244. orderInfoSubmit,
  245. gotoMicroPay,
  246. gotoCashPay,
  247. gotoCorporatePay,
  248. payQuery,
  249. selectRegion,
  250. orderInfoCancel,
  251. factorAuth
  252. } from '@/api/windowTicketSales/ticketingSales'
  253. import { pageList as getPrintListApi } from "@/api/device/pda";
  254. import { printApi } from '@/api/windowTicketSales/ticketingCollection'
  255. const mathM = require('mathjs')
  256. const https = require('https');
  257. const axios = require('axios');
  258. export default {
  259. dicts: ['personnel_type'],
  260. data() {
  261. return {
  262. loading: false,
  263. loadingText: '',
  264. dialogVisible: false,
  265. actionIndex: false,
  266. tableForm: {
  267. name: '', // 姓名
  268. mobile: '', // 电话
  269. idcard: '', // 身份证
  270. identity: '', // 观影人身份
  271. remark: '', // 备注信息
  272. salePrice: '', // 原价
  273. realPrice: '', // 实付金额
  274. seatId: '', // 座位ID
  275. seatName: '', // 座位名称
  276. seatType: '', // 座位类型
  277. },
  278. ruleForm: {
  279. performId: "", // 剧目ID
  280. retailId: "", // 分销ID
  281. goodsList: [], // 商品列表
  282. auditoriumId: "", // 演出厅ID
  283. performTimeId: "1", // 场次时段ID
  284. seatTypeId: "", // 座位类型ID
  285. source: '', // 订单来源
  286. purchaser: {},// 购票人信息
  287. viewerList: [], // 观影人列表
  288. orderIdOrQrCode: '',
  289. paymentType: '', // 支付方式
  290. small: '',// 找零
  291. realPrice: '', // 实付金额
  292. },
  293. viewerList: [], // 观影人列表
  294. rules: {
  295. source: [
  296. { required: true, message: '请选择用户来源', trigger: ['blur','change']},
  297. ],
  298. orderIdOrQrCode: [
  299. { required: true, message: '请输入核销码/订单码', trigger: ['blur','change']},
  300. ],
  301. paymentType: [
  302. { required: true, message: '请选择支付方式', trigger: ['blur','change']},
  303. ],
  304. realPrice: [
  305. { required: true, message: '请输入实付金额', trigger: ['blur','change']},
  306. ],
  307. sourceRemark: [
  308. { required: true, message: '请输入备注', trigger: ['blur','change']},
  309. ],
  310. },
  311. moneyAll: '',
  312. payment: '',
  313. payStatus: null, // 支付状态
  314. orderId: null,
  315. websocket_connected: false, // 是否已连接
  316. websocketCtrl: null,
  317. websocketData: null,
  318. idcardLoading: false,
  319. payTime: null, // 支付等待时间
  320. payTimeNum: 0,
  321. printListId: null,
  322. printList: [],
  323. // 身份证校验 loading
  324. factorAuthLoading: false,
  325. };
  326. },
  327. methods: {
  328. async initData(list,params){
  329. try {
  330. this.websocketClear()
  331. this.idcardLoading = false
  332. this.ruleForm = {
  333. performId: "", // 剧目ID
  334. retailId: "", // 分销ID
  335. goodsList: [], // 商品列表
  336. auditoriumId: "", // 演出厅ID
  337. performTimeId: "", // 场次时段ID
  338. seatTypeId: "", // 座位类型ID
  339. source: '', // 订单来源
  340. purchaser: {},// 购票人信息
  341. viewerList: [], // 观影人列表
  342. orderIdOrQrCode: '',
  343. paymentType: '', // 支付方式
  344. small: '',// 实付金额
  345. realPrice: '', // 实付金额
  346. remark: '', // 订单备注
  347. sourceRemark: '', // 来源备注
  348. }
  349. this.payStatus = null
  350. this.orderId = null
  351. this.websocket_connected = false
  352. this.dialogVisible = true
  353. this.loading = true
  354. this.actionIndex = null
  355. this.viewerList = []
  356. let perform = await this.selectRegionFun(params,list[0].seatTypeId)
  357. console.log("perform===",perform)
  358. // let perform = {
  359. // money: 1,
  360. // name: '普通票'
  361. // }
  362. let listCopy = []
  363. let listCopy1 = []
  364. list.forEach((item,index)=>{
  365. listCopy.push({
  366. id: index+1,
  367. name: '', // 姓名
  368. mobile: '', // 电话
  369. idcard: '', // 身份证
  370. identity: '', // 观影人身份
  371. remark: '', // 备注信息
  372. salePrice: perform.money, // 原价
  373. realPrice: perform.money, // 实付金额
  374. seatId: item.id, // 座位ID
  375. seatName: item.name?item.name:'暂无命名', // 座位名称
  376. seatType: perform.seatTypeId, // 座位类型
  377. seatTypeId: perform.seatTypeId,
  378. seatTypeName: perform.seatTypeName,
  379. })
  380. })
  381. //this.goodsList =
  382. this.viewerList = JSON.parse(JSON.stringify(listCopy))
  383. this.setMoneyAll()
  384. console.log(this.viewerList)
  385. this.loading = false
  386. this.$nextTick(()=>{
  387. this.$refs.ruleForm11.clearValidate()
  388. })
  389. } catch (error) {
  390. console.error("error====",error)
  391. }
  392. },
  393. /** 获取票务信息 */
  394. async selectRegionFun(params,seatTypeId){
  395. try {
  396. this.loadingText = "获取票务信息中..."
  397. let res = await selectRegion({
  398. "auditoriumId": params.auditoriumId, // 演艺厅ID
  399. "goodsId": params.goodsId, // 商品ID
  400. "performId": params.performId, // 上一界面节目ID
  401. "performTimeId": params.timeId, // 时段ID
  402. "retailId": "" // 分销ID
  403. })
  404. if(res.code == 200) {
  405. if(res.data.regionPriceList &&res.data.regionPriceList.length>0){
  406. //let obj = res.data.regionPriceList[0]
  407. let obj = {}
  408. res.data.regionPriceList.forEach((item,index)=>{
  409. if(seatTypeId == item.seatTypeId) {
  410. obj = item
  411. }
  412. })
  413. if(JSON.stringify(obj) != '{}'){
  414. this.ruleForm.performId = obj.performId
  415. this.ruleForm.goodsList = [
  416. {
  417. goodsId: obj.goodsId,
  418. salePeice: obj.salePrice,
  419. saleNum: 1,
  420. }
  421. ]
  422. this.ruleForm.auditoriumId = obj.auditoriumId
  423. this.ruleForm.performId = obj.performId
  424. this.ruleForm.performTimeId = res.data.performTimeId
  425. this.ruleForm.seatTypeId = obj.seatTypeId
  426. return {
  427. money: obj.salePrice,
  428. //name: obj.goodsName,
  429. seatTypeId: obj.seatTypeId,
  430. seatTypeName: obj.seatTypeName,
  431. }
  432. }else {
  433. this.$message.error('存在座位未设置价格,请选择其他票!!!');
  434. this.loading = false
  435. this.dialogVisible = false
  436. }
  437. }else {
  438. this.$message.error('存在座位未设置价格,请选择其他票!!!');
  439. this.loading = false
  440. this.dialogVisible = false
  441. }
  442. console.log("res====",res)
  443. }else {
  444. this.$message.error(res.msg);
  445. this.loading = false
  446. this.dialogVisible = false
  447. }
  448. } catch (error) {
  449. console.error("error=====",error)
  450. this.$message.error('价格查询出错');
  451. this.loading = false
  452. this.dialogVisible = false
  453. }
  454. },
  455. /** 取消订单 */
  456. async orderInfoCancelFun(type){
  457. try {
  458. this.loading = true
  459. this.loadingText = "取消订单中..."
  460. orderInfoCancel({
  461. orderId: this.orderId
  462. }).then((res)=>{
  463. if(res.code==200) {
  464. if(type){ // 关闭弹窗
  465. this.$emit('clearDialogVisible')
  466. this.dialogVisible = false
  467. }else {
  468. this.payStatus = 9
  469. this.loading = false
  470. }
  471. }
  472. }).catch(()=>{
  473. this.$message.error('订单关闭失败!!!');
  474. })
  475. } catch (error) {
  476. }
  477. },
  478. /** 退出窗口 */
  479. handleClose(done) {
  480. // if(this.payStatus==8) {
  481. // this.$message.error('请daying');
  482. // return
  483. // }
  484. this.$confirm('确认关闭?')
  485. .then(_ => {
  486. if(this.orderId){
  487. this.orderInfoCancelFun(true)
  488. }else {
  489. this.dialogVisible = false
  490. }
  491. })
  492. .catch(_ => {});
  493. },
  494. /** 保存个人信息 */
  495. handleSeva(index, row) {
  496. if(!this.tableForm.name){
  497. this.$message.error('请输入姓名!!!');
  498. return
  499. }
  500. if(!this.tableForm.idcard){
  501. this.$message.error('请输入身份证号!!!');
  502. return
  503. }
  504. if(this.tableForm.identity && this.tableForm.identity != 0){
  505. if(!this.tableForm.remark){
  506. this.$message.error('请输入备注!!!');
  507. return
  508. }
  509. }
  510. //this.factorAuthFun(index,this.tableForm)
  511. this.$set(this.viewerList,index,JSON.parse(JSON.stringify(this.tableForm)))
  512. this.actionIndex = null
  513. this.setMoneyAll()
  514. },
  515. /** 校验 身份证 */
  516. async factorAuthFun(index, obj){
  517. try {
  518. this.factorAuthLoading = true
  519. let res = await factorAuth({
  520. "name": obj.name,
  521. "idcard": obj.idcard
  522. })
  523. if(res.code == 200){
  524. this.factorAuthLoading = false
  525. if(res.data.status != 1) {
  526. this.$message.error(res.data.errReason);
  527. }else {
  528. this.$set(this.viewerList,index,JSON.parse(JSON.stringify(this.tableForm)))
  529. this.actionIndex = null
  530. this.setMoneyAll()
  531. }
  532. }else {
  533. this.$message.error(res.msg);
  534. this.factorAuthLoading = false
  535. }
  536. } catch (error) {
  537. this.$message.error(error);
  538. this.factorAuthLoading = false
  539. }
  540. },
  541. handleEdit(index, row) {
  542. this.actionIndex = row.id
  543. this.tableForm = JSON.parse(JSON.stringify(row))
  544. console.log(index, row);
  545. },
  546. handleDelete(index, row) {
  547. console.log(index, row);
  548. },
  549. setMoneyAll(){
  550. let moneyAll = 0
  551. this.viewerList.forEach((item,index) => {
  552. console.log("item.realPrice====",item.realPrice)
  553. if(item.realPrice && !isNaN(Number(item.realPrice))) {
  554. moneyAll = mathM.format(Number(moneyAll) + Number(item.realPrice),10)
  555. }
  556. })
  557. console.log("dsfsfdsf",moneyAll)
  558. this.moneyAll = moneyAll? moneyAll: ''
  559. },
  560. setRealPrice(value) {
  561. if(value && !isNaN(value)) {
  562. this.$set(this.ruleForm,'small',mathM.format(Number(value) - Number(this.moneyAll),10) )
  563. }
  564. },
  565. /** 检查是否存在空值 */
  566. checkViewerList() {
  567. let flog = false
  568. for(let i = 0; i < this.viewerList.length; i++){
  569. let obj = this.viewerList[i]
  570. if(!obj.name){
  571. this.$message.error('请填写观影人姓名!!!');
  572. flog = true
  573. break;
  574. }
  575. if(!obj.idcard){
  576. this.$message.error('请填写观影人身份证号!!!');
  577. flog = true
  578. break;
  579. }
  580. if(obj.identity && obj.identity != 0){
  581. if(!obj.remark){
  582. this.$message.error('请填写观影人备注!!!');
  583. flog = true
  584. break;
  585. }
  586. }
  587. }
  588. if(this.actionIndex){
  589. this.$message.error('请先保存观影影人信息!!!');
  590. flog = true
  591. }
  592. return flog
  593. },
  594. submitForm(formName) {
  595. this.$refs[formName].validate((valid) => {
  596. if (valid) {
  597. if(!this.checkViewerList()){
  598. this.orderInfoSubmitFun()
  599. }
  600. } else {
  601. console.log('error submit!!');
  602. return false;
  603. }
  604. });
  605. },
  606. resetForm(formName) {
  607. this.$refs[formName].resetFields();
  608. },
  609. /** 生成订单 */
  610. async orderInfoSubmitFun(){
  611. this.loading = true
  612. try {
  613. this.orderId = null
  614. this.loadingText = "生成订单中..."
  615. let res = await orderInfoSubmit({
  616. ...this.ruleForm,
  617. viewerList: this.viewerList
  618. })
  619. if(res.code == 200){
  620. this.orderId = res.data.orderId
  621. if(this.ruleForm.paymentType == 2) {
  622. this.gotoCashPayFun(this.orderId)
  623. }else if(this.ruleForm.paymentType == 3) { // 对公支付
  624. this.gotoCorporatePayFun(this.orderId)
  625. }else {
  626. // 扫码支付
  627. this.loading = false
  628. this.payStatus = 2
  629. }
  630. }else{
  631. this.$message.error('生成订单失败!!!');
  632. this.loading = false
  633. this.payStatus = 1
  634. }
  635. } catch (error) {
  636. this.$message.error('生成订单失败!!!');
  637. this.loading = false
  638. this.payStatus = 1
  639. }
  640. },
  641. /** 调取 订单支付码支付 */
  642. async gotoMicroPayFun(orderId,code){
  643. this.loading = true
  644. try {
  645. this.loadingText = "订单支付中..."
  646. this.payStatus = ''
  647. let res = await gotoMicroPay({
  648. "orderId": orderId, // 订单编号-提交订单返回
  649. "authCode": code // 微信扫码支付-支付码
  650. })
  651. if(res.code == 200){
  652. this.payTimeNum = 0
  653. this.websocketClear()
  654. if(this.payTime){
  655. clearInterval(this.payTime)
  656. }
  657. this.payTime = setInterval(()=>{
  658. this.payQueryFun(this.orderId)
  659. },1500)
  660. }else{
  661. this.$message.error('支付失败!!!');
  662. this.payStatus = ''
  663. this.loading = false
  664. this.payStatus = 6
  665. }
  666. } catch (error) {
  667. this.$message.error('支付失败!!!');
  668. this.loading = false
  669. this.payStatus = 6
  670. }
  671. },
  672. /** 对公支付 */
  673. async gotoCorporatePayFun(orderId) {
  674. this.loading = true
  675. try {
  676. this.loadingText = "订单入库中..."
  677. let res = await gotoCorporatePay({
  678. "orderId": orderId, // 订单编号-提交订单返回
  679. "payAmount": this.ruleForm.realPrice
  680. })
  681. if(res.code == 200){
  682. if(this.payTime){
  683. clearInterval(this.payTime)
  684. }
  685. this.payTimeNum = 0
  686. this.payTime = setInterval(()=>{
  687. this.payQueryFun(this.orderId)
  688. },1000)
  689. }else{
  690. this.$message.error('订单入库中失败!!!');
  691. this.loading = false
  692. this.payStatus = 3
  693. }
  694. } catch (error) {
  695. this.$message.error('订单入库中失败!!!');
  696. this.loading = false
  697. this.payStatus = 3
  698. }
  699. },
  700. /** 订单现金支付 */
  701. async gotoCashPayFun(orderId){
  702. this.loading = true
  703. try {
  704. this.loadingText = "订单入库中..."
  705. let res = await gotoCashPay({
  706. "orderId": orderId, // 订单编号-提交订单返回
  707. "payAmount": this.ruleForm.realPrice
  708. })
  709. if(res.code == 200){
  710. if(this.payTime){
  711. clearInterval(this.payTime)
  712. }
  713. this.payTimeNum = 0
  714. this.payTime = setInterval(()=>{
  715. this.payQueryFun(this.orderId)
  716. },1000)
  717. }else{
  718. this.$message.error('订单入库中失败!!!');
  719. this.loading = false
  720. this.payStatus = 3
  721. }
  722. } catch (error) {
  723. this.$message.error('订单入库中失败!!!');
  724. this.loading = false
  725. this.payStatus = 3
  726. }
  727. },
  728. // 跳转取票界面
  729. goTicketingCollections(){
  730. this.$router.push({
  731. path:"/windowTicketSales/ticketingCollections",
  732. query:{
  733. orderId: this.orderId
  734. }
  735. })
  736. },
  737. /** 查看支付 状态 */
  738. async payQueryFun(orderId){
  739. this.loading = true
  740. try {
  741. this.payTimeNum = this.payTimeNum + 1
  742. if(this.payTimeNum==15){
  743. if(this.payTime){
  744. clearInterval(this.payTime)
  745. }
  746. this.orderInfoCancelFun()
  747. return
  748. }
  749. if(this.ruleForm.paymentType == 2){
  750. this.loadingText = "订单入库中..."
  751. }else {
  752. this.loadingText = "订单支付中..."
  753. }
  754. this.payStatus = ''
  755. let res = await payQuery({
  756. orderId: orderId
  757. })
  758. if(res.code == 200){
  759. if(res.data) {
  760. if(res.data.payStatus == 0) {
  761. if(this.payTime){
  762. clearInterval(this.payTime)
  763. }
  764. if(this.ruleForm.paymentType == 2){
  765. this.$message.error('"订单入库中失败"');
  766. this.loading = false
  767. this.payStatus = 3
  768. }else {
  769. this.$message.error('用户未支付!!!');
  770. this.loading = false
  771. this.payStatus = 7
  772. }
  773. }else if(res.data.payStatus == 1) {
  774. if(this.payTime){
  775. clearInterval(this.payTime)
  776. }
  777. if(this.ruleForm.paymentType == 2){
  778. this.$message({
  779. message: '订单入库成功',
  780. type: 'success'
  781. });
  782. this.loading = false
  783. // this.payStatus = 8
  784. // this.getPrintListApi()
  785. this.goTicketingCollections()
  786. }else {
  787. this.$message({
  788. message: '用户已支付成功,请打印门票',
  789. type: 'success'
  790. });
  791. // 开始 打印
  792. this.loading = false
  793. // this.payStatus = 8
  794. // this.getPrintListApi()
  795. this.goTicketingCollections()
  796. }
  797. }else if(res.data.payStatus == 2) {
  798. }else if(res.data.payStatus == 3) {
  799. if(this.payTime){
  800. clearInterval(this.payTime)
  801. }
  802. if(this.ruleForm.paymentType == 2){
  803. this.$message.error('"订单入库中失败"');
  804. this.loading = false
  805. this.payStatus = 3
  806. }else {
  807. this.$message.error('用户支付失败!!!');
  808. this.loading = false
  809. this.payStatus = 7
  810. }
  811. }else if(res.data.payStatus == 4) {
  812. if(this.payTime){
  813. clearInterval(this.payTime)
  814. }
  815. if(this.ruleForm.paymentType == 2){
  816. this.$message.error('"订单入库中失败"');
  817. this.loading = false
  818. this.payStatus = 3
  819. }else {
  820. this.$message.error('支付退款!!!');
  821. this.loading = false
  822. this.payStatus = 7
  823. }
  824. }
  825. }
  826. }else{
  827. this.$message.error('支付失败!!!');
  828. this.loading = false
  829. this.payStatus = 7
  830. }
  831. } catch (error) {
  832. this.$message.error('支付失败!!!');
  833. this.loading = false
  834. this.payStatus = 7
  835. }
  836. },
  837. /** 连接VBarServer */
  838. vbar_open() {
  839. this.loading = true
  840. this.loadingText = "连接扫码盒子中!!!"
  841. this.payStatus = null
  842. this.websocketClear()
  843. console.log('sdfdsfsd')
  844. if (!this.websocket_connected) {
  845. var host = "ws://localhost:2693";
  846. this.websocketCtrl = new WebSocket(host,'ctrl');
  847. this.websocketData = new WebSocket(host,'data');
  848. this.websocketData.onopen = (evt) => {
  849. console.log('sdasdasd====',evt)
  850. this.loading = false
  851. this.payStatus = 5
  852. this.websocket_connected = true;
  853. this.websocket_open_state(evt);
  854. }
  855. this.websocketData.onerror = (evt) => {
  856. console.log('sdasdasd11111====',evt)
  857. this.payStatus = 6
  858. //this.vbar_open()
  859. }
  860. this.websocketData.onmessage = (evt) => {
  861. console.log("接受消息====",evt)
  862. this.websocket_decode(evt.data);
  863. }
  864. }
  865. //setTimeout(this.vbar_open(), 3000);
  866. },
  867. /** 连接结果 */
  868. websocket_open_state(message){
  869. //document.getElementById('wsocket').value = "已连接";
  870. },
  871. //接收扫码结果处理
  872. websocket_decode(code){
  873. console.log()
  874. if(this.orderId && this.payStatus==5 &&code) {
  875. this.gotoMicroPayFun(this.orderId,code)
  876. }
  877. },
  878. /** 关闭通讯 */
  879. websocketClear(){
  880. if(this.websocketCtrl){
  881. this.websocketCtrl.close()
  882. }
  883. if(this.websocketData){
  884. this.websocketData.close()
  885. }
  886. this.websocket_connected = false
  887. },
  888. /** 读取身份证 */
  889. readCert(){
  890. this.idcardLoading = true
  891. var result = "";
  892. try {
  893. let xmlHttp = new XMLHttpRequest();
  894. let Protocol = window.location.protocol.split(':')[0];
  895. //获取当前协议,并且分割字符串,得到http或者https
  896. if (Protocol === 'https'){
  897. //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
  898. xmlHttp.open("POST", "http://127.0.0.1:18889/api/readCert?ReadSN=" + 0, false); //readCert读卡,生成正反面仿复印件
  899. }else {
  900. //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
  901. xmlHttp.open("POST", "http://127.0.0.1:18889/api/readCert?ReadSN=" + 0, false); //readCert读卡,生成正反面仿复印件
  902. }
  903. //发送请求
  904. xmlHttp.send();
  905. if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
  906. result = xmlHttp.responseText;
  907. xmlHttp.readyState = 1;
  908. }
  909. } catch (e) {
  910. console.error("e====",e)
  911. }
  912. let obj = JSON.parse(result)
  913. if(obj.resultContent && obj.resultContent.certNumber){
  914. this.$set(this.tableForm,"idcard",obj.resultContent.certNumber)
  915. this.$set(this.tableForm,"name",obj.resultContent.partyName)
  916. }else {
  917. this.$message.error('读取失败!!!');
  918. }
  919. this.idcardLoading = false
  920. //return result;
  921. console.log(result,obj)
  922. },
  923. /** 查询打印机列表 */
  924. getPrintListApi() {
  925. getPrintListApi({deviceType:5,pageNum: 1,
  926. pageSize: 999,})
  927. .then(response => {
  928. this.printList = response.data.rows;
  929. }).catch((error)=>{
  930. console.log("error===",error)
  931. }
  932. );
  933. },
  934. // 打印
  935. async print(list = []){
  936. if(!this.printListId) {
  937. this.$message.error('请选择打印机!!');
  938. return
  939. }
  940. this.loading = true
  941. this.loadingText = '打印中...'
  942. this.payStatus = ''
  943. try {
  944. let res = await printApi({
  945. orderId: this.orderId,
  946. source: 2,
  947. deviceId: this.printListId
  948. })
  949. if(res.code == 200) {
  950. let url = res.data.linkIp
  951. let printInfo = res.data.printInfo
  952. this.connectPrint(url,printInfo)
  953. }else {
  954. throw new Error(res)
  955. }
  956. } catch (error) {
  957. this.loading = false
  958. this.payStatus = 8
  959. console.error("error=====",error)
  960. }
  961. },
  962. /** 连接打印机 */
  963. connectPrint(url,data){
  964. // 创建忽略 SSL 的 axios 实例
  965. const ignoreSSL = axios.create({
  966. httpsAgent: new https.Agent({
  967. rejectUnauthorized: false
  968. }),
  969. withCredentials: true, // 跨域请求时发送Cookie
  970. timeout: 60000, // 请求超时
  971. headers: {
  972. "Content-Type": "application/json; charset=UTF-8;"
  973. }
  974. });
  975. ignoreSSL.post(url,
  976. { ...data }
  977. ).then(()=>{
  978. this.dialogVisible = false
  979. this.loading = false
  980. }).catch(()=>{
  981. this.loading = false
  982. this.payStatus = 8
  983. // this.dialogVisible = false
  984. // this.loading = false
  985. })
  986. // 在 axios 请求时,选择性忽略 SSL
  987. // const agent = new https.Agent({
  988. // rejectUnauthorized: false
  989. // });
  990. // axios.post(
  991. // url,
  992. // { httpsAgent: agent,...data }
  993. // ).then(()=>{
  994. // this.dialogVisible = false
  995. // this.loading = false
  996. // })
  997. // .catch(()=>{
  998. // this.dialogVisible = false
  999. // this.loading = false
  1000. // })
  1001. },
  1002. }
  1003. }
  1004. </script>
  1005. <style scoped lang="scss">
  1006. .increase-viewers-box {
  1007. width: 100%;
  1008. height: calc( 100vh - 250px );
  1009. box-sizing: border-box;
  1010. overflow: hidden;
  1011. overflow-y: auto;
  1012. position: relative;
  1013. }
  1014. .increase-viewers-pay-status {
  1015. width: 100%;
  1016. height: 100%;
  1017. position: absolute;
  1018. z-index: 999;
  1019. background-color: rgba(0,0,0,0.3);
  1020. top: 0;
  1021. left: 0;
  1022. .increase-viewers-pay-status-info {
  1023. width: 100%;
  1024. height: 100%;
  1025. display: flex;
  1026. flex-direction: column;
  1027. justify-content: center;
  1028. align-items: center;
  1029. color: #fff;
  1030. }
  1031. }
  1032. </style>