Browse Source

feat: 优化评论时间格式,调整轮播图样式,修复相关逻辑

EvilDragon 3 months ago
parent
commit
1364da86f2

+ 0 - 1
packages/app/src/core/libs/requests.ts

@@ -24,7 +24,6 @@ import {
   ActivitySignUp,
 } from './models'
 import dayjs from 'dayjs'
-import { log } from 'console'
 
 export const getUserInfo = () =>
   httpGetMock<any>({

+ 1 - 1
packages/app/src/pages/home/components/comment-item.vue

@@ -116,7 +116,7 @@ defineExpose({
         </div>
         <view class="flex items-center mt--4 gap-3">
           <div class="text-black/30 text-[10px] font-normal font-['PingFang_SC']">
-            {{ dayjs(options.reviewTime).format('YYYY/MM/DD') }}
+            {{ dayjs(options.reviewTime).format('YYYY-MM-DD HH:mm') }}
           </div>
           <view class="">
             <wd-button custom-class="text-2.5!" type="text" @click="handleReplay">回复</wd-button>

+ 20 - 10
packages/app/src/pages/home/moment/index.vue

@@ -30,6 +30,7 @@ import { useRouter } from '../../../core/utils/router'
 import { usePermissions } from '../../../composables/permissions'
 import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html.vue'
 import WdInput from 'wot-design-uni/components/wd-input/wd-input.vue'
+import { getRect, addUnit } from 'wot-design-uni/components/common/util'
 
 const { features } = usePermissions()
 const userStore = useUserStore()
@@ -62,9 +63,9 @@ const isVideo = ref(false)
 const reviewId = ref()
 const refreshIndex = ref<number>()
 const handleChange = ({ detail: { current } }) => {
-  swiperStyle.value = {
-    height: swiperSizes.value[current].height + 'px',
-  }
+  // swiperStyle.value = {
+  //   height: swiperSizes.value[current].height + 'px',
+  // }
 }
 const setSwiperStyle = async () => {
   if (!data.value.bannerUrls.length) return
@@ -73,12 +74,21 @@ const setSwiperStyle = async () => {
     isVideo.value = true
     return
   }
-  swiperSizes.value = (
-    await Promise.all(data.value.bannerUrls.map((src) => uni.getImageInfo({ src })))
-  ).map(({ width, height }) => ({ width: screenWidth, height: height / (width / screenWidth) }))
+
+  const { width, height } = await uni.getImageInfo({ src: data.value.bannerUrls.at(0) })
+  console.log(screenWidth / width)
+
   swiperStyle.value = {
-    height: swiperSizes.value[0].height + 'px',
+    height:
+      height > width
+        ? addUnit(500)
+        : addUnit(
+            screenWidth / width > 1
+              ? height / (screenWidth / width)
+              : height * (screenWidth / width),
+          ),
   }
+  console.log('swiperStyle', swiperStyle.value)
 }
 const handleSend = async () => {
   if (!reviewContent.value) {
@@ -132,8 +142,8 @@ onLoad(async (query: { id: string; isShared?: boolean }) => {
   id.value = query.id
   isShared.value = query.isShared
   await run()
-  await runGetReviews()
   await setSwiperStyle()
+  await runGetReviews()
   await setCircleUpvotes()
 })
 // onShareAppMessage(async () => {
@@ -176,12 +186,12 @@ onShareAppMessage(async ({ from, target }) => {
       {{ data?.detailsDesc }}
     </div> -->
     <template v-if="data.circleType === '1'">
-      <template v-if="swiperSizes && !isVideo">
+      <template v-if="!isVideo">
         <div>
           <swiper class="" :style="swiperStyle" @change="handleChange">
             <template v-for="it of data?.bannerUrls" :key="it">
               <swiper-item>
-                <wd-img width="100%" :src="it" mode="widthFix"></wd-img>
+                <wd-img width="100%" height="100%" :src="it" mode="aspectFill"></wd-img>
               </swiper-item>
             </template>
           </swiper>