paymoment.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <view>
  3. <van-radio-group >
  4. <van-cell-group
  5. v-for="(item, index) in list"
  6. :key="index"
  7. >
  8. <van-cell
  9. :title="item.title"
  10. @click="onChange(index)"
  11. >
  12. <template slot="icon" style="padding-right: 10upx;">
  13. <van-radio-group :value="radio" >
  14. <van-radio checked-color="#D9332E" :name="index" >
  15. </van-radio>
  16. </van-radio-group>
  17. </template>
  18. </van-cell>
  19. </van-cell-group>
  20. </van-radio-group>
  21. <view class="payMoney" @click="payMoney">支付({{prices}})</view>
  22. <Dialog :orderCancel="orderCancel"
  23. :titles="titles"
  24. :values="values"
  25. @colseDialog="cancelDialog"
  26. @confirmPay="confirmOrder"
  27. />
  28. </view>
  29. </template>
  30. <script>
  31. import Dialog from '@/component/Dialog.vue'
  32. export default {
  33. components: {
  34. Dialog
  35. },
  36. data() {
  37. return {
  38. values:'',
  39. orderCancel: false,
  40. titles:'',
  41. list:[
  42. {title:'微信支付'},
  43. {title:'圈币支付'}
  44. ],
  45. radio: 0,
  46. prices: '',
  47. order_id:''
  48. }
  49. },
  50. onLoad(e) {
  51. this.prices = e.prices;
  52. this.order_id = e.order_id;
  53. },
  54. methods: {
  55. cancelDialog() {
  56. this.orderCancel = false;
  57. },
  58. confirmOrder() {
  59. this.orderCancel = false;
  60. this.request({
  61. url:'/v1/payment/pay',
  62. method:'POST',
  63. data: {
  64. pay_code: 'point',
  65. order_id: this.order_id
  66. },
  67. success: (res) => {
  68. console.log(res);
  69. }
  70. })
  71. },
  72. onChange(index) {
  73. this.radio = index;
  74. },
  75. payMoney() {
  76. console.log("kkk")
  77. if(this.radio == 0) {
  78. // 微信支付
  79. this.request({
  80. url:'/v1/payment/pay',
  81. method: 'post',
  82. data: {
  83. pay_code: 'wx',
  84. order_id: this.order_id
  85. },
  86. success:(res) => {
  87. let { wx } = res.data.data;
  88. console.log('prepay_id='+wx.prepayid,)
  89. uni.requestPayment({
  90. provider: 'wxpay',
  91. timeStamp: wx.timestamp,
  92. nonceStr: wx.noncestr,
  93. package: 'prepay_id='+wx.prepayid,
  94. signType: 'MD5',
  95. paySign: wx.sign,
  96. success: function (res) {
  97. console.log('success:' + JSON.stringify(res));
  98. },
  99. fail: function (err) {
  100. console.log('fail:' + JSON.stringify(err));
  101. }
  102. })
  103. }
  104. })
  105. }else {
  106. this.titles = "圈币支付";
  107. this.values = "使用圈币支付"+this.prices;
  108. this.orderCancel = true;
  109. // 圈币支付
  110. // this.request({
  111. // url:'/v1/payment/pay',
  112. // method:'POST',
  113. // data: {
  114. // pay_code: 'point',
  115. // order_id: this.order_id
  116. // },
  117. // success: (res) => {
  118. // console.log(res);
  119. // }
  120. // })
  121. }
  122. }
  123. }
  124. }
  125. </script>
  126. <style>
  127. .payMoney {
  128. width: 90%;
  129. color: #fff;
  130. background-color: #D9332E;
  131. position: fixed;
  132. text-align: center;
  133. padding: 20upx 0;
  134. bottom: 5%;
  135. left: 5%;
  136. }
  137. </style>