diff --git a/src/api/login.js b/src/api/login.js index b5348a22..43953fab 100644 --- a/src/api/login.js +++ b/src/api/login.js @@ -89,4 +89,6 @@ export const loginOut = (data) => request({ }).then(() => { setToken(null) setUserInfo(null) + common.setValue('me_statistics_data', null) // 我的页统计数据缓存 + common.setValue('index_statistics_data', null) // 首页统计数据缓存 }) \ No newline at end of file diff --git a/src/pages/courseDetail/components/comment.vue b/src/pages/courseDetail/components/comment.vue index 635f7cc4..7e00514d 100644 --- a/src/pages/courseDetail/components/comment.vue +++ b/src/pages/courseDetail/components/comment.vue @@ -1,87 +1,90 @@ + .back-image { + position: absolute; + width: 100%; + } + + .head-title { + border-radius: 24rpx 24rpx 0rpx 0rpx; + height: 162rpx; + background-color: #ffffff; + display: flex; + flex-direction: column; + padding-top: 36rpx; + padding-left: 42rpx; + padding-bottom: 24rpx; + } + + .title-text { + font-size: 34rpx; + color: #333333; + font-weight: 600; + margin-bottom: 20rpx; + } + + .title-icon { + width: 22rpx; + height: 30rpx; + margin-right: 10rpx; + } + + .title-num { + display: flex; + } + + .body-box { + background-color: #f5f5f5; + flex: 1; + padding-left: 16rpx; + padding-right: 16rpx; + padding-top: 20rpx; + padding-bottom: 245rpx; + } + + .body-tab { + background-color: #ffffff; + border-radius: 22rpx; + height: 92rpx; + // padding-top: 22rpx; + padding-bottom: 22rpx; + margin-bottom: 24rpx; + // :deep(.uv-tabs__wrapper__nav__line) { + // bottom: 10rpx; + // } + } + + + .btn-box { + position: fixed; + bottom: 0; + height: 187rpx; + width: 100%; + display: flex; + padding-top: 37rpx; + justify-content: space-around; + background-color: #ffffff; + // background-color: red; + + :deep(.uv-button-wrapper) { + flex: 1; + + &.send_evaluate { + margin: 0 60rpx; + } + + &:not(.send_evaluate) { + margin: 0 30rpx; + } + + .uv-button { + border-radius: 14rpx; + width: 100%; + height: 92rpx; + } + } + + } + + .num-item { + display: flex; + align-items: center; + font-size: 30rpx; + margin-right: 30rpx; + color: #666666; + } + + .point { + width: 100%; + } + + .learn { + color: #1dd17a; + } + + .unlearn { + color: #666666; + } + + .c-000 { + font-weight: 600; + color: #000000; + } + \ No newline at end of file diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 28393905..1a00f719 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -56,22 +56,22 @@ 本年学习时长 - h + h 累计训练次数 - 累计考试次数 - @@ -249,6 +249,10 @@ queryCrsInfoByRecmd, } from '@/api/index.js' const scrollTop = ref(0); + const stdtTmLenRef = ref(null); + const accmPracticeCntRef = ref(null); + const accmExamCntRef = ref(null); + // 计算透明度 const opacity = computed(() => { if (scrollTop.value <= 130) return 0; @@ -281,16 +285,6 @@ const new_class_list = ref([...init_class_data]) const recommend_class_list = ref([...init_class_data]) - // const statistics_data = reactive({ - // 'stdtTmLen': 0, // 学习 - // 'accmPracticeCnt': 0, // 训练 - // 'accmExamCnt': 0, //考试 - // 'start_tudy': 0, // 起始学习 - // 'start_train': 0, // 起始训练 - // 'start_exam': 0, //起始考试 - // 'request_time': 0, //上次请求时间 - // }) - const statistics_data = reactive({ 'stdtTmLen': 0, // 学习 'accmPracticeCnt': 0, // 训练 @@ -300,38 +294,40 @@ 'startAccmExamCnt': 0, // 起始考试 'request_time': 0, // 上次请求时间 "init": function() { // 初始化统计数据 - // const index_statistics_data = common.getValue('index_statistics_data') // 获取缓存 - // if (index_statistics_data) { - // this.stdtTmLen = index_statistics_data.study; - // this.start_train = index_statistics_data.train; - // this.start_exam = index_statistics_data.exam; - // } + const index_statistics_data = common.getValue('index_statistics_data') // 获取缓存 + if (index_statistics_data) { + this.stdtTmLen = index_statistics_data.stdtTmLen; + this.accmPracticeCnt = index_statistics_data.accmPracticeCnt; + this.accmExamCnt = index_statistics_data.accmExamCnt; + } }, "get_statistics_data": async function() { try { const time_now = Date.now(); - if (time_now - this.request_time > 300 * 1000) { + if (time_now - this.request_time > 30) { this.request_time = time_now; // 获取最新数据 - const res = await queryTraStdyStatisticsSelf(); - const accmPoint = res.body.accmPoint - const accmTaskCnt = res.body.accmTaskCnt + const res = await getStatisticsData(); + common.setValue('index_statistics_data', res.body) const stdtTmLen = res.body.stdtTmLen - if (accmPoint != this.accmPoint) { // 不相等就执行 - this.startAccmPoint = this.accmPoint - this.accmPoint = accmPoint - accmPointRef.value.start() - } - if (accmTaskCnt != this.accmTaskCnt) { // 不相等就执行 - this.startAccmTaskCnt = this.accmTaskCnt - this.accmTaskCnt = accmTaskCnt - accmTaskCntRef.value.start() - } + const accmPracticeCnt = res.body.accmPracticeCnt + const accmExamCnt = res.body.accmExamCnt if (stdtTmLen != this.stdtTmLen) { // 不相等就执行 this.startStdtTmLen = this.stdtTmLen this.stdtTmLen = stdtTmLen stdtTmLenRef.value.start() } + if (accmPracticeCnt != this.accmPracticeCnt) { // 不相等就执行 + this.startAccmPracticeCnt = this.accmPracticeCnt + this.accmPracticeCnt = accmPracticeCnt + accmPracticeCntRef.value.start() + } + if (accmExamCnt != this.accmExamCnt) { // 不相等就执行 + this.startAccmExamCnt = this.accmExamCnt + this.accmExamCnt = accmExamCnt + accmExamCntRef.value.start() + } + console.log('统计数据已更新'); } else { console.log('时间没到无需更新'); @@ -342,22 +338,6 @@ } }); - - // 获取首页统计数据方法 - const get_statistics_data = async () => { - const data = await getStatisticsData() - statistics_data['accmExamCnt'] = data['accmExamCnt'] - statistics_data['accmPracticeCnt'] = data['accmPracticeCnt'] - statistics_data['stdtTmLen'] = data['stdtTmLen'] - // const time_now = Date.now() - // // 暂时设置10分钟 - // if (time_now - statistics_data['request_time'] > 600 * 1000) { - // statistics_data['request_time'] = time_now - // const data = await getStatisticsData() - - // } - } - // 进入搜索页 const goto_search_page = () => { common.navigateTo('/pages/search/search') @@ -372,7 +352,7 @@ common.navigateTo('/pages/login/login') return } - get_statistics_data() // 获取首页统计数据 + statistics_data['get_statistics_data']() // 获取统计数据 }) onMounted(async () => { queryCrsInfoByLastnew().then(res => { @@ -384,8 +364,6 @@ queryCrsInfoByRecmd().then(res => { recommend_class_list.value = res.body }) - // 预加载我的页 - }) diff --git a/src/pages/me/index.vue b/src/pages/me/index.vue index 410c5240..e34556a1 100644 --- a/src/pages/me/index.vue +++ b/src/pages/me/index.vue @@ -133,18 +133,19 @@ "init": function() { // 初始化统计数据 const me_statistics_data = common.getValue('me_statistics_data') // 获取缓存 if (me_statistics_data) { - this.stdtTmLen = me_statistics_data.study; - this.start_train = me_statistics_data.train; - this.start_exam = me_statistics_data.exam; + this.stdtTmLen = me_statistics_data.stdtTmLen; + this.accmTaskCnt = me_statistics_data.accmTaskCnt; + this.accmPoint = me_statistics_data.accmPoint; } }, "get_statistics_data": async function() { try { const time_now = Date.now(); - if (time_now - this.request_time > 300 * 1000) { + if (time_now - this.request_time > 300 ) { this.request_time = time_now; // 获取最新数据 const res = await queryTraStdyStatisticsSelf(); + common.setValue('me_statistics_data', res.body) const accmPoint = res.body.accmPoint const accmTaskCnt = res.body.accmTaskCnt const stdtTmLen = res.body.stdtTmLen @@ -183,7 +184,7 @@ onShow(() => { const user_info_cache = getUserInfo() Object.assign(user_info, user_info_cache) - statistics_data['get_statistics_data']() // 获取首页统计数据 + statistics_data['get_statistics_data']() // 获取统计数据 }) const click_loginout = () => {