webview.vue 799 B

123456789101112131415161718192021222324252627282930313233343536
  1. <template>
  2. <web-view :src="webViewSrc"></web-view>
  3. </template>
  4. <script>
  5. import {getToken} from '@/libs/auth.js';
  6. export default {
  7. data() {
  8. return {
  9. webViewSrc:""
  10. }
  11. },
  12. onLoad(options) {
  13. this.init(options)
  14. },
  15. methods: {
  16. init(options){
  17. let t=new Date().getTime()
  18. if(options.type==='scan'){
  19. let href="http://h5.xazhyc.com/scanApp/#/pages/index/index"
  20. let qrcode=uni.getStorageSync('qrcode')
  21. qrcode=qrcode.split('?')[1]
  22. this.webViewSrc=`${href}?token=${getToken()}&${qrcode}&v=${t}`
  23. uni.setNavigationBarTitle({
  24. title:"扫码操作"
  25. })
  26. }else{
  27. this.webViewSrc=`${options.href}?token=${getToken()}&v=${t}`
  28. uni.setNavigationBarTitle({
  29. title:`${options.name}`
  30. })
  31. }
  32. }
  33. }
  34. }
  35. </script>