AliyunCaptcha.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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);
  27. console.log('e.detail.data111', e.detail.data);
  28. const captchaVerifyParam = e.detail.data[0];
  29. // 通过事件通道,触发在业务页面中定义的 'getCaptchaVerifyParam' 事件,并把验证参数发送至业务页面
  30. const eventChannel = this.getOpenerEventChannel();
  31. eventChannel && eventChannel.emit('getCaptchaVerifyParam', captchaVerifyParam);
  32. setTimeout(() => {
  33. console.log('back');
  34. // uni.navigateBack();
  35. }, 300);
  36. }
  37. }
  38. }
  39. </script>