add upload permission
This commit is contained in:
@ -9,6 +9,7 @@ import { PreviewImageMetadata } from "../../../../types/Attachment";
|
||||
import { MomentApi } from "../../../../api/MomentApi";
|
||||
import { JournalApi } from "../../../../api/JournalApi";
|
||||
import { Network } from "../../../../utils/Network";
|
||||
import Permission from "../../../../utils/Permission";
|
||||
|
||||
type Item = {
|
||||
id: number;
|
||||
@ -44,6 +45,7 @@ interface MomentData {
|
||||
isVisibleArchivePopup: boolean;
|
||||
archiveStep: ArchiveStep;
|
||||
selectedJournalId: number | null;
|
||||
canUpload: boolean;
|
||||
}
|
||||
|
||||
Page({
|
||||
@ -64,10 +66,11 @@ Page({
|
||||
isAuthLocation: false,
|
||||
isVisibleArchivePopup: false,
|
||||
archiveStep: "select-type",
|
||||
selectedJournalId: null
|
||||
selectedJournalId: null,
|
||||
canUpload: false
|
||||
},
|
||||
async onLoad() {
|
||||
this.fetch();
|
||||
await this.fetch();
|
||||
|
||||
// 授权定位
|
||||
const setting = await wx.getSetting();
|
||||
@ -116,6 +119,15 @@ Page({
|
||||
});
|
||||
});
|
||||
},
|
||||
async onShow() {
|
||||
const cached = Permission.getCachedUploadPermission();
|
||||
if (cached !== null) {
|
||||
this.setData({ canUpload: cached });
|
||||
} else {
|
||||
const canUpload = await Permission.checkAndCacheUploadPermission();
|
||||
this.setData({ canUpload });
|
||||
}
|
||||
},
|
||||
async chooseLocation() {
|
||||
const location = await wx.chooseLocation({});
|
||||
this.setData({
|
||||
|
||||
Reference in New Issue
Block a user