Browse Source

feat(mine): 添加radash依赖并重新配置首页和材料页

EvilDragon 7 months ago
parent
commit
95b38b6b05

+ 1 - 0
package.json

@@ -93,6 +93,7 @@
     "pinia": "2.0.36",
     "pinia-plugin-persistedstate": "3.2.1",
     "qs": "6.5.3",
+    "radash": "^12.1.0",
     "vue": "3.4.21",
     "wot-design-uni": "^1.2.26",
     "z-paging": "^2.7.10"

+ 1 - 7
pages.config.ts

@@ -28,16 +28,10 @@ export default defineUniPages({
     height: '0px',
     list: [
       {
-        // iconPath: 'static/tabbar/home.png',
-        // selectedIconPath: 'static/tabbar/homeHL.png',
         pagePath: 'pages/home/index',
-        // text: '首页',
       },
       {
-        // iconPath: 'static/tabbar/example.png',
-        // selectedIconPath: 'static/tabbar/exampleHL.png',
-        pagePath: 'pages/about/about',
-        // text: '关于',
+        pagePath: 'pages/material/index',
       },
       {
         pagePath: 'pages/publish/index',

File diff suppressed because it is too large
+ 171 - 149
pnpm-lock.yaml


File diff suppressed because it is too large
+ 11 - 0
src/assets/svgs/vip.svg


+ 6 - 2
src/components/tabbar-evo.vue

@@ -25,6 +25,10 @@ const props = defineProps({
 const safeAreaInsets = ref({ bottom: 0 })
 const tabbar = ref<HTMLElement | undefined>()
 
+const handleClick = (path: string) => {
+  uni.switchTab({ url: path })
+}
+
 onMounted(async () => {
   if (props.safeAreaInsetBottom) {
     // uniapp 获取safeAreaInsetBottom
@@ -54,8 +58,8 @@ onMounted(async () => {
         :class="[fixed ? 'fixed bottom-0 left-0 right-0' : '']"
         class="m-3.5 h-[60px] bg-white/70 rounded-[60px] border border-white backdrop-blur-[25px] flex items-center justify-around"
       >
-        <template v-for="({ iconPath, title, hiddenTitle }, i) in items" :key="i">
-          <div class="flex flex-col items-center justify-center">
+        <template v-for="({ iconPath, title, hiddenTitle, path }, i) in items" :key="i">
+          <div class="flex flex-col items-center justify-center" @click="handleClick(path)">
             <wd-img round height="40rpx" width="40rpx" :src="iconPath"></wd-img>
             <span v-if="!hiddenTitle">{{ title }}</span>
           </div>

+ 2 - 0
src/core/libs/svgs.ts

@@ -14,6 +14,7 @@ import order from '@/assets/svgs/order.svg'
 import agent from '@/assets/svgs/agent.svg'
 import setting from '@/assets/svgs/setting.svg'
 import logo from '@/assets/svgs/logo.svg'
+import vip from '@/assets/svgs/vip.svg'
 export {
   polygon16,
   frame,
@@ -31,4 +32,5 @@ export {
   agent,
   setting,
   logo,
+  vip,
 }

+ 0 - 0
src/core/utils/string


+ 5 - 2
src/pages.json

@@ -28,7 +28,7 @@
         "pagePath": "pages/home/index"
       },
       {
-        "pagePath": "pages/about/about"
+        "pagePath": "pages/material/index"
       },
       {
         "pagePath": "pages/publish/index"
@@ -85,6 +85,7 @@
     {
       "path": "pages/material/index",
       "type": "page",
+      "layout": "tabbar",
       "style": {
         "navigationBarTitleText": "材料"
       }
@@ -92,8 +93,9 @@
     {
       "path": "pages/messages/index",
       "type": "page",
+      "layout": "tabbar",
       "style": {
-        "navigationBarTitleText": "材料"
+        "navigationBarTitleText": "消息"
       }
     },
     {
@@ -108,6 +110,7 @@
     {
       "path": "pages/publish/index",
       "type": "page",
+      "layout": "tabbar",
       "style": {
         "navigationBarTitleText": "发布"
       }

+ 7 - 0
src/pages/login/index.vue

@@ -5,7 +5,10 @@ style:
 <script lang="ts" setup>
 import { weixinMiniAppLogin } from '@/core/libs/requests'
 import { logo } from '@/core/libs/svgs'
+import { useUserStore } from '@/store'
 
+const userStore = useUserStore()
+const { setUserInfo } = userStore
 const loginCode = ref('')
 const phoneCode = ref('')
 const loginType = ref('weixin')
@@ -50,6 +53,10 @@ const getPhoneNumber = async ({ detail: { code: phoneCode } }) => {
   console.log(code, phoneCode)
   const res = await weixinMiniAppLogin(phoneCode, code, '9b2ffbc1-7425-4155-9894-9d5c08541d62')
   console.log(res)
+  setUserInfo({ token: res.data.accessToken })
+  uni.switchTab({
+    url: '/pages/mine/index',
+  })
 }
 const getTestCode = async ({ detail }) => {
   phoneCode.value = detail.code

+ 1 - 1
src/pages/material/index.vue

@@ -1,5 +1,5 @@
 <route lang="json5">
-{ style: { navigationBarTitleText: '材料' } }
+{ layout: 'tabbar', style: { navigationBarTitleText: '材料' } }
 </route>
 
 <script setup lang="ts"></script>

+ 1 - 1
src/pages/messages/index.vue

@@ -1,5 +1,5 @@
 <route lang="json5">
-{ style: { navigationBarTitleText: '材料' } }
+{ layout: 'tabbar', style: { navigationBarTitleText: '消息' } }
 </route>
 
 <script setup lang="ts"></script>

+ 43 - 10
src/pages/mine/index.vue

@@ -9,9 +9,25 @@ import CardMenu from '@/components/card-menu.vue'
 import SectionHeading from '@/components/section-heading.vue'
 import StartMenuButton from '@/components/start-menu-button.vue'
 import { designer, settled, treaty, vipBg } from '@/core/libs/pngs'
-import { integral, coupon, order, agent, setting, wechat, award, camera } from '@/core/libs/svgs'
+import {
+  integral,
+  coupon,
+  order,
+  agent,
+  setting,
+  wechat,
+  award,
+  camera,
+  vip,
+} from '@/core/libs/svgs'
 import { getMemberUserInfo } from '@/core/libs/requests'
+import { useUserStore } from '@/store'
+import { storeToRefs } from 'pinia'
+import { isEmpty } from 'radash'
 
+const userStore = useUserStore()
+const { isLogined, userInfo } = storeToRefs(userStore)
+const { setUserInfo } = userStore
 const { data, run } = useRequest(getMemberUserInfo)
 const menus = ref([
   { title: '积分明细', icon: integral },
@@ -43,9 +59,25 @@ const pieces = ref([
     iconSize: 44,
   },
 ])
+const avatar = computed(() =>
+  !isEmpty(userInfo.value.avatar) ? userInfo.value.avatar : 'https://via.placeholder.com/72x72',
+)
+const nickNameClickHandle = async () => {
+  if (isLogined.value) return
+  uni.navigateTo({ url: '/pages/login/index' })
+}
+onShow(async () => {
+  if (isLogined.value) {
+    await run()
+    setUserInfo({
+      ...userInfo.value,
+      ...data.value,
+    })
+  }
+})
 onMounted(async () => {
-  await run()
-  console.log(data)
+  // await run()
+  // console.log(data.value)
 })
 </script>
 
@@ -54,13 +86,13 @@ onMounted(async () => {
     <div class="bg-black/30 backdrop-blur-[60px] aspect-[1.15/1]">
       <StartMenuButton />
       <div class="my-6.5 px-3.5 flex">
-        <img
-          class="w-[72px] h-[72px] rounded-full border border-white"
-          src="https://via.placeholder.com/72x72"
-        />
+        <img class="w-[72px] h-[72px] rounded-full border border-white" :src="avatar" />
         <div class="ms-3.5 ml-3.5">
-          <div class="text-white text-xl font-normal font-['PingFang SC'] leading-normal">
-            用户SEI142
+          <div
+            class="text-white text-xl font-normal font-['PingFang SC'] leading-normal"
+            @click="nickNameClickHandle"
+          >
+            {{ !isLogined ? '请点击登录' : userInfo?.nickname }}
           </div>
           <div
             class="mt-2 w-[63px] h-[26px] bg-black/10 rounded-[20px] border border-white/60 flex items-center justify-center"
@@ -118,8 +150,9 @@ onMounted(async () => {
       </div>
       <div class="mx-3.5 box-border absolute left-0 right-0 top-0 p-3.5">
         <div class="flex items-center">
+          <wd-img custom-class="vertical-bottom" :src="vip" width="35" mode="widthFix"></wd-img>
           <div
-            class="text-center text-[#faeac6] text-sm font-normal font-['PingFang SC'] leading-normal"
+            class="ml-2 text-center text-[#faeac6] text-sm font-normal font-['PingFang SC'] leading-normal"
           >
             查看会员等级权益
           </div>

+ 1 - 1
src/pages/publish/index.vue

@@ -1,5 +1,5 @@
 <route lang="json5">
-{ style: { navigationBarTitleText: '发布' } }
+{ layout: 'tabbar', style: { navigationBarTitleText: '发布' } }
 </route>
 
 <script setup lang="ts"></script>

+ 1 - 1
src/types/uni-pages.d.ts

@@ -25,7 +25,7 @@ interface NavigateToOptions {
 interface RedirectToOptions extends NavigateToOptions {}
 
 interface SwitchTabOptions {
-  url: "/pages/home/index" | "/pages/about/about" | "/pages/publish/index" | "/pages/messages/index" | "/pages/mine/index"
+  url: "/pages/home/index" | "/pages/material/index" | "/pages/publish/index" | "/pages/messages/index" | "/pages/mine/index"
 }
 
 type ReLaunchOptions = NavigateToOptions | SwitchTabOptions;

+ 5 - 0
src/utils/http.ts

@@ -1,7 +1,12 @@
 import { CustomRequestOptions } from '@/interceptors/request'
+import { useUserStore } from '@/store'
+
+const userStore = useUserStore()
+const Authorization = userStore.userInfo.token
 
 const header = {
   'tenant-id': 1,
+  Authorization,
 }
 export const http = <T>(options: CustomRequestOptions) => {
   // 1. 返回 Promise 对象

Some files were not shown because too many files changed in this diff