index.vue 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. <template>
  2. <view>
  3. <view class="con">
  4. <view class="title">支付金额</view>
  5. <view class="price">
  6. <text>¥</text>
  7. {{ payMoney }}
  8. </view>
  9. <view v-if="isPayFail" class="btn" @click="pay()">重新支付</view>
  10. </view>
  11. </view>
  12. </template>
  13. <script>
  14. const app = getApp();
  15. const req = require('../../utils/request.js');
  16. const api = require('../../utils/api.js');
  17. const utils = require('../../utils/util.js');
  18. const route = require('../../utils/route.js');
  19. export default {
  20. data() {
  21. return {
  22. orderId: '',
  23. orderDetail: '',
  24. openId: '',
  25. payMoney: '',
  26. // status: ''
  27. payType: '', //普通支付为空,钱包充值4
  28. isPayFail: false,
  29. };
  30. },
  31. onLoad(options) {
  32. var tha = this;
  33. this.options = options;
  34. this.orderId = options.orderId;
  35. this.payMoney = options.payMoney;
  36. this.payType = options.payType;
  37. // this.status = options.status;
  38. // this.getDetail();
  39. app.globalData.getCheckSessoin(json => {
  40. this.openId = json.openid;
  41. // //vip的支付
  42. // if (options.vip) {
  43. // tha.vipPay();
  44. // } else {
  45. // //其他订单的支付
  46. tha.pay();
  47. // }
  48. });
  49. },
  50. onShow() {},
  51. methods: {
  52. // getDetail() {
  53. // req.getRequest(
  54. // '/api/order/v2/detail', {
  55. // id: this.orderId
  56. // },
  57. // data => {
  58. // this.orderDetail = data;
  59. // },
  60. // true
  61. // );
  62. // },
  63. /**
  64. * 统一下单支付下单
  65. */
  66. pay() {
  67. // console.log('openId', this.openId);
  68. req.payAppOrder(this.orderId, this.openId, this.payType, res => {
  69. console.log('支付状态》》》》》res=', res);
  70. if (res) {
  71. this.isPayFail = false;
  72. uni.redirectTo({
  73. url: '/pay/wxPaySuccess/index'
  74. });
  75. } else {
  76. this.isPayFail = true;
  77. }
  78. });
  79. },
  80. }
  81. };
  82. </script>
  83. <style>
  84. @import './index.css';
  85. </style>