increaseViewers.vue 50 KB

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