Просмотр исходного кода

Update 小程序发布前优化

Yue 2 лет назад
Родитель
Сommit
b28d7b5668

+ 1 - 1
UI/XYH.APP/src/components/vber/list/vb-list.vue

@@ -109,7 +109,7 @@ function loadData() {
   if (queryParams.value) {
     params = Object.assign({}, params, queryParams.value)
   }
-  console.log("List-Params", params)
+  //console.log("List-Params", params)
   props.queryFun &&
     props
       .queryFun(params)

+ 3 - 2
UI/XYH.APP/src/core/config/index.ts

@@ -1,8 +1,9 @@
 // 应用全局配置
 export default {
   //baseUrl: "/api",
-  // baseUrl: "https://shvber.com/api6060",
-   baseUrl: 'http://localhost:5051',
+  baseUrl: "https://www.shvber.com/vberYzxyh",
+  //baseUrl: "http://xyhapi.yue.shvber.com:4031",
+  //baseUrl: 'http://localhost:5051',
   // 应用信息
   appInfo: {
     // 应用名称

+ 1 - 0
UI/XYH.APP/src/core/types/_alumnus.ts

@@ -6,6 +6,7 @@ export interface AlumnusProfile {
   phonenumber: string
   userType: string
   name: string
+  avatar?: string
   gender: string
   birthday: string
   type: string

+ 1 - 1
UI/XYH.APP/src/core/utils/message.ts

@@ -27,7 +27,7 @@ export const message = {
       delete opts.duration
       uni.showLoading(opts)
     } else {
-      console.log("--message--", opts)
+      //console.log("--message--", opts)
       uni.showToast(opts)
     }
   },

+ 3 - 3
UI/XYH.APP/src/manifest.json

@@ -1,7 +1,7 @@
 {
-  "name": "",
+  "name": "yzxyh",
   "appid": "",
-  "description": "",
+  "description": "盐中校友会",
   "versionName": "1.0.0",
   "versionCode": "100",
   "transformPx": false,
@@ -50,7 +50,7 @@
   "quickapp": {},
   /* 小程序特有相关 */
   "mp-weixin": {
-    "appid": "",
+    "appid": "wx378c6b0d5e65735f",
     "setting": {
       "urlCheck": false
     },

+ 14 - 4
UI/XYH.APP/src/pages-sub/alumnus/detail.vue

@@ -17,10 +17,18 @@
               }"
             ></i>
           </view>
+          <view
+            v-if="am.type != 0"
+            class="bg-primary text-white text-center py-3 br-10 fs-10 pos-a"
+            style="bottom: 0; width: 80%; margin-left: 10%"
+          >
+            {{ am.type == 1 || am.type == 2 ? "教职工" : "其他" }}
+          </view>
           <view
             v-if="am.orgName"
-            class="pos-a bg-success text-white br-20 py-2 px-10 fs-10"
-            style="bottom: 0; left: 50%; white-space: nowrap"
+            class="pos-a bg-success text-white br-20 py-3 px-10 fs-10"
+            style="bottom: 0; white-space: nowrap"
+            :style="{ left: am.type != 0 ? '100%' : '50%' }"
           >
             {{ am.orgName }}
           </view>
@@ -47,8 +55,10 @@
         </view>
         <view class="mt-15 d-flex align-end">
           <view class="fs-25 font-bold me-20">{{ am.name }}</view>
-          <view class="text-vb me-5">{{ am.graduateYear }} 届</view>
-          <view class="text-vb me-10">{{ am.amClass }}</view>
+          <template v-if="am.type == 0 || am.type == 2">
+            <view class="text-vb me-5">{{ am.graduateYear }} 届</view>
+            <view class="text-vb me-10">{{ am.amClass }}</view>
+          </template>
         </view>
         <view class="d-flex mt-10 justify-between">
           <view class="d-fcv">

+ 9 - 9
UI/XYH.APP/src/pages-sub/mine/profile/avatar.vue

@@ -4,7 +4,7 @@ import route from "@/route"
 import appStore from "@/stores"
 let sysInfo = uni.getSystemInfoSync()
 
-let SCREEN_WIDTH = sysInfo.screenWidth
+let SCREEN_WIDTH = sysInfo.screenWidth - 20
 let PAGE_X: number, // 手按下的x位置
   PAGE_Y: number, // 手按下y的位置
   //PR = sysInfo.pixelRatio, // dpi
@@ -23,10 +23,10 @@ let PAGE_X: number, // 手按下的x位置
   DRAG_POSITION = 100, // 屏幕宽度和裁剪区域的宽度之差,用于设置裁剪的宽度
   INIT_DRAG_POSITION = 0, // 初始化屏幕宽度和裁剪区域的宽度之差,用于设置初始化裁剪的宽度
   DRAW_IMAGE_W = sysInfo.screenWidth // 设置生成的图片宽度
-const user = appStore.authStore.user
+const user = computed(() => appStore.authStore.user)
 const opts = reactive<any>({
   isShowImg: false,
-  imageSrc: user.avatar ?? "",
+  imageSrc: user.value.avatar ?? "",
   // 初始化的宽高
   cropperInitW: SCREEN_WIDTH,
   cropperInitH: SCREEN_WIDTH,
@@ -52,12 +52,12 @@ const opts = reactive<any>({
 })
 
 function onChooseAvatar(e: any) {
-  console.log("onChooseAvatar", e)
+  //console.log("onChooseAvatar", e)
   const avatarUrl = e.detail.avatarUrl
   opts.imageSrc = avatarUrl
   INIT_DRAG_POSITION = DRAG_POSITION
   loadImage()
-  console.log("onChooseAvatar", avatarUrl)
+  //console.log("onChooseAvatar", avatarUrl)
 }
 
 function getImage() {
@@ -388,10 +388,10 @@ onReady(loadImage)
 <style>
 .uni-content-info {
   position: fixed;
-  top: 45px;
-  left: 0;
-  right: 0;
-  bottom: 0;
+  top: 10px;
+  left: 10px;
+  right: 10px;
+  bottom: 0px;
   display: block;
   align-items: center;
   flex-direction: column;

+ 1 - 1
UI/XYH.APP/src/pages-sub/mine/profile/edit.vue

@@ -134,7 +134,7 @@ function onIndustryConfirm(v: any, data: any) {
 
 function onBack() {
   if (appStore.authStore.getAuditStatus() != 1) {
-    appStore.authStore.getInfo().then(() => {
+    appStore.authStore.loadUserInfo().then(() => {
       route.reLaunch("welcome")
     })
   } else {

+ 2 - 1
UI/XYH.APP/src/pages.json

@@ -378,5 +378,6 @@
       // "van-collapse-item": "/wxcomponents/vant/dist/collapse-item/index",
       // "van-picker": "/wxcomponents/vant/dist/picker/index"
     }
-  }
+  },
+  "lazyCodeLoading": "requiredComponents"
 }

+ 2 - 4
UI/XYH.APP/src/pages/account/login.vue

@@ -62,7 +62,7 @@ function handleLogin() {
     message.loading("登录中,请耐心等待...")
     store.login(loginForm).then(() => {
       message.closeLoading()
-      store.getInfo().then(() => {
+      store.loadUserInfo().then(() => {
         route.reLaunch("welcome")
       })
     })
@@ -80,9 +80,7 @@ function handleWechatLogin() {
     .xcxLogin()
     .then((res: any) => {
       if (res) {
-        store.getInfo().then(() => {
-          route.reLaunch("index")
-        })
+        route.reLaunch("index")
       } else {
         getCode()
         loginForm.openid = appStore.authStore.getOpenId()

+ 14 - 5
UI/XYH.APP/src/pages/alumnus/index.vue

@@ -45,7 +45,7 @@
       :query-fun="apis.amActivity.alumnusApi.listAlumnus"
       :query-params="queryParams"
       :height="listHeight"
-      :data-length="10"
+      :dataLength="10"
       custom-class="pt-10"
     >
       <template #item="{ item }">
@@ -67,16 +67,25 @@
                   ></i>
                 </view>
                 <image class="w-100 h-100 br-round" :src="getAvatar(item)"></image>
+                <view
+                  v-if="item.type != 0"
+                  class="bg-primary text-white text-center py-3 br-10 fs-10 pos-a"
+                  style="bottom: 0; width: 80%; margin-left: 10%"
+                >
+                  {{ item.type == 1 || item.type == 2 ? "教职工" : "其他" }}
+                </view>
               </view>
             </view>
             <view class="am-info w-100 px-10 flex-column justify-around" style="">
               <view class="am-name d-flex align-baseline pb-3">
                 <text class="text-black fs-20 font-bold me-10">{{ item.name }}</text>
-                <text class="d-flex fs-16">
-                  <text class="text-vb">{{ item.graduateYear }}届-{{ item.amClass }}</text>
-                  <text class="text-gray-5 px-5">|</text>
+                <view class="d-flex fs-16">
+                  <template v-if="item.type == 0 || item.type == 2">
+                    <text class="text-vb">{{ item.graduateYear }}届-{{ item.amClass }}</text>
+                    <text class="text-gray-5 px-5">|</text>
+                  </template>
                   <text class="text-vb">{{ item.city }}</text>
-                </text>
+                </view>
               </view>
               <view v-if="isShowDetail" class="flex-column text-gray-6 fs-14">
                 <view v-if="item.workUnit" class="pt-5">

+ 2 - 2
UI/XYH.APP/src/pages/mine/index.vue

@@ -1,7 +1,6 @@
 <script setup lang="ts">
 import appStore from "@/stores"
 import route from "@/route"
-import configs from "@/core/config"
 import apis from "@/api"
 
 const ready = ref(false)
@@ -11,7 +10,7 @@ const user = computed(() => {
   return Object.assign({}, store.user, appStore.amProfileStore.getProfileInfo())
 })
 const avatar = computed(() => {
-  return user.value.avatar ? configs.baseUrl + user.value.avatar : `/static/images/avatars/empty.png`
+  return user.value.avatar ? user.value.avatar : `/static/images/avatars/empty.png`
 })
 const progress = computed(() => {
   return appStore.amProfileStore.getProfileProgress()
@@ -66,6 +65,7 @@ function loadData() {
 }
 
 function init() {
+  appStore.authStore.loadUserInfo()
   loadData()
 }
 onMounted(init)

+ 1 - 2
UI/XYH.APP/src/route/index.ts

@@ -2,7 +2,6 @@ import type { DeepReadonly } from "vue"
 import type { BackParams, Params } from "./_types"
 import pages from "./_pages"
 import appStore from "@/stores"
-import route from "@/route"
 
 type PageNames = keyof typeof pages
 
@@ -74,7 +73,7 @@ export function initRouteInterceptor() {
   uni.addInterceptor("navigateTo", {
     // 页面跳转前进行拦截, invoke根据返回值进行判断是否继续执行跳转
     invoke(e) {
-      console.log("_____", e)
+      //console.log("_____", e)
       if (!checkAuth(e.url)) {
         console.log("没有权限,请登录", e.url, e)
         return false

+ 2 - 4
UI/XYH.APP/src/static/font/iconfont.css

@@ -1,8 +1,7 @@
 @font-face {
   font-family: "iconfont"; /* Project id 4173588 */
-  src: url('iconfont.woff2?t=1706713072162') format('woff2'),
-       url('iconfont.woff?t=1706713072162') format('woff'),
-       url('iconfont.ttf?t=1706713072162') format('truetype');
+  src: url("iconfont.woff2?t=1706713072162") format("woff2"), url("iconfont.woff?t=1706713072162") format("woff"),
+    url("iconfont.ttf?t=1706713072162") format("truetype");
 }
 
 .iconfont {
@@ -448,4 +447,3 @@
 .icon-friend-fill:before {
   content: "\e657";
 }
-

BIN
UI/XYH.APP/src/static/images/banner/001.jpg


BIN
UI/XYH.APP/src/static/images/banner/002.jpg


BIN
UI/XYH.APP/src/static/images/profile.jpg


+ 6 - 13
UI/XYH.APP/src/stores/_auth.ts

@@ -33,10 +33,7 @@ export const useAuthStore = defineStore("auth", () => {
     user.value.orgId = u.orgId
     user.value.orgName = u.org?.orgName
     user.value.remark = u.remark
-    user.value.avatar = u.avatar
-      ? config.baseUrl + u.avatar
-      : `/static/images/avatars/default${user.value.gender ? user.value.gender : ""}.png`
-
+    user.value.avatar = u.avatar ? config.baseUrl + u.avatar : ""
     if (data.roles && data.roles.length > 0) {
       // 验证返回的roles是否是一个非空数组
       user.value.roles = data.roles
@@ -44,12 +41,11 @@ export const useAuthStore = defineStore("auth", () => {
     } else {
       user.value.roles = ["ROLE_DEFAULT"]
     }
-    console.log("---", user.value)
     localCache.setJSON(USER_KEY, user.value)
   }
 
   function changeAvatar(avatar: any) {
-    user.value.avatar = avatar ? config.baseUrl + avatar : avatar
+    user.value.avatar = avatar ? config.baseUrl + avatar : ""
     localCache.setJSON(USER_KEY, user.value)
   }
 
@@ -68,14 +64,11 @@ export const useAuthStore = defineStore("auth", () => {
         //console.log("WX_CODE", res.code)
         const code = res.code
         apis.loginApi.xcxLogin(code).then((res) => {
-          console.log("openid", res)
           if (res.code === 200) {
             setToken(res.data.token)
-            getInfo().then(() => {
-              appStore.amProfileStore.loadProfile()
+            loadUserInfo().then(() => {
+              resolve(true)
             })
-
-            resolve(true)
           } else if (res.code === 401) {
             openid.value = res.data.openid
             resolve(false)
@@ -107,7 +100,7 @@ export const useAuthStore = defineStore("auth", () => {
     })
   }
 
-  function getInfo() {
+  function loadUserInfo() {
     return new Promise((resolve, reject) => {
       apis.loginApi
         .getInfo()
@@ -169,7 +162,7 @@ export const useAuthStore = defineStore("auth", () => {
     login,
     logout,
     logoutWechat,
-    getInfo,
+    loadUserInfo,
     changeAvatar,
     getUser,
     getOpenId,

+ 5 - 0
UI/XYH.APP/src/stores/_profile.ts

@@ -1,3 +1,4 @@
+import config from "@/core/config"
 import apis from "@/api"
 import type { AlumnusProfile } from "@/core/types"
 import appStore from "."
@@ -12,6 +13,7 @@ export const useAmProfileStore = defineStore("amProfile", () => {
       // 这里需要根据amId获取对应的校友信息
       apis.amActivity.alumnusApi.getAlumnus(amId).then((res) => {
         amInfo.value = res
+        amInfo.value.avatar = res.avatar ? config.baseUrl + res.avatar : ""
         localCache.setJSON(ALUMNUS_PROFILE_KEY, res)
         resolve(amInfo.value)
       })
@@ -28,6 +30,9 @@ export const useAmProfileStore = defineStore("amProfile", () => {
   function getProfileProgress() {
     let count = 0,
       total = 0
+    if (!amInfo.value) {
+      return 0
+    }
     Object.keys(amInfo.value).forEach((key) => {
       total++
       if (amInfo.value[key as keyof typeof amInfo.value]) count++