classTeam.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import Api from "../../model/api";
  2. import {getDataSet, showLoading, toast} from "../../utils/utils";
  3. import {wxToPromise} from "../../utils/wx";
  4. Page({
  5. data: {
  6. images: [],
  7. teamName: ''
  8. },
  9. async onLoad(options) {
  10. let teamId = options.teamId;
  11. let res = await Api.getTeam(teamId);
  12. let images = JSON.parse(res.data.teamCodeUrls);
  13. this.setData({
  14. teamName: res.data.teamName,
  15. images
  16. })
  17. },
  18. async saveImg(e) {
  19. let url = getDataSet(e, "url");
  20. showLoading('保存中...')
  21. const res = await wxToPromise("downloadFile", {url});
  22. if (res.statusCode === 200) {
  23. try {
  24. await wx.saveImageToPhotosAlbum({
  25. filePath: res.tempFilePath,
  26. })
  27. } catch (e) {
  28. console.log(e)
  29. if (e.errMsg === "saveImageToPhotosAlbum:fail auth deny") {
  30. wx.showModal({
  31. title: "提示",
  32. content: "请点击右上角进入设置勾选相册后方可保存到相册",
  33. showCancel: false
  34. })
  35. }
  36. }
  37. } else {
  38. toast(`保存失败,请稍后重试${res.statusCode}:${res.errMsg}`)
  39. }
  40. wx.hideLoading();
  41. }
  42. })