add upload permission
This commit is contained in:
@ -3,6 +3,7 @@
|
||||
import Time from "../../../../utils/Time";
|
||||
import { TravelApi } from "../../../../api/TravelApi";
|
||||
import { Travel, TravelPage, TravelStatus, TravelStatusLabel, TravelStatusIcon, TransportationTypeLabel, TransportationTypeIcon } from "../../../../types/Travel";
|
||||
import Permission from "../../../../utils/Permission";
|
||||
|
||||
interface TravelData {
|
||||
/** 分页参数 */
|
||||
@ -28,6 +29,8 @@ interface TravelData {
|
||||
transportLabels: typeof TransportationTypeLabel;
|
||||
/** 交通类型图标映射 */
|
||||
transportIcons: typeof TransportationTypeIcon;
|
||||
/** 是否允许上传 */
|
||||
canUpload: boolean;
|
||||
}
|
||||
|
||||
Page({
|
||||
@ -46,12 +49,20 @@ Page({
|
||||
statusLabels: TravelStatusLabel,
|
||||
statusIcons: TravelStatusIcon,
|
||||
transportLabels: TransportationTypeLabel,
|
||||
transportIcons: TransportationTypeIcon
|
||||
transportIcons: TransportationTypeIcon,
|
||||
canUpload: false
|
||||
},
|
||||
onLoad() {
|
||||
this.resetAndFetch();
|
||||
},
|
||||
onShow() {
|
||||
async onShow() {
|
||||
const cached = Permission.getCachedUploadPermission();
|
||||
if (cached !== null) {
|
||||
this.setData({ canUpload: cached });
|
||||
} else {
|
||||
const canUpload = await Permission.checkAndCacheUploadPermission();
|
||||
this.setData({ canUpload });
|
||||
}
|
||||
// 页面显示时刷新数据(从编辑页返回时)
|
||||
if (0 < this.data.list.length) {
|
||||
this.resetAndFetch();
|
||||
|
||||
@ -96,6 +96,6 @@
|
||||
<view wx:if="{{isFinished && 0 < list.length}}" class="finished">没有更多了</view>
|
||||
</view>
|
||||
<!-- 新建按钮 -->
|
||||
<view class="fab" bind:tap="toCreate">
|
||||
<view wx:if="{{canUpload}}" class="fab" bind:tap="toCreate">
|
||||
<t-icon name="add" size="24px" color="#fff" />
|
||||
</view>
|
||||
|
||||
Reference in New Issue
Block a user