index.vue 19 KB

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