Zhifuyemian.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <view>
  3. <!-- <web-view :webview-styles="webviewStyles" src="https://uniapp.dcloud.io/static/web-view.html"></web-view> -->
  4. <web-view :webview-styles="webviewStyles" :src="Url" @message="webMessage"></web-view>
  5. </view>
  6. </template>
  7. <script>
  8. export default {
  9. data() {
  10. return {
  11. webviewStyles: {
  12. progress: {
  13. color: '#FF3333'
  14. }
  15. },
  16. Url:'',
  17. cid:'',
  18. ddid:''
  19. }
  20. },
  21. onLoad(option) {
  22. this.cid = uni.getStorageSync("cid");
  23. this.ddid = option.ddid;
  24. console.log(this.ddid);
  25. const url = JSON.parse(decodeURIComponent(option.url));
  26. this.Url = url;
  27. // setTimeout(() => {
  28. // console.log('setTimeout');
  29. // //this.pushMsg();
  30. // //uni.navigateBack();
  31. // }, 10000);
  32. uni.onPushMessage((res) => {
  33. console.log('onPushMessage',res);
  34. if(null==res.data.payload||undefined==res.data.payload||''==res.data.payload){
  35. return;
  36. }
  37. console.log('111',res.data.payload);
  38. //var str ='{vnp_BankCode=NCB, vnp_PayDate=20231218110305, vnp_TransactionNo=14248123, vnp_TmnCode=CITYTTTT, vnp_OrderInfo=25142218, vnp_TxnRef=1702872034164, vnp_Amount=1600000, vnp_CardType=ATM, vnp_TransactionStatus=00, vnp_BankTranNo=VNP14248123, vnp_ResponseCode=00}';
  39. var str = res.data.payload;
  40. var str=str.split('{').join('{"');
  41. var str=str.split('}').join('"}');
  42. var str=str.split('=').join('":"');
  43. var str4=str.split(', ').join('", "');
  44. var payload = JSON.parse(str4);
  45. console.log('完成支付订单',payload);
  46. //判断ddid正确则返回
  47. if(payload.vnp_TxnRef==this.ddid){
  48. if(payload.vnp_TransactionStatus=='00'&&payload.vnp_ResponseCode=='00'){
  49. uni.showToast({
  50. title: this.$t('order.zhifuchg'),
  51. icon: 'none',
  52. duration: 2000
  53. })
  54. }
  55. else{
  56. if(payload.vnp_ResponseCode=='00'){
  57. uni.showToast({
  58. title: this.$t('order.yinhangculz'),
  59. icon: 'none',
  60. duration: 2000
  61. })
  62. }
  63. else{
  64. uni.showToast({
  65. title: this.$t('order.zhifushib'),
  66. icon: 'none',
  67. duration: 2000
  68. })
  69. }
  70. }
  71. if(this.ddid.slice(0,2)=="99"){
  72. uni.setStorageSync("OrderList",1);
  73. setTimeout(function() {
  74. // 这里写要延时执行的代码
  75. uni.switchTab({
  76. url:'/pages/OrderList/OrderList'
  77. })
  78. }, 2000);
  79. }
  80. else{
  81. setTimeout(function() {
  82. // 这里写要延时执行的代码
  83. uni.switchTab({
  84. url:'/pages/index/mindex/mindex'
  85. })
  86. }, 2000);
  87. }
  88. }
  89. });
  90. },
  91. onShow() {
  92. },
  93. methods:{
  94. webMessage(data){
  95. console.log(data);
  96. },
  97. // async pushMsg(){//消息推送
  98. // await this.$http.get(`${pushMsg}`, {
  99. // cid:this.cid,
  100. // title:'11',
  101. // content:'22',
  102. // payload:"{\"date\":\"20230808000230\",\"orderNo\":\"1691419030972\",\"notes\":\"\",\"sign\":\"96411cf48914fc94c24593babac979b9\",\"remark\":\"手动调为成功\",\"orderAmt\":\"1.00\",\"version\":\"V2\",\"bizAmt\":\"1.00\",\"status\":\"1\"}",
  103. // },false)
  104. // .then(async r => {
  105. // console.log(r)
  106. // })
  107. // .catch(err => {
  108. // console.log(err)
  109. // })
  110. // },
  111. },
  112. }
  113. </script>
  114. <style>
  115. </style>