优化:去掉不必要的loading

This commit is contained in:
2025-12-12 11:57:43 +08:00
parent 6e5d63febe
commit 04e2196942
8 changed files with 66 additions and 28 deletions

View File

@@ -8,7 +8,7 @@ import type { ILoginResponse } from '@/types/user'
* @param code 验证码 * @param code 验证码
*/ */
export async function loginWithCode(tel: string, code: string) { export async function loginWithCode(tel: string, code: string) {
const res = await mainClient.request<IApiResponse<ILoginResponse>>({ const res = await mainClient.request<ILoginResponse>({
url: 'book/user/registerOrLogin', url: 'book/user/registerOrLogin',
method: 'GET', method: 'GET',
data: { tel, code } data: { tel, code }
@@ -22,7 +22,7 @@ export async function loginWithCode(tel: string, code: string) {
* @param password 密码 * @param password 密码
*/ */
export async function loginWithPassword(phone: string, password: string) { export async function loginWithPassword(phone: string, password: string) {
const res = await mainClient.request<IApiResponse<ILoginResponse>>({ const res = await mainClient.request<ILoginResponse>({
url: 'book/user/login', url: 'book/user/login',
method: 'POST', method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, headers: { 'Content-Type': 'application/x-www-form-urlencoded' },

View File

@@ -22,7 +22,7 @@ export const commonApi = {
* @param id 协议 ID (111: 用户协议, 112: 隐私政策) * @param id 协议 ID (111: 用户协议, 112: 隐私政策)
*/ */
getAgreement: async (id: number) => { getAgreement: async (id: number) => {
const res = await mainClient.request<IApiResponse<IAgreement>>({ const res = await skeletonClient.request<IApiResponse<IAgreement>>({
url: 'sys/agreement/getAgreement', url: 'sys/agreement/getAgreement',
method: 'POST', method: 'POST',
data: { id } data: { id }

View File

@@ -1,5 +1,5 @@
// api/modules/user.ts // api/modules/user.ts
import { mainClient } from '@/api/clients/main' import { mainClient, skeletonClient } from '@/api/clients'
import { paymentClient } from '@/api/clients/payment' import { paymentClient } from '@/api/clients/payment'
import type { IApiResponse } from '@/api/types' import type { IApiResponse } from '@/api/types'
import type { import type {
@@ -17,7 +17,7 @@ import { SERVICE_MAP } from '@/api/config'
* 获取用户信息 * 获取用户信息
*/ */
export async function getUserInfo() { export async function getUserInfo() {
const res = await mainClient.request<IApiResponse<{ user: IUserInfo }>>({ const res = await skeletonClient.request<IApiResponse<{ user: IUserInfo }>>({
url: 'common/user/getUserInfo', url: 'common/user/getUserInfo',
method: 'POST' method: 'POST'
}) })

View File

@@ -220,18 +220,16 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from 'vue' import { ref, onMounted } from 'vue'
import { onShow, onHide, onPullDownRefresh, onPageScroll, onLoad } from '@dcloudio/uni-app' import { onShow, onHide, onPullDownRefresh, onPageScroll } from '@dcloudio/uni-app'
import { useI18n } from 'vue-i18n'
import { courseApi } from '@/api/modules/course' import { courseApi } from '@/api/modules/course'
import { courseSubjectClassificationApi } from '@/api/modules/cousre_subject_classification' import { courseSubjectClassificationApi } from '@/api/modules/cousre_subject_classification'
import { commonApi } from '@/api/modules/common' import { commonApi } from '@/api/modules/common'
import { getNotchHeight } from '@/utils/system' import { getNotchHeight } from '@/utils/system'
// import { onPageJump } from '@/utils' // import { onPageJump } from '@/utils'
import type { IMedicalTag, ICourse, INews } from '@/types/course' import type { ICategory, ICourse, INews } from '@/types/course'
import { useUserStore } from '@/stores/user' import { useUserStore } from '@/stores/user'
const userStore = useUserStore() const userStore = useUserStore()
const { t } = useI18n()
// 系统信息 // 系统信息
const scrollTop = ref<number>(0) // 滚动位置 const scrollTop = ref<number>(0) // 滚动位置
@@ -246,10 +244,10 @@ const handleSearch = ({ value }: { value: string }) => {
} }
// 分类相关 // 分类相关
const curseTagList = ref<IMedicalTag[]>([]) // 一级分类标签列表 const curseTagList = ref<ICategory[]>([]) // 一级分类标签列表
const sbuMedicalTagsList = ref<IMedicalTag[]>([]) // 二级分类标签列表 const sbuMedicalTagsList = ref<ICategory[]>([]) // 二级分类标签列表
const currentIndex = ref<number>(0) // 当前选中的一级分类索引 const currentIndex = ref<number>(0) // 当前选中的一级分类索引
const currentItem = ref<IMedicalTag | null>(null) // 当前选中的一级分类项 const currentItem = ref<ICategory | null>(null) // 当前选中的一级分类项
// 学科数据 // 学科数据
const firstLevelCategories = ref<string[]>(['医学', '心理学', '国学']) const firstLevelCategories = ref<string[]>(['医学', '心理学', '国学'])
@@ -287,7 +285,7 @@ const getMedicineMenusSuccess = (res: any) => {
* 医学 * 医学
* 一级分类点击处理 * 一级分类点击处理
*/ */
const curseClick = (item: IMedicalTag, index: number) => { const curseClick = (item: ICategory, index: number) => {
currentItem.value = item currentItem.value = item
currentIndex.value = index currentIndex.value = index
@@ -350,7 +348,7 @@ const handleFirstLevelClick = (item: string) => {
/** /**
* 终极分类点击处理 * 终极分类点击处理
*/ */
const curseClickJump = (item: IMedicalTag) => { const curseClickJump = (item: ICategory) => {
getPrompt() getPrompt()
if(!uni.getStorageSync('token')) return if(!uni.getStorageSync('token')) return
uni.navigateTo({ uni.navigateTo({
@@ -512,7 +510,7 @@ onPullDownRefresh(() => {
/** /**
* 页面滚动 * 页面滚动
*/ */
onPageScroll((e) => { onPageScroll((e: any) => {
scrollTop.value = e.scrollTop scrollTop.value = e.scrollTop
}) })
</script> </script>

View File

@@ -1,6 +1,8 @@
<template> <template>
<view class="page"> <view class="page">
<view class="title" :style="{ 'margin-top': getNotchHeight() + 'px' }">{{ $t('forget.title') }}</view> <!-- 自定义导航栏 -->
<nav-bar :title="$t('forget.title')" />
<!-- <view class="title" :style="{ 'margin-top': getNotchHeight() + 'px' }">{{ $t('forget.title') }}</view> -->
<!-- 邮箱输入 --> <!-- 邮箱输入 -->
<view class="input-box"> <view class="input-box">
@@ -33,7 +35,7 @@
<input <input
class="input-text" class="input-text"
type="password" type="password"
maxlength="20" :maxlength="20"
v-model="password" v-model="password"
:placeholder="$t('forget.passwordPlaceholder')" :placeholder="$t('forget.passwordPlaceholder')"
@input="inputMethod(password)" @input="inputMethod(password)"
@@ -54,8 +56,8 @@
<input <input
class="input-text" class="input-text"
type="password" type="password"
minlength="8" :minlength="8"
maxlength="20" :maxlength="20"
v-model="confirmPassword" v-model="confirmPassword"
:placeholder="$t('forget.passwordAgainPlaceholder')" :placeholder="$t('forget.passwordAgainPlaceholder')"
/> />

View File

@@ -34,7 +34,7 @@
v-model="code" v-model="code"
:placeholder="$t('login.codePlaceholder')" :placeholder="$t('login.codePlaceholder')"
placeholder-class="grey" placeholder-class="grey"
maxlength="6" :maxlength="6"
@confirm="onSubmit" @confirm="onSubmit"
/> />
<wd-button type="info" :class="['code-btn', { 'active': !readonly }]" @click="onSetCode"> <wd-button type="info" :class="['code-btn', { 'active': !readonly }]" @click="onSetCode">
@@ -116,7 +116,7 @@
<!-- 游客体验 --> <!-- 游客体验 -->
<view class="youke-l" v-if="!isAndorid"> <view class="youke-l" v-if="!isAndorid">
<view @click="onPageJump('/pages/course/index')"> <view @click="onPageSwitch('/pages/course/index')">
{{ $t('login.noLogin') }} {{ $t('login.noLogin') }}
</view> </view>
</view> </view>
@@ -147,6 +147,7 @@ import { loginWithCode, loginWithPassword } from '@/api/modules/auth'
import { commonApi } from '@/api/modules/common' import { commonApi } from '@/api/modules/common'
import { validateEmail } from '@/utils/validator' import { validateEmail } from '@/utils/validator'
import { onPageJump } from '@/utils' import { onPageJump } from '@/utils'
import { ILoginResponse } from '@/types/user'
import { t } from '@/utils/i18n' import { t } from '@/utils/i18n'
@@ -303,14 +304,14 @@ const passwordLogin = async () => {
const onSubmit = async () => { const onSubmit = async () => {
if(!isAgree()) return false if(!isAgree()) return false
let res = null let res: ILoginResponse | null = null
switch (loginType.value) { switch (loginType.value) {
case 2000: case 2000:
res = await verifyCodeLogin() res = await verifyCodeLogin() as ILoginResponse
break break
case 1000: case 1000:
res = await passwordLogin() res = await passwordLogin() as ILoginResponse
break break
} }
@@ -399,7 +400,7 @@ const yszc = () => {
/** /**
* 页面跳转 * 页面跳转
*/ */
const onPageJump = (url: string) => { const onPageSwitch = (url: string) => {
uni.switchTab({ uni.switchTab({
url: url, url: url,
}) })

View File

@@ -217,9 +217,18 @@
.mt-2 { .mt-2 {
margin-top: calc(var(--spacing) * 2); margin-top: calc(var(--spacing) * 2);
} }
.mt-2\! {
margin-top: calc(var(--spacing) * 2) !important;
}
.mt-2\.5\! {
margin-top: calc(var(--spacing) * 2.5) !important;
}
.mt-3 { .mt-3 {
margin-top: calc(var(--spacing) * 3); margin-top: calc(var(--spacing) * 3);
} }
.mt-3\! {
margin-top: calc(var(--spacing) * 3) !important;
}
.mt-5 { .mt-5 {
margin-top: calc(var(--spacing) * 5); margin-top: calc(var(--spacing) * 5);
} }
@@ -229,12 +238,27 @@
.mt-20 { .mt-20 {
margin-top: calc(var(--spacing) * 20); margin-top: calc(var(--spacing) * 20);
} }
.mt-20\! {
margin-top: calc(var(--spacing) * 20) !important;
}
.mt-\[20rpx\]\! { .mt-\[20rpx\]\! {
margin-top: 20rpx !important; margin-top: 20rpx !important;
} }
.mr-\[20rpx\] {
margin-right: 20rpx;
}
.mr-\[20rpx\]\! {
margin-right: 20rpx !important;
}
.mb-1 { .mb-1 {
margin-bottom: calc(var(--spacing) * 1); margin-bottom: calc(var(--spacing) * 1);
} }
.mb-1\! {
margin-bottom: calc(var(--spacing) * 1) !important;
}
.mb-1\.5\! {
margin-bottom: calc(var(--spacing) * 1.5) !important;
}
.mb-2 { .mb-2 {
margin-bottom: calc(var(--spacing) * 2); margin-bottom: calc(var(--spacing) * 2);
} }
@@ -259,6 +283,12 @@
.ml-2\.5\! { .ml-2\.5\! {
margin-left: calc(var(--spacing) * 2.5) !important; margin-left: calc(var(--spacing) * 2.5) !important;
} }
.ml-\[20rpx\] {
margin-left: 20rpx;
}
.ml-\[20rpx\]\! {
margin-left: 20rpx !important;
}
.block { .block {
display: block; display: block;
} }
@@ -332,6 +362,9 @@
.p-2 { .p-2 {
padding: calc(var(--spacing) * 2); padding: calc(var(--spacing) * 2);
} }
.p-2\.5 {
padding: calc(var(--spacing) * 2.5);
}
.p-3 { .p-3 {
padding: calc(var(--spacing) * 3); padding: calc(var(--spacing) * 3);
} }
@@ -341,6 +374,9 @@
.p-\[20rpx\] { .p-\[20rpx\] {
padding: 20rpx; padding: 20rpx;
} }
.p-\[20rpx\]\! {
padding: 20rpx !important;
}
.p-\[30rpx\] { .p-\[30rpx\] {
padding: 30rpx; padding: 30rpx;
} }

View File

@@ -1,4 +1,5 @@
// types/user.ts // types/user.ts
import type { IApiResponse } from '@/api/types'
/** /**
* *
@@ -16,12 +17,12 @@ export interface IUserInfo {
/** /**
* *
*/ */
export interface ILoginResponse { export interface ILoginResponse<T = IUserInfo> extends IApiResponse {
userInfo: IUserInfo
token: { token: {
token: string token: string
[key: string]: any [key: string]: any
} },
userInfo: T
} }
/** /**