index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501
  1. <route lang="json">
  2. {
  3. "style": {
  4. "navigationStyle": "custom"
  5. }
  6. }
  7. </route>
  8. <script setup lang="ts">
  9. import NavbarEvo from '@/components/navbar-evo.vue'
  10. import {
  11. activitySignup,
  12. getActivity,
  13. getActivitySignups,
  14. getAppMemberLevelConfigs,
  15. getStudyTour,
  16. getStudyTourSignups,
  17. studyTourSignup,
  18. } from '../../../../core/libs/requests'
  19. import { bell, map, rightFill } from '@designer-hub/assets/src/assets/svgs'
  20. import dayjs from 'dayjs'
  21. import BottomAppBar from '@/components/bottom-app-bar.vue'
  22. import { useRouter } from '../../../../core/utils/router'
  23. import PageHelper from '@/components/page-helper.vue'
  24. import { ConfigProviderThemeVars } from 'wot-design-uni'
  25. import SectionHeading from '@/components/section-heading.vue'
  26. import AvatarGroupCasual from '@/components/avatar-group-casual/avatar-group-casual.vue'
  27. import { calendar, clock, funnel, location, user } from '@designer-hub/assets/src/icons'
  28. import { signupSuccessDialogBg } from '@designer-hub/assets/src/bgs'
  29. import { NetImages } from '../../../../core/libs/net-images'
  30. import signupListDialogBg from '@designer-hub/assets/src/libs/assets/signupListDialogBg'
  31. import { getActivityStatusText, getCountsArr } from '../../../../core/utils/common'
  32. import { extractColorsFromImageData } from 'extract-colors/lib/extract-colors.mjs'
  33. import { sort } from 'radash'
  34. import { Activity, StudyTour } from '../../../../core/libs/models'
  35. import mapLocation from '@designer-hub/assets/src/libs/assets/mapLocation'
  36. import cameraWhite from '@designer-hub/assets/src/libs/assets/cameraWhite'
  37. import ButtonEvo from '@/components/button-evo.vue'
  38. import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html.vue'
  39. import { useActivity } from '../../../../composables/activity'
  40. import ImageEvo from '@/components/image-evo.vue'
  41. import TooltipEvo from '@/components/tooltip-evo.vue'
  42. import ActivityAsOf from '../../components/activity-as-of.vue'
  43. const themeVars = ref<ConfigProviderThemeVars>({
  44. tableBorderColor: 'white',
  45. tabsNavLineBgColor: 'white',
  46. tabsNavColor: 'white',
  47. })
  48. const router = useRouter()
  49. const id = ref()
  50. const type = ref<'activity' | 'studyTour'>()
  51. const activityTypes = ref({ activity: '活动', studyTour: '游学' })
  52. const tab = ref(0)
  53. const request = ref<() => Promise<IResData<Partial<StudyTour> | Partial<Activity>>>>()
  54. const { data, run: setData } = useRequest(() => request.value(), { initialData: {} })
  55. const { data: signups, run: setSignups } = useRequest(
  56. () => getActivitySignups({ activityId: id.value }),
  57. { initialData: { list: [], total: 0 } },
  58. )
  59. const { data: levels, run: setLevels } = useRequest(() => getAppMemberLevelConfigs(), {
  60. initialData: [],
  61. })
  62. const show = ref(false)
  63. const successShow = ref(false)
  64. const listShow = ref(false)
  65. const dominantColor = ref()
  66. const isActivity = computed(() => type.value === 'activity')
  67. const isStudyTour = computed(() => type.value === 'studyTour')
  68. const levelsById = computed(() =>
  69. levels.value.reduce((acc, item) => {
  70. acc[item.id] = item
  71. return acc
  72. }, {}),
  73. )
  74. const levelsByMemberLevel = computed(() =>
  75. levels.value.reduce((acc, item) => {
  76. acc[item.memberLevel] = item
  77. return acc
  78. }, {}),
  79. )
  80. const places = computed(() => {
  81. if (isActivity.value && data.value?.activityAllowType === '1') {
  82. return data.value?.activityAllowCount
  83. }
  84. if (isStudyTour.value && data.value?.studyAllowType === '1') {
  85. return data.value?.studyAllowCount
  86. }
  87. return '不限制'
  88. })
  89. const remainedCount = computed(() => {
  90. if (isActivity.value && data.value?.activityAllowType === '1') {
  91. return data.value?.activityAllowCount - signups.value.total
  92. }
  93. if (isStudyTour.value && data.value?.studyAllowType === '1') {
  94. return data.value?.studyAllowCount - signups.value.total
  95. }
  96. return '不限制'
  97. })
  98. const infos = computed(() => [
  99. {
  100. icon: clock,
  101. title: '报名时间',
  102. content: [
  103. dayjs(data.value.applyStartTime).format('YYYY.MM.DD HH:mm'),
  104. // dayjs(data.value.applyEndTime).format('YYYY.MM.DD'),
  105. ],
  106. visable: true,
  107. },
  108. {
  109. icon: calendar,
  110. title: `${activityTypes.value[type.value]}时间`,
  111. content: [
  112. dayjs(
  113. data.value.activityStartTime || data.value.studyStartTime || data.value.planStudyStartTime,
  114. ).format('YYYY.MM.DD'),
  115. dayjs(
  116. data.value.activityEndTime || data.value.studyEndTime || data.value.planStudyEndTime,
  117. ).format('YYYY.MM.DD'),
  118. ],
  119. visable: true,
  120. },
  121. {
  122. icon: location,
  123. title: `${activityTypes.value[type.value]}地点`,
  124. content: [data.value.activityAddr || ''],
  125. visable: isActivity.value,
  126. },
  127. {
  128. icon: user,
  129. title: `${activityTypes.value[type.value]}名额`,
  130. content: [
  131. places.value === '不限制' ? `不限制` : `${places.value}人/剩余${remainedCount.value}人`,
  132. ],
  133. visable: true,
  134. },
  135. {
  136. icon: funnel,
  137. title: `等级限制`,
  138. content: [
  139. data.value.memberLevel
  140. ?.map((it) => levelsByMemberLevel.value[String(it)]?.memberLevelName)
  141. .join('、') || '',
  142. ],
  143. visable: true,
  144. },
  145. ])
  146. const { status, statusText, difference, refresh } = useActivity(data.value)
  147. const handleConfirm = async () => {
  148. const { data, code, msg } = await (isActivity.value ? activitySignup : studyTourSignup)({
  149. id: id.value,
  150. })
  151. console.log(msg)
  152. if (code === 0) {
  153. // todo: 报名成功弹框
  154. show.value = false
  155. successShow.value = true
  156. }
  157. await setData()
  158. }
  159. onLoad(async (query: { id: string; type: 'activity' | 'studyTour' }) => {
  160. id.value = query.id
  161. type.value = query.type
  162. if (type.value === 'activity') {
  163. request.value = () => getActivity(id.value)
  164. }
  165. if (type.value === 'studyTour') {
  166. request.value = () => getStudyTour(id.value)
  167. }
  168. await setData()
  169. const { path } = await uni.getImageInfo({ src: data.value.backgroundUrl })
  170. const ctx = uni.createCanvasContext('firstCanvas')
  171. uni
  172. .createSelectorQuery()
  173. .select('#firstCanvas')
  174. .fields({ size: true }, async ({ width, height }: any) => {
  175. // ctx.setFillStyle('#ffffff')
  176. ctx.drawImage(path, 0, 0, width, height)
  177. ctx.draw(true, async () => {
  178. const res1 = await uni.canvasGetImageData({
  179. canvasId: 'firstCanvas',
  180. x: 0,
  181. y: 0,
  182. width: width.toFixed(0),
  183. height: height.toFixed(0),
  184. })
  185. const { data: imageData } = res1
  186. dominantColor.value = `rgb(${getCountsArr(imageData, width, height)})`
  187. console.log(res1)
  188. const a = await extractColorsFromImageData(res1, {
  189. pixels: 1000000,
  190. distance: 0.22,
  191. colorValidator: (red, green, blue, alpha = 255) => alpha > 250,
  192. saturationDistance: 0.2,
  193. lightnessDistance: 0.2,
  194. hueDistance: 0.083333333,
  195. })
  196. console.log(a)
  197. const colors = sort(a, (it: any) => it.intensity, true)
  198. dominantColor.value = a[0].hex
  199. })
  200. })
  201. .exec()
  202. await setSignups()
  203. await setLevels()
  204. })
  205. onShareAppMessage(() => ({ title: data.value.name, imageUrl: data.value.thumbnailUrl }))
  206. onShareTimeline(() => ({ title: data.value.name, imageUrl: data.value.thumbnailUrl }))
  207. </script>
  208. <template>
  209. <div
  210. class="flex-grow bg-white px-3.5 bg-[length:100%_100%]"
  211. :style="{
  212. backgroundColor: `${dominantColor}`,
  213. }"
  214. >
  215. <NavbarEvo transparent dark></NavbarEvo>
  216. <div class="aspect-[1.26/1] relative mx--3.5 relative">
  217. <!-- <wd-img width="100%" height="100%" :src="data.bannerUrl?.at(0)"></wd-img> -->
  218. <canvas
  219. class="w-full h-full absolute top--1000"
  220. canvas-id="firstCanvas"
  221. id="firstCanvas"
  222. ></canvas>
  223. <ImageEvo :src="data?.backgroundUrl"></ImageEvo>
  224. <!-- <wd-img width="100%" height="100%" :src="data?.backgroundUrl"></wd-img> -->
  225. <div class="absolute left-3.5 bottom-3" @click="listShow = true">
  226. <div
  227. v-if="isStudyTour"
  228. class="bg-white/20 rounded-[20px] backdrop-blur-[6px] px-3.5 py-1 flex gap-2.5"
  229. >
  230. <wd-img width="20" height="20" :src="bell"></wd-img>
  231. <div class="text-[#c1c1c1] text-base font-normal font-['PingFang_SC'] leading-normal">
  232. 白金会员王凯峰已报名
  233. </div>
  234. <div class="w-6 bg-black aspect-square rounded-full flex items-center justify-center">
  235. <wd-img width="18" height="18" :src="rightFill"></wd-img>
  236. </div>
  237. </div>
  238. <div v-if="isActivity" class="flex items-center gap-1.25">
  239. <AvatarGroupCasual
  240. :urls="signups.list.map((it) => it.headImgUrl || NetImages.DefaultAvatar)"
  241. :width="40"
  242. :height="40"
  243. ></AvatarGroupCasual>
  244. <div class="text-white/60 text-sm font-normal font-['PingFang_SC'] leading-[10.18px]">
  245. {{ signups.total }}人已报名
  246. </div>
  247. </div>
  248. </div>
  249. </div>
  250. <div class="h-9">
  251. <div v-if="type === 'studyTour'" class="flex items-center h-full mt-9 gap-1.5">
  252. <wd-img width="18" height="18" :src="map"></wd-img>
  253. <div class="text-[#c1c1c1] text-base font-normal font-['PingFang_SC'] leading-normal">
  254. 第一站
  255. </div>
  256. </div>
  257. </div>
  258. <div
  259. class="text-white text-[26px] font-normal font-['PingFang_SC'] leading-[44px] flex items-center gap-4"
  260. >
  261. <!-- 日本研学·东京艺术大学设计游学 -->
  262. <div class="inline-block">{{ data?.name }}</div>
  263. <div class="inline-block py-1.5 px-4 bg-white rounded-[20px] backdrop-blur-[15px]">
  264. <div class="text-[#a60707] text-sm font-normal font-['PingFang_SC'] leading-relaxed">
  265. <!-- {{ getActivityStatusText(data?.applyStartTime, data?.applyEndTime) }} -->
  266. {{ statusText }}
  267. </div>
  268. </div>
  269. </div>
  270. <div
  271. class="px-4 py-6 bg-[#010102]/30 backdrop-blur-[20px] rounded-2xl my-8 flex flex-col gap-3"
  272. >
  273. <!-- {{ levelsById }} -->
  274. <template v-for="(it, i) in infos" :key="i">
  275. <div v-if="it.visable" class="flex items-center gap-1.5">
  276. <wd-img width="16" height="16" :src="it.icon"></wd-img>
  277. <div
  278. class="w-17.5 whitespace-nowrap text-[#c1c1c1] text-base font-normal font-['PingFang_SC'] leading-normal"
  279. >
  280. {{ it.title }}
  281. </div>
  282. <div class="w-3"></div>
  283. <div
  284. class="flex-1 flex break-all items-center text-white text-base font-normal font-['PingFang_SC'] leading-[34px]"
  285. >
  286. <template v-if="it.content.length === 2">
  287. <div class="w-22 text-start">{{ it.content[0] }}</div>
  288. <wd-icon name="play" size="22px"></wd-icon>
  289. <div class="w-22 text-center">{{ it.content[0] }}</div>
  290. </template>
  291. <template v-else>{{ it.content[0] }}</template>
  292. </div>
  293. </div>
  294. </template>
  295. </div>
  296. <div v-if="isStudyTour" class="w-50%">
  297. <wd-config-provider :themeVars="themeVars">
  298. <wd-tabs v-model="tab" class="bg-transparent!" custom-class="bg-transparent!">
  299. <wd-tab title="活动介绍"></wd-tab>
  300. <wd-tab title="行程安排"></wd-tab>
  301. </wd-tabs>
  302. </wd-config-provider>
  303. </div>
  304. <SectionHeading v-if="isActivity" size="lg" title="活动介绍"></SectionHeading>
  305. <div class="mt-5 mx-3.5">
  306. <!-- v-html="data['activityDesc'] || data['studyDesc']" -->
  307. <div
  308. v-if="tab === 0"
  309. class="text-justify text-[#c1c1c1] text-base font-normal font-['PingFang_SC'] leading-relaxed"
  310. >
  311. <!-- <u-parse :content="data['activityDesc'] || data['studyDesc']"></u-parse> -->
  312. <mpHtml :content="data['activityDesc'] || data['studyDesc']"></mpHtml>
  313. </div>
  314. <div v-if="tab === 1 && 'studyTravelList' in data">
  315. <template v-for="(it, i) in data.studyTravelList" :key="i">
  316. <div class="flex flex-col gap-6">
  317. <div class="text-white text-base font-normal font-['PingFang_SC'] leading-normal">
  318. <!-- 6月26日 第一天 -->
  319. {{ dayjs(it?.travelTime).format('MM月DD日') }}
  320. <span class="ml-1">{{ `第${i + 1}天` }}</span>
  321. </div>
  322. <div class="flex gap-2">
  323. <div class="w-7 h-7 bg-white/10 rounded-full flex items-center justify-center">
  324. <wd-img width="82%" height="82%" :src="mapLocation"></wd-img>
  325. </div>
  326. <div class="flex-1 flex flex-col gap-4">
  327. <div class="h-7 flex items-center gap-2.5">
  328. <div class="text-white text-sm font-normal font-['PingFang_SC'] leading-normal">
  329. 9:00
  330. </div>
  331. <div class="text-white text-sm font-normal font-['PingFang_SC'] leading-normal">
  332. <!-- 早稻田大学课程 -->
  333. {{ it.title }}
  334. </div>
  335. </div>
  336. <div class="">
  337. <span
  338. class="text-[#c1c1c1] text-sm font-normal font-['PingFang_SC'] leading-[23px]"
  339. >
  340. 行程介绍:
  341. </span>
  342. <span
  343. class="text-[#ababab] text-sm font-normal font-['PingFang_SC'] leading-[23px]"
  344. >
  345. <!-- 是位于日本东京都新宿区的一所著名的私立大学。它由早稻田大学的创始人大隈重信于1882年创立,是日本超级国际化大学计划(Top
  346. Global University Project)选定的大学之一,也是日本顶尖的高等教育机构之一。 -->
  347. {{ it.travelDesc }}
  348. </span>
  349. </div>
  350. <div class="flex items-center gap-1">
  351. <wd-img width="16" height="16" :src="cameraWhite"></wd-img>
  352. <div class="text-white text-xs font-normal font-['PingFang_SC'] leading-normal">
  353. 打卡示例
  354. </div>
  355. </div>
  356. <img class="w-full rounded-2xl border" :src="it.clockExplainUrl" />
  357. </div>
  358. </div>
  359. </div>
  360. </template>
  361. </div>
  362. </div>
  363. <BottomAppBar fixed placeholder transparent>
  364. <div
  365. class="h-[63px] bg-white/90 rounded-2xl backdrop-blur-[20px] flex items-center gap-1 px-4 box-border"
  366. >
  367. <div class="text-[#ef4343] text-2xl font-normal font-['D-DIN_Exp'] leading-normal">
  368. {{ data.needPointsCount || 0 }}
  369. </div>
  370. <div class="text-black/40 text-base font-normal font-['PingFang_SC'] leading-[34px]">
  371. 积分
  372. </div>
  373. <div class="flex-1"></div>
  374. <div>
  375. <div class="relative">
  376. <div class="absolute bottom-3 left-0 right-0 flex flex-col justify-center items-center">
  377. <div class="bg-[#3b3c46] rounded-[60px] flex items-center py-1.5 px-4">
  378. <ActivityAsOf
  379. :start-at="data?.applyStartTime || data?.planApplyStartTime"
  380. :end-at="data?.applyEndTime || data?.planApplyEndTime"
  381. @end="refresh"
  382. ></ActivityAsOf>
  383. </div>
  384. </div>
  385. </div>
  386. <TooltipEvo
  387. placement="top"
  388. :content="`还差${difference}积分`"
  389. :model-value="status === 'runing' && difference > 0"
  390. >
  391. <div @click="show = true">
  392. <ButtonEvo>{{ data?.ifSingnUp ? '已报名' : '立即报名' }}</ButtonEvo>
  393. </div>
  394. </TooltipEvo>
  395. </div>
  396. </div>
  397. </BottomAppBar>
  398. <wd-action-sheet v-model="show">
  399. <view class="px-3.5 py-10">
  400. <div class="flex gap-5 mb-13.5">
  401. <div class="w-[110px] h-[94px] bg-[#f6f6f6] rounded-2xl">
  402. <wd-img width="100%" height="100%" :src="data.thumbnailUrl"></wd-img>
  403. </div>
  404. <div class="flex flex-col justify-between flex-1">
  405. <div class="text-black text-base font-normal font-['PingFang_SC'] leading-normal">
  406. {{ data.name }}
  407. </div>
  408. <div class="flex items-end gap-1">
  409. <div class="text-[#ef4343] text-[22px] font-normal leading-[22px]">
  410. {{ data.needPointsCount || 0 }}
  411. </div>
  412. <div class="text-black/40 text-sm font-normal font-['PingFang_SC']">积分</div>
  413. <div class="ml-1 text-black/40 text-xs font-normal font-['PingFang_SC']">
  414. 剩余:{{ remainedCount || 0 }}
  415. </div>
  416. <div class="flex-1"></div>
  417. </div>
  418. </div>
  419. </div>
  420. <wd-button block :round="false" @click="handleConfirm">确认报名</wd-button>
  421. </view>
  422. </wd-action-sheet>
  423. <wd-overlay :show="listShow" @click="listShow = false">
  424. <view class="flex px-10 h-full items-center justify-center">
  425. <div class="w-full flex flex-col gap-5 aspect-[0.71/1] relative">
  426. <div class="absolute top-0 left-0 right-0 bottom-0 z--1">
  427. <wd-img width="100%" height="100%" :src="signupListDialogBg"></wd-img>
  428. </div>
  429. <div class="h-full box-border py-5 px-7.25 flex flex-col justify-between">
  430. <div class="flex justify-between">
  431. <div class="text-justify text-white text-2xl font-bold font-['Alimama_ShuHeiTi']">
  432. 报名详情
  433. </div>
  434. </div>
  435. <div class="flex flex-col justify-center aspect-[0.7/1] gap-5 p-6.5">
  436. <PageHelper
  437. :request="isActivity ? getActivitySignups : getStudyTourSignups"
  438. :query="isActivity ? { activityId: id } : { studyId: id }"
  439. class="flex-grow flex flex-col"
  440. >
  441. <template #default="{ source }">
  442. <div class="flex flex-col gap-5">
  443. <template v-for="(it, i) in source.list" :key="i">
  444. <div
  445. class="text-black text-sm font-normal font-['PingFang_SC'] leading-normal"
  446. >
  447. {{ dayjs(it.createTime).format('YYYY-MM-DD') }} {{ it.name }}已报名
  448. </div>
  449. </template>
  450. </div>
  451. </template>
  452. </PageHelper>
  453. </div>
  454. </div>
  455. </div>
  456. </view>
  457. </wd-overlay>
  458. <wd-overlay :show="successShow" @click="successShow = false">
  459. <view class="flex mx-10 h-full items-center justify-center">
  460. <div class="w-full flex flex-col gap-5 aspect-[1.12/1] relative">
  461. <div class="absolute top-0 left-0 right-0 bottom-0 z--1">
  462. <wd-img width="100%" height="100%" :src="signupSuccessDialogBg"></wd-img>
  463. </div>
  464. <div class="h-full box-border py-5 px-7.25 flex flex-col justify-between">
  465. <div class="flex justify-between">
  466. <div class="text-justify text-white text-2xl font-bold font-['Alimama_ShuHeiTi']">
  467. 报名成功
  468. </div>
  469. <wd-icon name="close" color="white" size="22px"></wd-icon>
  470. </div>
  471. <div class="flex flex-col justify-center aspect-[1.46/1] gap-5">
  472. <div class="flex gap-1.5">
  473. <wd-icon name="error-circle" size="22px"></wd-icon>
  474. <div
  475. class="w-[151px] h-[21px] text-justify text-black text-base font-normal font-['PingFang_SC'] leading-[21px]"
  476. >
  477. 请准时参加活动!
  478. </div>
  479. </div>
  480. <div
  481. class="w-[237px] h-[60px] text-justify text-black/60 text-base font-normal font-['PingFang_SC'] leading-normal"
  482. >
  483. 如有问题可咨询官方客服或您的专属经纪人!
  484. </div>
  485. </div>
  486. </div>
  487. </div>
  488. </view>
  489. </wd-overlay>
  490. </div>
  491. </template>
  492. <style lang="scss"></style>