paymentStatus.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <view class="content">
  3. <kevy-result-page v-if="type" :type="type" :title="title" :primarColor="primarColor" :details="details"
  4. :primaryBtnText="primaryBtnText" secondaryBtnText="返回" @primaryBtnClick="primaryBtnClick"
  5. @secondaryBtnClick="secondaryBtnClick" :codeUrlFailureTime="orderData.codeUrlFailureTime" @finish="finish">
  6. </kevy-result-page>
  7. </view>
  8. </template>
  9. <script>
  10. import {
  11. getOrderDetail,
  12. getWxPay
  13. } from '@/request/api/workark.js'
  14. export default {
  15. data() {
  16. return {
  17. type: '',
  18. title: '',
  19. details: [],
  20. primarColor: '',
  21. primaryBtnText: '',
  22. orderId: '',
  23. orderData: {},
  24. codeUrlFailureTime: ''
  25. }
  26. },
  27. onLoad(body) {
  28. this.orderId = body.orderId;
  29. if (this.orderId) this.init();
  30. },
  31. methods: {
  32. async init() {
  33. let orderData = await getOrderDetail(this.orderId);
  34. if (!orderData.state) return;
  35. this.orderData = orderData.data;
  36. this.details = [{
  37. label: '订单编号',
  38. value: orderData.data.orderNo
  39. }, {
  40. label: '订单金额',
  41. value: orderData.data.totalFee
  42. }, {
  43. label: '支付状态',
  44. value: orderData.data.orderStatus
  45. }];
  46. this.initStatus();
  47. },
  48. initStatus() {
  49. if (this.orderData.orderStatus === '支付成功') {
  50. this.type = 'success';
  51. this.title = '支付成功';
  52. this.primarColor = '#4fc08d';
  53. this.primaryBtnText = '查看订单';
  54. } else if (this.orderData.orderStatus === '未支付') {
  55. this.type = 'warning';
  56. this.title = '暂未支付';
  57. this.primarColor = '#f9b04d';
  58. this.primaryBtnText = '立即支付';
  59. } else if (this.orderData.orderStatus === '超时已关闭') {
  60. this.type = 'error';
  61. this.title = '订单已失效';
  62. this.primarColor = '#ff3927';
  63. this.primaryBtnText = '查看订单';
  64. }
  65. },
  66. async primaryBtnClick() {
  67. if (this.type === 'success') {
  68. this.$navigateTo('/subPages/indexPage/orderDetail/orderDetail?orderId=' + this.orderData.id)
  69. } else if (this.type === 'warning') {
  70. uni.showLoading({
  71. title: '订单支付中...'
  72. })
  73. let wxConfig = await getWxPay(this.orderData.orderNo, uni.getStorageSync('openId'));
  74. uni.requestPayment({
  75. provider: 'wxpay',
  76. timeStamp: wxConfig.data.timeStamp,
  77. nonceStr: wxConfig.data.nonceStr,
  78. package: wxConfig.data.prepayId,
  79. signType: wxConfig.data.signType,
  80. paySign: wxConfig.data.paySign,
  81. success: res => {
  82. this.init();
  83. uni.hideLoading();
  84. },
  85. fail: err => {
  86. uni.hideLoading();
  87. }
  88. });
  89. }
  90. },
  91. secondaryBtnClick() {
  92. uni.navigateBack();
  93. },
  94. finish() {
  95. this.init();
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss" scoped>
  101. ::v-deep .uv-count-down {
  102. .uv-count-down__text {
  103. color: #fff;
  104. }
  105. }
  106. .content {
  107. box-sizing: border-box;
  108. }
  109. </style>