鸿宇研学生前端代码
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.

58 lines
1.4 KiB

1 day ago
  1. <template>
  2. <view class="">
  3. <web-view :src="h5Url" @message="message"></web-view>
  4. </view>
  5. </template>
  6. <script>
  7. export default {
  8. data(){
  9. return{
  10. id: '',
  11. h5Url: '',
  12. imageData: '',
  13. }
  14. },
  15. onLoad({ id }) {
  16. this.id = id
  17. // this.h5Url = `https://adminh5.kjetax.com/#/?id=${id}&token=${uni.getStorageSync('token')}`
  18. this.h5Url = `https://192.168.10.100:8080/#/?id=${id}&token=${uni.getStorageSync('token')}`
  19. console.log('url', this.h5Url)
  20. console.log('...')
  21. },
  22. methods: {
  23. message(e) {
  24. const url = e.detail.data[0]
  25. console.log('pdf', url)
  26. this.downloadFile(url)
  27. },
  28. downloadFile(url) {
  29. console.log('downloadFile', url)
  30. uni.downloadFile({
  31. url, // 文件地址
  32. success: (downloadRes) => {
  33. console.log('downloadRes', downloadRes)
  34. if (downloadRes.statusCode === 200) {
  35. uni.openDocument({
  36. showMenu: true,
  37. filePath: downloadRes.tempFilePath,
  38. success: () => console.log('打开成功')
  39. });
  40. } else {
  41. uni.showToast({ title: '下载失败', icon: 'none' });
  42. }
  43. },
  44. fail: (err) => {
  45. console.log('downloadFile fail', err)
  46. uni.showToast({ title: '网络异常', icon: 'none' });
  47. }
  48. });
  49. },
  50. },
  51. }
  52. </script>
  53. <style>
  54. </style>