index.vue 17 KB

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