jumpMiddle.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <template>
  2. <view>
  3. <a ref="payUrlRef" :href="jumpUrl"></a>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. jumpUrl: "",
  11. }
  12. },
  13. onload() {
  14. let url = localStorage.getItem('jumpUrl');
  15. // let url = this.cookie.get("jumpUrl");
  16. if(url){
  17. this.jumpUrl = url;
  18. }else{
  19. this.jumpUrl = 'https://h5.pdzhtc.com';
  20. }
  21. this.getOrderId()
  22. },
  23. mounted() {
  24. this.$refs.payUrlRef.click();
  25. },
  26. methods: {
  27. getOrderId(id) {
  28. const localToken = JSON.parse(localStorage.getItem('lifeData') ?? '{}')
  29. const token = localToken?.data?.vuex_token
  30. $.ajax({
  31. //请求方式
  32. type : "get",
  33. //请求地址
  34. url : baseUrl + '/client/orderinfo/orderListByPoly/' + id,
  35. // token
  36. beforeSend: function(request) {
  37. request.setRequestHeader("Authorization", 'Bearer ' + token);
  38. },
  39. //请求成功
  40. success: function(result) {
  41. if (result.code === 200) {
  42. this.jumpUrl = result?.data?.jumpUrl ?? 'https://h5.pdzhtc.com'
  43. } else {
  44. alert(result.msg)
  45. }
  46. },
  47. //请求失败,包含具体的错误信息
  48. error: function(e){
  49. alert('程序错误!')
  50. }
  51. });
  52. }
  53. }
  54. }
  55. </script>
  56. <style>
  57. </style>