scroe and importance allow nullable
This commit is contained in:
@ -23,6 +23,34 @@
|
||||
.section {
|
||||
margin-top: 48rpx;
|
||||
|
||||
.rate-cell {
|
||||
|
||||
&.decided {
|
||||
|
||||
.rate {
|
||||
display: block;
|
||||
gap: 16rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.text {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.undecided {
|
||||
|
||||
.rate {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.text {
|
||||
display: block;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
> .title {
|
||||
color: var(--theme-text-secondary);
|
||||
padding: 0 32rpx;
|
||||
@ -149,11 +177,11 @@
|
||||
display: flex;
|
||||
padding: 24rpx 16rpx 48rpx 16rpx;
|
||||
|
||||
.delete-btn {
|
||||
.delete {
|
||||
flex: .6;
|
||||
}
|
||||
|
||||
.submit-btn {
|
||||
.submit {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,8 +34,12 @@ interface TravelLocationEditorData {
|
||||
requireAppointment: boolean;
|
||||
/** 评分 */
|
||||
score: number;
|
||||
/** 评分是否未定 */
|
||||
scoreUndecided: boolean;
|
||||
/** 重要程度 */
|
||||
importance: number;
|
||||
/** 重要程度是否未定 */
|
||||
importanceUndecided: boolean;
|
||||
/** 媒体列表(创建和编辑模式使用) */
|
||||
mediaList: (MediaItem | WechatMediaItem)[];
|
||||
/** 新媒体列表(编辑模式使用) */
|
||||
@ -77,7 +81,9 @@ Page({
|
||||
requireIdCard: false,
|
||||
requireAppointment: false,
|
||||
score: 3,
|
||||
scoreUndecided: true,
|
||||
importance: 1,
|
||||
importanceUndecided: true,
|
||||
mediaList: [],
|
||||
newMediaList: [],
|
||||
isLoading: false,
|
||||
@ -167,6 +173,14 @@ Page({
|
||||
} as MediaItem;
|
||||
});
|
||||
|
||||
// 判断评分是否未定
|
||||
const scoreUndecided = location.score === null || location.score === undefined;
|
||||
const score = location.score !== null && location.score !== undefined ? location.score : 3;
|
||||
|
||||
// 判断重要程度是否未定
|
||||
const importanceUndecided = location.importance === null || location.importance === undefined;
|
||||
const importance = location.importance !== null && location.importance !== undefined ? location.importance : 1;
|
||||
|
||||
this.setData({
|
||||
type,
|
||||
locationTypeIndex: locationTypeIndex >= 0 ? locationTypeIndex : 0,
|
||||
@ -178,8 +192,10 @@ Page({
|
||||
amount: location.amount || 0,
|
||||
requireIdCard: location.requireIdCard || false,
|
||||
requireAppointment: location.requireAppointment || false,
|
||||
score: location.score !== undefined ? location.score : 3,
|
||||
importance: location.importance !== undefined ? location.importance : 1,
|
||||
score,
|
||||
scoreUndecided,
|
||||
importance,
|
||||
importanceUndecided,
|
||||
mediaList,
|
||||
isLoading: false
|
||||
});
|
||||
@ -225,6 +241,32 @@ Page({
|
||||
this.setData({ importance: e.detail.value });
|
||||
},
|
||||
|
||||
/** 清除评分 */
|
||||
clearScore() {
|
||||
this.setData({ scoreUndecided: true });
|
||||
},
|
||||
|
||||
/** 清除重要程度 */
|
||||
clearImportance() {
|
||||
this.setData({ importanceUndecided: true });
|
||||
},
|
||||
|
||||
/** 点击未定文字选择评分 */
|
||||
selectScore() {
|
||||
this.setData({
|
||||
scoreUndecided: false,
|
||||
score: 3
|
||||
});
|
||||
},
|
||||
|
||||
/** 点击未定文字选择重要程度 */
|
||||
selectImportance() {
|
||||
this.setData({
|
||||
importanceUndecided: false,
|
||||
importance: 1
|
||||
});
|
||||
},
|
||||
|
||||
/** 选择位置 */
|
||||
chooseLocation() {
|
||||
wx.chooseLocation({
|
||||
@ -483,8 +525,8 @@ Page({
|
||||
amount: this.data.amount,
|
||||
requireIdCard: this.data.requireIdCard,
|
||||
requireAppointment: this.data.requireAppointment,
|
||||
score: this.data.score,
|
||||
importance: this.data.importance,
|
||||
score: this.data.scoreUndecided ? null : this.data.score,
|
||||
importance: this.data.importanceUndecided ? null : this.data.importance,
|
||||
tempFileIds
|
||||
});
|
||||
wx.showToast({
|
||||
@ -539,8 +581,8 @@ Page({
|
||||
amount: this.data.amount,
|
||||
requireIdCard: this.data.requireIdCard,
|
||||
requireAppointment: this.data.requireAppointment,
|
||||
score: this.data.score,
|
||||
importance: this.data.importance,
|
||||
score: this.data.scoreUndecided ? null : this.data.score,
|
||||
importance: this.data.importanceUndecided ? null : this.data.importance,
|
||||
attachmentIds,
|
||||
tempFileIds
|
||||
});
|
||||
|
||||
@ -61,24 +61,46 @@
|
||||
<switch checked="{{requireAppointment}}" bindchange="onChangeRequireAppointment" />
|
||||
</view>
|
||||
</t-cell>
|
||||
<t-cell title="重要程度">
|
||||
<view slot="right-icon">
|
||||
<t-rate
|
||||
value="{{importance}}"
|
||||
count="{{5}}"
|
||||
size="24px"
|
||||
bind:change="onChangeImportance"
|
||||
/>
|
||||
<t-cell title="重要程度" class="rate-cell importance {{importanceUndecided ? 'undecided' : 'decided'}}">
|
||||
<view slot="note">
|
||||
<view class="rate">
|
||||
<t-rate
|
||||
value="{{importance}}"
|
||||
count="{{5}}"
|
||||
size="20px"
|
||||
bind:change="onChangeImportance"
|
||||
/>
|
||||
<t-icon
|
||||
name="close-circle-filled"
|
||||
size="20px"
|
||||
class="clear-icon"
|
||||
bindtap="clearImportance"
|
||||
/>
|
||||
</view>
|
||||
<view class="text" bindtap="selectImportance">
|
||||
未定
|
||||
</view>
|
||||
</view>
|
||||
</t-cell>
|
||||
<t-cell title="评分">
|
||||
<view slot="right-icon">
|
||||
<t-rate
|
||||
value="{{score}}"
|
||||
count="{{5}}"
|
||||
size="24px"
|
||||
bind:change="onChangeScore"
|
||||
/>
|
||||
<t-cell title="评分" class="rate-cell score {{scoreUndecided ? 'undecided' : 'decided'}}">
|
||||
<view slot="note">
|
||||
<view class="rate">
|
||||
<t-rate
|
||||
value="{{score}}"
|
||||
count="{{5}}"
|
||||
size="20px"
|
||||
bind:change="onChangeScore"
|
||||
/>
|
||||
<t-icon
|
||||
name="close-circle-filled"
|
||||
size="20px"
|
||||
class="clear-icon"
|
||||
bindtap="clearScore"
|
||||
/>
|
||||
</view>
|
||||
<view class="text" bindtap="selectScore">
|
||||
未定
|
||||
</view>
|
||||
</view>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
|
||||
Reference in New Issue
Block a user