fuck wechat reviewer
This commit is contained in:
@@ -6,6 +6,7 @@ import { TravelLocationType, TravelLocationTypeLabel } from "../../../../types/T
|
||||
import { MediaAttachType, PreviewImageMetadata } from "../../../../types/Attachment";
|
||||
import config from "../../../../config/index";
|
||||
import { MediaItem, MediaItemType } from "../../../../types/UI";
|
||||
import Permission from "../../../../utils/Permission";
|
||||
|
||||
interface TravelLocationEditorData {
|
||||
/** 模式:create 或 edit */
|
||||
@@ -64,6 +65,10 @@ interface TravelLocationEditorData {
|
||||
deleteConfirmText: string;
|
||||
/** 媒体类型枚举 */
|
||||
mediaItemTypeEnum: any;
|
||||
/** 是否拥有上传权限 */
|
||||
canUpload: boolean;
|
||||
/** 是否已检查权限 */
|
||||
permissionChecked: boolean;
|
||||
}
|
||||
|
||||
Page({
|
||||
@@ -105,10 +110,16 @@ Page({
|
||||
],
|
||||
locationTypeIndex: 0,
|
||||
deleteDialogVisible: false,
|
||||
deleteConfirmText: ""
|
||||
deleteConfirmText: "",
|
||||
canUpload: false,
|
||||
permissionChecked: false
|
||||
},
|
||||
|
||||
onLoad(options: any) {
|
||||
async onLoad(options: any) {
|
||||
const canUpload = await this.ensureUploadPermission();
|
||||
if (!canUpload) {
|
||||
return;
|
||||
}
|
||||
// 获取 travelId(必填)
|
||||
const travelId = options.travelId ? parseInt(options.travelId) : 0;
|
||||
if (!travelId) {
|
||||
@@ -133,7 +144,7 @@ Page({
|
||||
travelId,
|
||||
isLoading: true
|
||||
});
|
||||
this.loadLocationDetail(id);
|
||||
await this.loadLocationDetail(id);
|
||||
} else {
|
||||
// 创建模式
|
||||
this.setData({
|
||||
@@ -143,6 +154,35 @@ Page({
|
||||
});
|
||||
}
|
||||
},
|
||||
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"
|
||||
});
|
||||
},
|
||||
|
||||
/** 加载地点详情(编辑模式) */
|
||||
async loadLocationDetail(id: number) {
|
||||
|
||||
Reference in New Issue
Block a user