index.vue 12 KB

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