Browse Source

优化微信用户展示

“shengjie.huang” 1 năm trước cách đây
mục cha
commit
b9bb60e4f3
3 tập tin đã thay đổi với 4 bổ sung3 xóa
  1. 1 1
      src/pages/login/index.vue
  2. 2 1
      src/pages/personal/index.vue
  3. 1 1
      src/service/api/index.ts

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

@@ -76,7 +76,7 @@ function handleToken(token) {
   if (token) {
     toast.success("登录成功")
     useUserStore().setToken(token)
-    // useUserStore().initUserInfo()
+    useUserStore().initUserInfo()
     uni.reLaunch({
       url: `/pages/index/index`,
     })

+ 2 - 1
src/pages/personal/index.vue

@@ -17,7 +17,7 @@
         :height="40"
         :src="userInfo.avatar"
       />
-      <view class="head-name">{{ isLogined ? "微信用户" : "请登录" }}</view>
+      <view class="head-name">{{ isLogined ? userName : "请登录" }}</view>
       <!-- <view class="head-name">{{ userInfo.name }}</view> -->
     </view>
     <view class="main-content mt6">
@@ -59,6 +59,7 @@ const userInfo = reactive({
 })
 const toast = useToast()
 const isLogined = computed(() => !!useUserStore().token)
+const userName = computed(() => useUserStore().userInfo?.name || "微信用户")
 
 function toAddUserHub() {
   if (isLogined.value) {

+ 1 - 1
src/service/api/index.ts

@@ -28,7 +28,7 @@ export const logout = () => {
   })
 }
 
-/** 用户信息--暂未使用 */
+/** 用户信息 */
 export const getUserInfo = () => {
   return http<any>({
     url: '/sys/user/info',