index.vue 15 KB

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