index.vue 19 KB

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