paymentStatus.vue 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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: '72',
  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. } else if (this.type === 'warning') {
  69. let wxConfig = await getWxPay(this.orderData.orderNo, uni.getStorageSync('openId'));
  70. uni.requestPayment({
  71. provider: 'wxpay',
  72. timeStamp: wxConfig.data.timeStamp,
  73. nonceStr: wxConfig.data.nonceStr,
  74. package: wxConfig.data.prepayId,
  75. signType: wxConfig.data.signType,
  76. paySign: wxConfig.data.paySign,
  77. success: res => {
  78. this.init();
  79. },
  80. fail: err => {}
  81. });
  82. }
  83. },
  84. secondaryBtnClick() {
  85. uni.navigateBack();
  86. },
  87. finish() {
  88. this.init();
  89. }
  90. }
  91. }
  92. </script>
  93. <style lang="scss" scoped>
  94. ::v-deep .uv-count-down {
  95. .uv-count-down__text {
  96. color: #fff;
  97. }
  98. }
  99. .content {
  100. box-sizing: border-box;
  101. }
  102. </style>