存档点
24
App.vue
@@ -1,17 +1,19 @@
|
||||
<script>
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
}
|
||||
export default {
|
||||
onLaunch: function() {
|
||||
console.log('App Launch')
|
||||
},
|
||||
onShow: function() {
|
||||
console.log('App Show')
|
||||
},
|
||||
onHide: function() {
|
||||
console.log('App Hide')
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/*每个页面公共css */
|
||||
page {
|
||||
background-color: #f0f0f0;
|
||||
}
|
||||
</style>
|
||||
|
||||
24
config.js
@@ -1,11 +1,29 @@
|
||||
const config = {
|
||||
baseUrl: 'http://127.0.0.1:8503',
|
||||
baseUrl: getBaseUrl(),
|
||||
api: {
|
||||
login: '/gw/login',
|
||||
getQuestion: '/user/get_question',
|
||||
answerQuestion: '/user/answer_question'
|
||||
getQuestion: '/qgdzs/get_question',
|
||||
answerQuestion: '/qgdzs/answer_question',
|
||||
getAllCategory: '/qgdzs/get_all_category'
|
||||
},
|
||||
timeout: 30000
|
||||
}
|
||||
|
||||
function getBaseUrl() {
|
||||
var baseUrl = 'http://127.0.0.1:8503'
|
||||
//#ifdef MP-WEIXIN
|
||||
const accountInfo = uni.getAccountInfoSync();
|
||||
if (accountInfo.miniProgram.envVersion == 'develop') {
|
||||
baseUrl = 'http://127.0.0.1:8503'
|
||||
}
|
||||
if (accountInfo.miniProgram.envVersion == 'trial') {
|
||||
baseUrl = 'https://www.hlsq.asia/api'
|
||||
}
|
||||
if (accountInfo.miniProgram.envVersion == 'release') {
|
||||
baseUrl = 'https://www.hlsq.asia/api'
|
||||
}
|
||||
//#endif
|
||||
return baseUrl
|
||||
}
|
||||
|
||||
export default config
|
||||
|
||||
35
convert.js
Normal file
@@ -0,0 +1,35 @@
|
||||
const sharp = require('sharp');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const icons = [
|
||||
{ svg: 'static/tab-home.svg', png: 'static/tab-home.png' },
|
||||
{ svg: 'static/tab-home-active.svg', png: 'static/tab-home-active.png' },
|
||||
{ svg: 'static/tab-game.svg', png: 'static/tab-game.png' },
|
||||
{ svg: 'static/tab-game-active.svg', png: 'static/tab-game-active.png' },
|
||||
{ svg: 'static/tab-mine.svg', png: 'static/tab-mine.png' },
|
||||
{ svg: 'static/tab-mine-active.svg', png: 'static/tab-mine-active.png' }
|
||||
];
|
||||
|
||||
async function convertSvgToPng() {
|
||||
console.log('开始转换SVG到PNG...');
|
||||
|
||||
for (const icon of icons) {
|
||||
try {
|
||||
const svgBuffer = fs.readFileSync(icon.svg);
|
||||
|
||||
await sharp(svgBuffer)
|
||||
.resize(81, 81)
|
||||
.png()
|
||||
.toFile(icon.png);
|
||||
|
||||
console.log(`✓ ${icon.svg} -> ${icon.png}`);
|
||||
} catch (error) {
|
||||
console.error(`✗ 转换失败: ${icon.svg}`, error.message);
|
||||
}
|
||||
}
|
||||
|
||||
console.log('转换完成!');
|
||||
}
|
||||
|
||||
convertSvgToPng().catch(console.error);
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"name" : "qgdzs",
|
||||
"appid" : "",
|
||||
"name" : "卷王大乱斗",
|
||||
"appid" : "__UNI__3947B70",
|
||||
"description" : "",
|
||||
"versionName" : "1.0.0",
|
||||
"versionCode" : "100",
|
||||
"versionName" : "1.0.7",
|
||||
"versionCode" : 107,
|
||||
"transformPx" : false,
|
||||
/* 5+App特有相关 */
|
||||
"app-plus" : {
|
||||
@@ -50,7 +50,7 @@
|
||||
"quickapp" : {},
|
||||
/* 小程序特有相关 */
|
||||
"mp-weixin" : {
|
||||
"appid" : "",
|
||||
"appid" : "wx1b6ea981a8bafd4e",
|
||||
"setting" : {
|
||||
"urlCheck" : false
|
||||
},
|
||||
|
||||
509
package-lock.json
generated
Normal file
@@ -0,0 +1,509 @@
|
||||
{
|
||||
"name": "svg-to-png",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "svg-to-png",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"sharp": "^0.33.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@emnapi/runtime": {
|
||||
"version": "1.8.1",
|
||||
"resolved": "https://registry.npmmirror.com/@emnapi/runtime/-/runtime-1.8.1.tgz",
|
||||
"integrity": "sha512-mehfKSMWjjNol8659Z8KxEMrdSJDDot5SXMq00dM8BN4o+CLNXQ0xH2V7EchNHV4RmbZLmmPdEaXZc5H2FXmDg==",
|
||||
"license": "MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"tslib": "^2.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-darwin-arm64": {
|
||||
"version": "0.33.5",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-darwin-arm64/-/sharp-darwin-arm64-0.33.5.tgz",
|
||||
"integrity": "sha512-UT4p+iz/2H4twwAoLCqfA9UH5pI6DggwKEGuaPy7nCVQ8ZsiY5PIcrRvD1DzuY3qYL07NtIQcWnBSY/heikIFQ==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-darwin-arm64": "1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-darwin-x64": {
|
||||
"version": "0.33.5",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-darwin-x64/-/sharp-darwin-x64-0.33.5.tgz",
|
||||
"integrity": "sha512-fyHac4jIc1ANYGRDxtiqelIbdWkIuQaI84Mv45KvGRRxSAa7o7d1ZKAOBaYbnepLC1WqxfpimdeWfvqqSGwR2Q==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-darwin-x64": "1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-darwin-arm64": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-libvips-darwin-arm64/-/sharp-libvips-darwin-arm64-1.0.4.tgz",
|
||||
"integrity": "sha512-XblONe153h0O2zuFfTAbQYAX2JhYmDHeWikp1LM9Hul9gVPjFY427k6dFEcOL72O01QxQsWi761svJ/ev9xEDg==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-darwin-x64": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-libvips-darwin-x64/-/sharp-libvips-darwin-x64-1.0.4.tgz",
|
||||
"integrity": "sha512-xnGR8YuZYfJGmWPvmlunFaWJsb9T/AO2ykoP3Fz/0X5XV2aoYBPkX6xqCQvUTKKiLddarLaxpzNe+b1hjeWHAQ==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"darwin"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linux-arm": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linux-arm/-/sharp-libvips-linux-arm-1.0.5.tgz",
|
||||
"integrity": "sha512-gvcC4ACAOPRNATg/ov8/MnbxFDJqf/pDePbBnuBDcjsI8PssmjoKMAz4LtLaVi+OnSb5FK/yIOamqDwGmXW32g==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linux-arm64": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linux-arm64/-/sharp-libvips-linux-arm64-1.0.4.tgz",
|
||||
"integrity": "sha512-9B+taZ8DlyyqzZQnoeIvDVR/2F4EbMepXMc/NdVbkzsJbzkUjhXv/70GQJ7tdLA4YJgNP25zukcxpX2/SueNrA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linux-s390x": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linux-s390x/-/sharp-libvips-linux-s390x-1.0.4.tgz",
|
||||
"integrity": "sha512-u7Wz6ntiSSgGSGcjZ55im6uvTrOxSIS8/dgoVMoiGE9I6JAfU50yH5BoDlYA1tcuGS7g/QNtetJnxA6QEsCVTA==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linux-x64": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linux-x64/-/sharp-libvips-linux-x64-1.0.4.tgz",
|
||||
"integrity": "sha512-MmWmQ3iPFZr0Iev+BAgVMb3ZyC4KeFc3jFxnNbEPas60e1cIfevbtuyf9nDGIzOaW9PdnDciJm+wFFaTlj5xYw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linuxmusl-arm64": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linuxmusl-arm64/-/sharp-libvips-linuxmusl-arm64-1.0.4.tgz",
|
||||
"integrity": "sha512-9Ti+BbTYDcsbp4wfYib8Ctm1ilkugkA/uscUn6UXK1ldpC1JjiXbLfFZtRlBhjPZ5o1NCLiDbg8fhUPKStHoTA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-libvips-linuxmusl-x64": {
|
||||
"version": "1.0.4",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-libvips-linuxmusl-x64/-/sharp-libvips-linuxmusl-x64-1.0.4.tgz",
|
||||
"integrity": "sha512-viYN1KX9m+/hGkJtvYYp+CCLgnJXwiQB39damAO7WMdKWlIhmYTfHjwSbQeUK/20vY154mwezd9HflVFM1wVSw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linux-arm": {
|
||||
"version": "0.33.5",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-linux-arm/-/sharp-linux-arm-0.33.5.tgz",
|
||||
"integrity": "sha512-JTS1eldqZbJxjvKaAkxhZmBqPRGmxgu+qFKSInv8moZ2AmT5Yib3EQ1c6gp493HvrvV8QgdOXdyaIBrhvFhBMQ==",
|
||||
"cpu": [
|
||||
"arm"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linux-arm": "1.0.5"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linux-arm64": {
|
||||
"version": "0.33.5",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-linux-arm64/-/sharp-linux-arm64-0.33.5.tgz",
|
||||
"integrity": "sha512-JMVv+AMRyGOHtO1RFBiJy/MBsgz0x4AWrT6QoEVVTyh1E39TrCUpTRI7mx9VksGX4awWASxqCYLCV4wBZHAYxA==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linux-arm64": "1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linux-s390x": {
|
||||
"version": "0.33.5",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-linux-s390x/-/sharp-linux-s390x-0.33.5.tgz",
|
||||
"integrity": "sha512-y/5PCd+mP4CA/sPDKl2961b+C9d+vPAveS33s6Z3zfASk2j5upL6fXVPZi7ztePZ5CuH+1kW8JtvxgbuXHRa4Q==",
|
||||
"cpu": [
|
||||
"s390x"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linux-s390x": "1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linux-x64": {
|
||||
"version": "0.33.5",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-linux-x64/-/sharp-linux-x64-0.33.5.tgz",
|
||||
"integrity": "sha512-opC+Ok5pRNAzuvq1AG0ar+1owsu842/Ab+4qvU879ippJBHvyY5n2mxF1izXqkPYlGuP/M556uh53jRLJmzTWA==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linux-x64": "1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linuxmusl-arm64": {
|
||||
"version": "0.33.5",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-linuxmusl-arm64/-/sharp-linuxmusl-arm64-0.33.5.tgz",
|
||||
"integrity": "sha512-XrHMZwGQGvJg2V/oRSUfSAfjfPxO+4DkiRh6p2AFjLQztWUuY/o8Mq0eMQVIY7HJ1CDQUJlxGGZRw1a5bqmd1g==",
|
||||
"cpu": [
|
||||
"arm64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linuxmusl-arm64": "1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-linuxmusl-x64": {
|
||||
"version": "0.33.5",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-linuxmusl-x64/-/sharp-linuxmusl-x64-0.33.5.tgz",
|
||||
"integrity": "sha512-WT+d/cgqKkkKySYmqoZ8y3pxx7lx9vVejxW/W4DOFMYVSkErR+w7mf2u8m/y4+xHe7yY9DAXQMWQhpnMuFfScw==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"linux"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-libvips-linuxmusl-x64": "1.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-wasm32": {
|
||||
"version": "0.33.5",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-wasm32/-/sharp-wasm32-0.33.5.tgz",
|
||||
"integrity": "sha512-ykUW4LVGaMcU9lu9thv85CbRMAwfeadCJHRsg2GmeRa/cJxsVY9Rbd57JcMxBkKHag5U/x7TSBpScF4U8ElVzg==",
|
||||
"cpu": [
|
||||
"wasm32"
|
||||
],
|
||||
"license": "Apache-2.0 AND LGPL-3.0-or-later AND MIT",
|
||||
"optional": true,
|
||||
"dependencies": {
|
||||
"@emnapi/runtime": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-win32-ia32": {
|
||||
"version": "0.33.5",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-win32-ia32/-/sharp-win32-ia32-0.33.5.tgz",
|
||||
"integrity": "sha512-T36PblLaTwuVJ/zw/LaH0PdZkRz5rd3SmMHX8GSmR7vtNSP5Z6bQkExdSK7xGWyxLw4sUknBuugTelgw2faBbQ==",
|
||||
"cpu": [
|
||||
"ia32"
|
||||
],
|
||||
"license": "Apache-2.0 AND LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/@img/sharp-win32-x64": {
|
||||
"version": "0.33.5",
|
||||
"resolved": "https://registry.npmmirror.com/@img/sharp-win32-x64/-/sharp-win32-x64-0.33.5.tgz",
|
||||
"integrity": "sha512-MpY/o8/8kj+EcnxwvrP4aTJSWw/aZ7JIGR4aBeZkZw5B7/Jn+tY9/VNwtcoGmdT7GfggGIU4kygOMSbYnOrAbg==",
|
||||
"cpu": [
|
||||
"x64"
|
||||
],
|
||||
"license": "Apache-2.0 AND LGPL-3.0-or-later",
|
||||
"optional": true,
|
||||
"os": [
|
||||
"win32"
|
||||
],
|
||||
"engines": {
|
||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
}
|
||||
},
|
||||
"node_modules/color": {
|
||||
"version": "4.2.3",
|
||||
"resolved": "https://registry.npmmirror.com/color/-/color-4.2.3.tgz",
|
||||
"integrity": "sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1",
|
||||
"color-string": "^1.9.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=12.5.0"
|
||||
}
|
||||
},
|
||||
"node_modules/color-convert": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-name": "~1.1.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/color-name": {
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmmirror.com/color-name/-/color-name-1.1.4.tgz",
|
||||
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/color-string": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmmirror.com/color-string/-/color-string-1.9.1.tgz",
|
||||
"integrity": "sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-name": "^1.0.0",
|
||||
"simple-swizzle": "^0.2.2"
|
||||
}
|
||||
},
|
||||
"node_modules/detect-libc": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmmirror.com/detect-libc/-/detect-libc-2.1.2.tgz",
|
||||
"integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==",
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/is-arrayish": {
|
||||
"version": "0.3.4",
|
||||
"resolved": "https://registry.npmmirror.com/is-arrayish/-/is-arrayish-0.3.4.tgz",
|
||||
"integrity": "sha512-m6UrgzFVUYawGBh1dUsWR5M2Clqic9RVXC/9f8ceNlv2IcO9j9J/z8UoCLPqtsPBFNzEpfR3xftohbfqDx8EQA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/semver": {
|
||||
"version": "7.7.3",
|
||||
"resolved": "https://registry.npmmirror.com/semver/-/semver-7.7.3.tgz",
|
||||
"integrity": "sha512-SdsKMrI9TdgjdweUSR9MweHA4EJ8YxHn8DFaDisvhVlUOe4BF1tLD7GAj0lIqWVl+dPb/rExr0Btby5loQm20Q==",
|
||||
"license": "ISC",
|
||||
"bin": {
|
||||
"semver": "bin/semver.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
}
|
||||
},
|
||||
"node_modules/sharp": {
|
||||
"version": "0.33.5",
|
||||
"resolved": "https://registry.npmmirror.com/sharp/-/sharp-0.33.5.tgz",
|
||||
"integrity": "sha512-haPVm1EkS9pgvHrQ/F3Xy+hgcuMV0Wm9vfIBSiwZ05k+xgb0PkBQpGsAA/oWdDobNaZTH5ppvHtzCFbnSEwHVw==",
|
||||
"hasInstallScript": true,
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"color": "^4.2.3",
|
||||
"detect-libc": "^2.0.3",
|
||||
"semver": "^7.6.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^18.17.0 || ^20.3.0 || >=21.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/libvips"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@img/sharp-darwin-arm64": "0.33.5",
|
||||
"@img/sharp-darwin-x64": "0.33.5",
|
||||
"@img/sharp-libvips-darwin-arm64": "1.0.4",
|
||||
"@img/sharp-libvips-darwin-x64": "1.0.4",
|
||||
"@img/sharp-libvips-linux-arm": "1.0.5",
|
||||
"@img/sharp-libvips-linux-arm64": "1.0.4",
|
||||
"@img/sharp-libvips-linux-s390x": "1.0.4",
|
||||
"@img/sharp-libvips-linux-x64": "1.0.4",
|
||||
"@img/sharp-libvips-linuxmusl-arm64": "1.0.4",
|
||||
"@img/sharp-libvips-linuxmusl-x64": "1.0.4",
|
||||
"@img/sharp-linux-arm": "0.33.5",
|
||||
"@img/sharp-linux-arm64": "0.33.5",
|
||||
"@img/sharp-linux-s390x": "0.33.5",
|
||||
"@img/sharp-linux-x64": "0.33.5",
|
||||
"@img/sharp-linuxmusl-arm64": "0.33.5",
|
||||
"@img/sharp-linuxmusl-x64": "0.33.5",
|
||||
"@img/sharp-wasm32": "0.33.5",
|
||||
"@img/sharp-win32-ia32": "0.33.5",
|
||||
"@img/sharp-win32-x64": "0.33.5"
|
||||
}
|
||||
},
|
||||
"node_modules/simple-swizzle": {
|
||||
"version": "0.2.4",
|
||||
"resolved": "https://registry.npmmirror.com/simple-swizzle/-/simple-swizzle-0.2.4.tgz",
|
||||
"integrity": "sha512-nAu1WFPQSMNr2Zn9PGSZK9AGn4t/y97lEm+MXTtUDwfP0ksAIX4nO+6ruD9Jwut4C49SB1Ws+fbXsm/yScWOHw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-arrayish": "^0.3.1"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmmirror.com/tslib/-/tslib-2.8.1.tgz",
|
||||
"integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==",
|
||||
"license": "0BSD",
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
}
|
||||
7
package.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "svg-to-png",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"sharp": "^0.33.0"
|
||||
}
|
||||
}
|
||||
50
pages.json
@@ -18,31 +18,67 @@
|
||||
"navigationBarTitleText": "登录",
|
||||
"navigationStyle": "custom"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/gameplay/gameplay",
|
||||
"style": {
|
||||
"navigationBarTitleText": "玩法选择"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/random/random",
|
||||
"style": {
|
||||
"navigationBarTitleText": "随机答题"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/category/category",
|
||||
"style": {
|
||||
"navigationBarTitleText": "类目答题"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/category-question/category-question",
|
||||
"style": {
|
||||
"navigationBarTitleText": "类目题目"
|
||||
}
|
||||
},
|
||||
{
|
||||
"path": "pages/quick/quick",
|
||||
"style": {
|
||||
"navigationBarTitleText": "快速答题"
|
||||
}
|
||||
}
|
||||
],
|
||||
"globalStyle": {
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationBarTitleText": "qgdzs",
|
||||
"navigationBarBackgroundColor": "#F8F8F8",
|
||||
"backgroundColor": "#F8F8F8"
|
||||
"backgroundColor": "#f0f0f0"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#7A7E83",
|
||||
"selectedColor": "#667eea",
|
||||
"borderStyle": "black",
|
||||
"backgroundColor": "#ffffff",
|
||||
"fontSize": "14px",
|
||||
"backgroundColor": "#f5f5f5",
|
||||
"fontSize": "15px",
|
||||
"list": [
|
||||
{
|
||||
"pagePath": "pages/index/index",
|
||||
"iconPath": "",
|
||||
"selectedIconPath": "",
|
||||
"iconPath": "static/tab-home.png",
|
||||
"selectedIconPath": "static/tab-home-active.png",
|
||||
"text": "首页"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/gameplay/gameplay",
|
||||
"iconPath": "static/tab-game.png",
|
||||
"selectedIconPath": "static/tab-game-active.png",
|
||||
"text": "玩法选择"
|
||||
},
|
||||
{
|
||||
"pagePath": "pages/mine/mine",
|
||||
"iconPath": "",
|
||||
"selectedIconPath": "",
|
||||
"iconPath": "static/tab-mine.png",
|
||||
"selectedIconPath": "static/tab-mine-active.png",
|
||||
"text": "我的"
|
||||
}
|
||||
]
|
||||
|
||||
373
pages/category-question/category-question.vue
Normal file
@@ -0,0 +1,373 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view v-if="question" class="question-card">
|
||||
<view class="question-header">
|
||||
<text class="question-title">题目</text>
|
||||
<view class="question-meta">
|
||||
<view class="meta-tag category-tag">
|
||||
<text class="meta-text">{{ getCategoryText(question.category) }}</text>
|
||||
</view>
|
||||
<view class="meta-tag difficulty-tag" :class="getDifficultyClass(question.difficulty)">
|
||||
<text class="meta-text">{{ getDifficultyText(question.difficulty) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="question-content">
|
||||
<text class="question-text">{{ question.question }}</text>
|
||||
</view>
|
||||
<view v-if="question.options" class="options-list">
|
||||
<view
|
||||
v-for="(option, index) in question.options"
|
||||
:key="index"
|
||||
class="option-item"
|
||||
:class="{
|
||||
'correct': answered && correctAnswer === String.fromCharCode(65 + index),
|
||||
'wrong': answered && selectedAnswer === String.fromCharCode(65 + index) && correctAnswer !== String.fromCharCode(65 + index)
|
||||
}"
|
||||
@click="handleAnswer(option, index)"
|
||||
>
|
||||
<text class="option-text">{{ option }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="answered && explanation" class="explanation">
|
||||
<view class="explanation-title">解析</view>
|
||||
<text class="explanation-text">{{ explanation }}</text>
|
||||
</view>
|
||||
<view class="action-buttons">
|
||||
<button class="next-btn" @click="refreshQuestion">下一题</button>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="empty-state">
|
||||
<text class="empty-text">暂无题目</text>
|
||||
<button class="refresh-btn" @click="refreshQuestion">刷新</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import storage from '../../utils/storage.js'
|
||||
import api from '../../utils/api.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
categorySn: '',
|
||||
categoryName: '',
|
||||
question: null,
|
||||
answered: false,
|
||||
correctAnswer: '',
|
||||
selectedAnswer: '',
|
||||
explanation: ''
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
this.categorySn = options.categorySn || ''
|
||||
this.categoryName = options.categoryName || ''
|
||||
this.refreshQuestion()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
if (this.question) {
|
||||
this.checkAnsweredQuestion()
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
loadQuestion() {
|
||||
const question = storage.getQuestion()
|
||||
if (question) {
|
||||
this.question = question
|
||||
this.resetAnswer()
|
||||
}
|
||||
},
|
||||
|
||||
checkAnsweredQuestion() {
|
||||
if (this.question && storage.isQuestionAnswered(this.question.sn)) {
|
||||
this.refreshQuestion()
|
||||
}
|
||||
},
|
||||
|
||||
resetAnswer() {
|
||||
this.answered = false
|
||||
this.correctAnswer = ''
|
||||
this.selectedAnswer = ''
|
||||
this.explanation = ''
|
||||
},
|
||||
|
||||
getCategoryText(category) {
|
||||
return category || '其他'
|
||||
},
|
||||
|
||||
getDifficultyText(difficulty) {
|
||||
if (!difficulty && difficulty !== 0) return '简单'
|
||||
if (difficulty <= 30) return '简单'
|
||||
if (difficulty <= 60) return '中等'
|
||||
if (difficulty <= 80) return '困难'
|
||||
return '极难'
|
||||
},
|
||||
|
||||
getDifficultyClass(difficulty) {
|
||||
if (!difficulty && difficulty !== 0) return 'difficulty-easy'
|
||||
if (difficulty <= 30) return 'difficulty-easy'
|
||||
if (difficulty <= 60) return 'difficulty-medium'
|
||||
if (difficulty <= 80) return 'difficulty-hard'
|
||||
return 'difficulty-extreme'
|
||||
},
|
||||
|
||||
async handleAnswer(option, index) {
|
||||
if (this.answered) return
|
||||
|
||||
const answer = String.fromCharCode(65 + index)
|
||||
this.selectedAnswer = answer
|
||||
|
||||
try {
|
||||
const res = await api.answerQuestion(this.question.sn, answer)
|
||||
if (res.data) {
|
||||
this.answered = true
|
||||
this.correctAnswer = res.data.answer || answer
|
||||
this.explanation = res.data.explanation || ''
|
||||
|
||||
storage.addAnsweredQuestion(this.question.sn)
|
||||
|
||||
if (this.correctAnswer === answer) {
|
||||
uni.showToast({
|
||||
title: '回答正确',
|
||||
icon: 'success'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '回答错误',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提交答案失败:', error)
|
||||
uni.showToast({
|
||||
title: '提交失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async refreshQuestion() {
|
||||
try {
|
||||
const res = await api.getQuestion(this.categorySn)
|
||||
if (res.data) {
|
||||
if (storage.isQuestionAnswered(res.data.sn)) {
|
||||
this.refreshQuestion()
|
||||
return
|
||||
}
|
||||
storage.setQuestion(res.data)
|
||||
this.question = res.data
|
||||
this.resetAnswer()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '暂无题目',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取题目失败:', error)
|
||||
uni.showToast({
|
||||
title: '刷新失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
padding: 40rpx;
|
||||
}
|
||||
|
||||
.question-card {
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
padding: 40rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.question-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 30rpx;
|
||||
padding-bottom: 20rpx;
|
||||
border-bottom: 2rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.question-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.question-meta {
|
||||
display: flex;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.meta-tag {
|
||||
padding: 8rpx 20rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.category-tag {
|
||||
background: #e3f2fd;
|
||||
}
|
||||
|
||||
.difficulty-tag {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.difficulty-easy {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.difficulty-medium {
|
||||
background: #fff3cd;
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.difficulty-hard {
|
||||
background: #fd7e14;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.difficulty-extreme {
|
||||
background: #dc3545;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.meta-text {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.question-content {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.question-text {
|
||||
font-size: 30rpx;
|
||||
color: #666;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.options-list {
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
|
||||
.option-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 24rpx 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
background: #f8f9fa;
|
||||
border-radius: 12rpx;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.option-item:active {
|
||||
background: #e9ecef;
|
||||
}
|
||||
|
||||
.option-item.correct {
|
||||
background: #d4edda;
|
||||
border: 2rpx solid #28a745;
|
||||
}
|
||||
|
||||
.option-item.wrong {
|
||||
background: #f8d7da;
|
||||
border: 2rpx solid #dc3545;
|
||||
}
|
||||
|
||||
.option-label {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #667eea;
|
||||
margin-right: 20rpx;
|
||||
min-width: 40rpx;
|
||||
}
|
||||
|
||||
.option-item.correct .option-label {
|
||||
color: #28a745;
|
||||
}
|
||||
|
||||
.option-item.wrong .option-label {
|
||||
color: #dc3545;
|
||||
}
|
||||
|
||||
.option-text {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.explanation {
|
||||
margin-top: 40rpx;
|
||||
padding: 30rpx;
|
||||
background: #fff3cd;
|
||||
border-radius: 12rpx;
|
||||
border-left: 4rpx solid #ffc107;
|
||||
}
|
||||
|
||||
.explanation-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #856404;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.explanation-text {
|
||||
font-size: 28rpx;
|
||||
color: #856404;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
margin-top: 40rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.next-btn {
|
||||
width: 200rpx;
|
||||
height: 70rpx;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
border-radius: 35rpx;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 60vh;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 32rpx;
|
||||
color: #999;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.refresh-btn {
|
||||
width: 200rpx;
|
||||
height: 70rpx;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
border-radius: 35rpx;
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
162
pages/category/category.vue
Normal file
@@ -0,0 +1,162 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view v-if="loading" class="loading">
|
||||
<text class="loading-text">加载中...</text>
|
||||
</view>
|
||||
<view v-else-if="categories.length > 0" class="category-list">
|
||||
<view
|
||||
v-for="item in categories"
|
||||
:key="item.sn"
|
||||
class="category-item"
|
||||
@click="handleCategory(item)"
|
||||
>
|
||||
<view class="category-icon">{{ getCategoryIcon(item.category) }}</view>
|
||||
<text class="category-name">{{ item.category }}</text>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="empty-state">
|
||||
<text class="empty-text">暂无类目</text>
|
||||
<button class="refresh-btn" @click="loadCategories">刷新</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import api from '../../utils/api.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
categories: [],
|
||||
loading: false
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadCategories()
|
||||
},
|
||||
|
||||
methods: {
|
||||
async loadCategories() {
|
||||
this.loading = true
|
||||
try {
|
||||
const res = await api.getAllCategory()
|
||||
if (res.data && res.data.categories) {
|
||||
this.categories = res.data.categories
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取类目列表失败:', error)
|
||||
uni.showToast({
|
||||
title: '获取类目失败',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
},
|
||||
|
||||
getCategoryIcon(category) {
|
||||
const iconMap = {
|
||||
'传统文化': '🏮',
|
||||
'动物世界': '🦁',
|
||||
'地理自然': '🌍',
|
||||
'文学历史': '📜',
|
||||
'文学成语': '📖',
|
||||
'生活常识': '🏠',
|
||||
'科技常识': '🔬',
|
||||
'美食文化': '🍜',
|
||||
'自然科学': '🧬'
|
||||
}
|
||||
return iconMap[category] || '📚'
|
||||
},
|
||||
|
||||
handleCategory(item) {
|
||||
uni.navigateTo({
|
||||
url: `/pages/category-question/category-question?categorySn=${item.sn}&categoryName=${item.category}`
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
padding: 40rpx;
|
||||
}
|
||||
|
||||
.loading {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
min-height: 60vh;
|
||||
}
|
||||
|
||||
.loading-text {
|
||||
font-size: 32rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.category-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 30rpx;
|
||||
}
|
||||
|
||||
.category-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
padding: 40rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.category-item:active {
|
||||
transform: scale(0.98);
|
||||
box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
|
||||
.category-icon {
|
||||
font-size: 60rpx;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.category-name {
|
||||
flex: 1;
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
font-size: 50rpx;
|
||||
color: #ccc;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 60vh;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 32rpx;
|
||||
color: #999;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.refresh-btn {
|
||||
width: 200rpx;
|
||||
height: 70rpx;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
border-radius: 35rpx;
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
190
pages/gameplay/gameplay.vue
Normal file
@@ -0,0 +1,190 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="header">
|
||||
<view class="welcome">
|
||||
<text class="welcome-title">欢迎来到答题挑战</text>
|
||||
<text class="welcome-subtitle">多种玩法,等你来挑战</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="gameplay-list">
|
||||
<view class="gameplay-item" @click="handleRandom">
|
||||
<view class="gameplay-icon random-icon">🎲</view>
|
||||
<view class="gameplay-info">
|
||||
<text class="gameplay-title">随机答题</text>
|
||||
<text class="gameplay-desc">随机抽取题目,自由挑战</text>
|
||||
</view>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
|
||||
<view class="gameplay-item" @click="handleCategory">
|
||||
<view class="gameplay-icon category-icon">📚</view>
|
||||
<view class="gameplay-info">
|
||||
<text class="gameplay-title">类目答题</text>
|
||||
<text class="gameplay-desc">按类目分类,系统学习</text>
|
||||
</view>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
|
||||
<view class="gameplay-item" @click="handleQuick">
|
||||
<view class="gameplay-icon quick-icon">⚡</view>
|
||||
<view class="gameplay-info">
|
||||
<text class="gameplay-title">快速答题</text>
|
||||
<text class="gameplay-desc">限时挑战,速度比拼</text>
|
||||
</view>
|
||||
<text class="arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="tips">
|
||||
<view class="tip-item">
|
||||
<text class="tip-icon">💡</text>
|
||||
<text class="tip-text">每日坚持答题,提升知识储备</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
methods: {
|
||||
handleRandom() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/random/random'
|
||||
})
|
||||
},
|
||||
|
||||
handleCategory() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/category/category'
|
||||
})
|
||||
},
|
||||
|
||||
handleQuick() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/quick/quick'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
padding: 40rpx;
|
||||
}
|
||||
|
||||
.header {
|
||||
margin-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.welcome {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.welcome-title {
|
||||
display: block;
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
color: #ffffff;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.welcome-subtitle {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.gameplay-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 30rpx;
|
||||
}
|
||||
|
||||
.gameplay-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: #ffffff;
|
||||
border-radius: 24rpx;
|
||||
padding: 40rpx;
|
||||
box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.15);
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.gameplay-item:active {
|
||||
transform: scale(0.98);
|
||||
box-shadow: 0 4rpx 15rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.gameplay-icon {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-size: 50rpx;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.random-icon {
|
||||
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
|
||||
}
|
||||
|
||||
.category-icon {
|
||||
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
|
||||
}
|
||||
|
||||
.quick-icon {
|
||||
background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
|
||||
}
|
||||
|
||||
.gameplay-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.gameplay-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.gameplay-desc {
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.arrow {
|
||||
font-size: 50rpx;
|
||||
color: #ccc;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tips {
|
||||
margin-top: 60rpx;
|
||||
}
|
||||
|
||||
.tip-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.tip-icon {
|
||||
font-size: 36rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.tip-text {
|
||||
font-size: 28rpx;
|
||||
color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
@@ -1,147 +1,74 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view v-if="question" class="question-card">
|
||||
<view class="question-header">
|
||||
<text class="question-title">题目</text>
|
||||
</view>
|
||||
<view class="question-content">
|
||||
<text class="question-text">{{ question.question }}</text>
|
||||
</view>
|
||||
<view v-if="question.options" class="options-list">
|
||||
<view
|
||||
v-for="(option, index) in question.options"
|
||||
:key="index"
|
||||
class="option-item"
|
||||
:class="{
|
||||
'correct': answered && correctAnswer === String.fromCharCode(65 + index),
|
||||
'wrong': answered && selectedAnswer === String.fromCharCode(65 + index) && correctAnswer !== String.fromCharCode(65 + index)
|
||||
}"
|
||||
@click="handleAnswer(option, index)"
|
||||
>
|
||||
<text class="option-text">{{ option }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="answered && explanation" class="explanation">
|
||||
<view class="explanation-title">解析</view>
|
||||
<text class="explanation-text">{{ explanation }}</text>
|
||||
</view>
|
||||
<view class="action-buttons">
|
||||
<button class="next-btn" @click="refreshQuestion">下一题</button>
|
||||
<view class="header">
|
||||
<view class="welcome">
|
||||
<text class="welcome-title">欢迎来到答题挑战</text>
|
||||
<text class="welcome-subtitle">多种玩法,等你来挑战</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="empty-state">
|
||||
<text class="empty-text">暂无题目</text>
|
||||
<button class="refresh-btn" @click="refreshQuestion">刷新</button>
|
||||
|
||||
<view class="game-modes">
|
||||
<view class="mode-card" @click="goToRandom">
|
||||
<view class="mode-icon random-icon">🎲</view>
|
||||
<view class="mode-info">
|
||||
<text class="mode-title">随机答题</text>
|
||||
<text class="mode-desc">随机抽取题目,自由挑战</text>
|
||||
</view>
|
||||
<text class="mode-arrow">›</text>
|
||||
</view>
|
||||
|
||||
<view class="mode-card" @click="goToCategory">
|
||||
<view class="mode-icon category-icon">📚</view>
|
||||
<view class="mode-info">
|
||||
<text class="mode-title">类目答题</text>
|
||||
<text class="mode-desc">按类目分类,系统学习</text>
|
||||
</view>
|
||||
<text class="mode-arrow">›</text>
|
||||
</view>
|
||||
|
||||
<view class="mode-card" @click="goToQuick">
|
||||
<view class="mode-icon quick-icon">⚡</view>
|
||||
<view class="mode-info">
|
||||
<text class="mode-title">快速答题</text>
|
||||
<text class="mode-desc">限时挑战,速度比拼</text>
|
||||
</view>
|
||||
<text class="mode-arrow">›</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="tips">
|
||||
<view class="tip-item">
|
||||
<text class="tip-icon">💡</text>
|
||||
<text class="tip-text">每日坚持答题,提升知识储备</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import storage from '../../utils/storage.js'
|
||||
import api from '../../utils/api.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
question: null,
|
||||
answered: false,
|
||||
correctAnswer: '',
|
||||
selectedAnswer: '',
|
||||
explanation: ''
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadQuestion()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadQuestion()
|
||||
this.checkAnsweredQuestion()
|
||||
},
|
||||
|
||||
methods: {
|
||||
loadQuestion() {
|
||||
const question = storage.getQuestion()
|
||||
if (question) {
|
||||
this.question = question
|
||||
this.resetAnswer()
|
||||
}
|
||||
goToRandom() {
|
||||
uni.switchTab({
|
||||
url: '/pages/random/random'
|
||||
})
|
||||
},
|
||||
|
||||
checkAnsweredQuestion() {
|
||||
if (this.question && storage.isQuestionAnswered(this.question.sn)) {
|
||||
this.refreshQuestion()
|
||||
}
|
||||
goToCategory() {
|
||||
uni.switchTab({
|
||||
url: '/pages/category/category'
|
||||
})
|
||||
},
|
||||
|
||||
resetAnswer() {
|
||||
this.answered = false
|
||||
this.correctAnswer = ''
|
||||
this.selectedAnswer = ''
|
||||
this.explanation = ''
|
||||
},
|
||||
|
||||
async handleAnswer(option, index) {
|
||||
if (this.answered) return
|
||||
|
||||
const answer = String.fromCharCode(65 + index)
|
||||
this.selectedAnswer = answer
|
||||
|
||||
try {
|
||||
const res = await api.answerQuestion(this.question.sn, answer)
|
||||
if (res.data) {
|
||||
this.answered = true
|
||||
this.correctAnswer = res.data.answer || answer
|
||||
this.explanation = res.data.explanation || ''
|
||||
|
||||
storage.addAnsweredQuestion(this.question.sn)
|
||||
|
||||
if (this.correctAnswer === answer) {
|
||||
uni.showToast({
|
||||
title: '回答正确',
|
||||
icon: 'success'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '回答错误',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提交答案失败:', error)
|
||||
uni.showToast({
|
||||
title: '提交失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async refreshQuestion() {
|
||||
try {
|
||||
const res = await api.getQuestion()
|
||||
if (res.data) {
|
||||
if (storage.isQuestionAnswered(res.data.sn)) {
|
||||
this.refreshQuestion()
|
||||
return
|
||||
}
|
||||
storage.setQuestion(res.data)
|
||||
this.question = res.data
|
||||
this.resetAnswer()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '暂无题目',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取题目失败:', error)
|
||||
uni.showToast({
|
||||
title: '刷新失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
goToQuick() {
|
||||
uni.switchTab({
|
||||
url: '/pages/quick/quick'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -150,147 +77,119 @@ export default {
|
||||
<style scoped>
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
padding: 40rpx;
|
||||
}
|
||||
|
||||
.question-card {
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
padding: 40rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
|
||||
.header {
|
||||
margin-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.question-header {
|
||||
margin-bottom: 30rpx;
|
||||
padding-bottom: 20rpx;
|
||||
border-bottom: 2rpx solid #f0f0f0;
|
||||
.welcome {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.question-title {
|
||||
font-size: 32rpx;
|
||||
.welcome-title {
|
||||
display: block;
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
color: #ffffff;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
|
||||
.question-content {
|
||||
margin-bottom: 40rpx;
|
||||
.welcome-subtitle {
|
||||
display: block;
|
||||
font-size: 28rpx;
|
||||
color: rgba(255, 255, 255, 0.9);
|
||||
}
|
||||
|
||||
.question-text {
|
||||
font-size: 30rpx;
|
||||
color: #666;
|
||||
line-height: 1.8;
|
||||
.game-modes {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 30rpx;
|
||||
}
|
||||
|
||||
.options-list {
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
|
||||
.option-item {
|
||||
.mode-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 24rpx 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
background: #f8f9fa;
|
||||
border-radius: 12rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 24rpx;
|
||||
padding: 40rpx;
|
||||
box-shadow: 0 8rpx 30rpx rgba(0, 0, 0, 0.15);
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.option-item:active {
|
||||
background: #e9ecef;
|
||||
.mode-card:active {
|
||||
transform: scale(0.98);
|
||||
box-shadow: 0 4rpx 15rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.option-item.correct {
|
||||
background: #d4edda;
|
||||
border: 2rpx solid #28a745;
|
||||
}
|
||||
|
||||
.option-item.wrong {
|
||||
background: #f8d7da;
|
||||
border: 2rpx solid #dc3545;
|
||||
}
|
||||
|
||||
.option-label {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #667eea;
|
||||
margin-right: 20rpx;
|
||||
min-width: 40rpx;
|
||||
}
|
||||
|
||||
.option-item.correct .option-label {
|
||||
color: #28a745;
|
||||
}
|
||||
|
||||
.option-item.wrong .option-label {
|
||||
color: #dc3545;
|
||||
}
|
||||
|
||||
.option-text {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.explanation {
|
||||
margin-top: 40rpx;
|
||||
padding: 30rpx;
|
||||
background: #fff3cd;
|
||||
border-radius: 12rpx;
|
||||
border-left: 4rpx solid #ffc107;
|
||||
}
|
||||
|
||||
.explanation-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #856404;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.explanation-text {
|
||||
font-size: 28rpx;
|
||||
color: #856404;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
margin-top: 40rpx;
|
||||
.mode-icon {
|
||||
width: 100rpx;
|
||||
height: 100rpx;
|
||||
border-radius: 20rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.next-btn {
|
||||
width: 200rpx;
|
||||
height: 70rpx;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
border-radius: 35rpx;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 60vh;
|
||||
font-size: 50rpx;
|
||||
margin-right: 30rpx;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
.random-icon {
|
||||
background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
|
||||
}
|
||||
|
||||
.category-icon {
|
||||
background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
|
||||
}
|
||||
|
||||
.quick-icon {
|
||||
background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);
|
||||
}
|
||||
|
||||
.mode-info {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.mode-title {
|
||||
font-size: 32rpx;
|
||||
color: #999;
|
||||
margin-bottom: 40rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.refresh-btn {
|
||||
width: 200rpx;
|
||||
height: 70rpx;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #ffffff;
|
||||
.mode-desc {
|
||||
font-size: 26rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.mode-arrow {
|
||||
font-size: 50rpx;
|
||||
color: #ccc;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.tips {
|
||||
margin-top: 60rpx;
|
||||
}
|
||||
|
||||
.tip-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
border-radius: 16rpx;
|
||||
padding: 30rpx;
|
||||
}
|
||||
|
||||
.tip-icon {
|
||||
font-size: 36rpx;
|
||||
margin-right: 20rpx;
|
||||
}
|
||||
|
||||
.tip-text {
|
||||
font-size: 28rpx;
|
||||
border-radius: 35rpx;
|
||||
border: none;
|
||||
color: #ffffff;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,38 +1,30 @@
|
||||
<template>
|
||||
<view class="login-container">
|
||||
<view class="login-box">
|
||||
<view class="title">欢迎登录</view>
|
||||
|
||||
<view class="form-item">
|
||||
<view class="label">手机号</view>
|
||||
<input
|
||||
class="input"
|
||||
type="number"
|
||||
v-model="phone"
|
||||
placeholder="请输入手机号"
|
||||
maxlength="11"
|
||||
/>
|
||||
</view>
|
||||
|
||||
<view class="form-item">
|
||||
<view class="label">验证码</view>
|
||||
<input
|
||||
class="input"
|
||||
type="number"
|
||||
v-model="code"
|
||||
placeholder="请输入验证码"
|
||||
maxlength="6"
|
||||
/>
|
||||
<view class="logo-section">
|
||||
<image class="logo" src="/static/logo.png" mode="aspectFit"></image>
|
||||
<view class="app-name">趣味答题</view>
|
||||
<view class="app-desc">海量题库,轻松学习</view>
|
||||
</view>
|
||||
|
||||
<button
|
||||
class="login-btn"
|
||||
class="wx-login-btn"
|
||||
:class="{ 'disabled': isLoading }"
|
||||
:disabled="isLoading"
|
||||
@click="handleLogin"
|
||||
open-type="getUserInfo"
|
||||
@getuserinfo="handleWxLogin"
|
||||
>
|
||||
{{ isLoading ? '登录中...' : '登录' }}
|
||||
<text class="wx-icon">👤</text>
|
||||
<text>{{ isLoading ? '登录中...' : '微信一键登录' }}</text>
|
||||
</button>
|
||||
|
||||
<view class="skip-btn" @click="handleSkip">
|
||||
<text>暂不登录</text>
|
||||
</view>
|
||||
|
||||
<view class="tips">
|
||||
登录即表示同意《用户协议》和《隐私政策》
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
@@ -44,82 +36,149 @@ import storage from '../../utils/storage.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
phone: '',
|
||||
code: '',
|
||||
isLoading: false
|
||||
isLoading: false,
|
||||
redirectUrl: ''
|
||||
}
|
||||
},
|
||||
|
||||
onLoad(options) {
|
||||
if (options.redirect) {
|
||||
this.redirectUrl = decodeURIComponent(options.redirect)
|
||||
}
|
||||
},
|
||||
|
||||
methods: {
|
||||
async handleLogin() {
|
||||
if (!this.phone) {
|
||||
uni.showToast({
|
||||
title: '请输入手机号',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!/^1[3-9]\d{9}$/.test(this.phone)) {
|
||||
uni.showToast({
|
||||
title: '手机号格式不正确',
|
||||
icon: 'none'
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!this.code) {
|
||||
uni.showToast({
|
||||
title: '请输入验证码',
|
||||
icon: 'none'
|
||||
})
|
||||
async handleWxLogin(e) {
|
||||
if (this.isLoading) {
|
||||
return
|
||||
}
|
||||
|
||||
this.isLoading = true
|
||||
|
||||
try {
|
||||
const res = await api.login(this.phone, this.code)
|
||||
uni.showLoading({
|
||||
title: '登录中...',
|
||||
mask: true
|
||||
})
|
||||
|
||||
if (res.data && res.data.accessToken) {
|
||||
storage.setToken(res.data.accessToken)
|
||||
|
||||
const userInfo = {
|
||||
...res.data,
|
||||
phone: this.phone
|
||||
}
|
||||
storage.setUserInfo(userInfo)
|
||||
|
||||
try {
|
||||
const questionRes = await api.getQuestion()
|
||||
if (questionRes.data) {
|
||||
storage.setQuestion(questionRes.data)
|
||||
uni.login({
|
||||
provider: 'weixin',
|
||||
success: async (loginRes) => {
|
||||
console.log('uni.login 成功:', loginRes)
|
||||
|
||||
if (!loginRes.code) {
|
||||
throw new Error('获取微信登录凭证失败')
|
||||
}
|
||||
} catch (questionError) {
|
||||
console.error('获取题目失败:', questionError)
|
||||
}
|
||||
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
|
||||
try {
|
||||
const res = await api.wxLogin(loginRes.code)
|
||||
console.log('后端登录返回:', res)
|
||||
|
||||
if (res.data && res.data.accessToken) {
|
||||
storage.setToken(res.data.accessToken)
|
||||
|
||||
const userInfo = {
|
||||
...res.data,
|
||||
nickName: res.data.nickName || '微信用户',
|
||||
avatarUrl: res.data.avatarUrl || ''
|
||||
}
|
||||
storage.setUserInfo(userInfo)
|
||||
|
||||
try {
|
||||
const questionRes = await api.getQuestion()
|
||||
if (questionRes.data) {
|
||||
storage.setQuestion(questionRes.data)
|
||||
}
|
||||
} catch (questionError) {
|
||||
console.error('获取题目失败:', questionError)
|
||||
}
|
||||
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '登录成功',
|
||||
icon: 'success'
|
||||
})
|
||||
|
||||
setTimeout(() => {
|
||||
this.navigateAfterLogin()
|
||||
}, 1500)
|
||||
} else {
|
||||
throw new Error(res.message || '登录失败')
|
||||
}
|
||||
} catch (apiError) {
|
||||
console.error('登录接口调用失败:', apiError)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: apiError.message || '登录失败,请重试',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('uni.login 失败:', err)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '微信登录失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}, 1500)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: res.message || '登录失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
} catch (error) {
|
||||
console.error('登录失败:', error)
|
||||
console.error('登录异常:', error)
|
||||
uni.hideLoading()
|
||||
uni.showToast({
|
||||
title: '登录失败,请重试',
|
||||
icon: 'none'
|
||||
})
|
||||
} finally {
|
||||
this.isLoading = false
|
||||
}
|
||||
},
|
||||
|
||||
handleSkip() {
|
||||
if (this.redirectUrl) {
|
||||
if (this.isTabBarPage(this.redirectUrl)) {
|
||||
uni.switchTab({
|
||||
url: this.redirectUrl
|
||||
})
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: this.redirectUrl
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
navigateAfterLogin() {
|
||||
if (this.redirectUrl) {
|
||||
if (this.isTabBarPage(this.redirectUrl)) {
|
||||
uni.switchTab({
|
||||
url: this.redirectUrl
|
||||
})
|
||||
} else {
|
||||
uni.redirectTo({
|
||||
url: this.redirectUrl
|
||||
})
|
||||
}
|
||||
} else {
|
||||
uni.switchTab({
|
||||
url: '/pages/index/index'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
isTabBarPage(url) {
|
||||
const tabBarPages = [
|
||||
'/pages/index/index',
|
||||
'/pages/gameplay/gameplay',
|
||||
'/pages/mine/mine'
|
||||
]
|
||||
return tabBarPages.some(page => url.includes(page))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,55 +199,72 @@ export default {
|
||||
max-width: 600rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
padding: 60rpx 40rpx;
|
||||
padding: 80rpx 40rpx;
|
||||
box-shadow: 0 10rpx 40rpx rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.title {
|
||||
.logo-section {
|
||||
text-align: center;
|
||||
margin-bottom: 80rpx;
|
||||
}
|
||||
|
||||
.logo {
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
margin-bottom: 30rpx;
|
||||
}
|
||||
|
||||
.app-name {
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
margin-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.form-item {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.label {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.input {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
border: 2rpx solid #e0e0e0;
|
||||
border-radius: 12rpx;
|
||||
padding: 0 24rpx;
|
||||
font-size: 32rpx;
|
||||
box-sizing: border-box;
|
||||
transition: all 0.3s;
|
||||
.app-desc {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.input:focus {
|
||||
border-color: #667eea;
|
||||
}
|
||||
|
||||
.login-btn {
|
||||
.wx-login-btn {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
height: 96rpx;
|
||||
background: linear-gradient(135deg, #07c160 0%, #06ae56 100%);
|
||||
color: #ffffff;
|
||||
font-size: 32rpx;
|
||||
border-radius: 12rpx;
|
||||
border-radius: 48rpx;
|
||||
border: none;
|
||||
margin-top: 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 30rpx;
|
||||
box-shadow: 0 8rpx 24rpx rgba(7, 193, 96, 0.3);
|
||||
}
|
||||
|
||||
.login-btn.disabled {
|
||||
.wx-login-btn.disabled {
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.wx-icon {
|
||||
font-size: 36rpx;
|
||||
margin-right: 12rpx;
|
||||
}
|
||||
|
||||
.skip-btn {
|
||||
text-align: center;
|
||||
padding: 20rpx 0;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.skip-btn text {
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.tips {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
text-align: center;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view class="user-info">
|
||||
<view class="avatar">
|
||||
<text class="avatar-text">{{ userInfo ? userInfo.name.charAt(0).toUpperCase() : 'U' }}</text>
|
||||
<view class="user-info" @click="handleUserInfoClick">
|
||||
<image v-if="userInfo.avatarUrl" class="avatar" :src="userInfo.avatarUrl" mode="aspectFill"></image>
|
||||
<view v-else class="avatar">
|
||||
<text class="avatar-text">{{ userInfo.nickName ? userInfo.nickName.charAt(0) : 'U' }}</text>
|
||||
</view>
|
||||
<view class="info">
|
||||
<text class="username">{{ userInfo ? userInfo.name : '未登录' }}</text>
|
||||
<text class="username">{{ userInfo.nickName || '未登录' }}</text>
|
||||
<text v-if="!userInfo.nickName" class="login-tip">点击登录,保存答题记录</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="menu-list">
|
||||
<view class="menu-item" @click="handleLogout">
|
||||
<text class="menu-text">退出登录</text>
|
||||
<view class="menu-item">
|
||||
<text class="menu-text">关于我们</text>
|
||||
<text class="arrow">></text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="userInfo.nickName" class="action-section">
|
||||
<button class="logout-btn" @click="handleLogout">退出登录</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -24,14 +30,10 @@ import storage from '../../utils/storage.js'
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
userInfo: null
|
||||
userInfo: {}
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadUserInfo()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadUserInfo()
|
||||
},
|
||||
@@ -41,18 +43,39 @@ export default {
|
||||
const userInfo = storage.getUserInfo()
|
||||
if (userInfo) {
|
||||
this.userInfo = userInfo
|
||||
} else {
|
||||
this.userInfo = {}
|
||||
}
|
||||
},
|
||||
|
||||
handleUserInfoClick() {
|
||||
if (!this.userInfo.nickName) {
|
||||
this.handleLogin()
|
||||
}
|
||||
},
|
||||
|
||||
handleLogin() {
|
||||
uni.navigateTo({
|
||||
url: '/pages/login/login?redirect=' + encodeURIComponent('/pages/mine/mine')
|
||||
})
|
||||
},
|
||||
|
||||
handleLogout() {
|
||||
uni.showModal({
|
||||
title: '提示',
|
||||
content: '确定要退出登录吗?',
|
||||
success: (res) => {
|
||||
if (res.confirm) {
|
||||
storage.clearAll()
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
storage.removeToken()
|
||||
storage.removeUserInfo()
|
||||
storage.removeQuestion()
|
||||
storage.clearAnsweredQuestions()
|
||||
|
||||
this.userInfo = {}
|
||||
|
||||
uni.showToast({
|
||||
title: '已退出登录',
|
||||
icon: 'success'
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -65,7 +88,6 @@ export default {
|
||||
<style scoped>
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.user-info {
|
||||
@@ -75,6 +97,10 @@ export default {
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.user-info:active {
|
||||
opacity: 0.9;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 120rpx;
|
||||
height: 120rpx;
|
||||
@@ -105,8 +131,8 @@ export default {
|
||||
margin-bottom: 10rpx;
|
||||
}
|
||||
|
||||
.phone {
|
||||
font-size: 28rpx;
|
||||
.login-tip {
|
||||
font-size: 24rpx;
|
||||
color: rgba(255, 255, 255, 0.8);
|
||||
}
|
||||
|
||||
@@ -136,4 +162,26 @@ export default {
|
||||
font-size: 32rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.action-section {
|
||||
margin-top: 60rpx;
|
||||
padding: 0 40rpx;
|
||||
}
|
||||
|
||||
.logout-btn {
|
||||
width: 100%;
|
||||
height: 88rpx;
|
||||
background: #ffffff;
|
||||
color: #ff4d4f;
|
||||
font-size: 32rpx;
|
||||
border-radius: 12rpx;
|
||||
border: 2rpx solid #ff4d4f;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.logout-btn:active {
|
||||
background: #fff1f0;
|
||||
}
|
||||
</style>
|
||||
|
||||
533
pages/quick/quick.vue
Normal file
@@ -0,0 +1,533 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view v-if="gameState === 'prepare'" class="prepare-screen">
|
||||
<view class="countdown-circle">
|
||||
<text class="countdown-text">{{ prepareCountdown }}</text>
|
||||
</view>
|
||||
<text class="prepare-text">准备开始</text>
|
||||
</view>
|
||||
|
||||
<view v-else-if="gameState === 'playing'" class="game-screen">
|
||||
<view class="timer-bar">
|
||||
<view class="timer-progress" :style="{ width: timerProgress + '%' }"></view>
|
||||
<text class="timer-text">{{ countdown }}s</text>
|
||||
</view>
|
||||
|
||||
<view class="stats-bar">
|
||||
<view class="stat-item">
|
||||
<text class="stat-label">正确</text>
|
||||
<text class="stat-value correct">{{ correctCount }}</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-label">错误</text>
|
||||
<text class="stat-value wrong">{{ wrongCount }}</text>
|
||||
</view>
|
||||
<view class="stat-item">
|
||||
<text class="stat-label">正确率</text>
|
||||
<text class="stat-value">{{ accuracy }}%</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-if="question" class="question-card">
|
||||
<view class="question-header">
|
||||
<text class="question-title">题目</text>
|
||||
<view class="question-meta">
|
||||
<view class="meta-tag category-tag">
|
||||
<text class="meta-text">{{ getCategoryText(question.category) }}</text>
|
||||
</view>
|
||||
<view class="meta-tag difficulty-tag" :class="getDifficultyClass(question.difficulty)">
|
||||
<text class="meta-text">{{ getDifficultyText(question.difficulty) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="question-content">
|
||||
<text class="question-text">{{ question.question }}</text>
|
||||
</view>
|
||||
<view v-if="question.options" class="options-list">
|
||||
<view
|
||||
v-for="(option, index) in question.options"
|
||||
:key="index"
|
||||
class="option-item"
|
||||
:class="{
|
||||
'correct': answered && correctAnswer === String.fromCharCode(65 + index),
|
||||
'wrong': answered && selectedAnswer === String.fromCharCode(65 + index) && correctAnswer !== String.fromCharCode(65 + index)
|
||||
}"
|
||||
@click="handleAnswer(option, index)"
|
||||
>
|
||||
<text class="option-text">{{ option }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view v-else-if="gameState === 'finished'" class="result-screen">
|
||||
<view class="result-card">
|
||||
<text class="result-title">答题结束</text>
|
||||
<view class="result-stats">
|
||||
<view class="result-stat-item">
|
||||
<text class="result-stat-label">答题总数</text>
|
||||
<text class="result-stat-value">{{ totalCount }}</text>
|
||||
</view>
|
||||
<view class="result-stat-item">
|
||||
<text class="result-stat-label">正确</text>
|
||||
<text class="result-stat-value correct">{{ correctCount }}</text>
|
||||
</view>
|
||||
<view class="result-stat-item">
|
||||
<text class="result-stat-label">错误</text>
|
||||
<text class="result-stat-value wrong">{{ wrongCount }}</text>
|
||||
</view>
|
||||
<view class="result-stat-item">
|
||||
<text class="result-stat-label">正确率</text>
|
||||
<text class="result-stat-value">{{ accuracy }}%</text>
|
||||
</view>
|
||||
</view>
|
||||
<button class="restart-btn" @click="restartGame">再来一次</button>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import api from '../../utils/api.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
gameState: 'prepare',
|
||||
prepareCountdown: 5,
|
||||
countdown: 60,
|
||||
timerProgress: 100,
|
||||
question: null,
|
||||
answered: false,
|
||||
correctAnswer: '',
|
||||
selectedAnswer: '',
|
||||
correctCount: 0,
|
||||
wrongCount: 0,
|
||||
totalCount: 0,
|
||||
prepareTimer: null,
|
||||
gameTimer: null
|
||||
}
|
||||
},
|
||||
|
||||
computed: {
|
||||
accuracy() {
|
||||
if (this.totalCount === 0) return 0
|
||||
return Math.round((this.correctCount / this.totalCount) * 100)
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.startPrepare()
|
||||
},
|
||||
|
||||
onUnload() {
|
||||
this.clearTimers()
|
||||
},
|
||||
|
||||
methods: {
|
||||
startPrepare() {
|
||||
this.gameState = 'prepare'
|
||||
this.prepareCountdown = 5
|
||||
this.prepareTimer = setInterval(() => {
|
||||
this.prepareCountdown--
|
||||
if (this.prepareCountdown <= 0) {
|
||||
this.clearTimers()
|
||||
this.startGame()
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
|
||||
startGame() {
|
||||
this.gameState = 'playing'
|
||||
this.countdown = 60
|
||||
this.timerProgress = 100
|
||||
this.correctCount = 0
|
||||
this.wrongCount = 0
|
||||
this.totalCount = 0
|
||||
this.loadQuestion()
|
||||
|
||||
this.gameTimer = setInterval(() => {
|
||||
this.countdown--
|
||||
this.timerProgress = (this.countdown / 60) * 100
|
||||
if (this.countdown <= 0) {
|
||||
this.clearTimers()
|
||||
this.finishGame()
|
||||
}
|
||||
}, 1000)
|
||||
},
|
||||
|
||||
async loadQuestion() {
|
||||
try {
|
||||
const res = await api.getQuestion()
|
||||
if (res.data) {
|
||||
this.question = res.data
|
||||
this.resetAnswer()
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取题目失败:', error)
|
||||
}
|
||||
},
|
||||
|
||||
resetAnswer() {
|
||||
this.answered = false
|
||||
this.correctAnswer = ''
|
||||
this.selectedAnswer = ''
|
||||
},
|
||||
|
||||
getCategoryText(category) {
|
||||
return category || '其他'
|
||||
},
|
||||
|
||||
getDifficultyText(difficulty) {
|
||||
if (!difficulty && difficulty !== 0) return '简单'
|
||||
if (difficulty <= 30) return '简单'
|
||||
if (difficulty <= 60) return '中等'
|
||||
if (difficulty <= 80) return '困难'
|
||||
return '极难'
|
||||
},
|
||||
|
||||
getDifficultyClass(difficulty) {
|
||||
if (!difficulty && difficulty !== 0) return 'difficulty-easy'
|
||||
if (difficulty <= 30) return 'difficulty-easy'
|
||||
if (difficulty <= 60) return 'difficulty-medium'
|
||||
if (difficulty <= 80) return 'difficulty-hard'
|
||||
return 'difficulty-extreme'
|
||||
},
|
||||
|
||||
async handleAnswer(option, index) {
|
||||
if (this.answered) return
|
||||
|
||||
const answer = String.fromCharCode(65 + index)
|
||||
this.selectedAnswer = answer
|
||||
this.answered = true
|
||||
this.totalCount++
|
||||
|
||||
try {
|
||||
const res = await api.answerQuestion(this.question.sn, answer)
|
||||
if (res.data) {
|
||||
this.correctAnswer = res.data.answer || answer
|
||||
|
||||
if (this.correctAnswer === answer) {
|
||||
this.correctCount++
|
||||
} else {
|
||||
this.wrongCount++
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
this.loadQuestion()
|
||||
}, 500)
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提交答案失败:', error)
|
||||
this.wrongCount++
|
||||
setTimeout(() => {
|
||||
this.loadQuestion()
|
||||
}, 500)
|
||||
}
|
||||
},
|
||||
|
||||
finishGame() {
|
||||
this.gameState = 'finished'
|
||||
},
|
||||
|
||||
restartGame() {
|
||||
this.startPrepare()
|
||||
},
|
||||
|
||||
clearTimers() {
|
||||
if (this.prepareTimer) {
|
||||
clearInterval(this.prepareTimer)
|
||||
this.prepareTimer = null
|
||||
}
|
||||
if (this.gameTimer) {
|
||||
clearInterval(this.gameTimer)
|
||||
this.gameTimer = null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
min-height: 100vh;
|
||||
padding: 40rpx;
|
||||
}
|
||||
|
||||
.prepare-screen {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 80vh;
|
||||
}
|
||||
|
||||
.countdown-circle {
|
||||
width: 300rpx;
|
||||
height: 300rpx;
|
||||
border-radius: 50%;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
margin-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.countdown-text {
|
||||
font-size: 120rpx;
|
||||
font-weight: bold;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.prepare-text {
|
||||
font-size: 40rpx;
|
||||
color: #333;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.game-screen {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 30rpx;
|
||||
}
|
||||
|
||||
.timer-bar {
|
||||
position: relative;
|
||||
height: 80rpx;
|
||||
background: #e0e0e0;
|
||||
border-radius: 40rpx;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.timer-progress {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
height: 100%;
|
||||
background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
|
||||
transition: width 0.3s;
|
||||
}
|
||||
|
||||
.timer-text {
|
||||
position: absolute;
|
||||
left: 50%;
|
||||
top: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.stats-bar {
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
padding: 30rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.stat-item {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.stat-label {
|
||||
font-size: 24rpx;
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.stat-value {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.stat-value.correct {
|
||||
color: #28a745;
|
||||
}
|
||||
|
||||
.stat-value.wrong {
|
||||
color: #dc3545;
|
||||
}
|
||||
|
||||
.question-card {
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
padding: 40rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.question-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 30rpx;
|
||||
padding-bottom: 20rpx;
|
||||
border-bottom: 2rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.question-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.question-meta {
|
||||
display: flex;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.meta-tag {
|
||||
padding: 8rpx 20rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.category-tag {
|
||||
background: #e3f2fd;
|
||||
}
|
||||
|
||||
.difficulty-tag {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.difficulty-easy {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.difficulty-medium {
|
||||
background: #fff3cd;
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.difficulty-hard {
|
||||
background: #fd7e14;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.difficulty-extreme {
|
||||
background: #dc3545;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.meta-text {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.question-content {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.question-text {
|
||||
font-size: 30rpx;
|
||||
color: #666;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.options-list {
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
|
||||
.option-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 24rpx 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
background: #f8f9fa;
|
||||
border-radius: 12rpx;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.option-item:active {
|
||||
background: #e9ecef;
|
||||
}
|
||||
|
||||
.option-item.correct {
|
||||
background: #d4edda;
|
||||
border: 2rpx solid #28a745;
|
||||
}
|
||||
|
||||
.option-item.wrong {
|
||||
background: #f8d7da;
|
||||
border: 2rpx solid #dc3545;
|
||||
}
|
||||
|
||||
.option-text {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.result-screen {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 80vh;
|
||||
}
|
||||
|
||||
.result-card {
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
padding: 60rpx 40rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.result-title {
|
||||
font-size: 48rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
text-align: center;
|
||||
margin-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.result-stats {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 30rpx;
|
||||
margin-bottom: 60rpx;
|
||||
}
|
||||
|
||||
.result-stat-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 20rpx 30rpx;
|
||||
background: #f8f9fa;
|
||||
border-radius: 12rpx;
|
||||
}
|
||||
|
||||
.result-stat-label {
|
||||
font-size: 28rpx;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.result-stat-value {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.result-stat-value.correct {
|
||||
color: #28a745;
|
||||
}
|
||||
|
||||
.result-stat-value.wrong {
|
||||
color: #dc3545;
|
||||
}
|
||||
|
||||
.restart-btn {
|
||||
width: 100%;
|
||||
height: 80rpx;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #ffffff;
|
||||
font-size: 32rpx;
|
||||
border-radius: 40rpx;
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
368
pages/random/random.vue
Normal file
@@ -0,0 +1,368 @@
|
||||
<template>
|
||||
<view class="container">
|
||||
<view v-if="question" class="question-card">
|
||||
<view class="question-header">
|
||||
<text class="question-title">题目</text>
|
||||
<view class="question-meta">
|
||||
<view class="meta-tag category-tag">
|
||||
<text class="meta-text">{{ getCategoryText(question.category) }}</text>
|
||||
</view>
|
||||
<view class="meta-tag difficulty-tag" :class="getDifficultyClass(question.difficulty)">
|
||||
<text class="meta-text">{{ getDifficultyText(question.difficulty) }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="question-content">
|
||||
<text class="question-text">{{ question.question }}</text>
|
||||
</view>
|
||||
<view v-if="question.options" class="options-list">
|
||||
<view
|
||||
v-for="(option, index) in question.options"
|
||||
:key="index"
|
||||
class="option-item"
|
||||
:class="{
|
||||
'correct': answered && correctAnswer === String.fromCharCode(65 + index),
|
||||
'wrong': answered && selectedAnswer === String.fromCharCode(65 + index) && correctAnswer !== String.fromCharCode(65 + index)
|
||||
}"
|
||||
@click="handleAnswer(option, index)"
|
||||
>
|
||||
<text class="option-text">{{ option }}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view v-if="answered && explanation" class="explanation">
|
||||
<view class="explanation-title">解析</view>
|
||||
<text class="explanation-text">{{ explanation }}</text>
|
||||
</view>
|
||||
<view class="action-buttons">
|
||||
<button class="next-btn" @click="refreshQuestion">下一题</button>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="empty-state">
|
||||
<text class="empty-text">暂无题目</text>
|
||||
<button class="refresh-btn" @click="refreshQuestion">刷新</button>
|
||||
</view>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import storage from '../../utils/storage.js'
|
||||
import api from '../../utils/api.js'
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
question: null,
|
||||
answered: false,
|
||||
correctAnswer: '',
|
||||
selectedAnswer: '',
|
||||
explanation: ''
|
||||
}
|
||||
},
|
||||
|
||||
onLoad() {
|
||||
this.loadQuestion()
|
||||
},
|
||||
|
||||
onShow() {
|
||||
this.loadQuestion()
|
||||
this.checkAnsweredQuestion()
|
||||
},
|
||||
|
||||
methods: {
|
||||
loadQuestion() {
|
||||
const question = storage.getQuestion()
|
||||
if (question) {
|
||||
this.question = question
|
||||
this.resetAnswer()
|
||||
}
|
||||
},
|
||||
|
||||
checkAnsweredQuestion() {
|
||||
if (this.question && storage.isQuestionAnswered(this.question.sn)) {
|
||||
this.refreshQuestion()
|
||||
}
|
||||
},
|
||||
|
||||
resetAnswer() {
|
||||
this.answered = false
|
||||
this.correctAnswer = ''
|
||||
this.selectedAnswer = ''
|
||||
this.explanation = ''
|
||||
},
|
||||
|
||||
getCategoryText(category) {
|
||||
return category || '其他'
|
||||
},
|
||||
|
||||
getDifficultyText(difficulty) {
|
||||
if (!difficulty && difficulty !== 0) return '简单'
|
||||
if (difficulty <= 30) return '简单'
|
||||
if (difficulty <= 60) return '中等'
|
||||
if (difficulty <= 80) return '困难'
|
||||
return '极难'
|
||||
},
|
||||
|
||||
getDifficultyClass(difficulty) {
|
||||
if (!difficulty && difficulty !== 0) return 'difficulty-easy'
|
||||
if (difficulty <= 30) return 'difficulty-easy'
|
||||
if (difficulty <= 60) return 'difficulty-medium'
|
||||
if (difficulty <= 80) return 'difficulty-hard'
|
||||
return 'difficulty-extreme'
|
||||
},
|
||||
|
||||
async handleAnswer(option, index) {
|
||||
if (this.answered) return
|
||||
|
||||
const answer = String.fromCharCode(65 + index)
|
||||
this.selectedAnswer = answer
|
||||
|
||||
try {
|
||||
const res = await api.answerQuestion(this.question.sn, answer)
|
||||
if (res.data) {
|
||||
this.answered = true
|
||||
this.correctAnswer = res.data.answer || answer
|
||||
this.explanation = res.data.explanation || ''
|
||||
|
||||
storage.addAnsweredQuestion(this.question.sn)
|
||||
|
||||
if (this.correctAnswer === answer) {
|
||||
uni.showToast({
|
||||
title: '回答正确',
|
||||
icon: 'success'
|
||||
})
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '回答错误',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('提交答案失败:', error)
|
||||
uni.showToast({
|
||||
title: '提交失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
},
|
||||
|
||||
async refreshQuestion() {
|
||||
try {
|
||||
const res = await api.getQuestion()
|
||||
if (res.data) {
|
||||
if (storage.isQuestionAnswered(res.data.sn)) {
|
||||
this.refreshQuestion()
|
||||
return
|
||||
}
|
||||
storage.setQuestion(res.data)
|
||||
this.question = res.data
|
||||
this.resetAnswer()
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: '暂无题目',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取题目失败:', error)
|
||||
uni.showToast({
|
||||
title: '刷新失败',
|
||||
icon: 'none'
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.container {
|
||||
padding: 40rpx;
|
||||
}
|
||||
|
||||
.question-card {
|
||||
background: #ffffff;
|
||||
border-radius: 20rpx;
|
||||
padding: 40rpx;
|
||||
box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.08);
|
||||
}
|
||||
|
||||
.question-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 30rpx;
|
||||
padding-bottom: 20rpx;
|
||||
border-bottom: 2rpx solid #f0f0f0;
|
||||
}
|
||||
|
||||
.question-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.question-meta {
|
||||
display: flex;
|
||||
gap: 10rpx;
|
||||
}
|
||||
|
||||
.meta-tag {
|
||||
padding: 8rpx 20rpx;
|
||||
border-radius: 20rpx;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
|
||||
.category-tag {
|
||||
background: #e3f2fd;
|
||||
}
|
||||
|
||||
.difficulty-tag {
|
||||
background: #f8f9fa;
|
||||
}
|
||||
|
||||
.difficulty-easy {
|
||||
background: #d4edda;
|
||||
color: #155724;
|
||||
}
|
||||
|
||||
.difficulty-medium {
|
||||
background: #fff3cd;
|
||||
color: #856404;
|
||||
}
|
||||
|
||||
.difficulty-hard {
|
||||
background: #fd7e14;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.difficulty-extreme {
|
||||
background: #dc3545;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.meta-text {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.question-content {
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.question-text {
|
||||
font-size: 30rpx;
|
||||
color: #666;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.options-list {
|
||||
margin-top: 30rpx;
|
||||
}
|
||||
|
||||
.option-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 24rpx 30rpx;
|
||||
margin-bottom: 20rpx;
|
||||
background: #f8f9fa;
|
||||
border-radius: 12rpx;
|
||||
transition: all 0.3s;
|
||||
}
|
||||
|
||||
.option-item:active {
|
||||
background: #e9ecef;
|
||||
}
|
||||
|
||||
.option-item.correct {
|
||||
background: #d4edda;
|
||||
border: 2rpx solid #28a745;
|
||||
}
|
||||
|
||||
.option-item.wrong {
|
||||
background: #f8d7da;
|
||||
border: 2rpx solid #dc3545;
|
||||
}
|
||||
|
||||
.option-label {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #667eea;
|
||||
margin-right: 20rpx;
|
||||
min-width: 40rpx;
|
||||
}
|
||||
|
||||
.option-item.correct .option-label {
|
||||
color: #28a745;
|
||||
}
|
||||
|
||||
.option-item.wrong .option-label {
|
||||
color: #dc3545;
|
||||
}
|
||||
|
||||
.option-text {
|
||||
font-size: 28rpx;
|
||||
color: #333;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.explanation {
|
||||
margin-top: 40rpx;
|
||||
padding: 30rpx;
|
||||
background: #fff3cd;
|
||||
border-radius: 12rpx;
|
||||
border-left: 4rpx solid #ffc107;
|
||||
}
|
||||
|
||||
.explanation-title {
|
||||
font-size: 28rpx;
|
||||
font-weight: bold;
|
||||
color: #856404;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.explanation-text {
|
||||
font-size: 28rpx;
|
||||
color: #856404;
|
||||
line-height: 1.8;
|
||||
}
|
||||
|
||||
.action-buttons {
|
||||
margin-top: 40rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.next-btn {
|
||||
width: 200rpx;
|
||||
height: 70rpx;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
border-radius: 35rpx;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 60vh;
|
||||
}
|
||||
|
||||
.empty-text {
|
||||
font-size: 32rpx;
|
||||
color: #999;
|
||||
margin-bottom: 40rpx;
|
||||
}
|
||||
|
||||
.refresh-btn {
|
||||
width: 200rpx;
|
||||
height: 70rpx;
|
||||
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||
color: #ffffff;
|
||||
font-size: 28rpx;
|
||||
border-radius: 35rpx;
|
||||
border: none;
|
||||
}
|
||||
</style>
|
||||
BIN
static/tab-game-active.png
Normal file
|
After Width: | Height: | Size: 707 B |
6
static/tab-game-active.svg
Normal file
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="81" height="81" viewBox="0 0 81 81" fill="none">
|
||||
<rect x="20" y="20" width="41" height="41" rx="8" fill="#667eea"/>
|
||||
<circle cx="30" cy="35" r="5" fill="white"/>
|
||||
<circle cx="51" cy="35" r="5" fill="white"/>
|
||||
<rect x="25" y="45" width="31" height="8" rx="4" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 332 B |
BIN
static/tab-game.png
Normal file
|
After Width: | Height: | Size: 705 B |
6
static/tab-game.svg
Normal file
@@ -0,0 +1,6 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="81" height="81" viewBox="0 0 81 81" fill="none">
|
||||
<rect x="20" y="20" width="41" height="41" rx="8" fill="#7A7E83"/>
|
||||
<circle cx="30" cy="35" r="5" fill="white"/>
|
||||
<circle cx="51" cy="35" r="5" fill="white"/>
|
||||
<rect x="25" y="45" width="31" height="8" rx="4" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 332 B |
BIN
static/tab-home-active.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
5
static/tab-home-active.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="81" height="81" viewBox="0 0 81 81" fill="none">
|
||||
<path d="M40.5 15C26.4 15 15 26.4 15 40.5C15 54.6 26.4 66 40.5 66C54.6 66 66 54.6 66 40.5C66 26.4 54.6 15 40.5 15Z" fill="#667eea"/>
|
||||
<path d="M40.5 25C34.7 25 30 29.7 30 35.5C30 41.3 34.7 46 40.5 46C46.3 46 51 41.3 51 35.5C51 29.7 46.3 25 40.5 25Z" fill="white"/>
|
||||
<rect x="37" y="28" width="7" height="15" rx="3.5" fill="#667eea"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 441 B |
BIN
static/tab-home.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
5
static/tab-home.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="81" height="81" viewBox="0 0 81 81" fill="none">
|
||||
<path d="M40.5 15C26.4 15 15 26.4 15 40.5C15 54.6 26.4 66 40.5 66C54.6 66 66 54.6 66 40.5C66 26.4 54.6 15 40.5 15Z" fill="#7A7E83"/>
|
||||
<path d="M40.5 25C34.7 25 30 29.7 30 35.5C30 41.3 34.7 46 40.5 46C46.3 46 51 41.3 51 35.5C51 29.7 46.3 25 40.5 25Z" fill="white"/>
|
||||
<rect x="37" y="28" width="7" height="15" rx="3.5" fill="#7A7E83"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 441 B |
BIN
static/tab-mine-active.png
Normal file
|
After Width: | Height: | Size: 1.2 KiB |
5
static/tab-mine-active.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="81" height="81" viewBox="0 0 81 81" fill="none">
|
||||
<circle cx="40.5" cy="40.5" r="25" fill="#667eea"/>
|
||||
<circle cx="40.5" cy="32" r="8" fill="white"/>
|
||||
<path d="M28 50C28 46 31 43 35 43C39 43 42 46 42 50C42 54 39 57 35 57C31 57 28 54 28 50Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 313 B |
BIN
static/tab-mine.png
Normal file
|
After Width: | Height: | Size: 1.3 KiB |
5
static/tab-mine.svg
Normal file
@@ -0,0 +1,5 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="81" height="81" viewBox="0 0 81 81" fill="none">
|
||||
<circle cx="40.5" cy="40.5" r="25" fill="#7A7E83"/>
|
||||
<circle cx="40.5" cy="32" r="8" fill="white"/>
|
||||
<path d="M28 50C28 46 31 43 35 43C39 43 42 46 42 50C42 54 39 57 35 57C31 57 28 54 28 50Z" fill="white"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 313 B |
78
utils/api.js
@@ -1,50 +1,75 @@
|
||||
import config from '../config.js'
|
||||
import storage from './storage.js'
|
||||
|
||||
const request = (options) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const fullUrl = config.baseUrl + options.url
|
||||
console.log('=== 请求开始 ===')
|
||||
console.log('URL:', fullUrl)
|
||||
console.log('Method:', options.method || 'GET')
|
||||
console.log('Data:', options.data)
|
||||
|
||||
uni.request({
|
||||
url: config.baseUrl + options.url,
|
||||
url: fullUrl,
|
||||
method: options.method || 'GET',
|
||||
data: options.data || {},
|
||||
header: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': storage.getToken() ? `Bearer ${storage.getToken()}` : '',
|
||||
...options.header
|
||||
},
|
||||
timeout: config.timeout,
|
||||
success: (res) => {
|
||||
console.log('=== 请求成功 ===')
|
||||
console.log('StatusCode:', res.statusCode)
|
||||
console.log('Response:', res.data)
|
||||
|
||||
const { statusCode, data } = res
|
||||
|
||||
if (statusCode === 200) {
|
||||
if (data.code === 0 || data.success === true) {
|
||||
resolve(data)
|
||||
} else {
|
||||
uni.showToast({
|
||||
title: data.message || '请求失败',
|
||||
icon: 'none'
|
||||
console.error('=== 业务错误 ===')
|
||||
console.error('Code:', data.code)
|
||||
console.error('Message:', data.message)
|
||||
uni.showModal({
|
||||
title: '请求失败',
|
||||
content: data.message || '服务器返回错误',
|
||||
showCancel: false
|
||||
})
|
||||
reject(data)
|
||||
}
|
||||
} else if (statusCode === 401) {
|
||||
storage.removeToken()
|
||||
storage.removeUserInfo()
|
||||
uni.reLaunch({
|
||||
url: '/pages/login/login'
|
||||
})
|
||||
reject(res)
|
||||
} else {
|
||||
uni.showToast({
|
||||
console.error('=== HTTP错误 ===')
|
||||
console.error('StatusCode:', statusCode)
|
||||
console.error('Response:', data)
|
||||
uni.showModal({
|
||||
title: '网络错误',
|
||||
icon: 'none'
|
||||
content: `状态码: ${statusCode}`,
|
||||
showCancel: false
|
||||
})
|
||||
reject(res)
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
uni.showToast({
|
||||
title: '网络连接失败',
|
||||
icon: 'none'
|
||||
console.error('=== 请求失败 ===')
|
||||
console.error('Error:', err)
|
||||
console.error('Error Message:', err.errMsg)
|
||||
|
||||
let errorMsg = '网络连接失败'
|
||||
if (err.errMsg) {
|
||||
if (err.errMsg.includes('timeout')) {
|
||||
errorMsg = '请求超时,请检查网络'
|
||||
} else if (err.errMsg.includes('fail')) {
|
||||
errorMsg = '网络连接失败,请检查网络设置'
|
||||
} else if (err.errMsg.includes('request:fail')) {
|
||||
errorMsg = `连接失败: ${err.errMsg}`
|
||||
}
|
||||
}
|
||||
|
||||
uni.showModal({
|
||||
title: '错误',
|
||||
content: errorMsg,
|
||||
showCancel: false
|
||||
})
|
||||
reject(err)
|
||||
}
|
||||
@@ -53,21 +78,21 @@ const request = (options) => {
|
||||
}
|
||||
|
||||
const api = {
|
||||
login(phone, code) {
|
||||
wxLogin(code) {
|
||||
return request({
|
||||
url: config.api.login,
|
||||
method: 'POST',
|
||||
data: {
|
||||
phone,
|
||||
code
|
||||
wxMiniCode: code
|
||||
}
|
||||
})
|
||||
},
|
||||
|
||||
getQuestion() {
|
||||
getQuestion(categorySn) {
|
||||
return request({
|
||||
url: config.api.getQuestion,
|
||||
method: 'POST'
|
||||
method: 'POST',
|
||||
data: categorySn ? { category_sn: categorySn } : {}
|
||||
})
|
||||
},
|
||||
|
||||
@@ -82,6 +107,13 @@ const api = {
|
||||
})
|
||||
},
|
||||
|
||||
getAllCategory() {
|
||||
return request({
|
||||
url: config.api.getAllCategory,
|
||||
method: 'POST'
|
||||
})
|
||||
},
|
||||
|
||||
get(url, data = {}) {
|
||||
return request({
|
||||
url,
|
||||
|
||||