index.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // index.js
  2. // 获取应用实例
  3. const app = getApp()
  4. import {
  5. VueLikePage
  6. } from '../../utils/page'
  7. import {
  8. CDN_URL
  9. } from '../../config/index'
  10. import {
  11. isPhoneX
  12. } from './../../utils/tools'
  13. import Router from '../../utils/routes'
  14. VueLikePage([], {
  15. data: {
  16. cdn_url: CDN_URL,
  17. },
  18. methods: {
  19. onLoad: function (options) {
  20. let {
  21. vr_link
  22. } = options
  23. this.setData({
  24. vr_link
  25. })
  26. isPhoneX().then(res => {
  27. this.setData({
  28. isIphoneX: res
  29. })
  30. })
  31. },
  32. saveAlbum(e) {
  33. const { type } = e.currentTarget.dataset
  34. console.log(type);
  35. let img = this.data.vr_link
  36. wx.showLoading({
  37. title: '保存中…',
  38. mask: true
  39. });
  40. wx.downloadFile({
  41. url: img,
  42. type: 'image',
  43. success: function (res) {
  44. var tempFilePath = res.tempFilePath;
  45. wx.saveImageToPhotosAlbum({
  46. filePath: tempFilePath,
  47. success(res) {
  48. wx.showModal({
  49. title: '保存成功',
  50. showCancel: false,
  51. complete:()=>{
  52. Router.redirectTo({
  53. url:'select'
  54. })
  55. }
  56. });
  57. },
  58. fail: (err) => {
  59. wx.showModal({
  60. title: '保存失败,请稍后再试',
  61. });
  62. },
  63. complete: () => {
  64. wx.hideLoading();
  65. }
  66. })
  67. },
  68. fail: function (res) {
  69. wx.showModal({
  70. title: '下载失败,请稍后再试',
  71. });
  72. wx.hideLoading();
  73. }
  74. });
  75. },
  76. back(){
  77. Router.back()
  78. }
  79. }
  80. })