moment-item.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <script lang="ts" setup>
  2. import Card from '@/components/card.vue'
  3. import dayjs from 'dayjs'
  4. import { beforeNow } from '../utils/date-util'
  5. import Tag from './tag.vue'
  6. import { stringify } from 'qs'
  7. import { isImageOrVideo } from '../core/utils/common'
  8. import { useRouter } from '../core/utils/router'
  9. import { likeActived, likeBlack } from '@designer-hub/assets/src/icons'
  10. import { NetImages } from '../core/libs/net-images'
  11. import { currRoute } from '../utils'
  12. import { usePermissions } from '../composables/permissions'
  13. import { useMemberLevelsStore } from '../store/member-levles'
  14. import { useDictStore } from '../store'
  15. import { DictType } from '../core/libs/models'
  16. import { CircleRes } from '../core/libs/requests'
  17. const props = withDefaults(
  18. defineProps<{
  19. options: CircleRes
  20. isOwn?: boolean
  21. isShared?: boolean
  22. }>(),
  23. {},
  24. )
  25. const emits = defineEmits<{
  26. delete: [id: number]
  27. like: [options: any]
  28. share: [options: CircleRes]
  29. }>()
  30. const router = useRouter()
  31. const { features, clickByPermission } = usePermissions()
  32. const memberLevelsStore = useMemberLevelsStore()
  33. const { getMemberLevelLogo, getMemberAvatarFrame } = memberLevelsStore
  34. const dictStore = useDictStore()
  35. const { getOptionLabel } = dictStore
  36. const imgClass = ref('')
  37. // const isVideo = ref(false)
  38. const isVideo = computed(
  39. () => props.options.bannerUrls?.length && isImageOrVideo(props.options.bannerUrls[0]) === 'video',
  40. )
  41. const toDetail = () => {
  42. uni.navigateTo({
  43. url: `/pages/home/moment/index?${stringify({ id: props.options.id })}${props.isShared ? '&isShared=true' : ''}`,
  44. })
  45. }
  46. const handleDelete = async () => {
  47. emits('delete', props.options.id)
  48. }
  49. onMounted(async () => {
  50. if (
  51. props.options.circleType === '1' &&
  52. props.options.bannerUrls?.length === 1 &&
  53. isImageOrVideo(props.options.bannerUrls[0]) === 'image'
  54. ) {
  55. const { width, height } = await uni.getImageInfo({
  56. src: props.options.bannerUrls[0],
  57. })
  58. if (Number(width / height) > 1) {
  59. imgClass.value = 'w-[60vw]'
  60. } else {
  61. imgClass.value = 'w-[44vw]'
  62. }
  63. }
  64. // if (
  65. // props.options.bannerUrls?.length === 1 &&
  66. // isImageOrVideo(props.options.bannerUrls[0]) === 'video'
  67. // ) {
  68. // isVideo.value = true
  69. // }
  70. })
  71. </script>
  72. <template>
  73. <div @click="toDetail">
  74. <Card>
  75. <view class="flex items-center gap-2">
  76. <view
  77. class="relative"
  78. @click.stop="
  79. features.toDesignerHomePage &&
  80. ['1', '2'].includes(options?.circleType) &&
  81. currRoute().path !== '/pages/mine/homepage/index' &&
  82. router.push(`/pages/mine/homepage/index?id=${options.stylistId}`)
  83. "
  84. >
  85. <wd-img
  86. custom-class="vertical-bottom"
  87. :width="35"
  88. :height="35"
  89. round
  90. :src="props.options.headUrl || NetImages.DefaultAvatar"
  91. mode="scaleToFill"
  92. />
  93. <wd-img
  94. v-if="getMemberAvatarFrame(options?.levelId)"
  95. custom-class="vertical-bottom absolute! top--1.25 left--1.25"
  96. :width="40"
  97. :height="40"
  98. :src="getMemberAvatarFrame(options?.levelId) || ''"
  99. ></wd-img>
  100. </view>
  101. <view class="">{{ props.options.stylistName || props.options.marketing }}</view>
  102. <template v-if="getMemberLevelLogo(options?.levelId)">
  103. <wd-img
  104. width="63"
  105. height="18.6"
  106. :src="getMemberLevelLogo(options?.levelId) || ''"
  107. ></wd-img>
  108. </template>
  109. <view class="flex-1"></view>
  110. <div class="text-black/40 text-sm font-medium font-['PingFang_SC'] leading-[10.18px]">
  111. {{ beforeNow(dayjs(props.options.createTime).toDate()) }}
  112. </div>
  113. </view>
  114. <div v-if="isVideo" class="aspect-[1.64/1] rounded-lg overflow-hidden my-6" @click.stop>
  115. <video class="w-full h-full" :src="options.bannerUrls[0]"></video>
  116. </div>
  117. <view v-if="!isVideo" class="my-6">
  118. <template v-if="options.circleType === '1'">
  119. <div
  120. :class="[
  121. props.options.bannerUrls?.length > 1 ? 'grid grid-cols-3 grid-gap-1' : 'w-full',
  122. '',
  123. ]"
  124. >
  125. <template v-for="it of props.options.bannerUrls" :key="it">
  126. <view
  127. :class="[
  128. props.options.bannerUrls?.length > 1 ? 'aspect-square' : '',
  129. 'rounded-lg overflow-hidden',
  130. imgClass,
  131. ]"
  132. >
  133. <wd-img
  134. custom-class="vertical-bottom"
  135. :width="'100%'"
  136. :src="it"
  137. :height="props.options.bannerUrls?.length > 1 ? '100%' : 'auto'"
  138. :mode="props.options.bannerUrls?.length > 1 ? 'aspectFill' : 'widthFix'"
  139. ></wd-img>
  140. </view>
  141. </template>
  142. </div>
  143. </template>
  144. <view class="aspect-[1.64/1] rounded-lg overflow-hidden" v-else>
  145. <wd-img
  146. custom-class="vertical-bottom"
  147. width="100%"
  148. height="100%"
  149. :src="options.bannerUrls[0]"
  150. mode="aspectFill"
  151. ></wd-img>
  152. </view>
  153. </view>
  154. <div
  155. v-if="options.circleType === '2'"
  156. class="text-black/90 text-xl font-normal font-['PingFang_SC']"
  157. >
  158. 设计案例:{{ options?.caseName }}
  159. </div>
  160. <view class="text-[rgba(0,0,0,0.85)] text-4 font-400 my-1 flex items-center">
  161. <template v-if="options.circleType === '2'">
  162. <!-- <span>-->
  163. <!-- {{ getOptionLabel(DictType.circleSpaceType, options.spaceType) }}-->
  164. <!-- </span>-->
  165. <!-- <div class="mx-2 h-3.5 w-[1.5px] bg-black/40"></div>-->
  166. <!-- <span>-->
  167. <!-- {{ getOptionLabel(DictType.memberDesignStyle, options.designStyle) }}-->
  168. <!-- </span>-->
  169. <!-- <div class="mx-2 h-3.5 w-[1.5px] bg-black/40"></div>-->
  170. <!-- <span>{{ options.caseName }}</span>-->
  171. <div class="w-full mt-4 flex items-center justify-between text-black/40 text-sm">
  172. <div class="font-normal font-['PingFang_SC']">
  173. 类别:{{ getOptionLabel(DictType.circleSpaceType, options?.spaceType) }}
  174. </div>
  175. |
  176. <div class="text-black/40 text-sm font-normal font-['PingFang_SC']">
  177. 风格:{{ getOptionLabel(DictType.memberDesignStyle, options.designStyle) }}
  178. </div>
  179. |
  180. <div class="text-black/40 text-sm font-normal font-['PingFang_SC']">
  181. 面积:{{ options.spaceExtent }}
  182. </div>
  183. </div>
  184. </template>
  185. <template v-else>{{ options.circleDesc }}</template>
  186. </view>
  187. <view v-if="props.options.tagName !== ''" class="my-5.5 flex flex-wrap gap-3.5">
  188. <template v-if="props.options.tagName !== ''">
  189. <template v-for="it of props.options.tagName?.split(',')" :key="it">
  190. <Tag>{{ it }}</Tag>
  191. </template>
  192. </template>
  193. </view>
  194. <view v-if="!isShared" class="flex justify-between">
  195. <div>
  196. <template v-if="features.shareMoment">
  197. <button
  198. open-type="share"
  199. class="bg-transparent! p-0!"
  200. :data-options="options"
  201. @click.stop
  202. >
  203. <view
  204. class="flex items-center text-[rgba(0,0,0,0.85)] text-3.5 font-400 line-height-5.5"
  205. >
  206. <wd-img width="15" height="15" src="/static/svgs/share.svg"></wd-img>
  207. <view class="ml-1">{{ props.options.shareCount }}</view>
  208. </view>
  209. </button>
  210. </template>
  211. <template v-else>
  212. <view
  213. @click.stop="clickByPermission('share', () => {})"
  214. class="flex items-center text-[rgba(0,0,0,0.85)] text-3.5 font-400 line-height-5.5"
  215. >
  216. <wd-img width="15" height="15" src="/static/svgs/share.svg"></wd-img>
  217. <view class="ml-1">{{ props.options.shareCount }}</view>
  218. </view>
  219. </template>
  220. </div>
  221. <view class="flex items-center text-[rgba(0,0,0,0.85)] text-3.5 font-400 line-height-5.5">
  222. <wd-img width="15" height="15" src="/static/svgs/comment.svg"></wd-img>
  223. <view class="ml-1">{{ props.options.reviewCount }}</view>
  224. </view>
  225. <view
  226. class="flex items-center text-3.5 font-400 line-height-5.5"
  227. :class="[options.ownUpvote ? 'text-[#ca5141]' : 'text-[rgba(0,0,0,0.85)]']"
  228. @click.stop="
  229. clickByPermission('thumbsUp', () =>
  230. emits('like', { upvote: options.ownUpvote, circleId: options.id }),
  231. )
  232. "
  233. >
  234. <template v-if="options.ownUpvote">
  235. <wd-img width="18" height="18" :src="likeActived"></wd-img>
  236. </template>
  237. <template v-else>
  238. <wd-img width="18" height="18" :src="likeBlack"></wd-img>
  239. </template>
  240. <view class="ml-1">{{ props.options.upvoteCount }}</view>
  241. </view>
  242. <div v-if="isOwn" @click.stop="handleDelete()">
  243. <wd-button type="text" size="small">
  244. <span class="text-black/30 text-xs font-normal font-['PingFang_SC']">
  245. 删除
  246. <wd-icon name="close" size="12"></wd-icon>
  247. </span>
  248. </wd-button>
  249. </div>
  250. </view>
  251. </Card>
  252. </div>
  253. </template>