1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- import Api from "../../model/api";
- import {getDataSet, showLoading, toast} from "../../utils/utils";
- import {wxToPromise} from "../../utils/wx";
- Page({
- data: {
- images: [],
- teamName: ''
- },
- async onLoad(options) {
- let teamId = options.teamId;
- let res = await Api.getTeam(teamId);
- let images = JSON.parse(res.data.teamCodeUrls);
- this.setData({
- teamName: res.data.teamName,
- images
- })
- },
- async saveImg(e) {
- let url = getDataSet(e, "url");
- showLoading('保存中...')
- const res = await wxToPromise("downloadFile", {url});
- if (res.statusCode === 200) {
- try {
- await wx.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- })
- } catch (e) {
- console.log(e)
- if (e.errMsg === "saveImageToPhotosAlbum:fail auth deny") {
- wx.showModal({
- title: "提示",
- content: "请点击右上角进入设置勾选相册后方可保存到相册",
- showCancel: false
- })
- }
- }
- } else {
- toast(`保存失败,请稍后重试${res.statusCode}:${res.errMsg}`)
- }
- wx.hideLoading();
- }
- })
|