index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  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 { getDesignerInfo, getMemberUserInfo, getTasks } from '../../core/libs/requests'
  11. import { useUserStore } from '../../store'
  12. import { storeToRefs } from 'pinia'
  13. import { isEmpty } from 'radash'
  14. import TasksCard from './components/tasks-card.vue'
  15. import { useRouter } from '../../core/utils/router'
  16. import { NetImages } from '../../core/libs/net-images'
  17. const router = useRouter()
  18. const userStore = useUserStore()
  19. const { isLogined, userInfo } = storeToRefs(userStore)
  20. const { setUserInfo } = userStore
  21. const { data, run } = useRequest(getMemberUserInfo)
  22. const { data: taskData, run: getTaskData } = useRequest(() => getTasks({}), {
  23. initialData: { list: [] },
  24. })
  25. const { data: designerInfo, run: setDesignerInfo } = useRequest(
  26. () => getDesignerInfo(userInfo.value.userId),
  27. { initialData: {} },
  28. )
  29. const menus = ref([
  30. { title: '积分明细', icon: integral, path: '/pages/mine/points/index' },
  31. { title: '优惠券包', icon: coupon, path: '/pages/mine/coupons/index' },
  32. { title: '我的订单', icon: order, path: '/pages/mine/orders/index' },
  33. { title: '专属客服', icon: agent, path: '/pages/mine/agents/index' },
  34. { title: '个人设置', icon: setting, path: '/pages/mine/setting/index' },
  35. ])
  36. const levels = ref({
  37. 1: {
  38. color: '#3b5369',
  39. bgImg:
  40. 'https://image.zhuchaohui.com/zhucaohui/997de03a59d201c7b5dc124561925431abdc849cc7044ad4fb7c758bc12fafb2.png',
  41. },
  42. 2: {
  43. color: '#3b5369',
  44. bgImg:
  45. 'https://image.zhuchaohui.com/zhucaohui/77b6712b1cab7e769b630010be01eceec6cdd27f6947777b5a805e3cbf077db4.png',
  46. },
  47. 3: {
  48. color: '#3b5369',
  49. bgImg:
  50. 'https://image.zhuchaohui.com/zhucaohui/60811dfd5c5a4fa7502cfc2ff3db188849d4f9363849420ba72e32c03f20eca5.png',
  51. },
  52. })
  53. const pieces = ref([
  54. {
  55. title: '设计师成长计划',
  56. desc: '赋能设计共同成长',
  57. icon: designer,
  58. class: 'items-start! pb-0 pr-0',
  59. iconSize: 102,
  60. gridItemClass: 'col-start-1 row-start-1 row-end-3',
  61. },
  62. {
  63. title: '材料商入驻',
  64. desc: '提供优质材料商',
  65. icon: settled,
  66. class: 'flex-row! pb-0 pr-0',
  67. iconSize: 68,
  68. gridItemClass: 'col-start-2 row-start-1',
  69. path: '/pages/material/settled-in/index',
  70. },
  71. {
  72. title: '筑巢荟公约',
  73. desc: '共同遵守平台公约',
  74. icon: treaty,
  75. class: 'col-start-2 row-start-2 flex-row! pb-0',
  76. iconSize: 44,
  77. gridItemClass: 'col-start-2 row-start-2',
  78. path: '/pages/mine/convention/index',
  79. },
  80. ])
  81. const avatar = computed(() =>
  82. !isEmpty(userInfo.value.avatar) ? userInfo.value.avatar : NetImages.DefaultAvatar,
  83. )
  84. const certificationStatusText = computed(() => {
  85. if (!userInfo.value.userStatusEnabled) return '未认证'
  86. if (userInfo.value.userStatusEnabled && userInfo.value.userAuthStatus === 1) return '审核中'
  87. if (userInfo.value.userStatusEnabled && userInfo.value.userAuthStatus === 2) return '已驳回'
  88. return '通过'
  89. })
  90. const certificationBtnText = computed(
  91. () => ({ 0: '通过', 1: '审核中', 2: '已驳回' })[userInfo.value.userAuthStatus] || '去认证',
  92. )
  93. const isCertified = computed(
  94. () => userInfo.value.userStatusEnabled && userInfo.value.userAuthStatus === 0,
  95. )
  96. const nickNameClickHandle = async () => {
  97. if (isLogined.value) return
  98. uni.navigateTo({ url: '/pages/login/index' })
  99. }
  100. onShow(async () => {
  101. if (isLogined.value) {
  102. await run()
  103. setUserInfo({
  104. ...userInfo.value,
  105. ...data.value,
  106. })
  107. await setDesignerInfo()
  108. await getTaskData()
  109. console.log(taskData.value)
  110. }
  111. })
  112. const handleToAuthentication = () => {
  113. if (!isLogined.value) return
  114. uni.navigateTo({ url: '/pages/mine/authentication/index' })
  115. }
  116. const handleToHomepage = () => {
  117. uni.navigateTo({ url: '/pages/mine/homepage/index' })
  118. }
  119. const handleMenuClick = (path) => {
  120. path && uni.navigateTo({ url: path })
  121. }
  122. onMounted(async () => {})
  123. const navBarProps = ref({ customClass: 'bg-transparent!' })
  124. onPageScroll(({ scrollTop }: { scrollTop: number }) => {
  125. // console.log(scrollTop)
  126. navBarProps.value.customClass = scrollTop === 0 ? 'bg-transparent!' : ''
  127. })
  128. </script>
  129. <template>
  130. <view>
  131. <wd-navbar
  132. fixed
  133. safeAreaInsetTop
  134. custom-class="bg-transparent!"
  135. :bordered="false"
  136. v-bind="navBarProps"
  137. >
  138. <template #left>
  139. <wd-button type="text" size="small" custom-class="p-0!" :round="false">
  140. <wd-img width="25" height="25" :src="scan" custom-class="vertical-bottom"></wd-img>
  141. </wd-button>
  142. </template>
  143. </wd-navbar>
  144. <div
  145. class="bg-black/30 flex flex-col justify-end box-border bg-[url(https://image.zhuchaohui.com/zhucaohui/c706ec14a5a927c10e9e1fa0153affb11bbdd9255882e18c67ee82687ff9813a.png)] bg-[length:100%_auto]"
  146. :class="[isCertified ? 'aspect-[0.94/1] pb-44' : 'aspect-[1.15/1] pb-20']"
  147. >
  148. <div class="my-6.5 px-3.5 flex">
  149. <img class="w-[72px] h-[72px] rounded-full border border-white" :src="avatar" />
  150. <div class="ms-3.5 ml-3.5">
  151. <div
  152. class="text-white text-xl font-normal font-['PingFang_SC'] leading-normal"
  153. @click="nickNameClickHandle"
  154. >
  155. {{ !isLogined ? '请点击登录' : userInfo?.nickname }}
  156. </div>
  157. <div
  158. v-if="!isCertified"
  159. class="mt-2 w-[63px] h-[26px] bg-black/10 rounded-[20px] border border-white/60 flex items-center justify-center"
  160. >
  161. <div
  162. class="text-center text-white text-xs font-normal font-['PingFang_SC'] leading-normal"
  163. >
  164. <!-- 未认证 -->
  165. {{ certificationStatusText }}
  166. </div>
  167. </div>
  168. <div v-if="isCertified" class="flex items-center text-white" @click="handleToHomepage">
  169. <div
  170. class="text-center text-white text-sm font-normal font-['PingFang_SC'] leading-normal"
  171. >
  172. 个人主页
  173. </div>
  174. <wd-icon name="arrow-right"></wd-icon>
  175. </div>
  176. </div>
  177. </div>
  178. <div class="px-3.5 flex items-center">
  179. <div class="flex items-center">
  180. <div class="text-white text-base font-normal font-['PingFang_SC'] leading-normal mr-1">
  181. <!-- 0 -->
  182. {{ designerInfo?.shareCount }}
  183. </div>
  184. <div
  185. class="text-center text-[#e9e7e4] text-xs font-normal font-['PingFang_SC'] leading-normal"
  186. >
  187. 分享
  188. </div>
  189. </div>
  190. <div class="h-4 w-[2px] mx-4 bg-[#e9e7e4]"></div>
  191. <div class="flex items-center">
  192. <div class="text-white text-base font-normal font-['PingFang_SC'] leading-normal mr-1">
  193. 0
  194. <!-- {{designerInfo.c}} -->
  195. </div>
  196. <div
  197. class="text-center text-[#e9e7e4] text-xs font-normal font-['PingFang_SC'] leading-normal"
  198. >
  199. 获客
  200. </div>
  201. </div>
  202. <div class="h-4 w-[2px] mx-4 bg-[#e9e7e4]"></div>
  203. <div class="flex items-center">
  204. <div class="text-white text-base font-normal font-['PingFang_SC'] leading-normal mr-1">
  205. <!-- 0 -->
  206. {{ designerInfo?.viewCount }}
  207. </div>
  208. <div
  209. class="text-center text-[#e9e7e4] text-xs font-normal font-['PingFang_SC'] leading-normal"
  210. >
  211. 浏览
  212. </div>
  213. </div>
  214. </div>
  215. </div>
  216. <div class="relative top--18" v-if="!isCertified">
  217. <div class="mx-3.5 box-border absolute left-0 right-0 top-0">
  218. <wd-img :src="vipBg" width="100%" mode="widthFix"></wd-img>
  219. </div>
  220. <div class="mx-3.5 box-border absolute left-0 right-0 top-0 p-3.5">
  221. <div class="flex items-center">
  222. <wd-img custom-class="vertical-bottom" :src="vip" width="35" mode="widthFix"></wd-img>
  223. <div
  224. class="ml-2 text-center text-[#faeac6] text-sm font-normal font-['PingFang_SC'] leading-normal"
  225. >
  226. 查看会员等级权益
  227. </div>
  228. <div class="flex-1"></div>
  229. <div
  230. class="w-[83px] h-[29px] bg-gradient-to-l from-[#ffdab6] to-[#ffebd5] rounded-[30px] flex items-center justify-center"
  231. @click="handleToAuthentication()"
  232. >
  233. <div
  234. class="text-[#9e5934] text-[13px] font-normal font-['PingFang_SC'] leading-relaxed"
  235. >
  236. <!-- 去认证 -->
  237. <!-- {{ !isCertified ? '去认证' : certificationStatusText }} -->
  238. {{ certificationBtnText }}
  239. </div>
  240. </div>
  241. </div>
  242. </div>
  243. </div>
  244. <template v-else>
  245. <div class="relative top--36">
  246. <div
  247. 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%]"
  248. :class="['text-[#8FB8DB]']"
  249. :style="{
  250. backgroundImage: `url(${levels[userInfo.level.level].bgImg})`,
  251. color: levels[userInfo.level.level].color,
  252. }"
  253. >
  254. <div class="flex items-center">
  255. <div class="flex-1"></div>
  256. <div
  257. class="h-[22px] bg-gradient-to-r from-[#333333] to-[#20201e] rounded-tl-[20px] rounded-bl-[20px] mr--3.5 px-2 mt-3"
  258. @click="router.push('/pages/mine/levels/index')"
  259. >
  260. <div class="text-xs font-normal font-['PingFang_SC'] leading-relaxed color-[#f3f3f3]">
  261. 更多等级权益
  262. </div>
  263. </div>
  264. </div>
  265. <div class="flex items-end mt-10">
  266. <div>
  267. <span class="text-4xl font-normal font-['D-DIN Exp'] mr-1">
  268. {{ userInfo.level.point }}
  269. </span>
  270. <span class="text-center text-xs font-normal font-['PingFang_SC']">积分</span>
  271. </div>
  272. <div class="flex-1"></div>
  273. <div class="text-sm font-normal font-['PingFang_SC']">
  274. 会员号:{{ userInfo.level.cardCode }}
  275. </div>
  276. </div>
  277. </div>
  278. </div>
  279. <!-- <div class="relative h-4 box-border bg-transparent rounded-b-[50%] z-1"></div> -->
  280. </template>
  281. <view
  282. class="relative bottom-4 py-1 px-3.5"
  283. :class="[
  284. userInfo.userStatusEnabled
  285. ? 'bg-[url(https://image.zhuchaohui.com/zhucaohui/f12b86304c84eec692f4c8f040a06c63fe7110359b8a4a1262b97b1eef6b605c.png)] bg-[length:100%]'
  286. : 'bg-neutral-100 rounded-t-2xl',
  287. ]"
  288. >
  289. <div class="flex justify-around my-6">
  290. <template v-for="({ title, icon, path }, i) in menus" :key="i">
  291. <div class="flex flex-col items-center" @click="handleMenuClick(path)">
  292. <div class="relative flex-col justify-start items-start inline-flex">
  293. <wd-img :src="icon" width="24" height="24" custom-class="vertical-bottom"></wd-img>
  294. </div>
  295. <div
  296. class="mt-2 text-black/90 text-[12.86px] font-normal font-['PingFang_SC'] leading-relaxed"
  297. >
  298. {{ title }}
  299. </div>
  300. </div>
  301. </template>
  302. </div>
  303. <TasksCard custom-class="my-6" :items="taskData.list"></TasksCard>
  304. <SectionHeading custom-class="my-6" title="和筑巢荟一起共同成长"></SectionHeading>
  305. <CardMenu :items="pieces" custom-class="grid-cols-2" />
  306. </view>
  307. </view>
  308. </template>
  309. <style scoped lang="scss"></style>