index.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // index.js
  2. // 获取应用实例
  3. const app = getApp()
  4. import {
  5. VueLikePage
  6. } from '../../utils/page'
  7. import {
  8. CDN_URL,API_BASE_URL,IMGSTR
  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. baseUrl: API_BASE_URL+'/'
  18. },
  19. methods: {
  20. onLoad: function (options) {
  21. let {
  22. vr_link,
  23. id
  24. } = options
  25. this.setData({
  26. vr_link,
  27. id,
  28. show_img: this.data.baseUrl + vr_link + IMGSTR.normal
  29. })
  30. isPhoneX().then(res => {
  31. this.setData({
  32. isIphoneX: res
  33. })
  34. })
  35. },
  36. loadcompele(){
  37. this.setData({
  38. loadCompele: true
  39. })
  40. },
  41. saveAlbum(e) {
  42. const { type } = e.currentTarget.dataset
  43. let img = this.data.baseUrl + this.data.vr_link + (!type?IMGSTR.normal:IMGSTR.qrcode)
  44. wx.showLoading({
  45. title: '保存中…',
  46. mask: true
  47. });
  48. wx.downloadFile({
  49. url: img,
  50. type: 'image',
  51. success: function (res) {
  52. var tempFilePath = res.tempFilePath;
  53. wx.saveImageToPhotosAlbum({
  54. filePath: tempFilePath,
  55. success(res) {
  56. wx.showModal({
  57. title: type?'已保存,快去分享吧':'已保存到相册',
  58. showCancel: false,
  59. complete:()=>{
  60. }
  61. });
  62. },
  63. fail: (err) => {
  64. wx.showModal({
  65. title: '保存失败,请稍后再试',
  66. });
  67. },
  68. complete: () => {
  69. wx.hideLoading();
  70. }
  71. })
  72. },
  73. fail: function (res) {
  74. wx.showModal({
  75. title: '下载失败,请稍后再试',
  76. });
  77. wx.hideLoading();
  78. }
  79. });
  80. },
  81. back(){
  82. wx.navigateBack({
  83. delta: 1
  84. })
  85. // Router.redirectTo({
  86. // url:'camera',
  87. // query:{
  88. // id:this.data.id
  89. // }
  90. // })
  91. },
  92. backtoexample(){
  93. wx.navigateBack({
  94. delta: 2
  95. })
  96. // Router.redirectTo({
  97. // url:'example',
  98. // query:{
  99. // id:this.data.id
  100. // }
  101. // })
  102. }
  103. }
  104. })