123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- 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
- })
- },
- })
|