orderPay.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  1. <template>
  2. <view class="pay">
  3. <view class="state" v-if="info.goodsList[0].goodsState == 'WAIT_PAYMENT' && !isNotTime">
  4. 等待支付,剩余<u-count-down :time="closeTime" format="mm:ss" @finish="finish"></u-count-down>
  5. </view>
  6. <view class="state" v-else>
  7. {{ info.goodsList[0] | filterType }}
  8. </view>
  9. <view class="pay-info">
  10. <view class="goods-info">
  11. <image class="goods-img"
  12. src="http://zswl-dev.oss-cn-chengdu.aliyuncs.com/63b7c68b71a69169d1b33f92/store/65fe8e5874d67a7dbd842c5a/ext/GOODS_INFO/School.png/5.png"
  13. mode=""></image>
  14. <view class="info">
  15. <view class="goods-name">
  16. {{ info.goodsList[0].goodsInfo.goodsName }}
  17. </view>
  18. <view class="num">
  19. {{ info.goodsList[0].goodsInfo.goodsDescribe }}
  20. </view>
  21. <view class="priceColumn">
  22. <view class="price">
  23. <text class="unit">¥</text>{{ info.goodsList[0].goodsInfo.realPrice }}
  24. </view>
  25. <view class="goodsNum">
  26. x{{ reserve.persons.length || 1 }}
  27. </view>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="setoff">
  32. <view class="text">
  33. 出发时间
  34. </view>
  35. <view class="date" @click="openCalendar">
  36. {{ reserve.reserveTime }}
  37. </view>
  38. </view>
  39. </view>
  40. <view class="card-box"
  41. v-if="info.goodsList[0].jobFlowMap != 'P802' && info.goodsList[0].goodsState == 'WAIT_USE' && info.goodsList[0].goodsName != '二维码支付'">
  42. <view class="title-top">
  43. <view class="title-text">
  44. 券码信息
  45. </view>
  46. </view>
  47. <view class="code-box">
  48. <view class="qrcode">
  49. <uqrcode ref="uqrcode" :size="qrsize" type="2d" auto canvas-id="qrcode" :value="codeData" :loading="loading">
  50. <template v-slot:loading>
  51. <text style="color: black;">拼命加载中...</text>
  52. </template>
  53. </uqrcode>
  54. </view>
  55. <view class="coode">{{ codeData }}</view>
  56. </view>
  57. </view>
  58. <view class="card-box">
  59. <view class="title-top">
  60. <view class="title-text">
  61. 预定人信息
  62. </view>
  63. </view>
  64. <view class="info border">
  65. <view class="label">
  66. 姓名
  67. </view>
  68. <view class="value">
  69. {{ reserve.reserveName }}
  70. </view>
  71. </view>
  72. <view class="info">
  73. <view class="label">
  74. 手机号
  75. </view>
  76. <view class="value">
  77. {{ reserve.reservePhone }}
  78. </view>
  79. </view>
  80. </view>
  81. <view class="card-box">
  82. <view class="title-top">
  83. <view class="title-text">
  84. 出游人信息
  85. </view>
  86. </view>
  87. <template v-for="item in reserve.persons">
  88. <view class="info border">
  89. <view class="label">
  90. 姓名
  91. </view>
  92. <view class="value">
  93. {{ item.userName }}
  94. </view>
  95. </view>
  96. <view class="info">
  97. <view class="label">
  98. 手机号
  99. </view>
  100. <view class="value">
  101. {{ item.phone }}
  102. </view>
  103. </view>
  104. </template>
  105. </view>
  106. <view class="card-box">
  107. <view class="title-top">
  108. <view class="title-text">
  109. 订单信息
  110. </view>
  111. </view>
  112. <view class="info ">
  113. <view class="label">
  114. 订单编号
  115. </view>
  116. <view class="value">
  117. {{ info.orderNo }}
  118. </view>
  119. </view>
  120. <view class="info">
  121. <view class="label">
  122. 付款方式
  123. </view>
  124. <view class="value">
  125. {{ info.payment | filterPay }}
  126. </view>
  127. </view>
  128. <view class="info ">
  129. <view class="label">
  130. 下单时间
  131. </view>
  132. <view class="value">
  133. {{ $u.timeFormat(info.createTime, 'yyyy-mm-dd hh:MM:ss') }}
  134. </view>
  135. </view>
  136. <view class="info">
  137. <view class="label">
  138. 支付时间
  139. </view>
  140. <view class="value">
  141. {{ payTime }}
  142. </view>
  143. </view>
  144. </view>
  145. <view class="card-box" style="margin-bottom: 160rpx;">
  146. <view class="title-top">
  147. <view class="title-text">
  148. 交易信息
  149. </view>
  150. </view>
  151. <view class="info ">
  152. <view class="label">
  153. 金额
  154. </view>
  155. <view class="value">
  156. ¥{{ info.totalAmount }}
  157. </view>
  158. </view>
  159. <view class="info">
  160. <view class="label">
  161. 优惠券
  162. </view>
  163. <view class="value">
  164. -¥{{ info.discountAmount }}
  165. </view>
  166. </view>
  167. <view class="info ">
  168. <view class="label">
  169. 合计
  170. </view>
  171. <view class="value">
  172. ¥{{ info.payAmount }}
  173. </view>
  174. </view>
  175. </view>
  176. <view class="btn-box" v-if="info.goodsList[0].goodsState == 'WAIT_PAYMENT'">
  177. <button class="cancel-btn" @click="cancel" :loading="btnLoading">
  178. 取消订单
  179. </button>
  180. <button class="btn" @click="pay" :loading="btnLoading">
  181. 立即支付
  182. </button>
  183. </view>
  184. </view>
  185. </template>
  186. <script>
  187. import { qrCode, getReserve } from '@/api/order.js'
  188. import { payDetails, queryPayOrder, unRefund, refundIntervene } from '@/api/payment.js';
  189. import { cancelOrder } from '@/api/refuel.js'
  190. export default {
  191. data() {
  192. return {
  193. info: {
  194. goodsList: []
  195. },
  196. reserve: {
  197. persons: [],
  198. },
  199. codeData: '123',
  200. show: false,
  201. loading: false,
  202. pageLoading: true,
  203. btnLoading: false,
  204. btnLoading1: false,
  205. oldBright: 0,
  206. isNotTime: false,
  207. qrsize: uni.upx2px(200)
  208. };
  209. },
  210. methods: {
  211. // 申请客服介入
  212. refundIntervene() {
  213. let that = this
  214. uni.showModal({
  215. title: '提示',
  216. content: '确认申请客服介入吗?',
  217. success: function (res) {
  218. if (res.confirm) {
  219. that.btnLoading1 = true
  220. refundIntervene(that.info.goodsList[0].id).then(res => {
  221. that.btnLoading1 = false
  222. if (res.state == 'Success') {
  223. that.payDetails(that.info.orderNo)
  224. }
  225. })
  226. } else if (res.cancel) {
  227. console.log('用户点击取消');
  228. }
  229. }
  230. });
  231. },
  232. isRefund() {
  233. if (!this.info.goodsList[0].verifyModel) {//没核销
  234. return true
  235. } else if (this.info.goodsList[0].verifyModel && (new Date().getTime() < (this.info.goodsList[0].verifyModel.checkTime + 1000 * 60 * 60 * 48))) {// 已核销 并且没超过48小时
  236. return true
  237. } else {
  238. return false
  239. }
  240. },
  241. finish() {
  242. this.isNotTime = true
  243. this.payDetails(this.info.orderNo)
  244. },
  245. refundDetail() {
  246. uni.navigateTo({
  247. url: `/my/order/refundDetail?id=${this.info.orderNo}`
  248. })
  249. },
  250. checkCode() {
  251. this.codeData = ''
  252. this.$nextTick(() => {
  253. this.show = true
  254. this.loading = true
  255. let that = this
  256. // uni.getScreenBrightness({
  257. // success(res) {
  258. // // 获取用户手机亮度 保存起来
  259. // that.oldBright = res.value
  260. // setTimeout(()=>{
  261. // uni.setScreenBrightness({
  262. // value:1
  263. // })
  264. // },200)
  265. // }
  266. // })
  267. qrCode(this.info.goodsList[0].id).then(res => {
  268. this.loading = false
  269. if (res.state == 'Success') {
  270. this.codeData = res.content
  271. }
  272. })
  273. })
  274. },
  275. close() {
  276. this.show = false
  277. // uni.setScreenBrightness({
  278. // value:this.oldBright
  279. // })
  280. },
  281. handleCall() {
  282. uni.makePhoneCall({
  283. phoneNumber: '4000016553'//仅为示例
  284. });
  285. },
  286. apply() {
  287. let that = this
  288. if (this.info.goodsList[0].jobFlowMap == 'XiaoJu') {
  289. uni.navigateTo({
  290. url: './webView'
  291. })
  292. } else {
  293. uni.navigateTo({
  294. url: './refund',
  295. success: function (res) {
  296. // 通过eventChannel向被打开页面传送数据
  297. res.eventChannel.emit('orderInfo', that.info)
  298. }
  299. })
  300. }
  301. },
  302. // 获取订单详情
  303. payDetails(orderNo) {
  304. payDetails(orderNo).then(res => {
  305. this.pageLoading = false
  306. this.info = res.content
  307. if (this.info.goodsList[0].jobFlowMap == 'P802') {
  308. this.isVisual = true
  309. }
  310. if (!this.info.goodsList[0].refundLog) {
  311. this.info.goodsList[0].refundLog = {}
  312. }
  313. if (this.info.goodsList[0].jobFlowMap != 'P802' && this.info.goodsList[0].goodsState == 'WAIT_USE' && this.info.goodsList[0].goodsName != '二维码支付') {
  314. qrCode(this.info.goodsList[0].id).then(res => {
  315. this.loading = false
  316. if (res.state == 'Success') {
  317. this.codeData = res.content
  318. }
  319. })
  320. }
  321. })
  322. getReserve(orderNo).then(res => {
  323. if (res.state == 'Success') {
  324. this.reserve = res.content
  325. }
  326. })
  327. },
  328. // 取消支付
  329. cancel() {
  330. uni.showLoading({
  331. title: '取消中'
  332. })
  333. let obj = {}
  334. try {
  335. obj = JSON.parse(this.info.goodsList[0].extend)
  336. } catch (error) {
  337. obj = {}
  338. }
  339. cancelOrder(obj).then(res => {
  340. if (res.state == 'Success') {
  341. uni.showToast({
  342. title: '取消成功',
  343. icon: 'success'
  344. })
  345. this.payDetails(this.info.orderNo)
  346. }
  347. })
  348. },
  349. // 支付
  350. pay() {
  351. let that = this
  352. if (this.info.goodsList[0].jobFlowMap == 'XiaoJu') {
  353. let { xjOrderId, tradeId } = JSON.parse(this.info.goodsList[0].extend)
  354. uni.navigateToMiniProgram({
  355. appId: "wx0d252f6ed9755862", // 滴滴加油小程序appId
  356. path: `packageA/pages/open-energy-pay/index?orderId=${xjOrderId}&tradeId=${tradeId}`, // 滴滴加油收银台页面地址,需要拼接orderId和tradeId
  357. envVersion: 'release', // 固定release
  358. })
  359. } else {
  360. if (this.btnLoading) return
  361. this.btnLoading = true
  362. uni.showLoading({
  363. title: '支付中'
  364. })
  365. let miniPayRequest = JSON.parse(this.info.payment.miniPayRequest)
  366. uni.requestPayment({
  367. "provider": "wxpay",
  368. "orderInfo": miniPayRequest,
  369. "appid": miniPayRequest.appId, // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
  370. "paySign": miniPayRequest.paySign,
  371. "nonceStr": miniPayRequest.nonceStr, // 随机字符串
  372. "package": miniPayRequest.package, // 固定值
  373. // "prepayid": miniPayRequest.package, // 统一下单订单号
  374. "timeStamp": miniPayRequest.timeStamp, // 时间戳(单位:秒)
  375. "signType": miniPayRequest.signType, //签名算法
  376. success(msg) {
  377. console.log('msg', msg);
  378. queryPayOrder(that.info.orderNo).then(res1 => {
  379. if (res1.state == 'Success') {
  380. uni.hideLoading()
  381. uni.showToast({
  382. title: '支付成功',
  383. icon: 'success'
  384. })
  385. that.btnLoading = false
  386. that.payDetails(that.info.orderNo)
  387. }
  388. })
  389. },
  390. fail(e) {
  391. that.btnLoading = false
  392. uni.hideLoading()
  393. uni.showToast({
  394. title: '取消支付',
  395. icon: 'fail'
  396. })
  397. // 取消支付后,获取支付信息以备再次支付
  398. that.payDetails(that.info.orderNo)
  399. console.log('err', e, this);
  400. }
  401. })
  402. }
  403. },
  404. // 取消退款申请
  405. cancelReply() {
  406. if (this.btnLoading) return
  407. this.btnLoading = true
  408. uni.showLoading({
  409. title: '取消中'
  410. })
  411. console.log(this.info.goodsList[0])
  412. unRefund({ id: this.info.goodsList[0].id }).then(res => {
  413. this.btnLoading = false
  414. uni.hideLoading()
  415. if (res.state == 'Success') {
  416. this.payDetails(this.info.orderNo)
  417. uni.showToast({
  418. title: '取消成功',
  419. icon: 'success'
  420. })
  421. }
  422. })
  423. }
  424. },
  425. filters: {
  426. filterType: function (val) {
  427. if (val.refundLog && val.refundLog.refund == 'REFUSAL_REFUND' && !val.change) {
  428. return '拒绝退款'
  429. }
  430. else if (val.goodsState == 'APPLY_REFUND') {
  431. return '退款审核中'
  432. } else if (val.goodsState == 'CLOSE') {
  433. return '关闭订单'
  434. } else if (val.goodsState == 'REFUNDED') {
  435. return '已退款'
  436. } else if (val.goodsState == 'REFUSAL_REFUND') {
  437. return '拒绝退款'
  438. } else if (val.goodsState == 'APPLY_REFUNDING') {
  439. return '退款中'
  440. } else if (val.goodsState == 'USED') {
  441. return '订单已完成'
  442. } else if (val.goodsState == 'WAIT_PAYMENT') {
  443. return '待付款'
  444. } else if (val.goodsState == 'WAIT_USE') {
  445. return '待使用'
  446. } else {
  447. return ''
  448. }
  449. },
  450. filterPay(val) {
  451. if (val) {
  452. if (val.paymentWay == 'wx.unifiedOrder') {
  453. return '微信支付'
  454. } else if (val.paymentWay == 'trade.create') {
  455. return '支付宝支付'
  456. } else if (val.paymentWay == 'uac.miniOrder') {
  457. return '云闪付支付'
  458. }
  459. }
  460. else {
  461. return '-'
  462. }
  463. }
  464. },
  465. computed: {
  466. closeTime() {
  467. return (this.info.createTime + 1000 * 60 * 30) - new Date().getTime()
  468. },
  469. payTime() {
  470. if (this.info.goodsList[0].extend && !JSON.parse(this.info.goodsList[0].extend).hasOwnProperty('account')) {
  471. if (JSON.parse(this.info.goodsList[0].extend).hasOwnProperty('notifyOrderInfo')) {
  472. return JSON.parse(this.info.goodsList[0].extend).notifyOrderInfo.payTime
  473. } else {
  474. return '-'
  475. }
  476. } else {
  477. if (this.info.payment && this.info.payment.paymentTime) {
  478. return uni.$u.timeFormat(this.info.payment.paymentTime, 'yyyy-mm-dd hh:MM:ss')
  479. } else {
  480. return '-'
  481. }
  482. }
  483. }
  484. },
  485. onLoad(options) {
  486. this.info.orderNo = options.id
  487. },
  488. onShow() {
  489. this.pageLoading = true
  490. this.payDetails(this.info.orderNo)
  491. },
  492. };
  493. </script>
  494. <style lang="scss" scoped>
  495. .pay {
  496. background: #F9F9F9;
  497. min-height: 100vh;
  498. padding: 20rpx;
  499. .state {
  500. display: flex;
  501. color: #222222;
  502. font-size: 32rpx;
  503. font-weight: bold;
  504. margin: 8rpx 0 28rpx 0;
  505. }
  506. .pay-info {
  507. background: #FFFFFF;
  508. border-radius: 16rpx 16rpx 16rpx 16rpx;
  509. padding: 24rpx;
  510. .goods-info {
  511. display: flex;
  512. margin-bottom: 26rpx;
  513. .goods-img {
  514. width: 164rpx;
  515. height: 164rpx;
  516. border-radius: 16rpx;
  517. }
  518. .info {
  519. margin-left: 28rpx;
  520. flex: 1;
  521. .goods-name {
  522. font-weight: bold;
  523. color: #181818;
  524. font-size: 32rpx;
  525. width: 100%;
  526. word-break: break-all;
  527. text-overflow: ellipsis;
  528. overflow: hidden;
  529. display: -webkit-box;
  530. -webkit-box-orient: vertical;
  531. -webkit-line-clamp: 2;
  532. /* 这里是超出几行省略 */
  533. }
  534. .num {
  535. color: #999999;
  536. font-size: 24rpx;
  537. margin-top: 16rpx;
  538. }
  539. .priceColumn {
  540. display: flex;
  541. justify-content: space-between;
  542. align-items: center;
  543. margin-top: 30rpx;
  544. .price {
  545. font-weight: bold;
  546. color: #FF4D3A;
  547. font-size: 32rpx;
  548. .unit {
  549. font-size: 20rpx;
  550. }
  551. }
  552. .goodsNum {
  553. font-size: 24rpx;
  554. color: #AAAAAA;
  555. }
  556. }
  557. }
  558. }
  559. .setoff {
  560. border-top: 1px solid #F0F0F0;
  561. display: flex;
  562. justify-content: space-between;
  563. align-items: center;
  564. font-size: 24rpx;
  565. padding-top: 24rpx;
  566. .text {
  567. color: #222222;
  568. }
  569. .date {
  570. color: #AAAAAA;
  571. }
  572. }
  573. }
  574. .card-box {
  575. padding: 24rpx;
  576. background: #FFFFFF;
  577. margin: 20rpx 0;
  578. border-radius: 16rpx 16rpx 16rpx 16rpx;
  579. .title-top {
  580. display: flex;
  581. justify-content: space-between;
  582. align-items: center;
  583. .title-text {
  584. font-size: 28rpx;
  585. font-weight: bold;
  586. color: #222222;
  587. }
  588. // margin-bottom: 24rpx;
  589. }
  590. .border {
  591. border-top: 1px solid #F0F0F0;
  592. margin-top: 20rpx;
  593. }
  594. .info {
  595. display: flex;
  596. justify-content: space-between;
  597. align-items: center;
  598. padding-top: 20rpx;
  599. .label {
  600. color: #AAAAAA;
  601. font-size: 24rpx;
  602. }
  603. .value {
  604. color: #222222;
  605. font-size: 24rpx;
  606. }
  607. }
  608. .code-box {
  609. display: flex;
  610. justify-content: center;
  611. align-items: center;
  612. flex-direction: column;
  613. .qrcode {
  614. width: 200rpx;
  615. height: 200rpx;
  616. }
  617. .coode {
  618. margin-top: 20rpx;
  619. font-size: 28rpx;
  620. color: #222222;
  621. }
  622. }
  623. }
  624. .btn-box {
  625. position: fixed;
  626. bottom: 0%;
  627. left: 0%;
  628. width: 100%;
  629. display: flex;
  630. align-items: center;
  631. justify-content: space-between;
  632. box-sizing: border-box;
  633. padding: 10rpx 24rpx env(safe-area-inset-bottom);
  634. background: #fff;
  635. border-top: 1rpx solid #EEEEEE;
  636. .cancel-btn {
  637. width: 344rpx;
  638. height: 80rpx;
  639. line-height: 80rpx;
  640. text-align: center;
  641. border-radius: 40rpx;
  642. font-weight: 600;
  643. font-size: 28rpx;
  644. border: 1px solid #AAAAAA;
  645. color: #AAAAAA;
  646. margin: 0;
  647. }
  648. .btn {
  649. width: 344rpx;
  650. height: 80rpx;
  651. line-height: 80rpx;
  652. text-align: center;
  653. background: #3B83FF;
  654. border-radius: 40rpx;
  655. font-weight: 600;
  656. font-size: 28rpx;
  657. color: #FFFFFF;
  658. margin: 0;
  659. margin-left: 20rpx;
  660. }
  661. }
  662. }
  663. </style>