pay.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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. type:'',
  19. }
  20. },
  21. onLoad(opt) {
  22. var that=this;
  23. console.log(opt)
  24. if(opt.redisId){
  25. this.redisId=opt.redisId
  26. this.money=opt.money
  27. this.id=opt.id
  28. this.type=opt.type
  29. this.getPayInfoByRedis()
  30. }
  31. /* this.redisId='91CA851E-624C-44DE-ACDE-15EC5D0CC4B4'
  32. this.getPayInfoByRedis() */
  33. //console.log(opt.payInfo)
  34. 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=="}'
  35. this.payInfo=JSON.parse(data)
  36. },
  37. methods: {
  38. getPayInfoByRedis(){
  39. var that=this;
  40. this.$http('km66MiniApp/sys/getPayInfoByRedis', {
  41. redisId:this.redisId,
  42. },'GET').then(res => {
  43. console.log(res)
  44. this.payInfo=JSON.parse(res.data)
  45. this.settlement()
  46. })
  47. },
  48. settlement(){
  49. var that=this
  50. console.log(this.payInfo)
  51. uni.requestPayment({
  52. provider: 'wxpay',
  53. // timeStamp: String(Date.now()),
  54. timeStamp:that.payInfo.timeStamp,
  55. nonceStr: that.payInfo.nonceStr,
  56. package: that.payInfo.package,
  57. signType: that.payInfo.signType,
  58. paySign: that.payInfo.paySign,
  59. success: function (res) {
  60. console.log('success:' + JSON.stringify(res));
  61. uni.showToast({
  62. title: '支付成功',
  63. icon:'none',
  64. duration: 2000
  65. });
  66. uni.reLaunch({
  67. url:'../index/index?id='+that.id+'&type='+that.type
  68. })
  69. },
  70. fail: function (err) {
  71. console.log('取消支付fail:' + JSON.stringify(err));
  72. uni.reLaunch({
  73. url:'../index/index?id='+that.id+'&type='+that.type+'&quxiao=1'
  74. })
  75. }
  76. });
  77. }
  78. }
  79. }
  80. </script>
  81. <style scoped>
  82. .settlement{
  83. width: 203rpx;
  84. height: 74rpx;
  85. background: #FF4F00;
  86. border-radius: 37rpx;
  87. text-align: center;
  88. line-height: 74rpx;
  89. font-size: 30rpx;
  90. font-family: PingFangSC-Medium, PingFang SC;
  91. font-weight: 500;
  92. color: #FEFFFE;
  93. margin-top: 23rpx;
  94. margin-right: 32rpx;
  95. }
  96. .content{
  97. height: 100vh;
  98. background:#F4F5F7 ;
  99. }
  100. .boxtop{
  101. background: #FFFFFF;
  102. text-align: center;
  103. }
  104. .money{
  105. color: #FF4F00;
  106. font-size: 50rpx;
  107. padding-top: 50rpx;
  108. }
  109. .moneyMS{
  110. color: #999999;
  111. font-size: 28rpx;
  112. padding: 20rpx;
  113. }
  114. </style>