pay.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <template>
  2. <view>
  3. <u-popup v-model="show" mode="bottom" :closeable="true" @close="close">
  4. <view class="plr-40">
  5. <view class="center ptb-30">选择支付方式</view>
  6. <u-radio-group v-model="value">
  7. <u-radio name="2" class="w100 bb ptb-30">
  8. 微信支付
  9. </u-radio>
  10. <u-radio name="1" class="w100 ptb-30">
  11. 余额支付
  12. </u-radio>
  13. </u-radio-group>
  14. <view class="ptb-50">
  15. <u-button type="primary" @click="pay">确定</u-button>
  16. </view>
  17. </view>
  18. </u-popup>
  19. </view>
  20. </template>
  21. <script>
  22. import {baseUrl} from '../common/http.js';
  23. export default {
  24. props: ['show','money'],
  25. data() {
  26. return {
  27. value: 2,//1=余额,2=微信
  28. };
  29. },
  30. created() {
  31. console.log(this.money);
  32. },
  33. methods: {
  34. close() {
  35. this.$emit('close')
  36. },
  37. pay() {
  38. if (this.value == 1) {
  39. this.$http('/addons/ddrive/user/service_pay', {
  40. type: this.value
  41. }, "POST").then(data => {
  42. uni.showToast({
  43. title: '支付成功'
  44. })
  45. this.close()
  46. uni.$emit('money')
  47. })
  48. } else if (this.value == 2) {
  49. //微信支付
  50. this.$http('/addons/ddrive/user/service_pay', {
  51. type: this.value
  52. }, "POST").then(data => {
  53. console.log(data);
  54. let _this = this
  55. //data返回参数
  56. //{
  57. // appid: "wxd5cdb23fa8a8a8a4"
  58. // noncestr: "ElHzMeZUqs676yRK"
  59. // package: "Sign=WXPay"
  60. // partnerid: "1601210852"
  61. // prepayid: "wx271544341817098433edb8b12397d20000"
  62. // sign: "5E26B16FE8B6995D333F09A44A5C7EC3"
  63. // timestamp: "1603784674"
  64. //}
  65. uni.requestPayment({
  66. provider: 'wxpay',
  67. orderInfo: data, //微信、支付宝订单数据
  68. success: function(res) {
  69. console.log('success:' + JSON.stringify(res));
  70. uni.showToast({
  71. title: '支付成功'
  72. })
  73. _this.close()
  74. },
  75. fail: function(err) {
  76. console.log('fail:' + JSON.stringify(err));
  77. }
  78. });
  79. })
  80. }
  81. }
  82. }
  83. }
  84. </script>
  85. <style lang="scss" scoped>
  86. /deep/.u-primary-hover {
  87. background: linear-gradient(to right,#00b6b4,#00d496) !important;
  88. }
  89. /deep/.u-radio {
  90. display: flex;
  91. flex-direction: row-reverse;
  92. }
  93. /deep/.u-radio-group {
  94. width: 100% !important;
  95. }
  96. /deep/.u-radio__label {
  97. width: 100%;
  98. }
  99. </style>