import Card from "../../model/card"; import {getEventParam, showLoading} from "../../utils/utils"; import {logicStatus} from "../../model/enum"; import Api from "../../model/api"; Page({ data: { info: null, template: { drawWidth: 350, drawHeight: 484, }, image: '', isGraduated: false, eInfo: {}, isPCDeviceUnkonw: false, }, async onLoad(options) { const {detail} = options; let app = getApp(); let isPCDeviceUnkonw = app.globalData.isPCDeviceUnkonw; let eInfo = JSON.parse(detail); this.setData({ eInfo, isPCDeviceUnkonw }); showLoading(); const res = await Api.getStudentNum(eInfo.eduStuId); if (res && res.data.graduateType) { const template = await Api.getTemplate({ stuId: eInfo.eduStuId }); if (template) { this.setData({ template: template.data, }); } this.setData({ isGraduated: true, info: new Card().palette(this.data.template), }); if (eInfo.graduateType != res.data.graduateType) { const eventChannel = this.getOpenerEventChannel() eventChannel.emit('get'); } } wx.hideLoading(); }, async produce(e) { let eInfo = this.data.eInfo; const res = await Api.produceGradu(eInfo.eduStuId, eInfo.teamId, eInfo.isOnline ? logicStatus.YES : logicStatus.NO, true); const template = await Api.getTemplate({ stuId: eInfo.eduStuId }); if (template) { this.setData({ template: template.data }); } const eventChannel = this.getOpenerEventChannel(); eventChannel.emit('get'); this.setData({ isGraduated: true, info: new Card().palette(this.data.template), }); }, async save(e) { if (this.data.image && typeof this.data.image === 'string') { showLoading('保存中...') try { await wx.saveImageToPhotosAlbum({ filePath: this.data.image, }) } catch (e) { console.log(e) if (e.errMsg === "saveImageToPhotosAlbum:fail auth deny") { wx.showModal({ title: "提示", content: "请点击右上角进入设置勾选相册后方可保存到相册", showCancel: false }) } } wx.hideLoading() } }, onImgOK(e) { this.imagePath = getEventParam(e, "path"); this.setData({ image: this.imagePath }) }, })