index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568
  1. <template>
  2. <div class="payStatusPopup">
  3. <el-dialog :visible.sync="show" width="600px" :close-on-click-modal="false" :close-on-press-escape="false" :show-close="false" append-to-body custom-class="popup_box">
  4. <!-- 支付成功打印小票 -->
  5. <div v-if="type === 1">
  6. <div class="icon">
  7. <i class="el-icon-success success"></i>
  8. </div>
  9. <div class="message">支付成功</div>
  10. <div class="btn_box" v-if="hidePointer">
  11. <div class="btn" @click="confirm">确认</div>
  12. </div>
  13. <div class="btn_box" v-else>
  14. <template v-if="isRecharge">
  15. <div class="btn" @click="setPointer(0)">打印小票</div>
  16. </template>
  17. <template v-else>
  18. <div class="btn" @click="setPointer(0)">打印小票</div>
  19. <div class="line"></div>
  20. <div class="btn" @click="setPointer(1)">打印条码</div>
  21. </template>
  22. <div class="line"></div>
  23. <div class="btn" @click="close">关闭</div>
  24. </div>
  25. </div>
  26. <!-- 未支付 -->
  27. <div v-if="type === 2">
  28. <div class="icon">
  29. <i class="el-icon-warning warning"></i>
  30. </div>
  31. <div class="message">请支付后取衣</div>
  32. <div class="cell">
  33. <div class="label">需支付金额</div>
  34. <div class="amount_box">
  35. <span>¥</span>
  36. <span>{{ orderInfo.payAmount }}</span>
  37. </div>
  38. </div>
  39. <div class="cell">
  40. <div class="label">支付方式</div>
  41. <el-radio-group v-model="payType" @input="changePayType">
  42. <el-radio-button :label="3">余额</el-radio-button>
  43. <el-radio-button :label="2">现金</el-radio-button>
  44. <el-radio-button :label="0">微信/支付宝</el-radio-button>
  45. </el-radio-group>
  46. </div>
  47. <el-descriptions border direction="vertical" :column="3" :labelStyle="{ width: '140px' }" v-if="payType == '3'" style="margin: 0 30px">
  48. <el-descriptions-item label="用户" v-if="appUserInfo">{{ appUserInfo.realName }}</el-descriptions-item>
  49. <el-descriptions-item label="当前余额(元)" v-if="appUserInfo">{{ appUserInfo.rechargeBalance + appUserInfo.giveBalance }}</el-descriptions-item>
  50. <el-descriptions-item label="支付后余额(元)" v-if="appUserInfo">{{ appUserInfo.rechargeBalance + appUserInfo.giveBalance - orderInfo.payAmount }}</el-descriptions-item>
  51. </el-descriptions>
  52. <div class="cell" v-if="payType == 0">
  53. <div class="label">付款码</div>
  54. <!-- @change="handleQuery" -->
  55. <el-input ref="autoFocus" v-model="authCode" clearable placeholder="请选择付款码" />
  56. </div>
  57. <div class="btn_box">
  58. <div class="btn" style="color: #67c23a" @click="pay">确认支付</div>
  59. <div class="line"></div>
  60. <div class="btn" @click="close">关闭</div>
  61. </div>
  62. </div>
  63. <!-- 支付中,请等待 -->
  64. <div v-if="type == 3 || type == 5">
  65. <div class="icon">
  66. <i class="el-icon-loading loading"></i>
  67. </div>
  68. <div class="message">支付确认中,请等待...</div>
  69. <el-button type="primary" style="width: 70%; height: 40px; margin: 20px 15%" @click="close" v-if="showPaySuccessBtn">已确认支付</el-button>
  70. </div>
  71. <!-- 支付失败 -->
  72. <div v-if="type == 4">
  73. <div class="icon">
  74. <i class="el-icon-error error"></i>
  75. </div>
  76. <div class="message">{{ errorMessage }}</div>
  77. <div class="cell" v-if="!hideUser">
  78. <div class="label">支付方式</div>
  79. <el-radio-group v-model="payType" @input="changePayType">
  80. <el-radio-button :label="3">余额</el-radio-button>
  81. <el-radio-button :label="2">现金</el-radio-button>
  82. <el-radio-button :label="0">微信/支付宝</el-radio-button>
  83. </el-radio-group>
  84. </div>
  85. <el-descriptions border direction="vertical" :column="3" :labelStyle="{ width: '140px' }" v-if="payType == '3' && !hideUser" style="margin: 0 30px">
  86. <el-descriptions-item label="用户" v-if="appUserInfo">{{ appUserInfo.realName }}</el-descriptions-item>
  87. <el-descriptions-item label="当前余额(元)" v-if="appUserInfo">{{ appUserInfo.rechargeBalance + appUserInfo.giveBalance }}</el-descriptions-item>
  88. <el-descriptions-item label="支付后余额(元)" v-if="appUserInfo">{{ appUserInfo.rechargeBalance + appUserInfo.giveBalance - orderInfo.payAmount }}</el-descriptions-item>
  89. </el-descriptions>
  90. <div class="cell" v-if="payType == 0 && !hideUser">
  91. <div class="label">付款码</div>
  92. <!-- @change="handleQuery" -->
  93. <el-input ref="autoFocus" v-model="authCode" clearable placeholder="请选择付款码" />
  94. </div>
  95. <div class="btn_box">
  96. <div class="btn" style="color: #67c23a" @click="pay" v-if="!hideUser">确认支付</div>
  97. <div class="line" v-if="!hideUser"></div>
  98. <div class="btn" @click="close">关闭</div>
  99. </div>
  100. </div>
  101. <!-- 支付成功打印小票 -->
  102. <div v-if="type === 6">
  103. <div class="icon">
  104. <i class="el-icon-success success"></i>
  105. </div>
  106. <div class="message">下单成功</div>
  107. <div class="btn_box" v-if="hidePointer">
  108. <div class="btn" @click="confirm">确认</div>
  109. </div>
  110. <div class="btn_box" v-else>
  111. <div class="btn" @click="setPointer(0)">打印小票</div>
  112. <div class="line"></div>
  113. <div class="btn" @click="setPointer(1)">打印条码</div>
  114. <div class="line"></div>
  115. <div class="btn" @click="close">关闭</div>
  116. </div>
  117. </div>
  118. </el-dialog>
  119. </div>
  120. </template>
  121. <script>
  122. import { getLodop } from '@/utils/lodopUtils'
  123. import { getClothItem, listOrderClothItem, printCloth } from '@/api/order/clothItem'
  124. import { getMemberInfoById } from '@/api/app/user'
  125. import { clothOrderPay, getOrderPayResult } from '@/api/order/cloth'
  126. import { getUserProfile } from "@/api/system/user";
  127. import { getStore } from '@/api/system/store'
  128. export default {
  129. props: {
  130. hidePointer: {
  131. type: Boolean,
  132. default: false
  133. },
  134. hideUser: {
  135. type: Boolean,
  136. default: false
  137. },
  138. isRecharge: {
  139. type: Boolean,
  140. default: false
  141. }
  142. },
  143. data() {
  144. return {
  145. show: false,
  146. type: 1,
  147. orderInfo: {},
  148. number: 1,
  149. // 打印机设置
  150. LODOP: null,
  151. pointerList: [],
  152. // 打印收衣订单的数据
  153. pointerInfo: null,
  154. payType: 3,
  155. appUserInfo: {},
  156. authCode: '',
  157. time: '',
  158. showPaySuccessBtn: false,
  159. resultCount: 0,
  160. errorMessage: ''
  161. }
  162. },
  163. mounted() {
  164. this.number = 1
  165. const printerTime = setInterval(() => {
  166. this.LODOP = getLodop()
  167. this.number++
  168. if (this.number == 25) {
  169. clearInterval(printerTime)
  170. }
  171. if (this.LODOP) {
  172. clearInterval(printerTime)
  173. }
  174. }, 200)
  175. this.pointerList = JSON.parse(this.$cache.local.get('printerSeting'))
  176. },
  177. methods: {
  178. openSelected(info) {
  179. console.log()
  180. this.orderInfo = info
  181. this.type = 2
  182. if (this.hideUser) {
  183. this.payType = 2
  184. } else {
  185. this.payType = 2
  186. this.getUserInfoData(info.appUserId)
  187. }
  188. this.show = true
  189. },
  190. open(type, info, appUserInfo = null) {
  191. console.log(JSON.stringify(info))
  192. this.orderInfo = info
  193. this.type = type
  194. this.showPaySuccessBtn = false
  195. // this.pointerInfo = info
  196. if (info.id && !this.hidePointer) {
  197. this.getClothItemInfo(info)
  198. }
  199. console.log(this.type, appUserInfo)
  200. if (appUserInfo) {
  201. this.appUserInfo = appUserInfo
  202. }
  203. if (type == 0) {
  204. //微信支付宝支付
  205. this.payType = 0
  206. this.authCode = info.authCode
  207. this.showPaySuccessBtn = false
  208. console.log('aasss', this.appUserInfo)
  209. this.pay()
  210. }
  211. if (type == 1) {
  212. }
  213. if (type == 2) {
  214. //现金支付
  215. this.appUserInfo = {}
  216. this.authCode = ''
  217. this.showPaySuccessBtn = false
  218. if (this.hideUser) {
  219. this.payType = 2
  220. } else {
  221. this.payType = 2
  222. this.getUserInfoData(info.appUserId)
  223. }
  224. this.pay()
  225. }
  226. if (type == 3) {
  227. //会员支付
  228. this.payType = 3
  229. this.showPaySuccessBtn = false
  230. if (appUserInfo) {
  231. this.appUserInfo = appUserInfo
  232. }
  233. console.log('aasss', this.appUserInfo)
  234. this.pay()
  235. }
  236. if (type == 4) {
  237. this.errorMessage = info.payMsg
  238. }
  239. if (type == 5) {
  240. // this.getPayResult()
  241. }
  242. if (type == 6) {
  243. }
  244. this.show = true
  245. },
  246. close() {
  247. const _ = this
  248. if (this.type == 1 || this.type == 6) {
  249. // this.$confirm('是否关闭打印操作?')
  250. // .then(() => {
  251. _.show = false
  252. _.$emit('close')
  253. // })
  254. // .catch(() => { })
  255. }
  256. if (this.type == 2) {
  257. this.$confirm('是否取消支付操作?')
  258. .then(() => {
  259. _.show = false
  260. })
  261. .catch(() => { })
  262. }
  263. if (this.type == 3 || this.type == 5) {
  264. this.$confirm('请确认客户已完成付款再关闭?')
  265. .then(() => {
  266. _.show = false
  267. _.clearTimeOut(_.time)
  268. _.$emit('paySuccess')
  269. })
  270. .catch(() => { })
  271. }
  272. if (this.type == 4) {
  273. _.show = false
  274. }
  275. // if (this.type == 6) {
  276. // // if (!this.hidePointer) {
  277. // // this.$confirm('是否关闭打印操作?')
  278. // // .then(() => {
  279. // _.show = false
  280. // _.$emit('close')
  281. // // })
  282. // // .catch(() => { })
  283. // // } else {
  284. // // _.show = false
  285. // // }
  286. // }
  287. },
  288. confirm() {
  289. this.show = false
  290. this.$emit('confirm', this.orderInfo)
  291. },
  292. setPointer(type) {
  293. if (!this.LODOP) {
  294. this.$modal.msgError('请安装打印机软件')
  295. return
  296. }
  297. let p_name = ''
  298. this.pointerList.forEach((pointer) => {
  299. if (pointer.printType == type) {
  300. p_name = pointer.printName
  301. }
  302. })
  303. if (this.isRecharge) {
  304. this.$emit('pointer', {
  305. id: this.orderInfo.orderId,
  306. appUserInfo: this.appUserInfo,
  307. LODOP: this.LODOP,
  308. p_name: p_name
  309. })
  310. return
  311. }
  312. console.log(this.pointerList, p_name)
  313. if (type == 0) {
  314. this.collectClothPrinter(this.LODOP, this.pointerInfo, p_name)
  315. } else {
  316. this.barCodePrinter(this.LODOP, this.pointerInfo, p_name)
  317. }
  318. // this.show = false CL1108946378974957568
  319. },
  320. // 获取打印数据
  321. getClothItemInfo(data) {
  322. // getClothItem
  323. printCloth(data.id).then((res) => {
  324. if (res) {
  325. console.log('打印数据', res)
  326. if (this.getUserInfo().userType == '02') {
  327. const obj = {
  328. name: this.getUserInfo().storeName,
  329. contactPhone: this.getUserInfo().phonenumber,
  330. user: this.getUserInfo().nickName,
  331. }
  332. // row.sysOrg = obj
  333. res.data.sysOrg = obj
  334. }
  335. this.pointerInfo = res.data
  336. // getStore(this.pointerInfo.orgId).then(res => {
  337. // console.log("AAA", res, this.pointerInfo)
  338. // this.pointerInfo.sysOrg = res.data
  339. // })
  340. // listOrderClothItem({ pageSize: 99999, pageNum: 1, orderNo: data.orderNo }).then((res) => {
  341. // console.log(res)
  342. // this.pointerInfo.orderClothDetails = res.rows
  343. // })
  344. }
  345. })
  346. },
  347. // 获取用户信息
  348. getUserInfoData(id) {
  349. getMemberInfoById({
  350. appUserId: id
  351. }).then((response) => {
  352. this.appUserInfo = response.data
  353. })
  354. },
  355. changePayType() {
  356. if (this.payType == 0) {
  357. this.$nextTick((_) => {
  358. this.$refs.autoFocus.focus()
  359. })
  360. }
  361. },
  362. handleQuery(e, event) {
  363. console.log(event)
  364. console.log(this.authCode)
  365. },
  366. pay() {
  367. if (this.payType == 0 && !this.authCode) {
  368. this.type = 4
  369. this.errorMessage = '请先扫码'
  370. this.authCode = ''
  371. this.changePayType()
  372. return
  373. }
  374. if (this.payType == 3 && this.appUserInfo.rechargeBalance + this.appUserInfo.giveBalance < this.orderInfo.payAmount) {
  375. this.errorMessage = '余额不足'
  376. this.type = 4
  377. this.authCode = ''
  378. this.changePayType()
  379. return
  380. }
  381. this.type = 3
  382. clothOrderPay({
  383. appUserId: this.orderInfo.appUserId,
  384. payType: this.payType,
  385. authCode: this.authCode,
  386. orderNo: this.orderInfo.orderNo,
  387. payAmount: this.orderInfo.payAmount
  388. })
  389. .then((res) => {
  390. console.log('支付结果', res)
  391. if (res) {
  392. if (res.data.payResult == 100) {
  393. this.getPayResult()
  394. }
  395. if (res.data.payResult == 101 || res.data.payResult == 0) {
  396. this.errorMessage = res.data.payMsg
  397. this.type = 4
  398. this.authCode = ''
  399. this.changePayType()
  400. }
  401. if (res.data.payResult == 200) {
  402. this.type = 1
  403. this.$emit('paySuccess')
  404. }
  405. }
  406. })
  407. .catch((e) => {
  408. console.log('支付报错', e)
  409. this.type = 4
  410. this.authCode = ''
  411. this.changePayType()
  412. this.errorMessage = e
  413. // this.$message.error(e.data.msg)
  414. })
  415. },
  416. getPayResult() {
  417. getOrderPayResult({
  418. orderNo: this.orderInfo.orderNo
  419. })
  420. .then((res) => {
  421. console.log('支付结果1', res)
  422. if (res) {
  423. if (res.data.payResult == 100) {
  424. this.time = setTimeout(() => {
  425. if (this.resultCount == 6) {
  426. this.showPaySuccessBtn = true
  427. } else {
  428. this.resultCount++
  429. }
  430. this.getPayResult()
  431. }, 5000)
  432. }
  433. if (res.data.payResult == 101 || res.data.payResult == 0) {
  434. this.errorMessage = res.data.payMsg
  435. this.type = 4
  436. this.authCode = ''
  437. this.changePayType()
  438. }
  439. if (res.data.payResult == 200) {
  440. this.type = 1
  441. this.$emit('paySuccess')
  442. }
  443. }
  444. })
  445. .catch((e) => {
  446. this.type = 4
  447. this.authCode = ''
  448. this.errorMessage = e.data.msg
  449. })
  450. }
  451. }
  452. }
  453. </script>
  454. <style>
  455. .popup_box .el-dialog__body {
  456. padding: 0;
  457. }
  458. </style>
  459. <style scoped lang="scss">
  460. .icon {
  461. font-size: 100px;
  462. text-align: center;
  463. .success {
  464. color: #67c23a;
  465. }
  466. .warning {
  467. color: #e6a23c;
  468. }
  469. .loading {
  470. color: #e4e7ed;
  471. }
  472. .error {
  473. color: #f56c6c;
  474. }
  475. }
  476. .btn_box {
  477. display: flex;
  478. align-items: center;
  479. margin-top: 20px;
  480. font-size: 16px;
  481. font-weight: 500;
  482. border-top: 1px solid #ebeef5;
  483. .btn {
  484. flex: 1;
  485. text-align: center;
  486. line-height: 60px;
  487. cursor: pointer;
  488. }
  489. .line {
  490. width: 1px;
  491. height: 60px;
  492. background: #ebeef5;
  493. }
  494. }
  495. .del_btn {
  496. position: absolute;
  497. top: 20px;
  498. right: 20px;
  499. font-size: 20px;
  500. cursor: pointer;
  501. }
  502. .cell {
  503. display: flex;
  504. align-items: center;
  505. padding: 0 40px 20px;
  506. .label {
  507. margin-right: 20px;
  508. min-width: 80px;
  509. }
  510. }
  511. .amount_box {
  512. span {
  513. color: #f56c6c;
  514. font-weight: bold;
  515. font-size: 20px;
  516. &:first-child {
  517. font-size: 16px;
  518. }
  519. }
  520. }
  521. .message {
  522. font-size: 20px;
  523. text-align: center;
  524. padding: 10px 0 20px;
  525. color: #606266;
  526. }
  527. </style>