increaseViewers.vue 43 KB

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