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({
|
||||
|
||||
@ -3,12 +3,12 @@
|
||||
<t-navbar class="custom-navbar" title="瞬间" placeholder />
|
||||
</view>
|
||||
<view class="moment">
|
||||
<view class="tips">
|
||||
<view wx:if="{{canUpload}}" class="tips">
|
||||
<text>由于微信限制,一次只能上传 20 张照片或视频,可以先在此页面分批次将所有照片或视频上传,</text>
|
||||
<text style="color: #F30">记得勾选原图</text>
|
||||
<text>。无需担心重复选择,已上传的文件不会再次上传。上传后有空再挑选归档,归档后此页面不再显示该照片或视频。</text>
|
||||
</view>
|
||||
<view class="action">
|
||||
<view wx:if="{{canUpload}}" class="action">
|
||||
<view class="line">
|
||||
<t-button
|
||||
class="btn upload"
|
||||
@ -49,7 +49,7 @@
|
||||
>删除已选</t-button>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:if="{{isUploading}}" class="uploading">
|
||||
<view wx:if="{{canUpload && isUploading}}" class="uploading">
|
||||
<progress
|
||||
class="progress"
|
||||
percent="{{uploadProgress}}"
|
||||
@ -81,6 +81,7 @@
|
||||
</view>
|
||||
</view>
|
||||
<t-popup
|
||||
wx:if="{{canUpload}}"
|
||||
class="archive-popup"
|
||||
visible="{{isVisibleArchivePopup}}"
|
||||
placement="bottom"
|
||||
@ -190,4 +191,4 @@
|
||||
/>
|
||||
</view>
|
||||
</view>
|
||||
</t-popup>
|
||||
</t-popup>
|
||||
|
||||
Reference in New Issue
Block a user