rebookBox.vue 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029
  1. <template>
  2. <!-- 改签对话框 -->
  3. <el-dialog
  4. title="订单改签"
  5. :visible.sync="rebookDialog"
  6. width="95%"
  7. append-to-body
  8. class="rebook1_dialog"
  9. :close-on-click-modal="false"
  10. :close-on-press-escape="false"
  11. :modal="false"
  12. :before-close="handleClose"
  13. center
  14. >
  15. <div class="rebook1_box" v-loading="loading">
  16. <div class="rebook1_from-box">
  17. <div class="rebook1_from">
  18. <div class="tip-box">
  19. <p>温馨提示:每张票仅限改签一次,改签成功后原订单费用将原路返回退还给客户,请知悉。</p>
  20. </div>
  21. <el-form :model="rebookForm" ref="rebookForm" label-width="100px" :rules="rules">
  22. <el-form-item label="剧目名称:">
  23. <span>{{ rebookForm.performName }}</span>
  24. </el-form-item>
  25. <el-form-item label="票务名称:">
  26. <span>{{ rebookForm.goodsName }}</span>
  27. </el-form-item>
  28. <el-form-item label="座位类型:">
  29. <span>{{ rebookForm.seatTypeName }}</span>
  30. </el-form-item>
  31. <el-form-item label="选择日期:" prop="performDate">
  32. <el-date-picker
  33. v-model="rebookForm.performDate"
  34. type="date"
  35. style="width: 100%"
  36. value-format="yyyy-MM-dd"
  37. placeholder="选择日期" @change="handleDateChange" />
  38. </el-form-item>
  39. <el-form-item label="选择场次:" prop="performTimeId">
  40. <el-select
  41. v-model="rebookForm.performTimeId"
  42. placeholder="选择场次"
  43. style="width: 100%"
  44. @change="selectRegionFun"
  45. >
  46. <el-option
  47. v-for="item in intervalList"
  48. :key="item.performTimeId"
  49. :label="item.performInterval"
  50. :value="item.performTimeId"
  51. />
  52. </el-select>
  53. </el-form-item>
  54. <el-form-item label="支付方式 :" prop="paymentType">
  55. <el-radio-group v-model="rebookForm.paymentType">
  56. <el-radio label="1">扫码支付</el-radio>
  57. <el-radio label="2">现金支付</el-radio>
  58. <!-- <el-radio v-if="['10','11','13','14','18','19'].includes(ruleForm.source)" label="3">对公支付</el-radio> -->
  59. <!-- <el-radio v-if="['10','11','13','14','18','19'].includes(ruleForm.source)" label="4">账户余额({{ balance }})</el-radio>
  60. <el-radio v-if="['10','11','13','14','18','19'].includes(ruleForm.source)" label="5">授信余额({{ grantQuota }})</el-radio> -->
  61. </el-radio-group>
  62. </el-form-item>
  63. </el-form>
  64. </div>
  65. <div class="rebook1_seat" v-loading="seatLoading" :element-loading-text="seatLoadText">
  66. <seatBox
  67. ref="seatBox"
  68. :seatTypeLimit="configStockNumObj"
  69. @selectSeat="selectSeat"
  70. height="100%"
  71. />
  72. </div>
  73. </div>
  74. <div style="width: 100%;display: flex;justify-content: center;">
  75. <el-button @click="rebookDialog = false">取 消</el-button>
  76. <el-button type="primary" @click="submitRebook">确认改签</el-button>
  77. </div>
  78. <!-- 支付过程 控制 -->
  79. <div v-if="payStatus" class="increase-viewers-pay-status">
  80. <div class="increase-viewers-pay-status-info" v-if="!loading">
  81. <span style="font-weight: 600;font-size: 20px;">提示</span>
  82. <span style="padding: 10px 0;">
  83. {{ payStatus==1 ? '生成订单失败!!!' :
  84. payStatus==2 ? '生成订单生成成功,请点击调取扫码盒子' :
  85. payStatus==4 ? '扫码支付失败!!!' :
  86. payStatus==5 ? '请出示付款码!!!' :
  87. payStatus==5.5 ? '扫码成功,支付中...' :
  88. payStatus==5.6 ? '扫码成功,支付中...' :
  89. payStatus==6 ? '连接扫码器失败!!!' :
  90. payStatus==7 ? '用户支付失败或未支付,请重新连接支付!!!' :
  91. payStatus==8 ? '用户支付成功,请点击打印票!!!' :
  92. payStatus==9 ? '支付超时!!!' :
  93. payStatus==10 ? '订单已关闭,请重新选择座位,再购买!!!' :
  94. payStatus==3 ? '现金支付记录入库失败,请重新提交' : '未知状态' }}
  95. </span>
  96. <span v-if="payStatus==2">需支付{{ rebookForm.payAmount }}元</span>
  97. <!-- 重新生成订单 1 -->
  98. <div v-if="payStatus==1" style="display: flex;">
  99. <el-button @click="payStatus = null" type="success">修改信息</el-button>
  100. <el-button @click="orderInfoSubmitFun()" style="margin-left: 20px;" type="primary">重新生成订单</el-button>
  101. </div>
  102. <!-- 生成订单成功 选择支付方式 -->
  103. <div>
  104. <!-- 扫码支付 2 -->
  105. <el-button v-if="payStatus==2" @click="vbar_open(orderId)" type="success">扫码支付</el-button>
  106. <!-- 扫码支付 4 -->
  107. <el-button v-if="payStatus==4" @click="vbar_open(orderId)" type="success">重新扫码支付</el-button>
  108. <!-- 重新支付 3 -->
  109. <el-button v-if="payStatus==3" @click="gotoCashPayFun(orderId)" type="success">重新提交入库</el-button>
  110. <!-- 重新支付 6 7 -->
  111. <el-button v-if="payStatus==6 || payStatus==7" @click="vbar_open(orderId)" type="success">重新连接扫码支付</el-button>
  112. <!-- 现金支付 -->
  113. <el-button v-if="payStatus==2" @click="vbar_open(orderId)" type="success">扫码支付</el-button>
  114. <!-- 现金支付 -->
  115. <el-button v-if="payStatus==2" @click="vbar_open(orderId)" type="success">扫码支付</el-button>
  116. </div>
  117. <!-- 打印 8 -->
  118. <div v-if="payStatus==8">
  119. <el-select v-model="printListId" placeholder="选择打印机">
  120. <el-option
  121. :label="item.deviceName"
  122. :key="item.id"
  123. :value="item.id"
  124. v-for="(item) in printList"></el-option>
  125. </el-select>
  126. <el-button style="margin-left: 15px" @click="print" type="success">打印门票</el-button>
  127. <el-button style="margin-left: 15px" @click="goTicketingCollections" type="success">跳转取票界面</el-button>
  128. </div>
  129. <!-- 支付超时 9 -->
  130. <div v-if="payStatus==9">
  131. <!-- <el-button @click="print" type="danger">取消支付</el-button> -->
  132. <el-button @click="orderInfoSubmitFun()" type="primary">重新扫码</el-button>
  133. </div>
  134. <!-- 订单被关闭 10 -->
  135. <div v-if="payStatus==10">
  136. <!-- <el-button @click="print" type="danger">取消支付</el-button> -->
  137. <el-button @click="handleClose()" type="primary">关闭</el-button>
  138. </div>
  139. </div>
  140. </div>
  141. </div>
  142. </el-dialog>
  143. </template>
  144. <script>
  145. import { reSubmitPageList, getDateTimeAll, rebook } from '@/api/windowTicketSales/rebook'
  146. import {
  147. orderInfoSubmit,
  148. gotoMicroPay,
  149. gotoCashPay,
  150. gotoCorporatePay,
  151. gotoBalancePay,
  152. gotoQuotaPay,
  153. payQuery,
  154. selectRegion,
  155. orderInfoCancel,
  156. factorAuth,
  157. selectMarketTeamBySourceApi,
  158. querySeatListNew
  159. } from '@/api/windowTicketSales/ticketingSales'
  160. import { pageList as getPrintListApi } from "@/api/device/pda";
  161. import { printApi } from '@/api/windowTicketSales/ticketingCollection'
  162. import { rebookApi } from '@/api/windowTicketSales/rebook'
  163. import { countBySeatTyp } from '@/api/ticketMr/InventoryTemplate'
  164. import { pageList as getSeatType } from '@/api/seatTypeMr/seatTypeMr'
  165. import seatBox from '@/components/seatBox/index.vue';
  166. import {
  167. querySeatList,
  168. } from '@/api/windowTicketSales/ticketingSales'
  169. const mathM = require('mathjs')
  170. const https = require('https');
  171. const axios = require('axios');
  172. export default {
  173. name: "RebookBox",
  174. components: { seatBox },
  175. data() {
  176. return {
  177. // 改签对话框
  178. rebookDialog: false,
  179. loading: false,
  180. // 改签表单
  181. rebookForm: {
  182. orderId: undefined,
  183. performDate: undefined,
  184. performTimeId: undefined,
  185. performInterval: undefined,
  186. performId: undefined,
  187. auditoriumId: undefined
  188. },
  189. rules: {
  190. performDate: [{ required: true, message: '请选择日期', trigger: ['blur','change'] }],
  191. performTimeId: [{ required: true, message: '请选择场次', trigger: ['blur','change'] }]
  192. },
  193. // 场次列表
  194. intervalList: [],
  195. intervalListLoading: false,
  196. // 支付相关
  197. payDialog: false,
  198. payStatus: null,
  199. code: '',
  200. websocketData: null,
  201. codeTime: null,
  202. // 成功对话框
  203. successDialog: false,
  204. newOrderId: '',
  205. printList: [],
  206. configStockNumObj: {},
  207. countBySeatTypList:[],
  208. seatTypeListAll: [],
  209. seatLoading: false,
  210. seatLoadText: '获取座位中...',
  211. setList: [],
  212. }
  213. },
  214. created(){
  215. this.getSeatTypeAllList()
  216. },
  217. methods: {
  218. async initData(row) {
  219. this.rebookDialog = true
  220. this.payStatus = null
  221. this.rebookForm = {
  222. performName: row.performName,
  223. goodsName: row.goodsName,
  224. seatTypeName: row.seatTypeName,
  225. seatTypeId: row.seatTypeId,
  226. goodsId: row.goodsId,
  227. orderId: row.orderId,
  228. performDate: undefined,
  229. performTimeId: undefined,
  230. performId: row.performId,
  231. auditoriumId: row.auditoriumId,
  232. paymentType: "1", // 支付方式
  233. seatList: []
  234. }
  235. await this.countBySeatTypFun(row.auditoriumId)
  236. this.$nextTick(()=>{
  237. this.$refs.rebookForm.clearValidate()
  238. })
  239. },
  240. handleDialogOpen() {
  241. const today = new Date()
  242. this.rebookForm.performDate = this.formatDate(today)
  243. this.handleDateChange()
  244. },
  245. /** 获取场次 */
  246. handleDateChange() {
  247. this.intervalListLoading = true
  248. this.rebookForm.performTimeId = undefined
  249. this.intervalList = []
  250. if (!this.rebookForm.performDate) return
  251. getDateTimeAll({
  252. performDate: this.rebookForm.performDate,
  253. orderId: this.rebookForm.orderId,
  254. performId: this.rebookForm.performId,
  255. auditoriumId: this.rebookForm.auditoriumId
  256. }).then(response => {
  257. this.intervalList = response.data.list || []
  258. this.intervalListLoading = false
  259. }).catch(()=>{
  260. this.intervalListLoading = true
  261. })
  262. },
  263. selectInterval(item) {
  264. this.rebookForm.performTimeId = item.performTimeId
  265. },
  266. formatDate(date) {
  267. const year = date.getFullYear()
  268. const month = String(date.getMonth() + 1).padStart(2, '0')
  269. const day = String(date.getDate()).padStart(2, '0')
  270. return `${year}-${month}-${day}`
  271. },
  272. /** 提交表单 */
  273. submitRebook() {
  274. this.$refs.rebookForm.validate((valid) => {
  275. if (valid) {
  276. if(!this.rebookForm.seatList||this.rebookForm.seatList.length==0) {
  277. this.$message.error('请选择座位!!!');
  278. return
  279. }
  280. this.orderInfoSubmitFun()
  281. } else {
  282. return false;
  283. }
  284. });
  285. },
  286. /** 退出窗口 */
  287. handleClose(done) {
  288. // if(this.payStatus==8) {
  289. // this.$message.error('请daying');
  290. // return
  291. // }
  292. this.$confirm('确认关闭?')
  293. .then(_ => {
  294. if(this.orderId){
  295. document.removeEventListener('keydown',this.keydownAdd);
  296. this.orderInfoCancelFun(true)
  297. }else {
  298. this.$refs.seatBox.querySeatListFun(true,[],[],[])
  299. this.rebookDialog = false
  300. }
  301. })
  302. .catch(_ => {});
  303. },
  304. /** 取消订单 */
  305. async orderInfoCancelFun(type){
  306. // let payStatus = this.payStatus
  307. // this.payStatus = null
  308. try {
  309. this.loading = true
  310. this.loadingText = "取消订单中..."
  311. orderInfoCancel({
  312. orderId: this.orderId
  313. }).then((res)=>{
  314. if(res.code==200) {
  315. if(type){ // 关闭弹窗
  316. if(this.codeTime) {
  317. clearInterval(this.codeTime)
  318. }
  319. this.orderId = null
  320. this.payStatus = null
  321. this.$emit('clearDialogVisible')
  322. this.rebookDialog = false
  323. }else {
  324. this.payStatus = 9
  325. this.loading = false
  326. }
  327. }else {
  328. }
  329. }).catch(()=>{
  330. this.$message.error('订单关闭失败!!!');
  331. })
  332. } catch (error) {
  333. }
  334. },
  335. /** 生成订单 */
  336. async orderInfoSubmitFun(){
  337. this.loading = true
  338. try {
  339. this.orderId = null
  340. this.loadingText = "生成订单中..."
  341. let res = await rebookApi({
  342. ...this.rebookForm
  343. })
  344. if(res.code == 200){
  345. this.orderId = res.data.orderId
  346. if(this.ruleForm.paymentType == 2) { // 现金支付
  347. this.gotoCashPayFun(this.orderId)
  348. }else if(this.ruleForm.paymentType == 3) { // 对公支付
  349. this.gotoCorporatePayFun(this.orderId)
  350. }else if(this.ruleForm.paymentType == 4){ // 账户余额
  351. this.gotoBalancePayFun(this.orderId)
  352. }else if(this.ruleForm.paymentType == 5){ // 授信余额
  353. this.gotoQuotaPayFun(this.orderId)
  354. }else {
  355. // 扫码支付
  356. this.loading = false
  357. this.payStatus = 2
  358. }
  359. }else{
  360. this.$message.error('生成订单失败!!!');
  361. this.loading = false
  362. this.payStatus = 1
  363. }
  364. } catch (error) {
  365. this.$message.error('生成订单失败!!!');
  366. this.loading = false
  367. this.payStatus = 1
  368. }
  369. },
  370. /** 调取 订单支付码支付 */
  371. async gotoMicroPayFun(orderId,code){
  372. this.loading = true
  373. try {
  374. this.loadingText = "订单支付中..."
  375. this.payStatus = ''
  376. let res = await gotoMicroPay({
  377. "orderId": orderId, // 订单编号-提交订单返回
  378. "authCode": code // 微信扫码支付-支付码
  379. })
  380. if(res.code == 200){
  381. this.payTimeNum = 0
  382. this.websocketClear()
  383. if(this.payTime){
  384. clearInterval(this.payTime)
  385. }
  386. this.payTime = setInterval(()=>{
  387. this.payQueryFun(this.orderId)
  388. },1500)
  389. }else{
  390. this.$message.error('支付失败!!!');
  391. this.payStatus = ''
  392. this.loading = false
  393. this.payStatus = 6
  394. }
  395. } catch (error) {
  396. this.$message.error('支付失败!!!');
  397. this.loading = false
  398. this.payStatus = 6
  399. }
  400. },
  401. /** 对公支付 */
  402. async gotoCorporatePayFun(orderId) {
  403. this.loading = true
  404. try {
  405. this.loadingText = "订单入库中..."
  406. let res = await gotoCorporatePay({
  407. "orderId": orderId, // 订单编号-提交订单返回
  408. "payAmount": this.ruleForm.realPrice
  409. })
  410. if(res.code == 200){
  411. if(this.payTime){
  412. clearInterval(this.payTime)
  413. }
  414. this.payTimeNum = 0
  415. this.payTime = setInterval(()=>{
  416. this.payQueryFun(this.orderId)
  417. },1000)
  418. }else{
  419. this.$message.error('订单入库中失败!!!');
  420. this.loading = false
  421. this.payStatus = 3
  422. }
  423. } catch (error) {
  424. this.$message.error('订单入库中失败!!!');
  425. this.loading = false
  426. this.payStatus = 3
  427. }
  428. },
  429. /** 授信额度支付 */
  430. async gotoQuotaPayFun(orderId) {
  431. this.loading = true
  432. try {
  433. this.loadingText = "订单入库中..."
  434. let res = await gotoQuotaPay({
  435. "orderId": orderId, // 订单编号-提交订单返回
  436. })
  437. if(res.code == 200){
  438. if(this.payTime){
  439. clearInterval(this.payTime)
  440. }
  441. this.payTimeNum = 0
  442. this.payTime = setInterval(()=>{
  443. this.payQueryFun(this.orderId)
  444. },1000)
  445. }else{
  446. this.$message.error('订单入库中失败!!!');
  447. this.loading = false
  448. this.payStatus = 3
  449. }
  450. } catch (error) {
  451. this.$message.error('订单入库中失败!!!');
  452. this.loading = false
  453. this.payStatus = 3
  454. }
  455. },
  456. /** 余额支付 */
  457. async gotoBalancePayFun(orderId) {
  458. this.loading = true
  459. try {
  460. this.loadingText = "订单入库中..."
  461. let res = await gotoBalancePay({
  462. "orderId": orderId, // 订单编号-提交订单返回
  463. })
  464. if(res.code == 200){
  465. if(this.payTime){
  466. clearInterval(this.payTime)
  467. }
  468. this.payTimeNum = 0
  469. this.payTime = setInterval(()=>{
  470. this.payQueryFun(this.orderId)
  471. },1000)
  472. }else{
  473. this.$message.error('订单入库中失败!!!');
  474. this.loading = false
  475. this.payStatus = 3
  476. }
  477. } catch (error) {
  478. this.$message.error('订单入库中失败!!!');
  479. this.loading = false
  480. this.payStatus = 3
  481. }
  482. },
  483. /** 订单现金支付 */
  484. async gotoCashPayFun(orderId){
  485. this.loading = true
  486. try {
  487. this.loadingText = "订单入库中..."
  488. let res = await gotoCashPay({
  489. "orderId": orderId, // 订单编号-提交订单返回
  490. "payAmount": this.ruleForm.realPrice
  491. })
  492. if(res.code == 200){
  493. if(this.payTime){
  494. clearInterval(this.payTime)
  495. }
  496. this.payTimeNum = 0
  497. this.payTime = setInterval(()=>{
  498. this.payQueryFun(this.orderId)
  499. },1000)
  500. }else{
  501. this.$message.error('订单入库中失败!!!');
  502. this.loading = false
  503. this.payStatus = 3
  504. }
  505. } catch (error) {
  506. this.$message.error('订单入库中失败!!!');
  507. this.loading = false
  508. this.payStatus = 3
  509. }
  510. },
  511. // 跳转取票界面
  512. goTicketingCollections(){
  513. this.$router.push({
  514. path:"/windowTicketSales/ticketingCollections",
  515. query:{
  516. orderId: this.orderId
  517. }
  518. })
  519. },
  520. /** 查看支付 状态 */
  521. async payQueryFun(orderId){
  522. this.loading = true
  523. try {
  524. this.payTimeNum = this.payTimeNum + 1
  525. if(this.payTimeNum==15){
  526. if(this.payTime){
  527. clearInterval(this.payTime)
  528. }
  529. this.orderInfoCancelFun()
  530. return
  531. }
  532. if(this.ruleForm.paymentType == 2){
  533. this.loadingText = "订单入库中..."
  534. }else {
  535. this.loadingText = "订单支付中..."
  536. }
  537. this.payStatus = ''
  538. let res = await payQuery({
  539. orderId: orderId
  540. })
  541. if(res.code == 200){
  542. if(res.data) {
  543. if(res.data.payStatus == 0) {
  544. if(this.payTime){
  545. clearInterval(this.payTime)
  546. }
  547. if(this.ruleForm.paymentType == 2){
  548. this.$message.error('"订单入库中失败"');
  549. this.loading = false
  550. this.payStatus = 3
  551. }else {
  552. if(res.data.orderStatus == 9 || res.data.orderStatus == 4 || res.data.orderStatus == 5){
  553. this.$message.error('订单已关闭,请重新选择座位,再购买!!!');
  554. this.loading = false
  555. this.payStatus = 10
  556. }else {
  557. this.$message.error('用户未支付!!!');
  558. this.loading = false
  559. this.payStatus = 7
  560. }
  561. }
  562. }else if(res.data.payStatus == 1) {
  563. if(this.payTime){
  564. clearInterval(this.payTime)
  565. }
  566. if(this.ruleForm.paymentType == 2){
  567. this.$message({
  568. message: '订单入库成功',
  569. type: 'success'
  570. });
  571. this.loading = false
  572. // this.payStatus = 8
  573. // this.getPrintListApi()
  574. this.goTicketingCollections()
  575. }else {
  576. this.$message({
  577. message: '用户已支付成功,请打印门票',
  578. type: 'success'
  579. });
  580. // 开始 打印
  581. this.loading = false
  582. // this.payStatus = 8
  583. // this.getPrintListApi()
  584. this.goTicketingCollections()
  585. }
  586. }else if(res.data.payStatus == 2) {
  587. }else if(res.data.payStatus == 3) {
  588. if(this.payTime){
  589. clearInterval(this.payTime)
  590. }
  591. if(this.ruleForm.paymentType == 2){
  592. this.$message.error('"订单入库中失败"');
  593. this.loading = false
  594. this.payStatus = 3
  595. }else {
  596. if(res.data.orderStatus == 9 || res.data.orderStatus == 4 || res.data.orderStatus == 5){
  597. this.$message.error('订单已关闭,请重新选择座位,再购买!!!');
  598. this.loading = false
  599. this.payStatus = 10
  600. }else {
  601. this.$message.error('用户支付失败!!!');
  602. this.loading = false
  603. this.payStatus = 7
  604. }
  605. }
  606. }else if(res.data.payStatus == 4) {
  607. if(this.payTime){
  608. clearInterval(this.payTime)
  609. }
  610. if(this.ruleForm.paymentType == 2){
  611. this.$message.error('"订单入库中失败"');
  612. this.loading = false
  613. this.payStatus = 3
  614. }else {
  615. if(res.data.orderStatus == 9 || res.data.orderStatus == 4 || res.data.orderStatus == 5){
  616. this.$message.error('订单已关闭,请重新选择座位,再购买!!!');
  617. this.loading = false
  618. this.payStatus = 10
  619. }else {
  620. this.$message.error('支付退款!!!');
  621. this.loading = false
  622. this.payStatus = 7
  623. }
  624. }
  625. }
  626. }
  627. }else{
  628. this.$message.error('支付失败!!!');
  629. this.loading = false
  630. this.payStatus = 7
  631. }
  632. } catch (error) {
  633. this.$message.error('支付失败!!!');
  634. this.loading = false
  635. this.payStatus = 7
  636. }
  637. },
  638. /** 连接VBarServer */
  639. vbar_open() {
  640. this.loading = true
  641. this.loadingText = "连接扫码盒子中!!!"
  642. this.payStatus = null
  643. this.code = ''
  644. this.websocketClear()
  645. this.payStatus = 5 // 连接成功
  646. document.addEventListener('keydown',this.keydownAdd);
  647. this.loading = false
  648. },
  649. /** 连接结果 */
  650. websocket_open_state(message){
  651. console.log("连接结果 ===== ",message)
  652. this.codeTime = setInterval(()=>{
  653. console.log("检测是否连接")
  654. if(this.websocketData.readyState != WebSocket.OPEN) {
  655. this.payStatus = 6
  656. }
  657. },3000)
  658. //document.getElementById('wsocket').value = "已连接";
  659. },
  660. // 拼接字符串
  661. keydownAdd(e){
  662. console.log("e=====",e)
  663. console.log("this.code=====",this.code)
  664. if( this.payStatus == 5 && e.key != 'Enter') {
  665. this.code = this.code + e.key
  666. }
  667. if( e.key == 'Enter') {
  668. document.removeEventListener('keydown',this.keydownAdd);
  669. let codeCopy = this.code
  670. this.payStatus == 5.5
  671. this.code = ''
  672. this.gotoMicroPayFun(this.orderId,codeCopy)
  673. }
  674. },
  675. //接收扫码完整结果处理
  676. websocket_decode(code){
  677. console.log("orderId=========",this.orderId )
  678. console.log("code=========",code)
  679. if(this.orderId && this.payStatus == 5.5 && regex.test(code) ) {
  680. this.payStatus = 5.6 // 支付中
  681. let codeCopy = code.replace("%%%", "").replace("%%%", "")
  682. this.gotoMicroPayFun(this.orderId,codeCopy)
  683. }else if(!code){
  684. this.payStatus = 5
  685. this.code = ''
  686. }
  687. },
  688. /** 关闭通讯 */
  689. websocketClear(){
  690. document.removeEventListener('keydown',this.keydownAdd);
  691. },
  692. /** 读取身份证 */
  693. readCert(){
  694. this.idcardLoading = true
  695. var result = "";
  696. try {
  697. let xmlHttp = new XMLHttpRequest();
  698. let Protocol = window.location.protocol.split(':')[0];
  699. //获取当前协议,并且分割字符串,得到http或者https
  700. if (Protocol === 'https'){
  701. //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
  702. xmlHttp.open("POST", "http://127.0.0.1:18889/api/readCert?ReadSN=" + 0, false); //readCert读卡,生成正反面仿复印件
  703. }else {
  704. //创建请求 第一个参数是代表以post方式发送;第二个是请求端口和地址;第三个表示是否异步
  705. xmlHttp.open("POST", "http://127.0.0.1:18889/api/readCert?ReadSN=" + 0, false); //readCert读卡,生成正反面仿复印件
  706. }
  707. //发送请求
  708. xmlHttp.send();
  709. if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
  710. result = xmlHttp.responseText;
  711. xmlHttp.readyState = 1;
  712. }
  713. } catch (e) {
  714. console.error("e====",e)
  715. }
  716. let obj = JSON.parse(result)
  717. if(obj.resultContent && obj.resultContent.certNumber){
  718. this.$set(this.tableForm,"idcard",obj.resultContent.certNumber)
  719. this.$set(this.tableForm,"name",obj.resultContent.partyName)
  720. }else {
  721. this.$message.error('读取失败!!!');
  722. }
  723. this.idcardLoading = false
  724. //return result;
  725. console.log(result,obj)
  726. },
  727. /** 查询打印机列表 */
  728. getPrintListApi() {
  729. getPrintListApi({deviceType:5,pageNum: 1,
  730. pageSize: 999,})
  731. .then(response => {
  732. this.printList = response.data.rows;
  733. }).catch((error)=>{
  734. console.log("error===",error)
  735. }
  736. );
  737. },
  738. // 打印
  739. async print(list = []){
  740. if(!this.printListId) {
  741. this.$message.error('请选择打印机!!');
  742. return
  743. }
  744. this.loading = true
  745. this.loadingText = '打印中...'
  746. this.payStatus = ''
  747. try {
  748. let res = await printApi({
  749. orderId: this.orderId,
  750. source: 2,
  751. deviceId: this.printListId
  752. })
  753. if(res.code == 200) {
  754. let url = res.data.linkIp
  755. let printInfo = res.data.printInfo
  756. this.connectPrint(url,printInfo)
  757. }else {
  758. throw new Error(res)
  759. }
  760. } catch (error) {
  761. this.loading = false
  762. this.payStatus = 8
  763. console.error("error=====",error)
  764. }
  765. },
  766. /** 连接打印机 */
  767. connectPrint(url,data){
  768. // 创建忽略 SSL 的 axios 实例
  769. const ignoreSSL = axios.create({
  770. httpsAgent: new https.Agent({
  771. rejectUnauthorized: false
  772. }),
  773. withCredentials: true, // 跨域请求时发送Cookie
  774. timeout: 60000, // 请求超时
  775. headers: {
  776. "Content-Type": "application/json; charset=UTF-8;"
  777. }
  778. });
  779. ignoreSSL.post(url,
  780. { ...data }
  781. ).then(()=>{
  782. this.rebookDialog = false
  783. this.loading = false
  784. }).catch(()=>{
  785. this.loading = false
  786. this.payStatus = 8
  787. // this.rebookDialog = false
  788. // this.loading = false
  789. })
  790. // 在 axios 请求时,选择性忽略 SSL
  791. // const agent = new https.Agent({
  792. // rejectUnauthorized: false
  793. // });
  794. // axios.post(
  795. // url,
  796. // { httpsAgent: agent,...data }
  797. // ).then(()=>{
  798. // this.rebookDialog = false
  799. // this.loading = false
  800. // })
  801. // .catch(()=>{
  802. // this.rebookDialog = false
  803. // this.loading = false
  804. // })
  805. },
  806. /** 获取授信余额和账户余额 */
  807. async selectMarketTeamBySourceFun(value) {
  808. console.log("value===",value)
  809. try {
  810. if(!['10','11','13','14','18','19'].includes(value)) return
  811. let res = await selectMarketTeamBySourceApi({
  812. source: value
  813. })
  814. this.balance = res.data.balance
  815. if(res.data.grantQuota && res.data.grantUsed) {
  816. this.grantQuota = res.data.grantQuota - res.data.grantUsed
  817. }else if(res.data.grantQuota) {
  818. this.grantQuota = res.data.grantQuota
  819. }else {
  820. this.grantQuota = 0
  821. }
  822. } catch (error) {
  823. this.balance = null
  824. this.grantQuota = null
  825. }
  826. },
  827. /** 获取票务信息 */
  828. async selectRegionFun(){
  829. try {
  830. this.seatLoading = true
  831. this.seatLoadText = "获取座位中..."
  832. let res = await selectRegion({
  833. "auditoriumId": this.rebookForm.auditoriumId, // 演艺厅ID
  834. "goodsId": this.rebookForm.goodsId, // 商品ID
  835. "performId": this.rebookForm.performId, // 上一界面节目ID
  836. "performTimeId": this.rebookForm.timeId, // 时段ID
  837. "retailId": "" // 分销ID
  838. })
  839. if(res.code == 200) {
  840. if(res.data.regionPriceList &&res.data.regionPriceList.length>0){
  841. let obj = {}
  842. res.data.regionPriceList.forEach((item,index)=>{
  843. if(this.rebookForm.seatTypeId == item.seatTypeId) {
  844. obj = item
  845. }
  846. })
  847. if(JSON.stringify(obj) != '{}'){
  848. this.querySeatListFun()
  849. }else {
  850. this.$message.error('存在座位未设置价格,请选择其他票!!!');
  851. this.seatLoading = false
  852. }
  853. }else {
  854. this.$message.error('存在座位未设置价格,请选择其他票!!!');
  855. this.seatLoading = false
  856. }
  857. console.log("res====",res)
  858. }else {
  859. this.$message.error(res.msg);
  860. this.seatLoading = false
  861. }
  862. } catch (error) {
  863. console.error("error=====",error)
  864. this.$message.error('价格查询出错');
  865. this.seatLoading = false
  866. }
  867. },
  868. /** 获取座位 */
  869. async querySeatListFun(type){
  870. try {
  871. let res = await querySeatList({
  872. auditoriumId: this.rebookForm.auditoriumId,
  873. timeId: this.rebookForm.performTimeId,
  874. goodsId: this.rebookForm.goodsId,
  875. })
  876. if(res.code == 200){
  877. this.setList = res.data;
  878. let list = []
  879. let list3 = []
  880. this.countBySeatTypList.forEach((item,index)=>{
  881. list3.push(item.seatTypeId)
  882. })
  883. let list4 = []
  884. this.seatTypeListAll.forEach((item,index)=>{
  885. if(list3.includes(item.id)) {
  886. list4.push({...item})
  887. }
  888. })
  889. this.$nextTick(() =>{
  890. this.$refs.seatBox.querySeatListFun(true,this.setList,list,list4)
  891. })
  892. }
  893. this.loading = false
  894. } catch (error) {
  895. this.loading = false
  896. console.error("error===",error)
  897. }
  898. },
  899. /** 获取座位类型 */
  900. async countBySeatTypFun(value) {
  901. try {
  902. if(!value) return
  903. let res = await countBySeatTyp({auditoriumId: value})
  904. this.countBySeatTypList = res.data ? res.data : []
  905. let obj = {}
  906. this.countBySeatTypList.forEach((item,index)=>{
  907. obj['seatNum_'+item.seatTypeId] = {
  908. stockTotal: item.stock,
  909. stockSelect: item.stock,
  910. stockYes: item.stock,
  911. stockNo: 0,
  912. isNoSelect: true,
  913. }
  914. if(item.seatTypeId == this.rebookForm.seatTypeId){
  915. obj['seatNum_'+item.seatTypeId].stockYes = item.stock-1
  916. obj['seatNum_'+item.seatTypeId].isNoSelect = false
  917. }
  918. })
  919. this.configStockNumObj = obj
  920. } catch (error) {
  921. console.error("error1====",error)
  922. }
  923. },
  924. /** 获取座位类型 说明 */
  925. async getSeatTypeAllList() {
  926. try {
  927. let res = await getSeatType({
  928. pageNum: 1,
  929. pageSize: 999,
  930. })
  931. if(res.code == 200) {
  932. this.seatTypeListAll = res.data.rows || [];
  933. }
  934. } catch (error) {
  935. }
  936. },
  937. /** 选择座位 */
  938. selectSeat(list) {
  939. let list1 = []
  940. list.forEach((item)=>{
  941. list1.push({
  942. seatId: item.id
  943. })
  944. })
  945. this.rebookForm.seatList = list1
  946. console.log("已选择的====",list)
  947. },
  948. }
  949. }
  950. </script>
  951. <style lang="scss" scoped>
  952. .rebook1_dialog ::v-deep .el-dialog__body {
  953. padding: 0 !important;
  954. }
  955. .rebook1_box {
  956. width: 100%;
  957. height: 100%;
  958. padding-bottom: 10px;
  959. .rebook1_from-box {
  960. display: flex;
  961. width: 100%;
  962. height: 80vh;
  963. box-sizing: border-box;
  964. padding: 0 20px 20px;
  965. }
  966. .rebook1_from {
  967. width: 100%;
  968. height: 100%;
  969. padding: 0 20px 0 0;
  970. width: 400px;
  971. box-sizing: border-box;
  972. }
  973. .rebook1_seat {
  974. width: calc( 100% - 400px );
  975. height: 100%;
  976. }
  977. }
  978. .increase-viewers-pay-status {
  979. width: 100%;
  980. height: 100%;
  981. position: absolute;
  982. z-index: 999;
  983. background-color: rgba(0,0,0,0.3);
  984. top: 0;
  985. left: 0;
  986. .increase-viewers-pay-status-info {
  987. width: 100%;
  988. height: 100%;
  989. display: flex;
  990. flex-direction: column;
  991. justify-content: center;
  992. align-items: center;
  993. color: #fff;
  994. }
  995. }
  996. </style>