天波h5前端应用
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
2.6KB

  1. <template>
  2. <div class="ai-call-container"></div>
  3. </template>
  4. <script>
  5. import axios from 'axios';
  6. export default {
  7. name:'',
  8. data(){
  9. return {
  10. code: '',
  11. createTime: '',
  12. }
  13. },
  14. created() {
  15. this.loadParams();
  16. },
  17. methods: {
  18. loadParams() {
  19. let params = this.$route.query;
  20. if( params ) {
  21. this.code = params.code;
  22. this.getLongLink();
  23. }
  24. },
  25. getLongLink() {
  26. let reqParams = {
  27. code: this.code
  28. };
  29. let baseUrl = process.env.NODE_ENV === "production" ? 'https://ai.ssjlai.com' : 'https://id.ssjlai.com';
  30. //let proxyUrl = '/api/id/';
  31. let reqUrl = `${baseUrl}/watersoutboundapi/getLongLink`;
  32. axios.get(reqUrl, {
  33. params: { ...reqParams },
  34. }).then(res =>{
  35. const data = res.data.data;
  36. if(data.length > 0) {
  37. let longLink = '';
  38. // 把接口中关于随手精灵公众号的链接地址替换成h5的链接地址
  39. if(data[0].long_link.indexOf('ai.ssjlai.com/parentweb') > -1) {
  40. // ai是正式环境
  41. longLink = data[0].long_link.replace('https://ai.ssjlai.com/parentweb/#/dangerAreaDetails', 'https://ai.ssjlai.com/h5-frontendweb/#/alarmDetails');
  42. } else if( data[0].long_link.indexOf('id.ssjlai.com/parentweb') > -1 ) {
  43. // id是测试环境
  44. longLink = data[0].long_link.replace('https://id.ssjlai.com/parentweb/#/dangerAreaDetails', 'https://id.ssjlai.com/h5-frontendweb/#/alarmDetails');
  45. } else {
  46. // 防止链接已经是h5的链接地址
  47. longLink = data[0].long_link;
  48. }
  49. const createTime = data[0].create_time;
  50. const nowTime = new Date().getTime();
  51. const twoHours = 7200;
  52. if(nowTime - createTime > twoHours) {
  53. // 增加过期失效判断,根据接口返回的创建时间与现在时间比较,超过两个小时提示链接过期并且不再跳转
  54. console.log("::已经超过两个小时");
  55. this.$dialog.confirm({
  56. message: '链接已失效',
  57. showCancelButton: false
  58. })
  59. } else {
  60. window.location.href = longLink;
  61. }
  62. } else {
  63. this.$dialog.confirm({
  64. message: '参数错误',
  65. showCancelButton: false
  66. })
  67. }
  68. })
  69. },
  70. }
  71. }
  72. </script>
  73. <style scoped>
  74. </style>