increaseViewers.vue 45 KB

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