Browse Source

refactor(mine): 优化设计师主页展示逻辑

- 调整页面加载顺序,先加载用户信息再加载设计师信息
- 修复未登录用户访问设计师主页的问题
- 优化设计师信息展示,包括头像、姓名等
- 更新浏览历史记录相关逻辑
EvilDragon 4 months ago
parent
commit
a451bca668

+ 78 - 76
packages/app/src/components/moment-item.vue

@@ -81,91 +81,93 @@ onMounted(async () => {
 })
 </script>
 <template>
-  <Card @click="toDetail" @tap="toDetail">
-    <view class="flex items-center">
-      <view
-        class="overflow-hidden rounded-full mr-2"
-        @click.stop="router.push(`/pages/mine/homepage/index?id=${options.stylistId}`)"
-      >
-        <wd-img
-          custom-class="vertical-bottom"
-          :width="35"
-          :height="35"
-          :src="props.options.headUrl || NetImages.DefaultAvatar"
-          mode="scaleToFill"
-        />
-      </view>
-      <view class="">{{ props.options.stylistName }}</view>
-      <view class="flex-1"></view>
-      <view>{{ beforeNow(dayjs(props.options.createTime).toDate()) }}</view>
-    </view>
-    <div v-if="isVideo" class="aspect-[1.64/1] rounded-lg overflow-hidden my-6" @click.stop>
-      <video class="w-full h-full" :src="options.bannerUrls[0]"></video>
-    </div>
-    <view
-      v-if="!isVideo"
-      :class="[
-        props.options.bannerUrls?.length > 1 ? 'grid grid-cols-3 grid-gap-1' : 'w-full',
-        'my-6',
-      ]"
-    >
-      <template v-for="it of props.options.bannerUrls" :key="it">
+  <div @click="toDetail">
+    <Card>
+      <view class="flex items-center">
         <view
-          :class="[
-            props.options.bannerUrls?.length > 1 ? 'aspect-square' : '',
-            'rounded-lg overflow-hidden',
-            imgClass,
-          ]"
+          class="overflow-hidden rounded-full mr-2"
+          @click.stop="router.push(`/pages/mine/homepage/index?id=${options.stylistId}`)"
         >
           <wd-img
             custom-class="vertical-bottom"
-            :width="'100%'"
-            :src="it"
-            :height="props.options.bannerUrls?.length > 1 ? '100%' : 'auto'"
-            :mode="props.options.bannerUrls?.length > 1 ? 'aspectFill' : 'widthFix'"
-          ></wd-img>
+            :width="35"
+            :height="35"
+            :src="props.options.headUrl || NetImages.DefaultAvatar"
+            mode="scaleToFill"
+          />
         </view>
-      </template>
-    </view>
-    <view class="text-[rgba(0,0,0,0.85)] text-4 font-400 my-1">
-      {{ props.options.circleDesc }}
-    </view>
-    <view class="my-5.5 flex flex-wrap gap-3.5">
-      <template v-if="props.options.tagName !== ''">
-        <template v-for="it of props.options.tagName?.split(',')" :key="it">
-          <Tag>{{ it }}</Tag>
-        </template>
-      </template>
-    </view>
-    <view class="flex justify-between">
-      <view class="flex items-center text-[rgba(0,0,0,0.85)] text-3.5 font-400 line-height-5.5">
-        <wd-img width="15" height="15" src="/static/svgs/share.svg"></wd-img>
-        <view class="ml-1">{{ props.options.shareCount }}</view>
-      </view>
-      <view class="flex items-center text-[rgba(0,0,0,0.85)] text-3.5 font-400 line-height-5.5">
-        <wd-img width="15" height="15" src="/static/svgs/comment.svg"></wd-img>
-        <view class="ml-1">{{ props.options.reviewCount }}</view>
+        <view class="">{{ props.options.stylistName }}</view>
+        <view class="flex-1"></view>
+        <view>{{ beforeNow(dayjs(props.options.createTime).toDate()) }}</view>
       </view>
+      <div v-if="isVideo" class="aspect-[1.64/1] rounded-lg overflow-hidden my-6" @click.stop>
+        <video class="w-full h-full" :src="options.bannerUrls[0]"></video>
+      </div>
       <view
-        class="flex items-center text-3.5 font-400 line-height-5.5"
-        :class="[options.ownUpvote ? 'text-[#ca5141]' : 'text-[rgba(0,0,0,0.85)]']"
+        v-if="!isVideo"
+        :class="[
+          props.options.bannerUrls?.length > 1 ? 'grid grid-cols-3 grid-gap-1' : 'w-full',
+          'my-6',
+        ]"
       >
-        <template v-if="options.ownUpvote">
-          <wd-img width="18" height="18" :src="likeActived"></wd-img>
+        <template v-for="it of props.options.bannerUrls" :key="it">
+          <view
+            :class="[
+              props.options.bannerUrls?.length > 1 ? 'aspect-square' : '',
+              'rounded-lg overflow-hidden',
+              imgClass,
+            ]"
+          >
+            <wd-img
+              custom-class="vertical-bottom"
+              :width="'100%'"
+              :src="it"
+              :height="props.options.bannerUrls?.length > 1 ? '100%' : 'auto'"
+              :mode="props.options.bannerUrls?.length > 1 ? 'aspectFill' : 'widthFix'"
+            ></wd-img>
+          </view>
         </template>
