tzWeixinPay.vue 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view>
  3. <view class="btn-box">
  4. <view class="btn" @click="payOrder()">支付</view>
  5. </view>
  6. </view>
  7. </template>
  8. <script>
  9. export default {
  10. data() {
  11. return {
  12. payData:null,
  13. payExtraData:null,
  14. }
  15. },
  16. onLoad(options) {
  17. console.log(options)
  18. this.payData=JSON.parse(decodeURIComponent(options.openid));
  19. var json=uni.getStorageSync("payExtraData")
  20. this.payExtraData=JSON.parse(json)
  21. console.log(this.payExtraData)
  22. console.log(this.payData)
  23. this.payOrder()
  24. },
  25. methods:{
  26. payOrder(){
  27. var that=this;
  28. uni.showLoading({
  29. title:"处理中..."
  30. })
  31. uni.requestPayment({
  32. provider: 'wxpay',
  33. timeStamp: that.payData.timeStamp,
  34. nonceStr: that.payData.nonceStr,
  35. package: that.payData.package,
  36. signType: that.payData.signType,
  37. paySign: that.payData.paySign,
  38. success: function(res) {
  39. uni.hideLoading();
  40. if(that.payExtraData.orderType==1){
  41. uni.redirectTo({
  42. url:"/pages_order/inquiryOrderPaySuccess?orderId="+that.payExtraData.orderId
  43. })
  44. }
  45. else if(that.payExtraData.orderType==2){
  46. uni.redirectTo({
  47. url:"/pages_order/storeOrderPaySuccess?orderId="+that.payExtraData.orderId
  48. })
  49. }
  50. else if(that.payExtraData.orderType==3){
  51. uni.redirectTo({
  52. url:"/pages_order/packageOrderPaySuccess?orderId="+that.payExtraData.orderId
  53. })
  54. }
  55. else if(that.payExtraData.orderType==4){
  56. uni.redirectTo({
  57. url:"/pages_order/courseOrderPaySuccess?orderId="+that.payExtraData.orderId
  58. })
  59. }
  60. else if(that.payExtraData.orderType==5){
  61. uni.redirectTo({
  62. url:"/pages_order/userVipOrderOrderPaySuccess?orderId="+that.payExtraData.orderId
  63. })
  64. }
  65. },
  66. fail: function(err) {
  67. uni.showToast({
  68. icon:'none',
  69. title:'fail:' + JSON.stringify(err),
  70. });
  71. uni.hideLoading();
  72. }
  73. });
  74. },
  75. }
  76. }
  77. </script>
  78. <style scoped lang="scss">
  79. page{
  80. height: 100%;
  81. }
  82. .content{
  83. height: 100%;
  84. }
  85. .btn-box{
  86. height: 140upx;
  87. z-index: 9999;
  88. width: 100%;
  89. padding: 0rpx 30upx;
  90. position: fixed;
  91. bottom: 0;
  92. left: 0;
  93. box-sizing: border-box;
  94. background-color: #ffffff;
  95. display: flex;
  96. align-items: center;
  97. justify-content: center;
  98. .btn{
  99. width: 100%;
  100. height: 88upx;
  101. line-height: 88upx;
  102. text-align: center;
  103. font-size: 34upx;
  104. font-family: PingFang SC;
  105. font-weight: 400;
  106. color: #FFFFFF;
  107. background: #C39A58;
  108. border-radius: 10upx;
  109. }
  110. }
  111. </style>