payment.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <view style="padding: 30rpx;" >
  3. <view class="bd">
  4. <text class="font2">付款金额</text>
  5. <text class="font1">¥{{price}}</text>
  6. <view class="flex">
  7. <view class="flex_item">付款方式</view>
  8. <view>微信支付</view>
  9. </view>
  10. <button type="button" class="btn" @click="pay">立即支付</button>
  11. </view>
  12. </view>
  13. </template>
  14. <script>
  15. export default {
  16. data() {
  17. return {
  18. price:0.01
  19. }
  20. },
  21. onLoad(option) {
  22. },
  23. onShow(){
  24. },
  25. methods: {
  26. pay(){
  27. this.wxPayment({})
  28. },
  29. wxPayment(param){
  30. let self = this
  31. this.$api.order(param).then(res => {
  32. if (res.data.code == 200){
  33. let data = res.data.data
  34. uni.requestPayment({
  35. provider: data.provider,
  36. nonceStr: data.nonceStr,
  37. package: data.package,
  38. signType: data.signType,
  39. paySign: data.sign,
  40. timeStamp: String(data.timeStamp),
  41. success: function (res) {
  42. console.log('success:' + JSON.stringify(res));
  43. },
  44. fail: function (err) {
  45. console.log('fail:' + JSON.stringify(err));
  46. }
  47. });
  48. }
  49. })
  50. },
  51. },
  52. }
  53. </script>
  54. <style scope>
  55. page {
  56. background: #f3f3f3;
  57. font-size: 28rpx;
  58. }
  59. .flex {
  60. display: flex;
  61. align-items: center;
  62. }
  63. .flex_item {
  64. flex: 1;
  65. }
  66. .container {
  67. padding: 30rpx;
  68. }
  69. .container .bd {
  70. background: #fff;
  71. border-radius: 10rpx;
  72. padding: 100rpx 30rpx 50rpx;
  73. }
  74. .container .bd .font1 {
  75. display: block;
  76. text-align: center;
  77. font-size: 88rpx;
  78. }
  79. .container .bd .font2 {
  80. display: block;
  81. text-align: center;
  82. font-size: 30rpx;
  83. margin: 30rpx 0 60rpx;
  84. color: #525252;
  85. }
  86. .container .bd .flex {
  87. border-bottom: 1px solid #eee;
  88. padding: 30rpx 0;
  89. margin-bottom: 30rpx;
  90. }
  91. .container .bd .btn {
  92. color: #fff;
  93. font-size: 28rpx;
  94. padding: 10rpx 0;
  95. background: #eb3b2f;
  96. }
  97. </style>