increaseViewers.vue 49 KB

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