feat: 接入三tab导航(首页/中奖记录/我的)、活动规则静态页、奖品详情弹窗;接口切换hnlylaw并透传authorization;缓存键统一Sft后缀;问卷ID切1005;注册增加收货地址;答题计时精确到0.01s及交互优化

This commit is contained in:
lcj
2026-10-30 09:47:31 +08:00
parent 305e22ddc5
commit ead48745c2
21 changed files with 1583 additions and 273 deletions
+27 -19
View File
@@ -10,7 +10,7 @@
<button class="retry-btn" @tap="fetchQuestions">重新加载</button>
</view>
<template v-if="questions.length > 0">
<image src="https://aliyunoss.hn12301.net/learnlaw/learn_dtbj.jpg" mode="widthFix" style="width:750rpx;"></image>
<image src="https://aliyunoss.hn12301.net/learnlaw/xfhm_dtbj.jpg" mode="scaleToFill" style="width:750rpx;height:1820rpx;"></image>
<view style="position:absolute;top:200rpx;left:0;z-index:0;padding: 30rpx;" >
<view class="quiz-header">
<view class="timer-wrap">
@@ -24,7 +24,7 @@
<view class="question-item" v-for="(q, qi) in questions" :key="q.question_id">
<view class="q-header">
<text class="q-index">{{ qi + 1 }}</text>
<text class="q-content">{{ q.question_content }}</text>
<text class="q-content">{{ formatContent(q.question_content) }}</text>
</view>
<view class="options">
<view
@@ -80,10 +80,10 @@
methods: {
fetchQuestions() {
this.loadError = ''
const userId = uni.getStorageSync('userId')
const userPhone = uni.getStorageSync('userPhone')
const userId = uni.getStorageSync('userIdSft')
const userPhone = uni.getStorageSync('userPhoneSft')
this.$u.api.queryWenjuanQA({
wenjuan_id: 1001,
wenjuan_id: 1005,
user_id: userId,
user_phone: userPhone
}).then(res => {
@@ -101,8 +101,8 @@
startTimer() {
this.startTime = Date.now()
this.timer = setInterval(() => {
this.usedSeconds = Math.floor((Date.now() - this.startTime) / 1000)
}, 1000)
this.usedSeconds = Math.round((Date.now() - this.startTime) / 10) / 100
}, 50)
},
stopTimer() {
if (this.timer) {
@@ -111,21 +111,29 @@
}
},
formatTime(sec) {
const m = Math.floor(sec / 60)
const s = sec % 60
return (m < 10 ? '0' : '') + m + ':' + (s < 10 ? '0' : '') + s
const total = Number(sec) || 0
const m = Math.floor(total / 60)
const s = total % 60
return (m < 10 ? '0' : '') + m + ':' + (s < 10 ? '0' : '') + s.toFixed(2)
},
formatContent(content) {
return (content || '').replace(/()/g, '(  )').replace(/\(\)/g, '(  )')
},
select(qId, oi) {
this.$set(this.answers, qId, oi)
},
submit() {
if (Date.now() - this.startTime < 9000) {
uni.showToast({ title: '操作繁忙,请重试', icon: 'none' })
return
}
if (this.answeredCount < this.questions.length) {
uni.showToast({ title: '还有题目未作答', icon: 'none' })
return
}
this.stopTimer()
const userId = uni.getStorageSync('userId')
const userPhone = uni.getStorageSync('userPhone')
this.usedSeconds = Math.round((Date.now() - this.startTime) / 10) / 100
const userId = uni.getStorageSync('userIdSft')
const userPhone = uni.getStorageSync('userPhoneSft')
const details = this.questions.map(q => ({
question_id: q.question_id,
user_answer: q.answerList[this.answers[q.question_id]]?.answer_content || ''
@@ -133,19 +141,20 @@
this.$u.api.submitQA({
user_id: userId,
user_phone: userPhone,
wenjuan_id: 1001,
wenjuan_id: 1005,
use_time: this.usedSeconds,
total_question_num: this.questions.length,
channel: 1,
user_answer_details: details
}).then(res => {
if (res.code === 0) {
uni.setStorageSync('resultData', {
this.stopTimer()
uni.setStorageSync('resultDataSft', {
...res.Data,
use_time: this.usedSeconds,
total_question_num: this.questions.length
})
uni.navigateTo({ url: '/pages/result/result' })
uni.redirectTo({ url: '/pages/result/result' })
} else {
uni.showToast({ title: res.msg || '提交失败', icon: 'none' })
}
@@ -159,15 +168,14 @@
<style lang="scss">
page {
background-color: #B3E9F3;
background-color: #7CC6EB;
}
.content {
position: relative;
display: flex;
flex-direction: column;
height: 100vh;
height: 100dvh;
}
.page-body {