pay.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <template>
  2. <view class="content">
  3. <!-- <view class="settlement" @click="settlement">去支付</view> -->
  4. <view class="boxtop">
  5. <view class="money">¥{{money}}</view>
  6. <view class="moneyMS">在线支付金额</view>
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. export default {
  12. data() {
  13. return {
  14. payInfo:'',
  15. redisId:'',
  16. money:'',
  17. id:'',
  18. }
  19. },
  20. onLoad(opt) {
  21. var that=this;
  22. console.log(opt)
  23. if(opt.redisId){
  24. this.redisId=opt.redisId
  25. this.money=opt.money
  26. this.id=opt.id
  27. this.getPayInfoByRedis()
  28. }
  29. /* this.redisId='91CA851E-624C-44DE-ACDE-15EC5D0CC4B4'
  30. this.getPayInfoByRedis() */
  31. //console.log(opt.payInfo)
  32. var data='{"appId":"wx89476d27c81a7a13","timeStamp":"1646302786","nonceStr":"813d19ffa04b471ba70d6a6f18fb15be","package":"prepay_id=wx031819462930106b0546efa10c765c0000","signType":"RSA","paySign":"TJW8aXN3foPeba9a2skAP0deAAPZ+9HPzGAYjd87V8WIo8joDnDqfu2+qBGIAIZ6pzS/r4nFY1FcOV+hB5sCETbGZJ1Q9V8OfDKFHmto5X8UDz1d75ZOZTAO+1KyimiJr2nQH24nNyt7cuutcs00R1+mY0xpfk3+udPPvn7P8AArKhsDefkGB0Wc/taSDSdMeOKgkJsDshC79KyvYsMjqNlXj/wWPGunuaP3VtSYk4ktCxTQUNQQPw6XanpF95x8cs76i1bAxN0Cj+TVRbrUg6oKDY3qnVdert2bTJ2Wrj9PZUWSsWvpIS0oFPr66tuo1DVy/XLnU0Oqa9UwHgf7Ww=="}'
  33. this.payInfo=JSON.parse(data)
  34. },
  35. methods: {
  36. getPayInfoByRedis(){
  37. var that=this;
  38. this.$http('km66MiniApp/sys/getPayInfoByRedis', {
  39. redisId:this.redisId,
  40. },'GET').then(res => {
  41. console.log(res)
  42. this.payInfo=JSON.parse(res.data)
  43. this.settlement()
  44. })
  45. },
  46. settlement(){
  47. var that=this
  48. console.log(this.payInfo)
  49. uni.requestPayment({
  50. provider: 'wxpay',
  51. // timeStamp: String(Date.now()),
  52. timeStamp:that.payInfo.timeStamp,
  53. nonceStr: that.payInfo.nonceStr,
  54. package: that.payInfo.package,
  55. signType: that.payInfo.signType,
  56. paySign: that.payInfo.paySign,
  57. success: function (res) {
  58. console.log('success:' + JSON.stringify(res));
  59. uni.showToast({
  60. title: '支付成功',
  61. icon:'none',
  62. duration: 2000
  63. });
  64. uni.reLaunch({
  65. url:'../index/index?id='+that.id
  66. })
  67. },
  68. fail: function (err) {
  69. console.log('取消支付fail:' + JSON.stringify(err));
  70. }
  71. });
  72. }
  73. }
  74. }
  75. </script>
  76. <style scoped>
  77. .settlement{
  78. width: 203rpx;
  79. height: 74rpx;
  80. background: #FF4F00;
  81. border-radius: 37rpx;
  82. text-align: center;
  83. line-height: 74rpx;
  84. font-size: 30rpx;
  85. font-family: PingFangSC-Medium, PingFang SC;
  86. font-weight: 500;
  87. color: #FEFFFE;
  88. margin-top: 23rpx;
  89. margin-right: 32rpx;
  90. }
  91. .content{
  92. height: 100vh;
  93. background:#F4F5F7 ;
  94. }
  95. .boxtop{
  96. background: #FFFFFF;
  97. text-align: center;
  98. }
  99. .money{
  100. color: #FF4F00;
  101. font-size: 50rpx;
  102. padding-top: 50rpx;
  103. }
  104. .moneyMS{
  105. color: #999999;
  106. font-size: 28rpx;
  107. padding: 20rpx;
  108. }
  109. </style>