index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. <route lang="json5">
  2. { layout: 'tabbar', style: { navigationBarTitleText: '我的', navigationStyle: 'custom' } }
  3. </route>
  4. <script setup lang="ts">
  5. import { onMounted, ref } from 'vue'
  6. import CardMenu from '@/components/card-menu.vue'
  7. import SectionHeading from '@/components/section-heading.vue'
  8. import { designer, settled, treaty, vipBg } from '../../core/libs/pngs'
  9. import { integral, coupon, order, agent, setting, vip, scan } from '../../core/libs/svgs'
  10. import {
  11. getDesignerInfo,
  12. getMemberUserInfo,
  13. getTasks,
  14. storeAndPunchIn,
  15. getAppMemberLevelConfigs,
  16. getCircleTaskStatus,
  17. getHonorStatistics,
  18. } from '../../core/libs/requests'
  19. import { useUserStore } from '../../store'
  20. import { storeToRefs } from 'pinia'
  21. import { isEmpty, set } from 'radash'
  22. import TasksCard from './components/tasks-card.vue'
  23. import { useRouter } from '../../core/utils/router'
  24. import { NetImages } from '../../core/libs/net-images'
  25. import { qrCodeString2Object, requestToast, toQrCodeString } from '../../core/utils/common'
  26. import { QrCodeBusinessType } from '../../core/libs/enums'
  27. import { usePermissions } from '../../composables/permissions'
  28. import { AnalysisEventType, useAnalysis } from '@/composables/analysis'
  29. const { option, report } = useAnalysis(false)
  30. const router = useRouter()
  31. const userStore = useUserStore()
  32. const { isLogined, userInfo } = storeToRefs(userStore)
  33. const { features, clickByPermission } = usePermissions()
  34. const { setUserInfo } = userStore
  35. const { data, run } = useRequest(getMemberUserInfo)
  36. const { data: taskData, run: getTaskData } = useRequest(() => getTasks({}), {
  37. initialData: { list: [] },
  38. })
  39. const { data: taskStatusData, run: setTaskStatus } = useRequest(
  40. async () => ({
  41. data: await Promise.all<any>([
  42. getCircleTaskStatus().then(({ data }) => ({
  43. completed: data,
  44. btnProps: {
  45. content: data ? '已完成' : '去发布',
  46. disabled: data,
  47. onClick: () => router.push('/pages/publish/moment/index?circleType=1'),
  48. },
  49. })),
  50. {
  51. btnProps: {
  52. content: '去打卡',
  53. onClick: () =>
  54. features.value.checkInAtStoreTask
  55. ? uni.showToast({ title: '请到店扫码完成', icon: 'none' })
  56. : router.push(`/pages/mine/authentication/index`),
  57. },
  58. },
  59. {
  60. btnProps: {
  61. content: '去邀请',
  62. onClick: () => router.push('/pages/mine/invite/index'),
  63. },
  64. },
  65. {
  66. btnProps: {
  67. content: '去关注',
  68. onClick: () => uni.showToast({ title: '敬请期待', icon: 'none' }),
  69. },
  70. },
  71. ]),
  72. code: 0,
  73. msg: '',
  74. }),
  75. { initialData: [] },
  76. )
  77. const { data: designerInfo, run: setDesignerInfo } = useRequest(
  78. () => getDesignerInfo(userInfo.value.userId),
  79. { initialData: {} },
  80. )
  81. const { data: levelConfigs, run: setLevelConfigs } = useRequest(() => getAppMemberLevelConfigs(), {
  82. initialData: [],
  83. })
  84. const { data: statistics, run: setStatistics } = useRequest(() => getHonorStatistics())
  85. const menus = ref([
  86. { title: '积分明细', icon: integral, path: '/pages/mine/points/index' },
  87. { title: '优惠券包', icon: coupon, path: '/pages/mine/coupons/index' },
  88. { title: '我的订单', icon: order, path: '/pages/mine/orders/index' },
  89. { title: '专属客服', icon: agent, path: '/pages/mine/agents/index' },
  90. { title: '个人设置', icon: setting, path: '/pages/mine/setting/index' },
  91. ])
  92. const levels = ref({
  93. 1: {
  94. color: '#3b5369',
  95. bgImg:
  96. 'https://image.zhuchaohui.com/zhucaohui/997de03a59d201c7b5dc124561925431abdc849cc7044ad4fb7c758bc12fafb2.png',
  97. },
  98. 2: {
  99. color: '#3b5369',
  100. bgImg:
  101. 'https://image.zhuchaohui.com/zhucaohui/77b6712b1cab7e769b630010be01eceec6cdd27f6947777b5a805e3cbf077db4.png',
  102. },
  103. 3: {
  104. color: '#3b5369',
  105. bgImg:
  106. 'https://image.zhuchaohui.com/zhucaohui/60811dfd5c5a4fa7502cfc2ff3db188849d4f9363849420ba72e32c03f20eca5.png',
  107. },
  108. 4: {
  109. color: '#65341d',
  110. bgImg:
  111. 'https://image.zhuchaohui.com/zhucaohui/236227e8094b50dafb21039c259b6fef9c9960a3347ae4286beddee23871e662.png',
  112. },
  113. })
  114. const pieces = ref([
  115. {
  116. title: '设计师成长计划',
  117. desc: '赋能设计共同成长',
  118. icon: designer,
  119. class: 'items-start! pb-0 pr-0',
  120. iconSize: 102,
  121. gridItemClass: 'col-start-1 row-start-1 row-end-3',
  122. path: '/pages/home/about/index',
  123. },
  124. {
  125. title: '材料商入驻',
  126. desc: '提供优质材料商',
  127. icon: settled,
  128. class: 'flex-row! pb-0 pr-0',
  129. iconSize: 68,
  130. gridItemClass: 'col-start-2 row-start-1',
  131. path: '/pages/material/settled-in/index',
  132. },
  133. {
  134. title: '筑巢荟公约',
  135. desc: '共同遵守平台公约',
  136. icon: treaty,
  137. class: 'col-start-2 row-start-2 flex-row! pb-0',
  138. iconSize: 44,
  139. gridItemClass: 'col-start-2 row-start-2',
  140. path: '/pages/mine/convention/index',
  141. },
  142. ])
  143. const avatar = computed(() =>
  144. !isEmpty(userInfo.value.avatar) ? userInfo.value.avatar : NetImages.DefaultAvatar,
  145. )
  146. const certificationStatusText = computed(() => {
  147. if (!userInfo.value.userStatusEnabled) return '未认证'
  148. if (userInfo.value.userStatusEnabled && userInfo.value.userAuthStatus === 1) return '审核中'
  149. if (userInfo.value.userStatusEnabled && userInfo.value.userAuthStatus === 2) return '已驳回'
  150. return '通过'
  151. })
  152. const certificationBtnText = computed(
  153. () => ({ 0: '通过', 1: '审核中', 2: '已驳回' })[userInfo.value.userAuthStatus] || '去认证',
  154. )
  155. const isCertified = computed(
  156. () => userInfo.value.userStatusEnabled && userInfo.value.userAuthStatus === 0,
  157. )
  158. const nickNameClickHandle = async () => {
  159. if (isLogined.value) return
  160. uni.navigateTo({ url: '/pages/login/index' })
  161. }
  162. const handleToAuthentication = () => {
  163. if (!isLogined.value) return router.push('/pages/login/index')
  164. router.push('/pages/mine/authentication/index')
  165. }
  166. const handleToHomepage = () => {
  167. uni.navigateTo({ url: `/pages/mine/homepage/index?id=${userInfo.value.userId}` })
  168. }
  169. const handleMenuClick = (path) => {
  170. path && router.push(path)
  171. }
  172. const handleClickScan = async () => {
  173. const { result } = await uni.scanCode({})
  174. console.log(result)
  175. // const a = qrCodeString2Object('WIFI:S:KM;T:WPA;P:km666888;H:false;;')
  176. // console.log(a)
  177. // console.log(toQrCodeString('到店', { a: 1, orderId: 2222 }))
  178. // console.log(qrCodeString2Object(toQrCodeString('到店', { a: 1, orderId: 2222 })))
  179. const { type, options } = qrCodeString2Object(result)
  180. if (type === QrCodeBusinessType.InStoreClockIn) {
  181. if (!features.value.checkInAtStoreTask) return router.push('/pages/mine/authentication/index')
  182. try {
  183. await storeAndPunchIn({ id: options.id })
  184. option.value = {
  185. remark: `最近到店品牌: ${options.name}`,
  186. }
  187. await report(AnalysisEventType.ViewPage)
  188. // await storeAndPunchIn({ id: 24 })
  189. await router.push(`/pages/mine/scan/result/index?result=${result}`)
  190. } catch (e) {
  191. if (e.code === 1000) {
  192. await router.push(
  193. `/pages/mine/scan/result/index?result=${toQrCodeString(type, { name: options.name, desc: e.msg })}`,
  194. )
  195. } else {
  196. await uni.showToast({ title: e.msg, icon: 'none' })
  197. }
  198. }
  199. return
  200. }
  201. if (type === QrCodeBusinessType.PagePath) {
  202. await router.push(options.path)
  203. return
  204. }
  205. await router.push(`/pages/mine/scan/result/index?result=${result}`)
  206. }
  207. const navBarProps = ref({ customClass: 'bg-transparent!' })
  208. onMounted(async () => {
  209. await setLevelConfigs()
  210. })
  211. onShow(async () => {
  212. if (isLogined.value) {
  213. await run()
  214. setUserInfo({
  215. ...userInfo.value,
  216. ...data.value,
  217. })
  218. await Promise.all([setDesignerInfo(), getTaskData(), setTaskStatus(), setStatistics()])
  219. console.log(taskStatusData.value)
  220. }
  221. })
  222. onPageScroll(({ scrollTop }: { scrollTop: number }) => {
  223. navBarProps.value.customClass = scrollTop === 0 ? 'bg-transparent!' : ''
  224. })
  225. </script>
  226. <template>
  227. <view>
  228. <wd-navbar
  229. fixed
  230. safeAreaInsetTop
  231. custom-class="bg-transparent!"
  232. :bordered="false"
  233. v-bind="navBarProps"
  234. >
  235. <template #left>
  236. <wd-button
  237. v-if="isLogined"
  238. type="text"
  239. size="small"
  240. custom-class="p-0!"
  241. :round="false"
  242. @click="clickByPermission('scan', () => handleClickScan())"
  243. >
  244. <wd-img width="25" height="25" :src="scan" custom-class="vertical-bottom"></wd-img>
  245. </wd-button>
  246. </template>
  247. </wd-navbar>
  248. <div
  249. class="bg-black/30 flex flex-col justify-end box-border bg-[url(https://image.zhuchaohui.com/zhucaohui/c706ec14a5a927c10e9e1fa0153affb11bbdd9255882e18c67ee82687ff9813a.png)] bg-[length:100%_auto]"
  250. :class="[isCertified ? 'aspect-[0.94/1] pb-44' : 'aspect-[1.15/1] pb-20']"
  251. >
  252. <div class="my-6.5 px-3.5 flex">
  253. <img class="w-[72px] h-[72px] rounded-full border border-white" :src="avatar" />
  254. <div class="ms-3.5 ml-3.5">
  255. <div class="flex items-center gap-1.25">
  256. <div
  257. class="text-white text-xl font-normal font-['PingFang_SC'] leading-normal"
  258. @click="nickNameClickHandle"
  259. >
  260. {{ !isLogined ? '请点击登录' : userInfo?.nickname }}
  261. </div>
  262. <div v-if="isCertified">
  263. <div class="w-[76px] h-6 relative" @click="router.push('/pages/mine/honors/index')">
  264. <div
  265. class="w-[76px] h-[18px] left-3 pl-1 top-[1.5px] absolute bg-[#4f4b42] rounded-[3px] border border-solid border-[#a89f89]"
  266. >
  267. <div
  268. class="text-center text-[#f2e3c4] text-xs font-normal font-['PingFang_SC'] leading-normal"
  269. >
  270. 荣誉徽章:{{ statistics?.badgeCount }}
  271. </div>
  272. </div>
  273. <wd-img width="23" height="23" :src="NetImages.HonorsLogo"></wd-img>
  274. </div>
  275. </div>
  276. </div>
  277. <div
  278. v-if="!isCertified"
  279. class="mt-2 w-[63px] h-[26px] bg-black/10 rounded-[20px] border border-white/60 flex items-center justify-center"
  280. >
  281. <div
  282. class="text-center text-white text-xs font-normal font-['PingFang_SC'] leading-normal"
  283. >
  284. <!-- 未认证 -->
  285. {{ certificationStatusText }}
  286. </div>
  287. </div>
  288. <div v-if="isCertified" class="flex items-center text-white" @click="handleToHomepage">
  289. <div
  290. class="text-center text-white text-sm font-normal font-['PingFang_SC'] leading-normal"
  291. >
  292. 个人主页
  293. </div>
  294. <wd-icon name="arrow-right"></wd-icon>
  295. </div>
  296. </div>
  297. </div>
  298. <div
  299. class="px-3.5 flex items-center"
  300. @click="router.push('/pages/mine/homepage/statistics/index')"
  301. >
  302. <div class="flex items-center">
  303. <div class="text-white text-base font-normal font-['PingFang_SC'] leading-normal mr-1">
  304. <!-- 0 -->
  305. {{ designerInfo?.shareCount || 0 }}
  306. </div>
  307. <div
  308. class="text-center text-[#e9e7e4] text-xs font-normal font-['PingFang_SC'] leading-normal"
  309. >
  310. 分享
  311. </div>
  312. </div>
  313. <div class="h-4 w-[2px] mx-4 bg-[#e9e7e4]"></div>
  314. <div class="flex items-center">
  315. <div class="text-white text-base font-normal font-['PingFang_SC'] leading-normal mr-1">
  316. <!-- 0 -->
  317. {{ designerInfo?.viewCount || 0 }}
  318. </div>
  319. <div
  320. class="text-center text-[#e9e7e4] text-xs font-normal font-['PingFang_SC'] leading-normal"
  321. >
  322. 浏览
  323. </div>
  324. </div>
  325. <div class="h-4 w-[2px] mx-4 bg-[#e9e7e4]"></div>
  326. <div class="flex items-center">
  327. <div class="text-white text-base font-normal font-['PingFang_SC'] leading-normal mr-1">
  328. <!-- 0 -->
  329. <!-- {{designerInfo.c}} -->
  330. {{ designerInfo?.winCustomerCount || 0 }}
  331. </div>
  332. <div
  333. class="text-center text-[#e9e7e4] text-xs font-normal font-['PingFang_SC'] leading-normal"
  334. >
  335. 获客
  336. </div>
  337. </div>
  338. </div>
  339. </div>
  340. <div class="relative top--18" v-if="!isCertified">
  341. <div class="mx-3.5 box-border absolute left-0 right-0 top-0">
  342. <wd-img :src="vipBg" width="100%" mode="widthFix"></wd-img>
  343. </div>
  344. <div class="mx-3.5 box-border absolute left-0 right-0 top-0 p-3.5">
  345. <div class="flex items-center">
  346. <wd-img custom-class="vertical-bottom" :src="vip" width="35" mode="widthFix"></wd-img>
  347. <div
  348. class="ml-2 text-center text-[#faeac6] text-sm font-normal font-['PingFang_SC'] leading-normal"
  349. >
  350. 查看会员等级权益
  351. </div>
  352. <div class="flex-1"></div>
  353. <div
  354. class="w-[83px] h-[29px] bg-gradient-to-l from-[#ffdab6] to-[#ffebd5] rounded-[30px] flex items-center justify-center"
  355. @click="handleToAuthentication()"
  356. >
  357. <div
  358. class="text-[#9e5934] text-[13px] font-normal font-['PingFang_SC'] leading-relaxed flex items-center gap-1"
  359. >
  360. <!-- 去认证 -->
  361. <!-- {{ !isCertified ? '去认证' : certificationStatusText }} -->
  362. {{ certificationBtnText }}
  363. <div
  364. class="w-3.5 h-3.5 bg-gradient-to-tl from-[#773b19] to-[#9e5a34] rounded-full flex items-center justify-center"
  365. >
  366. <wd-icon name="play" size="12" color="#ffead2"></wd-icon>
  367. </div>
  368. </div>
  369. </div>
  370. </div>
  371. </div>
  372. </div>
  373. <template v-else>
  374. <div @click="router.push('/pages/mine/levels/index')" class="relative top--36">
  375. <div
  376. class="mx-3.5 absolute left-0 right-0 top--4 aspect-[1.93/1] rounded-2.5 p-3.5 box-border bg-[length:100%]"
  377. :class="['text-[#8FB8DB]']"
  378. :style="{
  379. // backgroundImage: `url(${levels[userInfo.level?.level]?.bgImg})`,
  380. // color: levels[userInfo.level?.level]?.color,
  381. backgroundImage: `url(${userInfo.level?.icon})`,
  382. }"
  383. >
  384. <div class="flex items-center">
  385. <div class="flex-1"></div>
  386. <div
  387. class="bg-gradient-to-r from-[#333333] to-[#20201e] rounded-tl-[20px] rounded-bl-[20px] mr--3.5 px-2 mt-3"
  388. @click.stop="router.push('/pages/mine/levels/index')"
  389. >
  390. <div class="text-xs font-normal font-['PingFang_SC'] leading-relaxed color-[#f3f3f3]">
  391. 更多等级权益
  392. </div>
  393. </div>
  394. </div>
  395. <div class="flex items-end mt-10">
  396. <div>
  397. <span class="text-4xl font-normal font-['D-DIN_Exp'] mr-1">
  398. {{ userInfo.level?.point }}
  399. </span>
  400. <span class="text-center text-xs font-normal font-['PingFang_SC']">积分</span>
  401. </div>
  402. <div class="flex-1"></div>
  403. <div class="text-sm font-normal font-['PingFang_SC']">
  404. 会员号:{{ userInfo.level?.cardCode }}
  405. </div>
  406. </div>
  407. </div>
  408. </div>
  409. <!-- <div class="relative h-4 box-border bg-transparent rounded-b-[50%] z-1"></div> -->
  410. </template>
  411. <view
  412. class="relative bottom-4 py-1 px-3.5"
  413. :class="[
  414. userInfo.userStatusEnabled
  415. ? 'bg-[url(https://image.zhuchaohui.com/zhucaohui/f12b86304c84eec692f4c8f040a06c63fe7110359b8a4a1262b97b1eef6b605c.png)] bg-[length:100%]'
  416. : 'bg-neutral-100 rounded-t-2xl',
  417. ]"
  418. >
  419. <div class="flex justify-around my-6">
  420. <template v-for="({ title, icon, path }, i) in menus" :key="i">
  421. <div class="flex flex-col items-center" @click="handleMenuClick(path)">
  422. <div class="relative flex-col justify-start items-start inline-flex">
  423. <wd-img :src="icon" width="24" height="24" custom-class="vertical-bottom"></wd-img>
  424. </div>
  425. <div
  426. class="mt-2 text-black/90 text-[12.86px] font-normal font-['PingFang_SC'] leading-relaxed"
  427. >
  428. {{ title }}
  429. </div>
  430. </div>
  431. </template>
  432. </div>
  433. <TasksCard
  434. v-if="isLogined"
  435. custom-class="my-6"
  436. :items="
  437. taskData.list.map((it, i) => ({
  438. ...it,
  439. ...(taskStatusData[i] || {}),
  440. }))
  441. "
  442. ></TasksCard>
  443. <SectionHeading custom-class="my-6" title="和筑巢荟一起共同成长"></SectionHeading>
  444. <CardMenu :items="pieces" custom-class="grid-cols-2" />
  445. </view>
  446. </view>
  447. </template>
  448. <style scoped lang="scss">
  449. .uni-button:after {
  450. position: '' bsolute;
  451. top: 0;
  452. right: 0;
  453. bottom: 0;
  454. left: 0;
  455. content: '';
  456. background: #03f463;
  457. transform: skewX(15deg);
  458. }
  459. .aaaa {
  460. &::before {
  461. position: '' bsolute;
  462. top: 0;
  463. right: 0;
  464. bottom: 0;
  465. left: 0;
  466. content: '';
  467. background: #03f463;
  468. transform: skewX(15deg);
  469. }
  470. }
  471. </style>