increaseViewersNew.vue 51 KB

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