fuck wechat reviewer
This commit is contained in:
@@ -8,6 +8,7 @@ import { JournalType } from "../../../../types/Journal";
|
||||
import { MediaAttachType, PreviewImageMetadata } from "../../../../types/Attachment";
|
||||
import IOSize, { Unit } from "../../../../utils/IOSize";
|
||||
import { JournalApi } from "../../../../api/JournalApi";
|
||||
import Permission from "../../../../utils/Permission";
|
||||
|
||||
interface JournalEditorData {
|
||||
/** 模式:create 或 edit */
|
||||
@@ -48,6 +49,10 @@ interface JournalEditorData {
|
||||
deleteDialogVisible: boolean;
|
||||
/** 删除确认文本 */
|
||||
deleteConfirmText: string;
|
||||
/** 是否拥有上传权限 */
|
||||
canUpload: boolean;
|
||||
/** 是否已检查权限 */
|
||||
permissionChecked: boolean;
|
||||
}
|
||||
|
||||
Page({
|
||||
@@ -72,10 +77,16 @@ Page({
|
||||
},
|
||||
isAuthLocation: false,
|
||||
deleteDialogVisible: false,
|
||||
deleteConfirmText: ""
|
||||
deleteConfirmText: "",
|
||||
canUpload: false,
|
||||
permissionChecked: false
|
||||
},
|
||||
|
||||
async onLoad(options: any) {
|
||||
const canUpload = await this.ensureUploadPermission();
|
||||
if (!canUpload) {
|
||||
return;
|
||||
}
|
||||
// 授权定位
|
||||
const setting = await wx.getSetting();
|
||||
wx.setStorageSync("isAuthLocation", setting.authSetting["scope.userLocation"] || false);
|
||||
@@ -116,6 +127,35 @@ Page({
|
||||
this.getDefaultLocation();
|
||||
}
|
||||
},
|
||||
async ensureUploadPermission(): Promise<boolean> {
|
||||
const cached = Permission.getCachedUploadPermission();
|
||||
if (cached !== null) {
|
||||
this.setData({
|
||||
canUpload: cached,
|
||||
permissionChecked: true
|
||||
});
|
||||
if (!cached) {
|
||||
this.redirectNoPermission();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
const canUpload = await Permission.checkAndCacheUploadPermission();
|
||||
this.setData({
|
||||
canUpload,
|
||||
permissionChecked: true
|
||||
});
|
||||
if (!canUpload) {
|
||||
this.redirectNoPermission();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
redirectNoPermission() {
|
||||
wx.switchTab({
|
||||
url: "/pages/main/tabs/journal/index"
|
||||
});
|
||||
},
|
||||
/** 获取默认定位(创建模式) */
|
||||
getDefaultLocation() {
|
||||
wx.getLocation({
|
||||
|
||||
Reference in New Issue
Block a user