修复移动端bug

This commit is contained in:
2026-04-24 21:53:41 +08:00
parent ef6eb2aa6a
commit 3895ff7848
7 changed files with 809 additions and 7 deletions
+17 -4
View File
@@ -100,7 +100,7 @@
<text class="timeline-user">by {{ getUsernameById(commit.userId) }}</text>
<text class="timeline-comment" v-if="commit.comment">{{ commit.comment }}</text>
<view class="timeline-photos" v-if="commit.photos && commit.photos.length">
<image v-for="hash in commit.photos" :key="hash" class="timeline-photo" :src="getImageUrl(hash)" mode="aspectFill" @click="previewImages(hash)" />
<image v-for="(hash, idx) in commit.photos" :key="hash" class="timeline-photo" :src="getImageUrl(hash)" mode="aspectFill" @click="previewCommitImages(commit.photos, idx)" />
</view>
</view>
</view>
@@ -154,7 +154,7 @@ import { purchaseApi } from '@/api/purchase.js'
import { useConfigStore } from '@/stores/config.js'
import { fetchUserInfo, getUsername } from '@/stores/users.js'
import { api } from '@/api/index.js'
import { onLoad } from '@dcloudio/uni-app'
import { onLoad, onShow } from '@dcloudio/uni-app'
const configStore = useConfigStore()
@@ -222,11 +222,17 @@ function getImageUrl(sha256) {
}
function previewImages(currentSha) {
const urls = photos.value.map(p => getImageUrl(p.Sha256))
const idx = photos.value.findIndex(p => p.Sha256 === currentSha)
const allPhotos = photos.value || []
const urls = allPhotos.map(p => getImageUrl(p.Sha256))
const idx = allPhotos.findIndex(p => p.Sha256 === currentSha)
uni.previewImage({ urls, current: idx >= 0 ? idx : 0 })
}
function previewCommitImages(photoHashes, currentIndex) {
const urls = photoHashes.map(h => getImageUrl(h))
uni.previewImage({ urls, current: currentIndex })
}
function getUsernameById(userId) {
return getUsername(userId) || `用户${userId}`
}
@@ -348,6 +354,13 @@ onLoad((options) => {
fetchOrderDetail()
}
})
// 每次页面显示时刷新数据
onShow(() => {
if (orderId.value) {
fetchOrderDetail()
}
})
</script>
<style scoped>