AliyunCaptcha.vue 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <template>
  2. <!-- <web-view src="https://uniapp.dcloud.io/static/web-view.html" @message="onMessage"></web-view> -->
  3. <!-- <web-view src="https://www.chengxiangjiaoyu.com/indexAli.html" @message="onMessage"></web-view> -->
  4. <web-view :src="webViewUrl" @message="onMessage"></web-view>
  5. </template>
  6. <script>
  7. export default {
  8. data() {
  9. return {
  10. webViewUrl: ''
  11. }
  12. },
  13. onLoad(options) {
  14. console.log('接收到参数:', options);
  15. // 构造web-view的URL,传递code参数
  16. let url = 'https://www.chengxiangjiaoyu.com/h5/pages/Login/clientIndex';
  17. if (options.code) {
  18. // 将code参数拼接到URL中
  19. url += `?code=${options.code}`;
  20. console.log('生成的URL:', url);
  21. }
  22. this.webViewUrl = url;
  23. },
  24. methods: {
  25. onMessage(e) {
  26. console.log('e.detail.data[0]', e.detail.data[0]);
  27. const captchaVerifyParam = e.detail.data[0];
  28. // 通过事件通道,触发在业务页面中定义的 'getCaptchaVerifyParam' 事件,并把验证参数发送至业务页面
  29. const eventChannel = this.getOpenerEventChannel();
  30. eventChannel && eventChannel.emit('getCaptchaVerifyParam', captchaVerifyParam);
  31. setTimeout(() => {
  32. console.log('back');
  33. // uni.navigateBack();
  34. }, 300);
  35. }
  36. }
  37. }
  38. </script>