add upload permission
This commit is contained in:
@ -5,6 +5,7 @@ import { TravelApi } from "../../../../api/TravelApi";
|
||||
import { TravelLocationApi } from "../../../../api/TravelLocationApi";
|
||||
import config from "../../../../config/index";
|
||||
import { Travel, TravelStatusLabel, TravelStatusIcon, TransportationTypeLabel, TravelLocation, TravelLocationTypeLabel, TravelLocationTypeIcon, TransportationTypeIcon, TravelLocationType } from "../../../../types/Travel";
|
||||
import Permission from "../../../../utils/Permission";
|
||||
|
||||
interface TravelLocationView extends TravelLocation {
|
||||
/** 预览图 */
|
||||
@ -42,6 +43,8 @@ interface TravelDetailData {
|
||||
deleteDialogVisible: boolean;
|
||||
/** 删除确认文本 */
|
||||
deleteConfirmText: string;
|
||||
/** 是否允许上传 */
|
||||
canUpload: boolean;
|
||||
}
|
||||
|
||||
Page({
|
||||
@ -60,7 +63,8 @@ Page({
|
||||
locationTypes: ["全部", ...Object.values(TravelLocationTypeLabel)],
|
||||
selectedLocationTypeIndex: 0,
|
||||
deleteDialogVisible: false,
|
||||
deleteConfirmText: ""
|
||||
deleteConfirmText: "",
|
||||
canUpload: false
|
||||
},
|
||||
|
||||
onLoad(options: any) {
|
||||
@ -79,10 +83,17 @@ Page({
|
||||
}
|
||||
},
|
||||
|
||||
onShow() {
|
||||
async onShow() {
|
||||
const cached = Permission.getCachedUploadPermission();
|
||||
if (cached !== null) {
|
||||
this.setData({ canUpload: cached });
|
||||
} else {
|
||||
const canUpload = await Permission.checkAndCacheUploadPermission();
|
||||
this.setData({ canUpload });
|
||||
}
|
||||
// 页面显示时刷新地点列表(从编辑页返回时)
|
||||
if (this.data.travelId && !this.data.isLoading) {
|
||||
this.fetchLocations(this.data.travelId);
|
||||
await this.fetchLocations(this.data.travelId);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<!--pages/main/travel/detail/index.wxml-->
|
||||
<view class="custom-navbar">
|
||||
<t-navbar title="出行详情" leftArrow placeholder bind:go-back="goBack">
|
||||
<view slot="right" class="edit-btn" bind:tap="toEdit">
|
||||
<view wx:if="{{canUpload}}" slot="right" class="edit-btn" bind:tap="toEdit">
|
||||
<t-icon name="edit" size="24px" />
|
||||
</view>
|
||||
</t-navbar>
|
||||
@ -61,7 +61,14 @@
|
||||
</view>
|
||||
</picker>
|
||||
</view>
|
||||
<t-icon slot="right-icon" name="add" size="20px" color="var(--theme-wx)" bind:tap="toAddLocation" />
|
||||
<t-icon
|
||||
wx:if="{{canUpload}}"
|
||||
slot="right-icon"
|
||||
name="add"
|
||||
size="20px"
|
||||
color="var(--theme-wx)"
|
||||
bind:tap="toAddLocation"
|
||||
/>
|
||||
</t-cell>
|
||||
<t-cell wx:if="{{isLoadingLocations}}" class="loading">
|
||||
<t-loading slot="title" theme="dots" size="40rpx" />
|
||||
@ -117,6 +124,7 @@
|
||||
<!-- 操作按钮 -->
|
||||
<view class="section action">
|
||||
<t-button
|
||||
wx:if="{{canUpload}}"
|
||||
theme="danger"
|
||||
variant="outline"
|
||||
size="large"
|
||||
@ -127,6 +135,7 @@
|
||||
删除
|
||||
</t-button>
|
||||
<t-button
|
||||
wx:if="{{canUpload}}"
|
||||
theme="primary"
|
||||
size="large"
|
||||
icon="edit"
|
||||
|
||||
Reference in New Issue
Block a user