// index.js // 获取应用实例 const app = getApp() import { VueLikePage } from '../../utils/page' import { CDN_URL } from '../../config/index' import { isPhoneX } from './../../utils/tools' import Router from '../../utils/routes' VueLikePage([], { data: { cdn_url: CDN_URL, }, methods: { onLoad: function (options) { let { vr_link } = options this.setData({ vr_link }) isPhoneX().then(res => { this.setData({ isIphoneX: res }) }) }, saveAlbum(e) { const { type } = e.currentTarget.dataset console.log(type); let img = this.data.vr_link wx.showLoading({ title: '保存中…', mask: true }); wx.downloadFile({ url: img, type: 'image', success: function (res) { var tempFilePath = res.tempFilePath; wx.saveImageToPhotosAlbum({ filePath: tempFilePath, success(res) { wx.showModal({ title: '保存成功', showCancel: false, complete:()=>{ Router.redirectTo({ url:'select' }) } }); }, fail: (err) => { wx.showModal({ title: '保存失败,请稍后再试', }); }, complete: () => { wx.hideLoading(); } }) }, fail: function (res) { wx.showModal({ title: '下载失败,请稍后再试', }); wx.hideLoading(); } }); }, back(){ Router.back() } } })