-        <template v-else>
-          <wd-img width="18" height="18" :src="likeBlack"></wd-img>
+      </view>
+      <view class="text-[rgba(0,0,0,0.85)] text-4 font-400 my-1">
+        {{ props.options.circleDesc }}
+      </view>
+      <view class="my-5.5 flex flex-wrap gap-3.5">
+        <template v-if="props.options.tagName !== ''">
+          <template v-for="it of props.options.tagName?.split(',')" :key="it">
+            <Tag>{{ it }}</Tag>
+          </template>
         </template>
-        <view class="ml-1">{{ props.options.upvoteCount }}</view>
       </view>
-      <div v-if="isOwn">
-        <wd-button type="text" size="small" @click.stop="handleDelete">
-          <span class="text-black/30 text-xs font-normal font-['PingFang_SC']">
-            删除
-            <wd-icon name="close" size="12"></wd-icon>
-          </span>
-        </wd-button>
-      </div>
-    </view>
-  </Card>
+      <view class="flex justify-between">
+        <view class="flex items-center text-[rgba(0,0,0,0.85)] text-3.5 font-400 line-height-5.5">
+          <wd-img width="15" height="15" src="/static/svgs/share.svg"></wd-img>
+          <view class="ml-1">{{ props.options.shareCount }}</view>
+        </view>
+        <view class="flex items-center text-[rgba(0,0,0,0.85)] text-3.5 font-400 line-height-5.5">
+          <wd-img width="15" height="15" src="/static/svgs/comment.svg"></wd-img>
+          <view class="ml-1">{{ props.options.reviewCount }}</view>
+        </view>
+        <view
+          class="flex items-center text-3.5 font-400 line-height-5.5"
+          :class="[options.ownUpvote ? 'text-[#ca5141]' : 'text-[rgba(0,0,0,0.85)]']"
+        >
+          <template v-if="options.ownUpvote">
+            <wd-img width="18" height="18" :src="likeActived"></wd-img>
+          </template>
+          <template v-else>
+            <wd-img width="18" height="18" :src="likeBlack"></wd-img>
+          </template>
+          <view class="ml-1">{{ props.options.upvoteCount }}</view>
+        </view>
+        <div v-if="isOwn" @click.stop="handleDelete()">
+          <wd-button type="text" size="small">
+            <span class="text-black/30 text-xs font-normal font-['PingFang_SC']">
+              删除
+              <wd-icon name="close" size="12"></wd-icon>
+            </span>
+          </wd-button>
+        </div>
+      </view>
+    </Card>
+  </div>
 </template>

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

@@ -679,6 +679,15 @@ export const reserveDesigner = (data: {
   appointmentPhone: string
 }) => httpPost<any>('/app-api/member/designer/reserveDesigner', data)
 /**
+ * 创建设计师主页浏览记录
+ */
+export const createBrowseHistory = (data: {
+  stylistId: number
+  bizId: string
+  bizType: string
+  duration: string
+}) => httpPost('/app-api/member/designer/browseHistory', data)
+/**
  * 通过ID获取用户信息
  */
 export const getUserInfoById = (id) =>

+ 7 - 5
packages/app/src/pages/mine/homepage/index.vue

@@ -67,10 +67,11 @@ onMounted(async () => {})
 onLoad(async (query: { id: string }) => {
   if (query.id) {
     id.value = query.id
-    await setMemberInfo()
   } else {
     id.value = userInfo.value.userId
+    // memberInfo.value =
   }
+  await setMemberInfo()
   await setDesignerInfo()
 })
 onShareAppMessage(() => ({ title: `${userInfo.value.nickname}` }))
@@ -97,12 +98,12 @@ defineExpose({
               <wd-img
                 width="100%"
                 height="100%"
-                :src="isOwn ? userInfo?.avatar : memberInfo?.avatar"
+                :src="isOwn ? userInfo?.avatar : memberInfo?.avatar || NetImages.DefaultAvatar"
               ></wd-img>
             </div>
             <div>
               <div class="text-white text-2xl font-normal font-['PingFang_SC'] leading-normal">
-                {{ designerInfo?.brokerName }}
+                {{ memberInfo.name }}
               </div>
               <div>
                 <div
@@ -111,7 +112,8 @@ defineExpose({
                   <div
                     class="text-center text-white text-[10px] font-normal font-['PingFang_SC'] leading-normal"
                   >
-                    创设空间事务所创始人
+                    <!-- 创设空间事务所创始人 -->
+                    {{ designerInfo.personalIdentity }}
                   </div>
                 </div>
               </div>
@@ -139,7 +141,7 @@ defineExpose({
         </template>
       </div>
       <div class="text-black/80 text-sm font-normal font-['PingFang_SC'] leading-normal">
-        {{ designerInfo?.personalIdentity }}
+        {{ designerInfo?.designDesc }}
       </div>
       <div>
         <wd-tabs v-model="tab" custom-class="bg-transparent!">