pay-order.vue 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <template>
  2. <view class="pay-order">
  3. <view class="need">待支付<text>¥{{ money }}</text></view>
  4. <view class="app-item ">
  5. <text>账户余额</text>
  6. <text class="basecolor">¥{{ hadMoney | numDot }}</text>
  7. </view>
  8. <view class="app-item">
  9. <text>还需充值</text>
  10. <text class="basecolor">¥{{ (money - hadMoney) >= 0 ? (money - hadMoney) : 0 }}</text>
  11. </view>
  12. <view class="big-btn bg" @click="pay">确认支付</view>
  13. </view>
  14. </template>
  15. <script>
  16. import { _API_OrderPay } from '@/apis/order.js'
  17. export default {
  18. data() {
  19. return {
  20. order_num: '',
  21. order_id: '',
  22. money: '',
  23. fromS: ''
  24. }
  25. },
  26. computed: {
  27. hadMoney() {
  28. return this.$store.state.userinfo.money
  29. }
  30. },
  31. onLoad({ order_id, money, fromS, order_num }) {
  32. this.order_num = order_num
  33. this.order_id = order_id
  34. this.money = money
  35. this.fromS = fromS
  36. },
  37. methods: {
  38. pay() {
  39. if (this.money - this.hadMoney > 0) {
  40. uni.toast('您的余额不足,无法付款')
  41. } else {
  42. uni.loading()
  43. _API_OrderPay({ order_id: this.order_id }).then(({ code, message }) => {
  44. if (code == 200) {
  45. this.$store.commit('userinfo/REDUCEMONEY', this.money)
  46. uni.$emit('INIT')
  47. uni.$emit('PAYSUCCESS', this.order_num)
  48. uni.showModal({
  49. showCancel: false,
  50. title: '提示',
  51. content: '付款成功',
  52. success: () => {
  53. uni.navigateBack({ delta: this.fromS ? 2 : 1 })
  54. }
  55. })
  56. } else {
  57. uni.toast(message)
  58. }
  59. })
  60. }
  61. }
  62. }
  63. }
  64. </script>
  65. <style lang="scss">
  66. .pay-order {
  67. height: 100vh;
  68. background: $app-base-bg;
  69. .need {
  70. @include flex();
  71. height: 120rpx;
  72. background: #FFFFFF;
  73. font-size: 42rpx;
  74. text {
  75. font-weight: bold;
  76. margin-left: 57rpx;
  77. }
  78. }
  79. .app-item {
  80. margin-top: 20rpx;
  81. }
  82. .big-btn {
  83. margin-top: 390rpx;
  84. width: 400rpx;
  85. }
  86. }
  87. </style>