Commit 4023e7e7 authored by Facius's avatar Facius

Merge branch 'dev-v1.0.0' into test

parents b0cb18ff e0e0f649
const UNI_APP = { const UNI_APP = {
apiUrl: 'http://192.168.1.22', apiUrl: 'http://192.168.0.204:8760',
qn_base_url: 'https://qn-static.banshouhui.com/study/', qn_base_url: 'https://qn-static.banshouhui.com/study/',
argoDebugMode: 1, qn_asset_url: 'http://deudn.c.pp.cc/',
version: 'v1.0.0' uCenterUrl: 'http://192.168.0.5:8093/', //'http://rest-u.yunya.com/'
argoDebugMode: 1,
version: 'v1.0.0',
} }
module.exports = UNI_APP module.exports = UNI_APP
(function () { ;(function() {
let NODE_ENV = 'test'; // dev:开发环境 | test:测试环境 | prod:生产环境 let NODE_ENV = 'test' // dev:开发环境 | test:测试环境 | prod:生产环境
let ENV_VAR = null; let ENV_VAR = null
if (process.env.NODE_ENV === "development") { if (process.env.NODE_ENV === 'development') {
if (NODE_ENV === 'dev') { if (NODE_ENV === 'dev') {
ENV_VAR = require('./.env.dev.js'); ENV_VAR = require('./.env.dev.js')
} else if (NODE_ENV === 'test') { } else if (NODE_ENV === 'test') {
ENV_VAR = require('./.env.test.js'); ENV_VAR = require('./.env.test.js')
} else if (NODE_ENV === 'prod') { } else if (NODE_ENV === 'prod') {
ENV_VAR = require('./.env.prod.js'); ENV_VAR = require('./.env.prod.js')
} }
} else if (process.env.NODE_ENV === "production") { } else if (process.env.NODE_ENV === 'production') {
if (NODE_ENV === 'test') { if (NODE_ENV === 'test') {
ENV_VAR = require('./.env.test.js'); ENV_VAR = require('./.env.test.js')
} else if (NODE_ENV === 'prod') { } else if (NODE_ENV === 'prod') {
ENV_VAR = require('./.env.prod.js'); ENV_VAR = require('./.env.prod.js')
} }
} }
if (ENV_VAR) { ENV_VAR['bmapAK'] = 'lF1HoyXdiv4uZx6TrGQEZs48F5y8kEHI'
process.uniEnv = {}; ENV_VAR['qn_base_url'] = 'https://qn-static.banshouhui.com/study/'
process.uniEnv['node_env'] = NODE_ENV; if (ENV_VAR) {
for (let key in ENV_VAR) { process.uniEnv = {}
process.uniEnv[key] = ENV_VAR[key]; process.uniEnv['node_env'] = NODE_ENV
} for (let key in ENV_VAR) {
} process.uniEnv[key] = ENV_VAR[key]
})(); }
}
})()
const UNI_APP = { const UNI_APP = {
apiUrl: 'https://system.banshouhui.com', apiUrl: 'https://system.banshouhui.com',
qn_base_url: 'https://qn-static.banshouhui.com/study/', qn_base_url: 'https://qn-static.banshouhui.com/study/',
argoDebugMode: 1, qn_asset_url: 'https://img2.banshouhui.com/',
version: 'v1.0.0' uCenterUrl: 'http://rest-u.banshouhui.com/',
argoDebugMode: 1,
version: 'v1.0.0',
} }
module.exports = UNI_APP module.exports = UNI_APP
const UNI_APP = { const UNI_APP = {
apiUrl: 'https://system.dev.banshouhui.com', apiUrl: 'https://exam.banshouhui.com',
qn_base_url: 'https://qn-static.banshouhui.com/study/', qn_base_url: 'https://qn-static.banshouhui.com/study/',
argoDebugMode: 1, qn_asset_url: 'https://img2.banshouhui.com/',
version: 'v1.0.0' uCenterUrl: 'http://rest-u.test.ibanshou.cn/',
argoDebugMode: 1,
version: 'v1.0.0',
} }
module.exports = UNI_APP module.exports = UNI_APP
...@@ -15256,6 +15256,16 @@ ...@@ -15256,6 +15256,16 @@
"which-boxed-primitive": "^1.0.2" "which-boxed-primitive": "^1.0.2"
} }
}, },
"uni-read-pages": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/uni-read-pages/-/uni-read-pages-1.0.5.tgz",
"integrity": "sha512-GkrrZ0LX0vn9R5k6RKEi0Ez3Q3e2vUpjXQ8Z6/K/d28KudI9ajqgt8WEjQFlG5EPm1K6uTArN8LlqmZTEixDUA=="
},
"uni-simple-router": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/uni-simple-router/-/uni-simple-router-2.0.6.tgz",
"integrity": "sha512-n5gepoT3QcBrvVLeTCY/DjUjC4m1hNzwFlOa1VlCsww/4/34MGfvegpN9OWR8jOxxtUPKGHLAG0yODL/ITCwbw=="
},
"unicode-canonical-property-names-ecmascript": { "unicode-canonical-property-names-ecmascript": {
"version": "1.0.4", "version": "1.0.4",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz",
......
...@@ -29,6 +29,8 @@ ...@@ -29,6 +29,8 @@
"core-js": "^3.6.5", "core-js": "^3.6.5",
"flyio": "^0.6.2", "flyio": "^0.6.2",
"regenerator-runtime": "^0.12.1", "regenerator-runtime": "^0.12.1",
"uni-read-pages": "^1.0.5",
"uni-simple-router": "^2.0.6",
"vue": "^2.6.11", "vue": "^2.6.11",
"vuex": "^3.2.0" "vuex": "^3.2.0"
}, },
......
<script> <script>
import "./../.env.js"
export default { export default {
onLaunch: function () { globalData: {
// 开发环境
uniEnv: process.uniEnv,
questionList: [],
orgId: -1
},
onLaunch: function(options) {
this.globalData.orgId = options?.orgId || -1
// 版本更新 // 版本更新
this.updateApp() this.updateApp()
}, },
onShow: function () { onShow: function() {
console.log('App Show') console.log('App Show')
}, },
onHide: function () { onHide: function() {
console.log('App Hide') console.log('App Hide')
}, },
methods: { methods: {
...@@ -28,7 +36,7 @@ export default { ...@@ -28,7 +36,7 @@ export default {
// } // }
// }) // })
updateManager.onUpdateReady(function (res) { updateManager.onUpdateReady(function(res) {
uni.showModal({ uni.showModal({
title: '更新提示', title: '更新提示',
content: '新版本已经准备好,是否重启应用?', content: '新版本已经准备好,是否重启应用?',
...@@ -43,7 +51,7 @@ export default { ...@@ -43,7 +51,7 @@ export default {
content: content:
'本次版本更新涉及到新的功能添加,旧版本无法正常访问的哦~', '本次版本更新涉及到新的功能添加,旧版本无法正常访问的哦~',
showCancel: false, showCancel: false,
success: function (result) { success: function(result) {
if (result.confirm) updateManager.applyUpdate() if (result.confirm) updateManager.applyUpdate()
}, },
}) })
...@@ -52,7 +60,7 @@ export default { ...@@ -52,7 +60,7 @@ export default {
}) })
}) })
updateManager.onUpdateFailed(function (res) { updateManager.onUpdateFailed(function(res) {
// 新的版本下载失败 // 新的版本下载失败
uni.showModal({ uni.showModal({
title: '已经有新版本了哟~', title: '已经有新版本了哟~',
...@@ -63,7 +71,8 @@ export default { ...@@ -63,7 +71,8 @@ export default {
} else { } else {
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。', content:
'当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。',
showCancel: false, showCancel: false,
}) })
} }
......
let commonApiFun = function(vm) { let commonApiFun = function(vm) {
let loginWechatAuth = async (params = {}) => await vm.$u.post('/authorization', params) const globalUrl = process.uniEnv || {}
let uCenterApiUrl = globalUrl.uCenterUrl
const commonApi = { let loginWechatAuth = async (params = {}) =>
loginWechatAuth await vm.$u.post('/wxapp/unify/authorization', params)
} let payOrder = async (params = {}) => await vm.$u.post('/pay/order', params)
return commonApi let payQuery = async (params = {}) => await vm.$u.get('/pay/query', params)
let getQiNiuToken = async (params = {}) =>
await vm.$u.post(uCenterApiUrl + 'v1/tokens', params)
const commonApi = {
loginWechatAuth,
payOrder,
payQuery,
getQiNiuToken,
}
return commonApi
} }
module.exports = { module.exports = {
commonApiFun commonApiFun,
} }
import { commonApiFun } from './common.js'; import { commonApiFun } from './common.js'
import { learnApiFun } from './learn.js'
import { userApiFun } from './user.js'
const apiFun = function(vm) { const apiFun = function(vm) {
let commonApi = commonApiFun(vm); let commonApi = commonApiFun(vm)
let learnApi = learnApiFun(vm)
let apiUrl = { let userApi = userApiFun(vm)
...commonApi,
} let apiUrl = {
return apiUrl ...commonApi,
...learnApi,
...userApi,
}
return apiUrl
} }
module.exports = { module.exports = {
apiFun apiFun,
} }
let learnApiFun = function(vm) {
const globalUrl = process.uniEnv || {}
let ucenterApiUrl = globalUrl.uUrl
let getQuestion = async (params = {}) =>
await vm.$u.post('/rest/question/query/getQuestion', params)
let getQuestionTotal = async (params = {}) =>
await vm.$u.post('/rest/question/query/getQuestionTotal', params)
let answer = async (params = {}) =>
await vm.$u.post('/rest/question/save/answer', params)
// 获取科目
let subjectList = async (params = {}) =>
await vm.$u.get('/rest/question/query/subjectList', params)
// 获取科目对应的题库
let getQuestionWarehouse = async (subjectId, params = {}) =>
await vm.$u.get(
'/rest/question/query/getQuestionWarehouse/' + subjectId,
params
)
// 查询省份列表
let getProvinceList = async (params = {}) =>
await vm.$u.get('/rest/question/getProvinceList', params)
// 学生查询题库首页
let queryMyQuestionWarehouseDetail = async (questionWarehouseId) =>
await vm.$u.get(
'/rest/question/query/queryMyQuestionWarehouseDetail/' +
questionWarehouseId
)
// 学员增加自己的题库
let addQuestionWarehouse = async (params = {}) =>
await vm.$u.post('/rest/question/query/addQuestionWarehouse', params)
let joinCollection = async (params = {}) =>
await vm.$u.get(
'/rest/question/join/collection/' + params.questionId,
params
)
let removeCollection = async (params = {}) =>
await vm.$u.get(
'/rest/question/remove/collection/' + params.questionId,
params
)
let removeError = async (params = {}) =>
await vm.$u.get('/rest/question/remove/error/' + params.questionId, params)
// 题库详情
let queryQuestionWarehouseById = async (questionWarehouseId) =>
await vm.$u.get(
'/rest/question/query/queryQuestionWarehouseById/' + questionWarehouseId
)
let getExamPaper = async (params = {}) =>
await vm.$u.get(
'/rest/question/getExamPaper/' + params.questionWarehouseId,
params
)
let applyExam = async (params = {}) =>
await vm.$u.get(
`/rest/question/applyExam/${params.questionWarehouseId}/${params.paperId}`,
params
)
let submitExamRecord = async (params = {}) =>
await vm.$u.post('/rest/question/submit/examRecord', params)
let queryExamRecord = async (params = {}) =>
await vm.$u.post('/rest/question/queryExamRecord', params)
let queryExamRecordOne = async (params = {}) =>
await vm.$u.get(`/rest/question/queryExamRecord/${params.id}`, params)
// 学员获取自己的题库
let getMyQuestionWarehouseList = async (params = {}) =>
await vm.$u.get('/rest/question/query/getMyQuestionWarehouseList', params)
let bindCard = async (params = {}) =>
await vm.$u.post('/rest/card/bind', params)
let searchQuestion = async (params = {}) =>
await vm.$u.get(
`/rest/question/searchQuestion/${params.questionWarehouseId}`,
params
)
// 检查是否具有体验资格
let checkGetQuestion = async (questionWarehouseId) =>
await vm.$u.get('/rest/question/checkGetQuestion/' + questionWarehouseId)
const learnApi = {
getQuestion,
getQuestionTotal,
answer,
subjectList,
getQuestionWarehouse,
getProvinceList,
queryMyQuestionWarehouseDetail,
addQuestionWarehouse,
joinCollection,
removeCollection,
removeError,
queryQuestionWarehouseById,
getExamPaper,
applyExam,
submitExamRecord,
queryExamRecord,
queryExamRecordOne,
getMyQuestionWarehouseList,
bindCard,
searchQuestion,
checkGetQuestion,
}
return learnApi
}
module.exports = {
learnApiFun,
}
const globalUrl = process.uniEnv || {}
const apiUrl = globalUrl.apiUrl
const uCenterUrl = globalUrl.uCenterUrl
let userApiFun = function(vm) {
/* 更新学员信息 */
let updateUserInfo = async (params = {}) =>
await vm.$u.post(apiUrl + '/student/update', params)
//获取学员信息
let getUserInfo = async (params = {}) =>
await vm.$u.get(apiUrl + '/student/get', params)
//验证身份证正面
let checkIdCardFront = async (params = {}) =>
await vm.$u.post(uCenterUrl + 'v1/settled/card-front', params)
//验证身份证反面
let checkIdCardBack = async (params = {}) =>
await vm.$u.post(uCenterUrl + 'v1/settled/card-back', params)
let getCountryCertList = async (params = {}) =>
await vm.$u.post(apiUrl + '/rest/certificate/query', params)
let getlearnCertList = async (params = {}) =>
await vm.$u.get(apiUrl + '/rest/question/getSchoolCertificate', params)
let getlearnCertDetail = async (questionWarehouseId, params = {}) =>
await vm.$u.get(
apiUrl + '/rest/question/getSchoolCertificate/' + questionWarehouseId,
params
)
const userApi = {
updateUserInfo,
getUserInfo,
checkIdCardFront,
checkIdCardBack,
getCountryCertList,
getlearnCertList,
getlearnCertDetail,
}
return userApi
}
module.exports = {
userApiFun,
}
const globalUrl = process.uniEnv || {} const globalUrl = process.uniEnv || {}
// 这里的vm,就是我们在vue文件里面的this,所以我们能在这里获取vuex的变量,比如存放在里面的token变量 // 这里的vm,就是我们在vue文件里面的this,所以我们能在这里获取vuex的变量,比如存放在里面的token变量
const install = (Vue, vm) => { const install = (Vue, vm) => {
const systemApiUrl = globalUrl.apiUrl const systemApiUrl = globalUrl.apiUrl
// 此为自定义配置参数,具体参数见上方说明 // 此为自定义配置参数,具体参数见上方说明
Vue.prototype.$u.http.setConfig({ Vue.prototype.$u.http.setConfig({
baseUrl: systemApiUrl, baseUrl: systemApiUrl,
header: { header: {
'content-type': 'application/json; charset=utf-8' channel: 'Applets',
}, tenant: 'weixiuhui',
loadingTime: 800, 'content-type': 'application/json; charset=utf-8',
// ...... },
}); loadingTime: 800,
showLoading: false,
// 请求拦截,配置Token等参数 originalData: true,
Vue.prototype.$u.http.interceptor.request = (config) => { })
// 引用token
const token = vm.vuex_token // 请求拦截,配置Token等参数
const reg = /\?\w+/ Vue.prototype.$u.http.interceptor.request = (config) => {
if(config.url.indexOf('access-token=') >=0 && config.params['access-token']){ // 引用token
// 给默认参数增加access-token (Java端) // const token = vm.vuex_token
if(reg.test(config.url)){ config.header.token = vm.vuex_token
config.url += '&access-token=' + token // const reg = /\?\w+/
}else{ // if(config.url.indexOf('access-token=') >=0 && config.params['access-token']){
config.url += '?access-token=' + token // // 给默认参数增加access-token (Java端)
} // if(reg.test(config.url)){
} // config.url += '&access-token=' + token
// }else{
// config.url += '?access-token=' + token
// }
// }
// 最后需要将config进行return
return config
// 如果return一个false值,则会取消本次请求
// if(config.url == '/user/rest') return false; // 取消某次请求
}
// 最后需要将config进行return // 响应拦截,判断状态码是否通过
return config; Vue.prototype.$u.http.interceptor.response = (res) => {
// 如果return一个false值,则会取消本次请求 const data = res.data
// if(config.url == '/user/rest') return false; // 取消某次请求 let pages = getCurrentPages()
} let route = pages[pages.length - 1].route
if (res.statusCode === 200) {
// 响应拦截,判断状态码是否通过 if (data.code === 0) {
Vue.prototype.$u.http.interceptor.response = (res) => { return data.data
if(res.code == 200) { } else if (data.code === 401) {
// res为服务端返回值,可能有code,result等字段 vm.$u.toast(data.msg)
// 这里对res.result进行返回,将会在this.$u.post(url).then(res => {})的then回调中的res的到 // 如果不是在登录页,则跳转到登录页
// 如果配置了originalData为true,请留意这里的返回值 if (route !== 'pages/login/index') {
return res.result; setTimeout(() => {
} else if(res.code == 201) { vm.$u.route('/pages/login/index')
// 假设201为token失效,这里跳转登录 }, 1500)
vm.$u.toast('验证失败,请重新登录'); }
setTimeout(() => { return false
// 此为uView的方法,详见路由相关文档 } else {
vm.$u.route('/pages/user/login') // 如果返回false,则会调用Promise的reject回调,
}, 1500) vm.$u.toast(data.msg)
return false; return false
} else { }
// 如果返回false,则会调用Promise的reject回调, } else if (res.statusCode === 401) {
// 并将进入this.$u.post(url).then().catch(res=>{})的catch回调中,res为服务端的返回值 // 登录过期
return false; vm.$u.toast(data.msg)
} if (route !== 'pages/login/index') {
} setTimeout(() => {
vm.$u.route('/pages/login/index')
}, 1500)
}
} else {
// HTTP状态非200
vm.$u.toast(data.msg || '服务器错误')
return false
}
}
} }
export default { export default {
install install,
} }
\ No newline at end of file
function appLogin() {
return new Promise(function(resolve, reject) {
uni.login({
success(res) {
if (!res.code) {
uni.hideLoading()
uni.showModal({
content: res.errMsg,
showCancel: false,
})
}
resolve(res)
},
fail() {
uni.hideLoading()
uni.showModal({
content: '小程序登录失败',
showCancel: false,
})
reject()
},
})
})
}
export default {
appLogin,
}
/*
* A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
* Digest Algorithm, as defined in RFC 1321.
* Version 1.1 Copyright (C) Paul Johnston 1999 - 2002.
* Code also contributed by Greg Holt
* See http://pajhome.org.uk/site/legal.html for details.
*/
/*
* Add integers, wrapping at 2^32. This uses 16-bit operations internally
* to work around bugs in some JS interpreters.
*/
function safe_add(x, y)
{
var lsw = (x & 0xFFFF) + (y & 0xFFFF)
var msw = (x >> 16) + (y >> 16) + (lsw >> 16)
return (msw << 16) | (lsw & 0xFFFF)
}
/*
* Bitwise rotate a 32-bit number to the left.
*/
function rol(num, cnt)
{
return (num << cnt) | (num >>> (32 - cnt))
}
/*
* These functions implement the four basic operations the algorithm uses.
*/
function cmn(q, a, b, x, s, t)
{
return safe_add(rol(safe_add(safe_add(a, q), safe_add(x, t)), s), b)
}
function ff(a, b, c, d, x, s, t)
{
return cmn((b & c) | ((~b) & d), a, b, x, s, t)
}
function gg(a, b, c, d, x, s, t)
{
return cmn((b & d) | (c & (~d)), a, b, x, s, t)
}
function hh(a, b, c, d, x, s, t)
{
return cmn(b ^ c ^ d, a, b, x, s, t)
}
function ii(a, b, c, d, x, s, t)
{
return cmn(c ^ (b | (~d)), a, b, x, s, t)
}
/*
* Calculate the MD5 of an array of little-endian words, producing an array
* of little-endian words.
*/
function coreMD5(x)
{
var a = 1732584193
var b = -271733879
var c = -1732584194
var d = 271733878
for(var i = 0; i < x.length; i += 16)
{
var olda = a
var oldb = b
var oldc = c
var oldd = d
a = ff(a, b, c, d, x[i+ 0], 7 , -680876936)
d = ff(d, a, b, c, x[i+ 1], 12, -389564586)
c = ff(c, d, a, b, x[i+ 2], 17, 606105819)
b = ff(b, c, d, a, x[i+ 3], 22, -1044525330)
a = ff(a, b, c, d, x[i+ 4], 7 , -176418897)
d = ff(d, a, b, c, x[i+ 5], 12, 1200080426)
c = ff(c, d, a, b, x[i+ 6], 17, -1473231341)
b = ff(b, c, d, a, x[i+ 7], 22, -45705983)
a = ff(a, b, c, d, x[i+ 8], 7 , 1770035416)
d = ff(d, a, b, c, x[i+ 9], 12, -1958414417)
c = ff(c, d, a, b, x[i+10], 17, -42063)
b = ff(b, c, d, a, x[i+11], 22, -1990404162)
a = ff(a, b, c, d, x[i+12], 7 , 1804603682)
d = ff(d, a, b, c, x[i+13], 12, -40341101)
c = ff(c, d, a, b, x[i+14], 17, -1502002290)
b = ff(b, c, d, a, x[i+15], 22, 1236535329)
a = gg(a, b, c, d, x[i+ 1], 5 , -165796510)
d = gg(d, a, b, c, x[i+ 6], 9 , -1069501632)
c = gg(c, d, a, b, x[i+11], 14, 643717713)
b = gg(b, c, d, a, x[i+ 0], 20, -373897302)
a = gg(a, b, c, d, x[i+ 5], 5 , -701558691)
d = gg(d, a, b, c, x[i+10], 9 , 38016083)
c = gg(c, d, a, b, x[i+15], 14, -660478335)
b = gg(b, c, d, a, x[i+ 4], 20, -405537848)
a = gg(a, b, c, d, x[i+ 9], 5 , 568446438)
d = gg(d, a, b, c, x[i+14], 9 , -1019803690)
c = gg(c, d, a, b, x[i+ 3], 14, -187363961)
b = gg(b, c, d, a, x[i+ 8], 20, 1163531501)
a = gg(a, b, c, d, x[i+13], 5 , -1444681467)
d = gg(d, a, b, c, x[i+ 2], 9 , -51403784)
c = gg(c, d, a, b, x[i+ 7], 14, 1735328473)
b = gg(b, c, d, a, x[i+12], 20, -1926607734)
a = hh(a, b, c, d, x[i+ 5], 4 , -378558)
d = hh(d, a, b, c, x[i+ 8], 11, -2022574463)
c = hh(c, d, a, b, x[i+11], 16, 1839030562)
b = hh(b, c, d, a, x[i+14], 23, -35309556)
a = hh(a, b, c, d, x[i+ 1], 4 , -1530992060)
d = hh(d, a, b, c, x[i+ 4], 11, 1272893353)
c = hh(c, d, a, b, x[i+ 7], 16, -155497632)
b = hh(b, c, d, a, x[i+10], 23, -1094730640)
a = hh(a, b, c, d, x[i+13], 4 , 681279174)
d = hh(d, a, b, c, x[i+ 0], 11, -358537222)
c = hh(c, d, a, b, x[i+ 3], 16, -722521979)
b = hh(b, c, d, a, x[i+ 6], 23, 76029189)
a = hh(a, b, c, d, x[i+ 9], 4 , -640364487)
d = hh(d, a, b, c, x[i+12], 11, -421815835)
c = hh(c, d, a, b, x[i+15], 16, 530742520)
b = hh(b, c, d, a, x[i+ 2], 23, -995338651)
a = ii(a, b, c, d, x[i+ 0], 6 , -198630844)
d = ii(d, a, b, c, x[i+ 7], 10, 1126891415)
c = ii(c, d, a, b, x[i+14], 15, -1416354905)
b = ii(b, c, d, a, x[i+ 5], 21, -57434055)
a = ii(a, b, c, d, x[i+12], 6 , 1700485571)
d = ii(d, a, b, c, x[i+ 3], 10, -1894986606)
c = ii(c, d, a, b, x[i+10], 15, -1051523)
b = ii(b, c, d, a, x[i+ 1], 21, -2054922799)
a = ii(a, b, c, d, x[i+ 8], 6 , 1873313359)
d = ii(d, a, b, c, x[i+15], 10, -30611744)
c = ii(c, d, a, b, x[i+ 6], 15, -1560198380)
b = ii(b, c, d, a, x[i+13], 21, 1309151649)
a = ii(a, b, c, d, x[i+ 4], 6 , -145523070)
d = ii(d, a, b, c, x[i+11], 10, -1120210379)
c = ii(c, d, a, b, x[i+ 2], 15, 718787259)
b = ii(b, c, d, a, x[i+ 9], 21, -343485551)
a = safe_add(a, olda)
b = safe_add(b, oldb)
c = safe_add(c, oldc)
d = safe_add(d, oldd)
}
return [a, b, c, d]
}
/*
* Convert an array of little-endian words to a hex string.
*/
function binl2hex(binarray)
{
var hex_tab = "0123456789abcdef"
var str = ""
for(var i = 0; i < binarray.length * 4; i++)
{
str += hex_tab.charAt((binarray[i>>2] >> ((i%4)*8+4)) & 0xF) +
hex_tab.charAt((binarray[i>>2] >> ((i%4)*8)) & 0xF)
}
return str
}
/*
* Convert an array of little-endian words to a base64 encoded string.
*/
function binl2b64(binarray)
{
var tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
var str = ""
for(var i = 0; i < binarray.length * 32; i += 6)
{
str += tab.charAt(((binarray[i>>5] << (i%32)) & 0x3F) |
((binarray[i>>5+1] >> (32-i%32)) & 0x3F))
}
return str
}
/*
* Convert an 8-bit character string to a sequence of 16-word blocks, stored
* as an array, and append appropriate padding for MD4/5 calculation.
* If any of the characters are >255, the high byte is silently ignored.
*/
function str2binl(str)
{
var nblk = ((str.length + 8) >> 6) + 1 // number of 16-word blocks
var blks = new Array(nblk * 16)
for(var i = 0; i < nblk * 16; i++) blks[i] = 0
for(var i = 0; i < str.length; i++)
blks[i>>2] |= (str.charCodeAt(i) & 0xFF) << ((i%4) * 8)
blks[i>>2] |= 0x80 << ((i%4) * 8)
blks[nblk*16-2] = str.length * 8
return blks
}
/*
* Convert a wide-character string to a sequence of 16-word blocks, stored as
* an array, and append appropriate padding for MD4/5 calculation.
*/
function strw2binl(str)
{
var nblk = ((str.length + 4) >> 5) + 1 // number of 16-word blocks
var blks = new Array(nblk * 16)
for(var i = 0; i < nblk * 16; i++) blks[i] = 0
for(var i = 0; i < str.length; i++)
blks[i>>1] |= str.charCodeAt(i) << ((i%2) * 16)
blks[i>>1] |= 0x80 << ((i%2) * 16)
blks[nblk*16-2] = str.length * 16
return blks
}
/*
* External interface
*/
function hexMD5 (str) { return binl2hex(coreMD5( str2binl(str))) }
function hexMD5w(str) { return binl2hex(coreMD5(strw2binl(str))) }
function b64MD5 (str) { return binl2b64(coreMD5( str2binl(str))) }
function b64MD5w(str) { return binl2b64(coreMD5(strw2binl(str))) }
/* Backward compatibility */
function calcMD5(str) { return binl2hex(coreMD5( str2binl(str))) }
module.exports = {
hexMD5: hexMD5
}
\ No newline at end of file
function hasPermissionOfCamera() {
//如果没权限提示文字,还没取得权限会自动吊起询问权限,已经有权限自动返回true
return new Promise((r, j) => {
uni.authorize({
scope: 'scope.camera',
success: function() {
r(true)
},
fail: function() {
uni.showModal({
content: '拒绝授权将无法进行拍照和上传图片,是否去设置打开?',
confirmText: '确认',
cancelText: '取消',
success(res) {
if (res.confirm) {
openSetting()
}
},
fail() {
j(false)
},
})
},
complete: function() {
console.log('done!')
},
})
})
}
function openSetting() {
// 打开设置
wx.openSetting({
success(res) {
console.log(res)
},
})
}
//吊起设备原生相机相册取得文件,并自动上传七牛,返回七牛key,domain,本地file信息
function getPhoto(type, token) {
return new Promise((resolve, reject) => {
hasPermissionOfCamera().then((r) => {
if (!r) {
reject(false)
}
let sourceType = type == 1 ? ['album'] : ['album', 'camera']
uni.chooseImage({
count: 6, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: sourceType, //从相册选择
success: function(res) {
//上传七牛
let filePath = res.tempFiles[0].path //为需要上传的文件
upload(filePath, token)
.then((msg) => {
//最后七牛返回的key
resolve({
key: msg,
files: res.tempFiles,
})
})
.catch((msg) => {
console.error(msg)
reject(msg)
})
},
})
})
})
}
//上传七牛
function upload(filePath, token) {
console.log('filePath', filePath)
console.log('token', token)
return new Promise((resolve, reject) => {
let key =
new Date().getTime() + Math.random(1000) + filePath.split('/').pop() //key为自定义文件名
uni.uploadFile({
url: 'https://up.qiniup.com', // default ecn华北的地址,在七牛云中选择对应位置的网址
filePath: filePath,
name: 'file',
formData: {
token: token,
key: key,
},
complete: (res) => {
if (res.statusCode === 200) {
resolve(JSON.parse(res.data).key)
} else {
reject(res.errMsg)
}
},
})
})
}
export default {
upload,
getPhoto,
}
<template>
<!-- 合格/不合格弹窗 -->
<u-popup
border-radius="24"
v-model="visible"
safe-area-inset-bottom
mode="center"
width="654rpx"
:mask-close-able="false"
>
<view class="pop-view">
<image mode="widthFix" class="image-view" :src="backgroundImage"></image>
<view :class="['head-view', { 'is-daily': isDaily }]">
<view class="pop-title">
<text>{{ info.title }}</text>
</view>
<view class="pop-message" v-if="isDaily">
<text>{{ info.message }}</text>
</view>
</view>
<view class="pop-content">
<view
v-for="(item, index) in numberList"
:key="index"
:class="['list-view', { 'is-daily': isDaily }]"
>
<view>{{ item }}</view>
<view class="label-view">{{ info.labels[index] }}</view>
</view>
</view>
<view :class="['pop-btn-view', { timeout: timeout }]">
<u-button
v-if="!timeout"
:custom-style="customStyleCancel"
hover-class="none"
shape="circle"
@click="handleClickCancel"
>
{{ info.buttonTextCancel }}
</u-button>
<u-button
:custom-style="customStyleSave"
shape="circle"
type="primary"
@click="handleClickSure"
>
{{ info.buttonTextSure }}
</u-button>
</view>
</view>
</u-popup>
</template>
<script>
/**
* @description 创建一个遮罩层,提示文字和图片
* @property {Boolean} visible 是否显示(默认false)
* @property {String} type pass:合格;fail:不合格;daily:每日一练
* @property {Array} numberList 展示数字
* @example <answer-complete-pop :numberList="[1, 2, 3]" type="pass" :visible.sync="visible"></answer-complete-pop>
*/
export default {
props: {
visible: {
type: Boolean,
default: false,
},
// pass:合格;fail:不合格;
type: {
type: String,
default: '',
},
timeout: {
type: Boolean,
default: false,
},
numberList: {
type: Array,
default: [],
},
},
data() {
return {}
},
computed: {
info() {
switch (this.type) {
case 'pass':
return {
image: 'chegnjihege-f.png',
title: this.timeout ? '考试时间到' : '成绩已合格',
message: '',
buttonTextCancel: '继续答题',
buttonTextSure: '现在交卷',
labels: ['做错题', '未做题', '分数'],
}
case 'fail':
return {
image: 'chengjibuhege-f.png',
title: this.timeout ? '考试时间到' : '成绩不合格',
message: '',
buttonTextCancel: '继续答题',
buttonTextSure: '现在交卷',
labels: ['做错题', '未做题', '分数'],
}
}
},
isDaily() {
return this.type == 'daily'
},
backgroundImage() {
return process.uniEnv.qn_base_url + this.info.image
},
customStyleCancel() {
return {
width: '264rpx',
height: '96rpx',
color: '#9EA5BB',
fontWeight: 'bold',
fontSize: '32rpx',
}
},
customStyleSave() {
return {
backgroundColor: '#2953FF',
width: '264rpx',
height: '96rpx',
color: '#ffffff',
fontWeight: 'bold',
fontSize: '32rpx',
}
},
},
methods: {
changeVisibleValue(val) {
this.$emit('update:visible', val)
},
handleClickCancel() {
this.changeVisibleValue(false)
this.$emit('cancel')
},
handleClickSure() {
this.$emit('submit')
},
},
}
</script>
<style lang="scss" scoped>
.pop-view {
padding: 48rpx 24rpx;
min-height: 520rpx;
position: relative;
text-align: center;
.head-view {
width: 100%;
height: 432;
padding-top: 10rpx;
padding-bottom: 300rpx;
&.is-daily {
padding-top: 160rpx;
padding-bottom: 30rpx;
}
.pop-title {
font-size: 48rpx;
text-align: center;
color: #ffffff;
font-weight: bold;
}
.pop-message {
margin-top: 110rpx;
font-size: 28rpx;
text-align: center;
color: #5a6073;
}
}
.image-view {
width: 100%;
position: absolute;
top: 0;
left: 0;
z-index: -1;
}
.pop-content {
margin-bottom: 140rpx;
display: flex;
align-items: center;
justify-content: space-around;
.list-view {
font-size: 56rpx;
color: #191c27;
font-weight: bold;
padding-top: 40rpx;
width: 30%;
&.is-daily {
color: #2953ff;
font-size: 80rpx;
display: flex;
align-items: flex-end;
justify-content: center;
padding-bottom: 30rpx;
padding-top: 0rpx;
}
.label-view {
font-size: 28rpx;
color: #5a6073;
margin-bottom: 22rpx;
padding-top: 6rpx;
&.is-daily {
padding-left: 14rpx;
}
}
}
}
.line-view {
background-color: #e8ebf3;
height: 2rpx;
width: 100%;
margin-bottom: 40rpx;
margin-top: 40rpx;
}
.pop-btn-view {
display: flex;
align-items: center;
justify-content: space-between;
position: absolute;
bottom: 48rpx;
left: 40rpx;
right: 40rpx;
&.timeout {
justify-content: center;
}
}
}
</style>
<template>
<view class="card">
<view slot="head" class="u-flex head">
<view class="blue"></view>
<view class="title">试题详解:</view>
</view>
<view class="u-flex content" slot="body">
<view class="lists">正确答案:{{ answer }}</view>
<view class="lists">解释说明:{{ explain }}</view>
</view>
</view>
</template>
<script>
export default {
name: 'answerSheet',
props: {
answer: {
type: String,
default: '',
},
explain: {
type: String,
default: '',
},
},
}
</script>
<style lang="scss" scoped>
.card {
padding: 20rpx 10rpx 20rpx 5rpx;
border: 2px solid #e8ebf3;
border-radius: 10rpx;
.head {
font-size: 32rpx;
font-weight: bold;
padding: 10rpx 0rpx;
.blue {
width: 4rpx;
height: 34rpx;
background: #2953ff;
position: relative;
left: -8rpx;
}
.title {
padding-left: 25rpx;
color: #191C27;
}
}
.content {
flex-flow: column;
width: 100%;
padding-bottom: 20rpx;
.lists {
width: 100%;
text-align: left;
padding: 10rpx 0 0rpx 30rpx;
line-height: 50rpx;
color: #5A6073;
}
.lists:nth-of-type(1) {
color: #2953ff;
}
}
}
</style>
## 答案解释
## API
### Props
| 属性名 | 类型 | 默认值 | 可选值 | 说明 |
| :-----: | :----: | :----: | :----: | :------: |
| answer | String | - | - | 正确答案 |
| explain | String | - | - | 解释说明 |
## 组件用法
### 基础用法
```html
<answer-explanation answer="A" explain="无"></answer-explanation>
```
```javascript
import answerExplanation from '@/components/answer-explanation/index.vue'
export default {
components: {
answerExplanation,
}
}
```
<template>
<u-mask :show="show" :mask-close-able="false" :customStyle="customStyle">
<view class="tip-view">
<view class="tip-content">
<image class="tip-image" :src="imageUrl"></image>
<view class="tip-message">
<text>{{ message }}</text>
</view>
<view class="tip-btn-view">
<u-button
:custom-style="buttonStyle"
shape="circle"
type="primary"
@click="handleClick"
>
{{ buttonText }}
</u-button>
</view>
</view>
</view>
</u-mask>
</template>
<script>
/**
* @description 创建一个遮罩层,提示文字和图片
* @property {Boolean} visible 是否显示遮罩(默认false)
* @property {Object} customStyle 自定义样式对象,见上方说明
* @example <answer-operation-tips :show.sync="show"></answer-operation-tips>
*/
export default {
props: {
show: {
type: Boolean,
default: false,
},
message: {
type: String,
default: '左右滑动可切换上下题',
},
buttonText: {
type: String,
default: '我知道了',
},
customStyle: {
type: Object,
default() {
return {}
},
},
},
data() {
return {}
},
computed: {
imageUrl() {
return process.uniEnv.qn_base_url + 'zuoyouqiehuantishi.png'
},
buttonStyle() {
return {
backgroundColor: '#FFFFFF',
width: '304rpx',
height: '104rpx',
color: '#2953FF',
fontWeight: 'bold',
fontSize: '32rpx',
}
},
},
methods: {
handleClick() {
this.$emit('update:show', false)
this.$emit('click')
},
},
}
</script>
<style lang="scss" scoped>
.tip-view {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
.tip-content {
margin-top: 200rpx;
text-align: center;
.tip-image {
width: 662rpx;
height: 136rpx;
margin-bottom: 60rpx;
}
.tip-message {
font-size: 44rpx;
text-align: center;
color: #ffffff;
font-weight: bold;
}
.tip-btn-view {
padding-top: 288rpx;
}
}
}
</style>
<template>
<view class="u-flex sheet">
<view
class="u-flex u-col-center lists"
v-for="(item, index) in lists"
:key="index"
@click="select(index)"
>
<view v-if="!item.confirm" :class="['icons', { checked: item.checked }]">
{{ item.sort }}
</view>
<view
v-else
:class="[rightKey.includes(item.sort) ? 'success' : 'error']"
></view>
<view class="text">{{ item.text }}</view>
</view>
<view class="btn" v-if="rightKey.length > 1 && btnStatus">
<view
:class="['confirm', { active: getCheckedNum }]"
@click="confirmMultiple"
>确定</view
>
</view>
</view>
</template>
<script>
const equar = (a, b) => {
// 判断数组的长度
if (a.length !== b.length) {
return false
} else {
// 循环遍历数组的值进行比较
for (let i = 0; i < a.length; i++) {
if (a[i] !== b[i]) {
return false
}
}
return true
}
}
export default {
name: 'answerSheet',
props: {
answerList: {
type: Array,
default: [],
},
multiple: {
type: Boolean,
default: false,
},
rightKey: {
type: Array,
default: [],
},
submitStatus: {
type: Boolean,
default: false,
},
btnStatus: {
type: Boolean,
default: true,
}
},
data() {
return {
lists: [],
// 答案对错
answer: '',
userAnswer: ''
}
},
watch: {
answerList: {
handler: function(newValue, oldValue) {
if (newValue.length > 0) {
this.lists = newValue
}
},
immediate: true,
},
},
computed: {
getCheckedNum() {
const num = this.lists.filter((v) => v.checked)
return num.length > 1 ? true : false
}
},
methods: {
select(index) {
// 已选定
if (this.submitStatus) return
if (!this.multiple) {
// 非多选处理
this.lists.forEach((v) => {
v.checked = false // 勾选
v.confirm = false // 确认答案
if (this.rightKey.includes(v.sort)) {
this.$set(v, 'checked', true)
this.$set(v, 'confirm', true)
}
})
this.$set(this.lists[index], 'confirm', true)
// 用户选的答案
this.userAnswer = this.lists[index].sort
// 判断所选答案是否正确
this.answer = this.rightKey.includes(this.lists[index].sort)
? 'pass'
: 'fail'
}
this.$set(this.lists[index], 'checked', !this.lists[index].checked)
// 单选、判断提交答案
if (!this.multiple) this.submitAnswer()
},
// 多选提交答案
confirmMultiple() {
const num = this.lists.filter((v) => v.checked)
if (num.length > 1) {
// 判断所选答案是否正确
const checkedList = num.map((v) => v.sort)
// 用户选的答案
this.userAnswer = checkedList.join(',')
// 判断所选答案是否正确
this.answer = equar(checkedList, this.rightKey) ? 'pass' : 'fail'
// 处理显示逻辑
this.lists.forEach((v) => {
if (v.checked) this.$set(v, 'confirm', true)
if (this.rightKey.includes(v.sort)) this.$set(v, 'checked', true)
})
this.submitAnswer()
}
},
submitAnswer() {
this.$emit('change', this.answer, this.lists, this.userAnswer)
},
},
}
</script>
<style lang="scss" scoped>
.sheet {
flex-flow: column;
.lists {
padding: 10rpx 0;
width: 100%;
.icons {
font-size: 28rpx;
color: #191c27;
border: 2rpx solid #9ea5bb;
text-align: center;
width: 40rpx;
height: 40rpx;
line-height: 40rpx;
border-radius: 10rpx;
}
.checked {
background: #2953ff;
border: 2rpx solid #2953ff;
color: #fff;
}
.success {
width: 40rpx;
height: 40rpx;
line-height: 40rpx;
border-radius: 10rpx;
background: url('https://qn-static.banshouhui.com/study/pass.png') no-repeat;
background-size: 40rpx 40rpx;
text-align: center;
}
.error {
width: 40rpx;
height: 40rpx;
line-height: 40rpx;
border-radius: 10rpx;
background: url('https://qn-static.banshouhui.com/study/fail.png') no-repeat;
background-size: 40rpx 40rpx;
text-align: center;
}
.text {
color: #191C27;
padding-left: 20rpx;
flex: 1;
}
}
.btn {
text-align: center;
margin-top: 50rpx;
.confirm {
width: 400rpx;
height: 100rpx;
line-height: 100rpx;
background: #d4d7df;
color: #fff;
border-radius: 50rpx;
font-size: 32rpx;
font-weight: bold;
text-align: center;
}
.active {
background: #2953ff;
}
}
}
</style>
## 答题卡
```
答题卡组件,用于考试选择答案,可以单选、多选。
```
## API
### Props
| 属性名 | 类型 | 默认值 | 可选值 | 说明 |
| :----------: | :-----: | :----: | :--------: | :---------------------------------------------: |
| multiple | Boolean | false | true/false | 是否支持多选 |
| submitStatus | Boolean | false | true/false | 是否已选定答案, 选定后回到该页面将不能再重新选 |
| answerList | Array | [] | - | 答案列表 **格式见下文** |
| rightKey | Array | [] | - | 正确答案 ['A'] |
### answerList 格式
```json
[
{
sort: 'A',
text: '影响',
checked: 'true' // 默认勾选
confirm: 'true' // 确认勾选,确认后不可重新勾选,会显示该答案正确还是错误
},
{
sort: 'B',
text: '影响很小',
},
{
sort: 'C',
text: '影响很大',
},
{
sort: 'D',
text: '无影响',
},
]
```
### Events
| 事件称名 | 说明 | 返回值 |
| :------: | :------------: | :-------------------------: |
| @change | 改变答案后触发 | 已选答案数组 **格式见下文** |
```json
[
{
"text": "" // 答案描述
}
]
```
## 组件用法
### 基础用法
```html
<answer-sheet
:answerList="lists"
:multiple="true"
:rightKey="rightKey"
@change="answerChange"
></answer-sheet>
```
```javascript
import answerSheet from '@/components/answer-sheet/index.vue'
export default {
components: {
answerSheet,
},
data() {
return {
lists: [
{
sort: 'A',
text: '影响',
checked: 'true' // 默认勾选
confirm: 'true' // 确认勾选,确认后不可重新勾选,会显示该答案正确还是错误
},
{
sort: 'B',
text: '影响很小',
},
{
sort: 'C',
text: '影响很大',
},
{
sort: 'D',
text: '无影响',
},
],
rightKey: ['B', 'C']
}
},
methods: {
// 已选答案
answerChange(event) {
console.log('event', event)
},
},
}
```
<template>
<view
class="u-circle-progress"
:style="{
width: widthPx + 'px',
height: widthPx + 'px',
backgroundColor: bgColor,
}"
>
<!-- 支付宝小程序不支持canvas-id属性,必须用id属性 -->
<canvas
class="u-canvas-bg"
:canvas-id="elBgId"
:id="elBgId"
:style="{
width: widthPx + 'px',
height: widthPx + 'px',
}"
></canvas>
<canvas
class="u-canvas"
:canvas-id="elId"
:id="elId"
:style="{
width: widthPx + 'px',
height: widthPx + 'px',
}"
></canvas>
<slot></slot>
</view>
</template>
<script>
/**
* circleProgress 环形进度条
* @description 展示操作或任务的当前进度,比如上传文件,是一个圆形的进度条。注意:此组件的percent值只能动态增加,不能动态减少。
* @property {String Number} percent 圆环进度百分比值,为数值类型,0-100
* @property {String} inactive-color 圆环的底色,默认为灰色(该值无法动态变更)(默认#ececec)
* @property {String} active-color 圆环激活部分的颜色(该值无法动态变更)(默认#19be6b)
* @property {String Number} width 整个圆环组件的宽度,高度默认等于宽度值,单位rpx(默认200)
* @property {String Number} border-width 圆环的边框宽度,单位rpx(默认14)
* @property {String Number} duration 整个圆环执行一圈的时间,单位ms(默认呢1500)
* @property {String} type 如设置,active-color值将会失效
* @property {String} bg-color 整个组件背景颜色,默认为白色
* @example <circle-progress active-color="#2979ff" :percent="80"></circle-progress>
*/
export default {
name: 'circle-progress',
props: {
// 圆环进度百分比值
percent: {
type: Number,
default: 0,
// 限制值在0到100之间
validator: (val) => {
return val >= 0 && val <= 100
},
},
// 底部圆环的颜色(灰色的圆环)
inactiveColor: {
type: String,
default: '#ececec',
},
// 圆环激活部分的颜色
activeColor: {
type: String,
default: '#19be6b',
},
// 圆环线条的宽度,单位rpx
borderWidth: {
type: [Number, String],
default: 14,
},
// 整个圆形的宽度,单位rpx
width: {
type: [Number, String],
default: 200,
},
// 整个圆环执行一圈的时间,单位ms
duration: {
type: [Number, String],
default: 1500,
},
// 主题类型
type: {
type: String,
default: '',
},
// 整个圆环进度区域的背景色
bgColor: {
type: String,
default: '#ffffff',
},
},
data() {
return {
// #ifdef MP-WEIXIN
elBgId: 'uCircleProgressBgId', // 微信小程序中不能使用this.$u.guid()形式动态生成id值,否则会报错
elId: 'uCircleProgressElId',
// #endif
// #ifndef MP-WEIXIN
elBgId: this.$u.guid(), // 非微信端的时候,需用动态的id,否则一个页面多个圆形进度条组件数据会混乱
elId: this.$u.guid(),
// #endif
widthPx: uni.upx2px(this.width), // 转成px后的整个组件的背景宽度
borderWidthPx: uni.upx2px(this.borderWidth), // 转成px后的圆环的宽度
startAngle: Math.PI * 0.84, // canvas画圆的起始角度,默认为3点钟方向,定位到8点钟方向
progressContext: null, // 活动圆的canvas上下文
newPercent: 0, // 当动态修改进度值的时候,保存进度值的变化前后值,用于比较用
oldPercent: 0, // 当动态修改进度值的时候,保存进度值的变化前后值,用于比较用
}
},
watch: {
percent(nVal, oVal = 0) {
if (nVal > 100) nVal = 100
if (nVal < 0) oVal = 0
// 此值其实等于this.percent,命名一个新
this.newPercent = nVal
this.oldPercent = oVal
setTimeout(() => {
// 无论是百分比值增加还是减少,需要操作还是原来的旧的百分比值
// 将此值减少或者新增到新的百分比值
this.drawCircleByProgress(oVal)
}, 50)
},
},
created() {
// 赋值,用于加载后第一个画圆使用
this.newPercent = this.percent
this.oldPercent = 0
},
computed: {
// 有type主题时,优先起作用
circleColor() {
if (
['success', 'error', 'info', 'primary', 'warning'].indexOf(this.type) >=
0
)
return this.$u.color[this.type]
else return this.activeColor
},
},
mounted() {
// 在h5端,必须要做一点延时才起作用,this.$nextTick()无效(HX2.4.7)
setTimeout(() => {
this.drawProgressBg()
this.drawCircleByProgress(this.oldPercent)
}, 50)
},
methods: {
drawProgressBg() {
let ctx = uni.createCanvasContext(this.elBgId, this)
ctx.setLineWidth(this.borderWidthPx) // 设置圆环宽度
ctx.setStrokeStyle(this.inactiveColor) // 线条颜色
ctx.beginPath() // 开始描绘路径
// 设置一个原点(110,110),半径为100的圆的路径到当前路径
let radius = this.widthPx / 2
ctx.arc(
radius,
radius,
radius - this.borderWidthPx,
this.startAngle,
2.16 * Math.PI,
false
)
ctx.stroke() // 对路径进行描绘
ctx.draw()
},
drawCircleByProgress(progress) {
// 第一次操作进度环时将上下文保存到了this.data中,直接使用即可
let ctx = this.progressContext
if (!ctx) {
ctx = uni.createCanvasContext(this.elId, this)
this.progressContext = ctx
}
// 表示进度的两端为圆形
ctx.setLineCap('round')
// 设置线条的宽度和颜色
ctx.setLineWidth(this.borderWidthPx)
ctx.setStrokeStyle(this.circleColor)
// 将总过渡时间除以100,得出每修改百分之一进度所需的时间
let time = Math.floor(this.duration / 100)
// 结束角的计算依据为:将2π分为100份,乘以当前的进度值,得出终止点的弧度值,加起始角,为整个圆从默认的
// 3点钟方向开始画图,转为更好理解的12点钟方向开始作图,这需要起始角和终止角同时加上this.startAngle值
let endAngle = ((1.32 * Math.PI) / 100) * progress + this.startAngle
ctx.beginPath()
// 半径为整个canvas宽度的一半
let radius = this.widthPx / 2
ctx.arc(
radius,
radius,
radius - this.borderWidthPx,
this.startAngle,
endAngle,
false
)
ctx.stroke()
ctx.draw()
// 如果变更后新值大于旧值,意味着增大了百分比
if (this.newPercent > this.oldPercent) {
// 每次递增百分之一
progress++
// 如果新增后的值,大于需要设置的值百分比值,停止继续增加
if (progress > this.newPercent) return
} else {
// 同理于上面
progress--
if (progress < this.newPercent) return
}
setTimeout(() => {
// 定时器,每次操作间隔为time值,为了让进度条有动画效果
this.drawCircleByProgress(progress)
}, time)
},
},
}
</script>
<style lang="scss" scoped>
.u-circle-progress {
position: relative;
/* #ifndef APP-NVUE */
display: inline-flex;
/* #endif */
align-items: center;
justify-content: center;
}
.u-canvas-bg {
position: absolute;
}
.u-canvas {
position: absolute;
}
</style>
<template>
<!-- 每日一练完成弹窗 -->
<u-popup
border-radius="24"
v-model="visible"
safe-area-inset-bottom
mode="center"
width="654rpx"
:mask-close-able="false"
>
<view class="pop-view">
<image
mode="widthFix"
class="top-image-view"
:src="xunzhangImage"
></image>
<view class="pop-main">
<image
mode="widthFix"
class="image-view"
:src="backgroundImage"
></image>
<view class="head-view">
<view class="pop-title">
<text>每日一练已完成</text>
</view>
<view class="pop-message">
<text>您已经累计打卡</text>
</view>
</view>
<view class="pop-content">
<view class="list-view">
<view>{{ count }}</view>
<view class="label-view">天</view>
</view>
</view>
<view class="pop-btn-view">
<u-button
:custom-style="customStyleCancel"
hover-class="none"
shape="circle"
@click="handleClickCancel"
>
{{ cancelText }}
</u-button>
<u-button
:custom-style="customStyleSave"
shape="circle"
type="primary"
@click="handleClickSure"
>
{{ buttonText }}
</u-button>
</view>
</view>
</view>
</u-popup>
</template>
<script>
export default {
props: {
visible: {
type: Boolean,
default: false,
},
count: {
type: Number,
default: 0,
},
// normal 普通联系;experience 体验
type: {
type: String,
default: 'normal',
},
},
data() {
return {}
},
computed: {
isNormal() {
return this.type == 'normal'
},
cancelText() {
return this.isNormal ? '查看记录' : '回首页'
},
sureText() {
return this.isNormal ? '继续练习' : '去绑卡'
},
backgroundImage() {
return process.uniEnv.qn_base_url + 'lianxibeijing.png'
},
xunzhangImage() {
return process.uniEnv.qn_base_url + 'xunzhang.png'
},
customStyleCancel() {
return {
width: '264rpx',
height: '96rpx',
color: '#9EA5BB',
fontWeight: 'bold',
fontSize: '32rpx',
backgroundColor: 'transparent',
}
},
customStyleSave() {
return {
backgroundColor: '#2953FF',
width: '264rpx',
height: '96rpx',
color: '#ffffff',
fontWeight: 'bold',
fontSize: '32rpx',
}
},
},
methods: {
changeVisibleValue(val) {
this.$emit('update:visible', val)
},
handleClickCancel() {
this.changeVisibleValue(false)
this.$emit('cancel')
},
handleClickSure() {
this.changeVisibleValue(false)
this.$emit('submit')
},
},
}
</script>
<style lang="scss">
.u-mode-center-box {
background-color: transparent !important;
padding-top: 40rpx;
}
</style>
<style lang="scss" scoped>
.pop-view {
padding-top: 90rpx;
position: relative;
.top-image-view {
width: 182rpx;
height: 272rpx;
position: absolute;
top: 0;
left: calc(50% - 91rpx);
z-index: 2;
}
.pop-main {
padding: 48rpx 24rpx 48rpx 24rpx;
min-height: 520rpx;
position: relative;
text-align: center;
border-radius: 24rpx;
overflow: hidden;
background-color: #ffffff;
z-index: 1;
.head-view {
width: 100%;
height: 432;
padding-top: 160rpx;
padding-bottom: 30rpx;
.pop-title {
font-size: 48rpx;
text-align: center;
color: #191c27;
font-weight: bold;
}
.pop-message {
margin-top: 60rpx;
font-size: 28rpx;
text-align: center;
color: #5a6073;
}
}
.image-view {
width: 100%;
position: absolute;
top: 0;
left: 0;
z-index: -1;
}
.pop-content {
margin-bottom: 140rpx;
display: flex;
align-items: center;
justify-content: space-around;
.list-view {
font-weight: bold;
width: 30%;
color: #2953ff;
font-size: 80rpx;
display: flex;
align-items: flex-end;
justify-content: center;
padding-bottom: 30rpx;
padding-top: 0rpx;
.label-view {
font-size: 28rpx;
color: #5a6073;
margin-bottom: 22rpx;
padding-top: 6rpx;
padding-left: 14rpx;
}
}
}
.line-view {
background-color: #e8ebf3;
height: 2rpx;
width: 100%;
margin-bottom: 40rpx;
margin-top: 40rpx;
}
.pop-btn-view {
display: flex;
align-items: center;
justify-content: space-between;
position: absolute;
bottom: 48rpx;
left: 24rpx;
right: 24rpx;
}
}
}
</style>
<template>
<!-- 体验资格结束弹窗 -->
<u-popup
border-radius="24"
v-model="visible"
mode="center"
safe-area-inset-bottom
width="690rpx"
:mask-close-able="flase"
close-icon-color="#FFFFFF"
>
<view class="pop-view">
<image mode="widthFix" class="image-view" :src="backgroundImage"></image>
<view class="head-view">
<view class="pop-title">
<text>温馨提示</text>
</view>
</view>
<view class="pop-content">
<view>您的免费答题体验已完成</view>
<view class="label-view">绑卡/购买可继续完成答题练习</view>
</view>
<view class="pop-btn-view">
<u-button
:custom-style="customStyleCancel"
hover-class="none"
shape="circle"
@click="handleClickCancel"
>
回到首页
</u-button>
<u-button
:custom-style="customStyleSave"
shape="circle"
type="primary"
@click="handleClickSure"
>
去绑卡
</u-button>
</view>
</view>
</u-popup>
</template>
<script>
export default {
props: {
visible: {
type: Boolean,
default: false,
},
},
data() {
return {}
},
computed: {
backgroundImage() {
return process.uniEnv.qn_base_url + 'zigetanchaung-w.png'
},
customStyleCancel() {
return {
width: '264rpx',
height: '96rpx',
color: '#9EA5BB',
fontWeight: 'bold',
fontSize: '32rpx',
}
},
customStyleSave() {
return {
backgroundColor: '#2953FF',
width: '264rpx',
height: '96rpx',
color: '#ffffff',
fontWeight: 'bold',
fontSize: '32rpx',
}
},
},
methods: {
handleClickCancel() {
this.$emit('update:visible', false)
uni.switchTab({
url: '/pages/index/index',
})
},
handleClickSure() {
this.$emit('update:visible', false)
this.$u.route({
url: 'pages/learn/detail',
})
},
},
}
</script>
<style lang="scss" scoped>
.pop-view {
// margin-top: 80rpx;
padding: 48rpx 24rpx;
position: relative;
text-align: center;
background-color: #ffffff;
z-index: 1;
border-radius: 24rpx;
overflow: hidden;
.head-view {
width: 100%;
height: 432;
padding-top: 10rpx;
padding-bottom: 300rpx;
.pop-title {
font-size: 48rpx;
text-align: center;
color: #ffffff;
font-weight: bold;
}
}
.image-view {
width: 100%;
position: absolute;
top: 0;
left: 0;
z-index: -1;
}
.pop-content {
margin-bottom: 150rpx;
font-size: 36rpx;
font-weight: bold;
color: #191c27;
margin-top: 80rpx;
.label-view {
font-size: 28rpx;
color: #9ea5bb;
margin-top: 20rpx;
font-weight: 400;
}
}
}
.pop-btn-view {
display: flex;
align-items: center;
justify-content: space-between;
position: absolute;
bottom: 48rpx;
left: 40rpx;
right: 40rpx;
}
</style>
<template>
<u-popup
v-model="visible"
mode="center"
safe-area-inset-bottom
width="690rpx"
:mask-close-able="flase"
close-icon-color="#FFFFFF"
height="86%"
>
<view class="pop-view">
<image mode="widthFix" class="image-view" :src="backgroundImage"></image>
<view class="head-view">
<view class="pop-title">
<text>恭喜您获得</text>
</view>
</view>
<view class="pop-content">
<view>您已获得免费体验10道题机会</view>
<view class="label-view">每日一练,轻松完成课程练习</view>
</view>
<u-button
:custom-style="customStyle"
shape="circle"
type="primary"
@click="handleClick"
>
立即体验
</u-button>
</view>
<view class="colse-view">
<image
class="image-view"
:src="closeImage"
@click="$u.throttle(handleClose, 500)"
></image>
</view>
</u-popup>
</template>
<script>
export default {
props: {
visible: {
type: Boolean,
default: false,
},
},
data() {
return {}
},
computed: {
closeImage() {
return process.uniEnv.qn_base_url + 'dianjiquxiao.png'
},
backgroundImage() {
return process.uniEnv.qn_base_url + 'zigetanchaung.png'
},
customStyle() {
return {
backgroundColor: '#2953FF',
width: '360rpx',
height: '96rpx',
color: '#ffffff',
fontWeight: 'bold',
fontSize: '32rpx',
}
},
},
methods: {
handleClose() {
this.$emit('update:visible', false)
},
handleClick() {
this.$emit('update:visible', false)
this.$emit('click')
},
},
}
</script>
<style lang="scss" scoped>
.pop-view {
margin-top: 80rpx;
padding: 48rpx 24rpx;
position: relative;
text-align: center;
background-color: #ffffff;
z-index: 1;
border-radius: 24rpx;
overflow: hidden;
.head-view {
width: 100%;
height: 432;
padding-top: 10rpx;
padding-bottom: 300rpx;
.pop-title {
font-size: 48rpx;
text-align: center;
color: #ffffff;
font-weight: bold;
}
}
.image-view {
width: 100%;
position: absolute;
top: 0;
left: 0;
z-index: -1;
}
.pop-content {
margin-bottom: 60rpx;
font-size: 36rpx;
font-weight: bold;
color: #191c27;
margin-top: 80rpx;
.label-view {
font-size: 28rpx;
color: #9ea5bb;
margin-top: 20rpx;
font-weight: 400;
}
}
}
.colse-view {
height: 80rpx;
display: flex;
align-items: center;
justify-content: center;
margin-top: 30rpx;
.image-view {
width: 60rpx;
height: 60rpx;
}
}
</style>
<template>
<view class="u-flex my-details">
<view class="u-flex u-row-between top">
<view>{{ time }}</view>
<view :style="[statusStyle]">{{ status }}</view>
</view>
<view class="u-flex bottom">
<view class="title">{{ title }}</view>
<view class="subtitle">{{ subtitle }}</view>
</view>
</view>
</template>
<script>
export default {
name: 'mySubject',
props: {
time: {
type: String,
default: '',
},
status: {
type: String,
default: '',
},
title: {
type: String,
default: '',
},
subtitle: {
type: String,
default: '',
},
statusStyle: {
type: Object,
default() {
return {}
},
},
},
}
</script>
<style lang="scss" scoped>
.my-details {
width: 100%;
flex-flow: column;
background: #fbfbfb;
.top {
width: 100%;
font-size: 24rpx;
color: #797979;
padding: 20rpx;
}
.bottom {
width: 100%;
flex-flow: column;
padding: 30rpx 20rpx;
border-top: 1px solid #fff;
.title {
flex: 1;
margin-right: auto;
font-size: 32rpx;
color: #101010;
}
.subtitle {
flex: 1;
margin-right: auto;
margin-top: 20rpx;
font-size: 24rpx;
color: #ff9e62;
}
}
}
</style>
## 我的题库
```
我的题库组件,用于个人中心题库展示
```
## API
### Props
| 属性名 | 类型 | 默认值 | 可选值 | 说明 |
| :------: | :----: | :----: | :----: | :--------------------: |
| time | String | - | - | 绑卡成功或支付成功时间 |
| status | String | - | - | 题库状态 |
| title | String | - | - | 标题/题库名称 |
| subtitle | String | - | - | 副标题 |
## 组件用法
### 基础用法
```html
<my-subject
v-for="(item, index) in lists"
:key="index"
:time="item.time"
:status="item.status"
:title="item.title"
:subtitle="item.subtitle"
></my-subject>
```
```javascript
import mySubject from '@/components/my-subject/index.vue'
export default {
components: {
mySubject,
},
data() {
return {
lists: [
{
time: '2021.06.25 18:06',
status: '已激活',
title: '高处安装、维护、拆除作业人员',
subtitle: '题库将于48天后到期',
},
{
time: '2021.05.25 14:05',
status: '已绑定',
title: '高处安装、维护、拆除作业人员',
subtitle: '题库将于88天后到期',
},
{
time: '2021.07.25 11:06',
status: '已失效',
title: '高处安装、维护、拆除作业人员',
subtitle: '题库已过期',
},
],
}
},
}
```
<template>
<view class="u-flex top">
<view class="u-flex avatar">
<view class="avatar-list" v-for="(item, index) in avatars" :key="index">
<image :src="item" mode="aspectFill" />
</view>
</view>
<view class="notice">
<u-notice-bar
mode="horizontal"
type="none"
font-size="26"
:list="[noticeText]"
color="#FFFFFF"
:volume-icon="false"
autoplay
padding="0 10rpx"
></u-notice-bar>
</view>
</view>
</template>
<script>
export default {
data() {
return {
avatars: [],
produceTime: 1000,
duration: 60 * 1000,
}
},
computed: {
surnames() {
return '王李张刘陈杨黄赵吴周徐孙马朱胡郭何林罗高郑梁谢宋唐许韩邓冯曹彭曾肖田董潘袁蔡蒋余于杜叶程魏苏吕丁任卢姚沈钟姜崔谭陆范汪廖石金韦贾夏付方邹熊白孟秦邱侯江尹薛闫段雷龙黎史陶贺毛郝顾龚邵万覃武钱戴严莫孔向常'
},
courses() {
return [
'金属冶炼(炼铁)(常考题)',
'金属冶炼(炼钢)(常考题)',
'金属冶炼(铁合金冶炼、锰冶炼、铬冶炼)',
'金属冶炼(黑色金属铸造)',
'金属冶炼(铜冶炼)',
'金属冶炼(铅、锌冶炼)',
'金属冶炼(铝冶炼)',
'金属冶炼(铜及铜合金制造与铸造)',
'金属冶炼(铝及铝合金制造与铸造)',
'金属冶炼(锌及锌合金制造与铸造)',
'金属冶炼(镁及镁合金制造与铸造)',
'金属冶炼(镁及镁合金制造与铸造)金属非金属矿山(地下矿山)',
'金属冶炼(有色金属冶炼<除铜、铝、铅、锌之外的其他有色金属>)',
'金属冶炼(铝及铝合金制造与铸造)',
'金属冶炼(黑色金属铸造)金属非金属矿山(露天矿山)',
'危险化学品生产单位',
'金属非金属矿山(小型露天采石场)',
'危险化学品经营单位',
'烟花爆竹生产单位',
'烟花爆竹经营单位',
'金属冶炼(铝冶炼)',
'电气实验作业',
'电力电缆作业',
'高压电工作业',
'低压电工作业',
'防爆电气作业',
'继电保护作业',
'熔化焊接与热切割作业',
'压力焊作业',
'钎焊作业',
'登高架设作业',
'高处安装、维护、拆除作业',
'制冷与空调设备运行操作作业',
'制冷与空调设备安装修理作业',
'金属非金属矿山安全检查作业(露天矿山)',
'金属非金属矿井通风作业',
'尾矿作业',
'金属非金属矿山安全检查作业(小型露天采石场)',
'金属非金属矿山提升机操作作业',
'金属非金属矿山支柱作业',
'金属非金属矿山井下电气作业',
'金属非金属矿山排水作业',
'金属非金属矿山爆破作业',
'金属非金属矿山安全检查作业(地下矿山)',
'司钻作业(井下作业)',
'司钻作业(钻井作业)',
'煤气作业',
'氟化工艺作业',
'重氮化工艺作业',
'氧化工艺作业',
'胺基化工艺作业',
'聚合工艺作业',
'烷基化工艺作业',
'化工自动化控制仪表作业',
'光气及光气化工艺作业',
'氯碱电解工艺作业',
'氯化工艺作业',
'硝化工艺作业',
'合成氨工艺作业',
'烟花爆竹储存作业',
'烟火药制造作业',
'黑火药制造作业',
'引火线制造作业',
'烟花爆竹产品涉药作业',
]
},
noticeText() {
return (
Math.ceil(this.produceTime / 1000 / 60) +
'分钟前 ' +
this.surnames[this.$u.random(0, 99)] +
'**' +
'完成了"' +
this.courses[this.$u.random(0, 63)] +
'习题"练习'
)
},
defaultUrl() {
return process.uniEnv.qn_base_url + 'heads/'
},
},
created() {
this.initData()
this.beginNotic()
},
methods: {
initData() {
var a0 = this.$u.random(0, 49)
var a1 = this.$u.random(0, 49)
if (a1 == a0) a0 = this.$u.random(0, 49)
var a2 = this.$u.random(0, 49)
if ([a0, a1].indexOf(a2) != -1) a2 = this.$u.random(0, 49)
var a3 = this.$u.random(0, 49)
if ([a0, a1, a2].indexOf(a3) != -1) a3 = this.$u.random(0, 49)
this.avatars = [
this.defaultUrl + (a0 > 9 ? 'a' : 'a0') + String(a0) + '.jpeg',
this.defaultUrl + (a1 > 9 ? 'a' : 'a0') + String(a1) + '.jpeg',
this.defaultUrl + (a2 > 9 ? 'a' : 'a0') + String(a2) + '.jpeg',
this.defaultUrl + (a3 > 9 ? 'a' : 'a0') + String(a3) + '.jpeg',
]
this.list = [this.noticeText]
setInterval(() => {
this.produceTime += this.duration
}, this.duration)
},
beginNotic() {
var after = this.$u.random(1, 600) * 1000
this.produceTime = 1000
setTimeout(() => {
this.produceData()
this.beginNotic()
}, after)
},
produceData() {
var array = this.avatars.slice(1)
var a0 = this.$u.random(0, 49)
var str = (a0 > 9 ? 'a' : 'a0') + String(a0) + '.jpeg'
for (var item of this.avatars) {
if (item.indexOf(str) != -1) {
a0 = this.$u.random(0, 49)
str = (a0 > 9 ? 'a' : 'a0') + String(a0) + '.jpeg'
break
}
}
this.avatars = [...array, this.defaultUrl + str]
this.list = [this.noticeText]
},
},
}
</script>
<style lang="scss" scoped>
.top {
width: 100%;
margin-left: 15rpx;
display: flex;
align-items: center;
.avatar {
.avatar-list {
margin-left: -15rpx;
display: flex;
justify-content: flex-start;
align-items: center;
image {
width: 44rpx;
height: 44rpx;
border: 2rpx solid #ccc;
background: #fff;
border-radius: 50%;
margin-right: 1px;
}
}
}
.notice {
flex: 1;
width: 100%;
}
}
</style>
<template>
<view class="pageSwiperBox">
<view
class="pageSwiper"
:style="{
width: swiperWidth + 'px',
transform: 'translateX(' + (nowX + transX) + 'px)',
transition: !dragging ? duration + 'ms' : 'none',
}"
@touchstart="touchStart"
@touchmove="touchMove"
@touchend="touchEnd"
>
<block v-if="swiperType == 'lite'">
<view
class="pageSwiperItem"
:style="{ width: screenWidth + 'px', height: i != 1 ? 'auto' : '' }"
style="flex: 1;"
v-for="(item, i) in 3"
:key="i"
v-show="!waitShow"
>
<slot v-if="i == 1"></slot>
<view
class="pyh-pageSwiperMask"
v-show="i != 1"
@touchstart.stop="returnFalse"
@touchmove.stop.prevent="returnFalse"
@touchend.stop="returnFalse"
>
</view>
</view>
</block>
<block v-else-if="swiperType == 'static'">
<slot></slot>
</block>
</view>
</view>
</template>
<script>
export default {
name: 'pageSwiper',
props: {
swiperType: {
type: String,
default: 'lite',
},
dataLength: {
type: Number,
default: 1,
},
initIndex: {
type: Number,
default: 0,
},
duration: {
type: Number,
default: 200,
},
height: {
type: String,
default: '',
},
},
data() {
return {
swiperWidth: 3 * 375,
screenWidth: 375,
index: 0,
current: 1,
nowX: 0,
transX: 0,
dragging: true,
canMove: true,
showLoading: true,
waitShow: false,
pageTop: 0,
}
},
watch: {
dataLength(newValue, oldValue) {
if (newValue <= 1) this.canMove = false
},
},
created() {
this.index = this.initIndex
uni.getSystemInfo({
success: (res) => {
this.screenWidth = res.windowWidth
if (this.swiperType == 'lite') {
this.swiperWidth = 3 * res.windowWidth
this.nowX = -1 * this.current * this.screenWidth
} else if (this.swiperType == 'static') {
this.swiperWidth = this.dataLength * res.windowWidth
this.current = this.index
this.nowX = -1 * this.index * this.screenWidth
}
this.dragging = false
if (!this.height) {
var sQ = uni.createSelectorQuery().in(this)
var getTop = setInterval(() => {
sQ.select('.pageSwiperBox')
.boundingClientRect((data) => {
if (data) {
clearInterval(getTop)
this.pageTop = data.top
}
})
.exec()
}, 100)
}
},
})
},
methods: {
returnFalse() {},
swiperTap() {
this.$emit('swiperTap', this.current)
},
swiperTo(index) {
this.dragging = false
this.index = index
if (this.swiperType == 'lite') {
this.$emit('swiperChange', index)
} else if (this.swiperType == 'static') {
this.current = this.index
this.nowX = -1 * this.index * this.screenWidth
this.$emit('swiperChange', index)
}
if (!this.height) {
uni.pageScrollTo({
scrollTop: this.pageTop,
duration: 0,
})
}
},
touchStart(e) {
if (!this.canMove) return false
this.touchStartObj = e.mp.touches[0]
this.moveObj = null
},
touchMove(e) {
if (!this.canMove) return false
var moveObj = e.mp.touches[0]
if (!this.moveObj) {
this.moveObj = moveObj
if (Math.abs(this.moveObj.clientY - this.touchStartObj.clientY) <= 5) {
this.dragging = true
} else {
this.dragging = false
return false
}
}
if (!this.dragging) return false
var last = this.dataLength - 1
if (this.index == 0 && moveObj.clientX - this.touchStartObj.clientX > 0) {
this.dragging = false
this.$emit('endChange', 'left')
return false
} else if (
this.index == last &&
moveObj.clientX - this.touchStartObj.clientX < 0
) {
this.dragging = false
this.$emit('endChange', 'right')
return false
}
this.transX = parseInt(moveObj.clientX - this.touchStartObj.clientX)
if (moveObj.clientX < 0 || moveObj.clientX > this.screenWidth) {
this.touchEnd()
}
},
touchEnd() {
if (
Math.abs(this.transX) > this.screenWidth / 4 &&
this.canMove &&
this.dragging
) {
if (this.transX > 0) {
this.nowX += this.screenWidth
this.current--
} else {
this.nowX -= this.screenWidth
this.current++
}
var transAdd = this.transX > 0 ? false : true
var index = transAdd ? this.index + 1 : this.index - 1
this.transX = 0
this.dragging = false
this.canMove = false
setTimeout(() => {
this.canMove = true
this.$emit('swiperChange', index)
if (!this.height) {
uni.pageScrollTo({
scrollTop: this.pageTop,
duration: 0,
})
}
if (this.swiperType == 'lite') {
this.waitShow = true
this.dragging = true
this.index = index
this.current = 1
} else if (this.swiperType == 'static') {
if (transAdd) {
this.waitShow = true
this.dragging = true
}
this.index = index
}
this.nowX = -1 * this.current * this.screenWidth
setTimeout(() => {
this.waitShow = false
this.dragging = false
}, 200)
}, this.duration)
} else {
this.transX = 0
}
},
},
}
</script>
<style lang="scss">
.pageSwiperBox {
width: 100%;
overflow-x: hidden;
height: 100%;
flex: 1;
}
.pageSwiper {
width: 100%;
position: relative;
display: flex;
justify-content: flex-start;
align-items: flex-start;
flex: 1;
height: 100%;
}
.pageSwiper-wrap {
width: 100%;
display: flex;
align-items: flex-start;
min-height: 100%;
}
.pageSwiperItem {
overflow-x: hidden;
width: 750rpx;
position: relative;
}
.pyh-pageSwiperMask {
position: absolute;
top: 0;
width: 100%;
height: 100%;
}
.pyh-pageSwiperMask-text {
width: 750rpx;
height: 100%;
display: flex;
align-items: center;
justify-content: center;
}
/* 旋转动画 */
.loadRotate {
margin-right: 10rpx;
display: inline-block;
width: 32upx;
height: 32upx;
border-radius: 50%;
border: 2upx solid #333;
border-bottom-color: transparent;
vertical-align: middle;
-webkit-animation: loadRotate 0.6s linear infinite;
animation: loadRotate 0.6s linear infinite;
}
@-webkit-keyframes loadRotate {
0% {
-webkit-transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
}
}
@keyframes loadRotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
</style>
<template>
<u-popup
border-radius="12"
v-model="visible"
safe-area-inset-bottom
mode="center"
width="654rpx"
:mask-close-able="false"
>
<image
:src="tanchuangdingbuImage"
class="back-image"
mode="widthFix"
></image>
<view class="pop-view">
<view class="pop-title">
<text>{{ title }}</text>
</view>
<view class="pop-message">
<text>{{ message }}</text>
</view>
<view class="line-view" />
<view class="pop-content">
<slot></slot>
</view>
<view class="pop-btn-view">
<u-button
:custom-style="customStyleCancel"
hover-class="none"
shape="circle"
@click="handleClickCancel"
>
取消
</u-button>
<u-button
:custom-style="customStyleSave"
shape="circle"
type="primary"
:loading="loading"
@click="handleClickSure"
>
{{ buttonText }}
</u-button>
</view>
</view>
</u-popup>
</template>
<script>
export default {
props: {
visible: {
type: Boolean,
default: false,
},
title: {
type: String,
default: '',
},
message: {
type: String,
default: '',
},
buttonText: {
// 确定按钮
type: String,
default: '确定',
},
},
data() {
return {
loading: false,
}
},
computed: {
tanchuangdingbuImage() {
return process.uniEnv.qn_base_url + 'tanchuangdingbu.png'
},
customStyleCancel() {
return {
width: '264rpx',
height: '80rpx',
color: '#9EA5BB',
fontWeight: 'bold',
fontSize: '32rpx',
}
},
customStyleSave() {
return {
backgroundColor: '#2953FF',
width: '264rpx',
height: '80rpx',
color: '#ffffff',
fontWeight: 'bold',
fontSize: '32rpx',
}
},
},
watch: {
visible() {
this.loading = false
},
},
methods: {
changeVisibleValue(val) {
this.$emit('update:visible', val)
},
handleClickCancel() {
this.changeVisibleValue(false)
this.$emit('cancel')
},
handleClickSure() {
this.loading = true
this.$emit('submit')
},
},
}
</script>
<style lang="scss" scoped>
.back-image {
width: 100%;
position: absolute;
top: 0;
left: 0;
}
.pop-view {
padding: 48rpx 40rpx;
min-height: 520rpx;
position: relative;
// background-image: linear-gradient(to top, #ffffff 0%, #e9f3ff 50%);
// background-size: 100% 240rpx;
// background-repeat: no-repeat;
.pop-title {
font-size: 40rpx;
margin-bottom: 30rpx;
text-align: center;
color: #191c27;
font-weight: bold;
}
.pop-message {
font-size: 28rpx;
text-align: center;
color: #5a6073;
}
.pop-content {
margin-bottom: 140rpx;
}
.line-view {
background-color: #e8ebf3;
height: 2rpx;
width: calc(100% + 60rpx);
margin-bottom: 40rpx;
margin-top: 40rpx;
margin-left: -30rpx;
}
.pop-btn-view {
display: flex;
padding-top: 60rpx;
align-items: center;
justify-content: space-between;
position: absolute;
bottom: 48rpx;
left: 40rpx;
right: 40rpx;
}
}
</style>
<template>
<view class="question-bank-cell">
<view class="label-normal">
<view>{{ info.label || info.title }}</view>
<view class="label-text">
共
<text class="label-blue">{{ info.number }}</text
>道精编试题,通过率
<text class="label-blue">{{ $u.random(95, 99) }}%</text>
</view>
</view>
<u-button
v-if="!isNone"
:customStyle="buttonStyle"
@click="handleClick(index)"
type="primary"
>
<u-icon v-if="isAdd" class="button-icon" name="plus"></u-icon
>{{ buttonText }}
</u-button>
</view>
</template>
<script>
export default {
props: {
type: {
// add: '添加';change: '切换'; // none: 无按钮
type: String,
default: 'none',
},
info: {
type: Object,
default() {
return {}
},
},
},
data() {
return {}
},
computed: {
isAdd() {
return this.type == 'add'
},
isNone() {
return this.type == 'none'
},
buttonText() {
var text = ''
switch (this.type) {
case 'add':
text = '添加'
break
case 'change':
text = '切换'
break
case 'none':
default:
break
}
return text
},
buttonStyle() {
return {
width: '120rpx',
height: '64rpx',
backgroundColor: '#2953FF',
color: '#FFFFFF',
fontSize: '26rpx',
borderRadius: '12rpx',
}
},
},
methods: {
handleClick() {
this.$emit('action', this.info, this.type)
},
},
}
</script>
<style lang="scss" scoped>
.question-bank-cell {
padding: 40rpx 24rpx 40rpx 30rpx;
background-color: #ffffff;
border-radius: 12rpx;
display: flex;
justify-content: space-between;
align-items: center;
.label-normal {
width: 470rpx;
font-size: 36rpx;
color: #191c27;
font-weight: bold;
word-break: break-all;
.label-text {
margin-top: 24rpx;
font-size: 26rpx;
color: #5a6073;
.label-blue {
color: #2953ff;
padding-left: 6rpx;
padding-right: 6rpx;
}
}
}
.button-icon {
margin-right: 4rpx;
font-size: 28rpx;
font-weight: bold;
}
}
</style>
<template>
<view class="record-cell">
<view class="time-view">{{ timeText }}</view>
<view class="detail-view">
<view v-for="(value, key) in labels" :key="key" class="item-view">
<view>{{ value }}</view>
<view class="content-view">
<view
v-if="key == 'result'"
:class="['result-text', { passed: passed }]"
>{{ resultText }}</view
>
<view v-else class="content-text">{{ info[key] }}</view>
<view class="unit-text">{{ units[key] }}</view>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
props: {
info: {
type: Object,
default() {
return {}
},
},
},
data() {
return {}
},
computed: {
timeText() {
return this.$u.timeFormat(this.info.date, 'yyyy.mm.dd')
},
labels() {
return {
time: '模考用时',
score: '模考成绩',
result: '是否及格',
}
},
units() {
return {
time: '分钟',
score: '分',
result: '',
}
},
passed() {
// 及格、不及格
return this.info.score >= 60
},
resultText() {
return this.passed ? '及格' : '不及格'
},
},
methods: {},
}
</script>
<style lang="scss" scoped>
.record-cell {
height: 296rpx;
border-bottom: 2rpx solid #e8ebf3;
padding: 48rpx 0 40rpx 0;
.time-view {
color: #5a6073;
font-size: 28rpx;
}
.detail-view {
display: flex;
align-items: center;
justify-content: space-around;
margin-top: 34rpx;
.item-view {
color: #9ea5bb;
font-size: 28rpx;
text-align: center;
.content-view {
padding-top: 16rpx;
display: flex;
align-items: flex-end;
.result-text {
font-size: 44rpx;
color: #fa5a49;
font-weight: bold;
line-height: 80rpx;
height: 80rpx;
&.passed {
color: #2953ff;
}
}
.content-text {
color: #5a6073;
font-size: 56rpx;
font-weight: bold;
height: 80rpx;
line-height: 80rpx;
}
.unit-text {
padding-left: 14rpx;
font-weight: 400;
margin-bottom: 11rpx;
}
}
}
}
}
</style>
<template>
<view class="statis">
<image class="background-image" :src="meiriyilianImage"></image>
<view class="content-view">
<!-- <view class="u-flex top">
<view class="u-flex avatar">
<view
class="avatar-list"
v-for="(item, index) in info.avatar"
:key="index"
><image :src="item" mode="scaleToFill"
/></view>
</view>
<view class="notice">
<u-notice-bar
mode="horizontal"
type="none"
font-size="26"
:list="info.dynamic"
color="#FFFFFF"
:volume-icon="false"
autoplay
padding="0 10rpx"
></u-notice-bar>
</view>
</view> -->
<NoticeBar />
<view class="u-flex center">
<view v-for="(value, key) in detailLabels" :key="key" class="item-view">
<view v-if="key == 'total'" class="line-view"></view>
<view class="left-view" @click="handleClick(key)">
<view class="count-view">{{ info[key] }}</view>
<view>{{ value }}</view>
</view>
<view v-if="key == 'total'" class="line-view"></view>
</view>
</view>
<view class="bottom">
<view
:class="['bottom-button', { experience: info.experience }]"
type="primary"
shape="circle"
@click="$u.throttle(answer, 500)"
><image class="button-image" :src="lianxianniuImage"></image
>{{ buttonText }}</view
>
</view>
</view>
</view>
</template>
<script>
import NoticeBar from '@/components/notice-bar'
export default {
name: 'subjectStatistics',
components: {
NoticeBar,
},
props: {
info: {
type: Object,
default() {
return {
days: 0,
today: 0,
total: 0,
dynamic: [],
avatar: [],
selected: {},
experience: false,
}
},
},
},
data() {
return {
src: 'https://uviewui.com/common/logo.png',
lists: [],
}
},
computed: {
detailLabels() {
return {
today: '今日做题',
total: '累计做题',
days: '打卡天数',
}
},
meiriyilianImage() {
return process.uniEnv.qn_base_url + 'meiriyilianquyu.png'
},
lianxianniuImage() {
return process.uniEnv.qn_base_url + 'lianxianniu.png'
},
buttonText() {
return this.info.experience ? '立即体验答题' : '每日一练'
},
},
created() {},
methods: {
handleClick(key) {
this.$emit('click', key)
},
answer() {
this.$emit('answer')
},
},
}
</script>
<style lang="scss" scoped>
.statis {
// flex-flow: column;
// background: #fff;
// padding: 30rpx 30rpx 40rpx 30rpx;
border-radius: 24rpx;
overflow: hidden;
position: relative;
box-shadow: 0px 10px 16px rgba(29, 53, 155, 0.2);
margin-bottom: 56rpx;
z-index: 0;
height: 472rpx;
.background-image {
position: absolute;
z-index: -1;
height: 472rpx;
width: 702rpx;
}
.content-view {
padding: 40rpx 30rpx;
.top {
width: 100%;
margin-left: 15rpx;
display: flex;
align-items: center;
.avatar {
.avatar-list {
margin-left: -15rpx;
display: flex;
justify-content: flex-start;
align-items: center;
image {
width: 44rpx;
height: 44rpx;
border: 2rpx solid #ccc;
background: #fff;
border-radius: 50%;
margin-right: 1px;
}
}
}
.notice {
flex: 1;
width: 100%;
}
}
.center {
width: 100%;
justify-content: space-around;
padding-top: 56rpx;
padding-bottom: 66rpx;
.item-view {
display: flex;
align-items: center;
justify-content: center;
.left-view {
text-align: center;
color: #ffffff;
font-size: 26rpx;
width: 240rpx;
.count-view {
font-weight: bold;
font-size: 48rpx;
margin-bottom: 6rpx;
}
}
.line-view {
width: 2rpx;
background-color: #ffffff;
height: 70rpx;
}
}
}
.bottom {
display: flex;
justify-content: center;
align-items: center;
.bottom-button {
display: flex;
justify-content: center;
align-items: center;
position: relative;
overflow: hidden;
z-index: 0;
border-radius: 52rpx;
font-size: 32rpx;
font-weight: bold;
color: #2953ff;
height: 104rpx;
width: 400rpx;
&.experience {
color: #fa5a49;
}
.button-image {
width: 400rpx;
height: 104rpx;
position: absolute;
z-index: -1;
}
}
}
}
}
</style>
## 科目统计
```
科目统计组件,用于首页统计模块。
```
## API
### Props
| 属性名 | 类型 | 默认值 | 可选值 | 说明 |
| :-----: | :----: | :----: | :----: | :-------------------------: |
| days | Number | 0 | - | 累计坚持天数 |
| today | Number | 0 | - | 今日做题 |
| total | Number | 0 | - | 累计做题 |
| dynamic | Array | [] | [] | 滚动动态列表 **格式见下文** |
| avatar | Array | [] | [] | 头像列表 **格式见下文** |
### dynamic 格式
```json
const dynamic = ["寒雨连江夜入吴", "平明送客楚山孤", "洛阳亲友如相问", "一片冰心在玉壶"]
const avatar = ["https://uviewui.com/common/logo.png", "https://uviewui.com/common/logo.png", "https://uviewui.com/common/logo.png"]
```
### Events
| 事件称名 | 说明 | 返回值 |
| :------: | :------------------: | :----: |
| @answer | 点击每日一练按钮触发 | 无 |
## 组件用法
### 基础用法
```html
<subject-statistics
:days="40"
:today="97"
:total="668"
:dynamic="list"
:avatar="avatarList"
@answer="answer"
></subject-statistics>
```
```javascript
import subjectStatistics from '@/components/subject-statistics/index.vue'
export default {
components: {
subjectStatistics,
},
data() {
return {
list: [
'寒雨连江夜入吴',
'平明送客楚山孤',
'洛阳亲友如相问',
'一片冰心在玉壶',
],
avatarList: [
'https://uviewui.com/common/logo.png',
'https://uviewui.com/common/logo.png',
'https://uviewui.com/common/logo.png',
],
}
},
methods: {
answer() {
console.log('每日一练')
},
},
}
```
<template>
<view class="swipers">
<swiper
style="flex: 1;"
:duration="swiperDuration"
:current="swiperCurrent"
@change="swiperChange"
circular
>
<swiper-item v-for="(item, index) in swiperList" :key="index">
<view class="u-flex subject">
<view class="title" v-if="item.title"><text>{{ titleType[item.type - 1] }}</text>{{ item.title }}</view>
<view class="content">
<answer-sheet
ref="answerSheet"
:answerList="item.answerList"
:rightKey="item.rightKey"
:multiple="item.type === 3"
:submitStatus="item.submitStatus"
@change="answerChange"
></answer-sheet>
</view>
<view class="explain">
<answer-explanation v-show="model === 2 || item.errShow" :answer="item.answer" :explain="item.explain"></answer-explanation>
</view>
</view>
</swiper-item>
</swiper>
</view>
</template>
<script>
import answerSheet from '@/components/answer-sheet/index.vue'
import answerExplanation from '@/components/answer-explanation/index.vue'
const START = 0
const END = 2
const SWIPER_LENGTH = 3
const NO_PREV_PAGE = -1
const NO_NEXT_PAGE = -2
const app = getApp()
export default {
name: 'swiper-limited-load',
components: {
answerSheet,
answerExplanation
},
props: {
swiperHeight: {
type: Number,
default: 0
},
list: {
type: Array,
default: []
},
current: {
type: Number,
default: 0
},
type: {
type: Number,
default: 1
},
model: {
type: Number,
default: 1
},
// 值为0禁止切换动画
swiperDuration: {
type: String,
default: "250"
},
// 分页需要传此数据
total: {
type: Number,
default: 0
}
},
data() {
return {
titleType: ['单选题', '判断题', '多选题'],
// 滑动到的位置
swiperIndex: 0,
// 此值控制swiper的位置
swiperCurrent: 0,
// 当前swiper渲染的items
swiperList: [],
}
},
watch: {
current: {
handler: function(index, oldValue) {
let current = index % SWIPER_LENGTH
if (this.swiperList.length == 0 || this.swiperList[current] == null) {
return
}
// 如果change后还是之前的那一个item,直接return
if (current == this.swiperIndex && this.swiperList[this.swiperIndex].index == index) {
return
}
this.init(index)
// 如果change之后还是当前的current,比如之前是1、点击后是4 之前是2、点击后是5之类
// 那么不会走swiperChange的change方法,需要我们手动去给它加一个current,然后传出去
if (current == this.swiperIndex) {
this.$emit("change", {source: "",current: index})
}
},
immediate: true
},
model(newVal, oldVal){
this.changeModel(newVal)
}
},
methods: {
init (defaulaIndex) {
let list = JSON.parse(JSON.stringify(this.list))
if (list == null || list.length == 0) {
return
}
// 默认显示的index
let current = defaulaIndex % SWIPER_LENGTH
this.swiperList = this.getInitSwiperList(list, defaulaIndex)
this.swiperIndex = current
this.swiperCurrent = current
},
answerChange(status, lists, userAnswer) {
this.$set(this.swiperList[this.swiperIndex], 'errShow', this.type === 2 ? true : status === 'fail')
this.$set(this.swiperList[this.swiperIndex], 'submitStatus', true)
this.$emit("answerChange", status, lists, userAnswer)
},
clear () {
this.list = []
this.swiperList = []
},
swiperChange: function (e) {
let current = e.detail.current
let lastIndex = this.swiperIndex
let currentItem = this.swiperList[current]
let info = {}
info.source = e.detail.source
// 正向滑动,到下一个的时候
// 是正向衔接
let isLoopPositive = current == START && lastIndex == END
if (current - lastIndex == 1 || isLoopPositive) {
// 如果是滑到了左边界或者下一个还未有值,弹回去
if (currentItem == null) {
info.current = NO_NEXT_PAGE
this.$emit("change", info)
this.swiperCurrent = lastIndex - 1
this.$nextTick(() => {
this.swiperCurrent = lastIndex
})
return
}
this.$set(this.swiperList, this.getNextSwiperChangeIndex(current), this.getNextSwiperNeedItem(currentItem, this.list))
}
// 反向滑动,到上一个的时候
// 是反向衔接
let isLoopNegative = current == END && lastIndex == START
if (lastIndex - current == 1 || isLoopNegative) {
// 如果滑到了右边界或者上一个还未有值,弹回去
if (currentItem == null) {
info.current = NO_PREV_PAGE
this.$emit("change", info)
this.swiperCurrent = lastIndex + 1
this.$nextTick(() => {
this.swiperCurrent = lastIndex
})
return
}
this.$set(this.swiperList, this.getLastSwiperChangeIndex(current), this.getLastSwiperNeedItem(currentItem, this.list))
}
if (currentItem == null) return
info.current = currentItem.index
this.$emit("change", info)
// 记录滑过来的位置,此值对于下一次滑动的计算很重要
this.swiperIndex = current
if (this.model === 2) {
this.changeModel()
}
},
// 切换模式
changeModel(model) {
let info = JSON.parse(JSON.stringify(this.swiperList[this.swiperIndex]))
if (model === 1) {
const item = this.list.find(v => v.index === info.index)
this.$set(this.swiperList, this.swiperIndex, item)
} else {
// 学习模式,显示答案
info.errShow = true
info.answerList.forEach(v => {
if (info.rightKey.includes(v.sort)) {
v.checked = true
v.confirm = true
} else {
v.checked = false
v.confirm = false
}
})
this.$set(this.swiperList, this.swiperIndex, info)
}
},
/**
* 获取初始化的swiperList
*/
getInitSwiperList : function (list, defaultIndex) {
let current = defaultIndex % SWIPER_LENGTH
let realIndex = list.findIndex(item => item.index == defaultIndex)
let currentItem = list[realIndex]
let swiperList = []
swiperList[current] = currentItem
swiperList[this.getLastSwiperChangeIndex(current)] = this.getLastSwiperNeedItem(currentItem, list)
swiperList[this.getNextSwiperChangeIndex(current)] = this.getNextSwiperNeedItem(currentItem, list)
console.log("swiperList", swiperList)
return swiperList;
},
/**
* 获取swiperList中current上一个的index
*/
getLastSwiperChangeIndex : function (current) {
return current > START ? current - 1 : END
},
/**
* 获取swiperLit中current下一个的index
*/
getNextSwiperChangeIndex : function (current) {
return current < END ? current + 1 : START
},
/**
* 获取上一个要替换的list中的item
*/
getLastSwiperNeedItem : function (currentItem, list) {
if (currentItem == null) return null;
let listNeedIndex = currentItem.index - 1
let realIndex = list.findIndex(item => item.index == listNeedIndex)
if (realIndex == -1) return null
let item = listNeedIndex == -1 ? null : list[realIndex]
return item
},
/**
* 获取下一个要替换的list中的item
*/
getNextSwiperNeedItem : function (currentItem, list) {
if (currentItem == null) return null;
let listNeedIndex = currentItem.index + 1
let realIndex = list.findIndex(item => item.index == listNeedIndex)
if (realIndex == -1) return null
let total = this.total != 0 ? this.total : list.length
let item = listNeedIndex == total ? null : list[realIndex]
return item
}
},
}
</script>
<style lang="scss" scoped>
.swipers {
height: 100%;
display: flex;
flex-direction: column;
swiper-item {
overflow: auto;
}
.subject {
flex-flow: column;
padding: 20rpx;
.type {
width: 100%;
text-align: left;
padding: 20rpx 0;
}
.title {
color: #191C27;
font-size: 32rpx;
line-height: 50rpx;
font-weight: bold;
width: 100%;
text-align: left;
text {
background: #9EA5BB;
color: #fff;
padding: 8rpx 20rpx;
margin-right: 10rpx;
font-size: 20rpx;
border-radius: 50rpx;
border-radius: 50rpx 0 50rpx 50rpx;
}
}
.content, .explain, .btn {
width: 100%;
padding-top: 50rpx;
}
}
}
</style>
<template>
<u-popup
border-radius="12"
v-model="visible"
safe-area-inset-bottom
mode="center"
width="654rpx"
:mask-close-able="false"
>
<image
:src="tanchuangdingbuImage"
class="back-image"
mode="widthFix"
></image>
<view class="toast-pop">
<view class="pop-title">
<text>{{ title }}</text>
</view>
<view class="pop-message">
<text>{{ message }}</text>
</view>
<view class="pop-btn-view">
<view class="line-view"> </view>
<view class="content-view">
<view class="cancel-button" @click="handleClickCancel">
取消
</view>
<view class="line-view-v" />
<view class="sure-button" @click="$u.throttle(handleClickSure, 500)">
{{ buttonText }}
</view>
</view>
</view>
</view>
</u-popup>
</template>
<script>
export default {
props: {
visible: {
type: Boolean,
default: false,
},
title: {
type: String,
default: '温馨提示',
},
// select: 去选题库;bound: 去绑卡
type: {
type: String,
default: 'select',
},
},
data() {
return {}
},
computed: {
tanchuangdingbuImage() {
return process.uniEnv.qn_base_url + 'tanchuangdingbu.png'
},
message() {
switch (this.type) {
case 'select':
return '为了您能更好的使用“模考大师”小程序请先选择题库'
case 'bound':
return '为了您能更好的使用“模考大师”小程序请去绑定用户卡'
}
},
buttonText() {
switch (this.type) {
case 'select':
return '去选择'
case 'bound':
return '去绑定'
}
},
customStyleCancel() {
return {
width: '264rpx',
height: '80rpx',
color: '#9EA5BB',
fontWeight: 'bold',
fontSize: '32rpx',
}
},
customStyleSave() {
return {
backgroundColor: '#2953FF',
width: '264rpx',
height: '80rpx',
color: '#ffffff',
fontWeight: 'bold',
fontSize: '32rpx',
}
},
},
methods: {
changeVisibleValue(val) {
this.$emit('update:visible', val)
},
handleClickCancel() {
this.changeVisibleValue(false)
this.$emit('cancel')
},
handleClickSure() {
this.changeVisibleValue(false)
this.$emit('click', this.type)
},
},
}
</script>
<style lang="scss" scoped>
.back-image {
width: 100%;
position: absolute;
top: 0;
left: 0;
}
.toast-pop {
min-height: 480rpx;
position: relative;
// background-image: linear-gradient(to top, #ffffff 0%, #e9f3ff 50%);
// background-size: 100% 240rpx;
// background-repeat: no-repeat;
text-align: center;
.pop-title {
font-size: 40rpx;
text-align: center;
color: #9ea5bb;
font-weight: bold;
padding-top: 40rpx;
}
.pop-message {
font-size: 32rpx;
text-align: center;
color: #191c27;
font-weight: bold;
padding: 90rpx 30rpx 80rpx 30rpx;
}
.pop-btn-view {
position: absolute;
bottom: 0rpx;
left: 0rpx;
right: 0rpx;
height: 112rpx;
.line-view {
background-color: #e8ebf3;
height: 2rpx;
width: 100%;
}
.content-view {
display: flex;
align-items: center;
justify-content: space-between;
.cancel-button {
width: 50%;
color: #9ea5bb;
font-size: 32rpx;
font-weight: bold;
text-align: center;
height: 112rpx;
line-height: 112rpx;
}
.line-view-v {
width: 2rpx;
background-color: #e8ebf3;
height: 112rpx;
}
.sure-button {
width: 50%;
color: #2953ff;
font-size: 32rpx;
font-weight: bold;
text-align: center;
height: 112rpx;
line-height: 112rpx;
}
}
}
}
</style>
<template>
<!-- #ifndef APP-NVUE -->
<view class="uni-list uni-border-top-bottom">
<view v-if="border" class="uni-list--border-top"></view>
<slot />
<view v-if="border" class="uni-list--border-bottom"></view>
</view>
<!-- #endif -->
<!-- #ifdef APP-NVUE -->
<list class="uni-list" :class="{ 'uni-list--border': border }" :enableBackToTop="enableBackToTop" loadmoreoffset="15"><slot /></list>
<!-- #endif -->
</template>
<script>
/**
* List 列表
* @description 列表组件
* @tutorial https://ext.dcloud.net.cn/plugin?id=24
* @property {String} border = [true|false] 标题
*/
export default {
name: 'uniList',
'mp-weixin': {
options: {
multipleSlots: false
}
},
props: {
enableBackToTop: {
type: [Boolean, String],
default: false
},
scrollY: {
type: [Boolean, String],
default: false
},
border: {
type: Boolean,
default: true
}
},
// provide() {
// return {
// list: this
// };
// },
created() {
this.firstChildAppend = false;
},
methods: {
loadMore(e) {
this.$emit('scrolltolower');
}
}
};
</script>
<style lang="scss">
.uni-list {
/* #ifndef APP-NVUE */
display: flex;
/* #endif */
background-color: $uni-bg-color;
position: relative;
flex-direction: column;
}
.uni-list--border {
position: relative;
/* #ifdef APP-NVUE */
border-top-color: $uni-border-color;
border-top-style: solid;
border-top-width: 0.5px;
border-bottom-color: $uni-border-color;
border-bottom-style: solid;
border-bottom-width: 0.5px;
/* #endif */
z-index: -1;
}
/* #ifndef APP-NVUE */
.uni-list--border-top {
position: absolute;
top: 0;
right: 0;
left: 0;
height: 1px;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
background-color: $uni-border-color;
z-index: 1;
}
.uni-list--border-bottom {
position: absolute;
bottom: 0;
right: 0;
left: 0;
height: 1px;
-webkit-transform: scaleY(0.5);
transform: scaleY(0.5);
background-color: $uni-border-color;
}
/* #endif */
</style>
var t = function() {
function t(t, a) {
for (var e = 0; e < a.length; e++) {
var i = a[e];
i.enumerable = i.enumerable || !1, i.configurable = !0, "value" in i && (i.writable = !0),
Object.defineProperty(t, i.key, i);
}
}
return function(a, e, i) {
return e && t(a.prototype, e), i && t(a, i), a;
};
}(), a = function() {
function a(t) {
(function(t, a) {
if (!(t instanceof a)) throw new TypeError("Cannot call a class as a function");
})(this, a), this.ak = t.ak;
}
return t(a, [ {
key: "getWXLocation",
value: function(t, a, e, i) {
t = t || "gcj02", a = a || function() {}, e = e || function() {}, i = i || function() {},
wx.getLocation({
type: t,
success: a,
fail: e,
complete: i
});
}
}, {
key: "search",
value: function(t) {
var a = {
query: (t = t || {}).query || "生活服务$美食&酒店",
scope: t.scope || 1,
filter: t.filter || "",
coord_type: t.coord_type || 2,
page_size: t.page_size || 10,
page_num: t.page_num || 0,
output: t.output || "json",
ak: this.ak,
sn: t.sn || "",
timestamp: t.timestamp || "",
radius: t.radius || 2e3,
ret_coordtype: "gcj02ll"
}, e = {
iconPath: t.iconPath,
iconTapPath: t.iconTapPath,
width: t.width,
height: t.height,
alpha: t.alpha || 1,
success: t.success || function() {},
fail: t.fail || function() {}
}, i = function(t) {
a.location = t.latitude + "," + t.longitude, wx.request({
url: "https://api.map.baidu.com/place/v2/search",
data: a,
header: {
"content-type": "application/json"
},
method: "GET",
success: function(t) {
var a = t.data;
if (0 === a.status) {
var i = a.results, n = {};
n.originalData = a, n.wxMarkerData = [];
for (var o = 0; o < i.length; o++) n.wxMarkerData[o] = {
id: o,
latitude: i[o].location.lat,
longitude: i[o].location.lng,
title: i[o].name,
iconPath: e.iconPath,
iconTapPath: e.iconTapPath,
address: i[o].address,
telephone: i[o].telephone,
alpha: e.alpha,
width: e.width,
height: e.height
};
e.success(n);
} else e.fail({
errMsg: a.message,
statusCode: a.status
});
},
fail: function(t) {
e.fail(t);
}
});
};
if (t.location) {
var n = t.location.split(",")[1];
i({
errMsg: "input location",
latitude: t.location.split(",")[0],
longitude: n
});
} else this.getWXLocation("gcj02", i, function(t) {
e.fail(t);
}, function(t) {});
}
}, {
key: "suggestion",
value: function(t) {
var a = {
query: (t = t || {}).query || "",
region: t.region || "全国",
city_limit: t.city_limit || !1,
output: t.output || "json",
ak: this.ak,
sn: t.sn || "",
timestamp: t.timestamp || "",
ret_coordtype: "gcj02ll"
}, e = {
success: t.success || function() {},
fail: t.fail || function() {}
};
wx.request({
url: "https://api.map.baidu.com/place/v2/suggestion",
data: a,
header: {
"content-type": "application/json"
},
method: "GET",
success: function(t) {
var a = t.data;
0 === a.status ? e.success(a) : e.fail({
errMsg: a.message,
statusCode: a.status
});
},
fail: function(t) {
e.fail(t);
}
});
}
}, {
key: "regeocoding",
value: function(t) {
var a = {
coordtype: (t = t || {}).coordtype || "gcj02ll",
ret_coordtype: "gcj02ll",
radius: t.radius || 1e3,
ak: this.ak,
sn: t.sn || "",
output: t.output || "json",
callback: t.callback || function() {},
extensions_poi: t.extensions_poi || 1,
extensions_road: t.extensions_road || !1,
extensions_town: t.extensions_town || !1,
language: t.language || "zh-CN",
language_auto: t.language_auto || 0
}, e = {
iconPath: t.iconPath,
iconTapPath: t.iconTapPath,
width: t.width,
height: t.height,
alpha: t.alpha || 1,
success: t.success || function() {},
fail: t.fail || function() {}
}, i = function(t) {
a.location = t.latitude + "," + t.longitude, wx.request({
url: "https://api.map.baidu.com/reverse_geocoding/v3",
data: a,
header: {
"content-type": "application/json"
},
method: "GET",
success: function(a) {
var i = a.data;
if (0 === i.status) {
var n = i.result, o = {};
o.originalData = i, o.wxMarkerData = [], o.wxMarkerData[0] = {
id: 0,
latitude: t.latitude,
longitude: t.longitude,
address: n.formatted_address,
iconPath: e.iconPath,
iconTapPath: e.iconTapPath,
desc: n.sematic_description,
business: n.business,
alpha: e.alpha,
width: e.width,
height: e.height
}, e.success(o);
} else e.fail({
errMsg: i.message,
statusCode: i.status
});
},
fail: function(t) {
e.fail(t);
}
});
};
if (t.location) {
var n = t.location.split(",")[1];
i({
errMsg: "input location",
latitude: t.location.split(",")[0],
longitude: n
});
} else this.getWXLocation("gcj02", i, function(t) {
e.fail(t);
}, function(t) {});
}
}, {
key: "geocoding",
value: function(t) {
var a = {
address: (t = t || {}).address || "",
city: t.city || "",
ret_coordtype: t.coordtype || "gcj02ll",
ak: this.ak,
sn: t.sn || "",
output: t.output || "json",
callback: t.callback || function() {}
}, e = {
iconPath: t.iconPath,
iconTapPath: t.iconTapPath,
width: t.width,
height: t.height,
alpha: t.alpha || 1,
success: t.success || function() {},
fail: t.fail || function() {}
};
if (t.address) wx.request({
url: "https://api.map.baidu.com/geocoding/v3",
data: a,
header: {
"content-type": "application/json"
},
method: "GET",
success: function(t) {
var a = t.data;
if (0 === a.status) {
var i = a.result, n = a;
n.originalData = a, n.wxMarkerData = [], n.wxMarkerData[0] = {
id: 0,
latitude: i.location.lat,
longitude: i.location.lng,
iconPath: e.iconPath,
iconTapPath: e.iconTapPath,
alpha: e.alpha,
width: e.width,
height: e.height
}, e.success(n);
} else e.fail({
errMsg: a.message,
statusCode: a.status
});
},
fail: function(t) {
e.fail(t);
}
}); else {
e.fail({
errMsg: "input address!"
});
}
}
}, {
key: "weather",
value: function(t) {
var a = {
coord_type: (t = t || {}).coord_type || "gcj02",
output: t.output || "json",
ak: this.ak,
sn: t.sn || "",
timestamp: t.timestamp || ""
}, e = {
success: t.success || function() {},
fail: t.fail || function() {}
}, i = function(t) {
a.location = t.longitude + "," + t.latitude, wx.request({
url: "https://api.map.baidu.com/telematics/v3/weather",
data: a,
header: {
"content-type": "application/json"
},
method: "GET",
success: function(t) {
var a = t.data;
if (0 === a.error && "success" === a.status) {
var i = a.results, n = {};
n.originalData = a, n.currentWeather = [], n.currentWeather[0] = {
currentCity: i[0].currentCity,
pm25: i[0].pm25,
date: i[0].weather_data[0].date,
temperature: i[0].weather_data[0].temperature,
weatherDesc: i[0].weather_data[0].weather,
wind: i[0].weather_data[0].wind
}, e.success(n);
} else e.fail({
errMsg: a.message,
statusCode: a.status
});
},
fail: function(t) {
e.fail(t);
}
});
};
if (t.location) {
var n = t.location.split(",")[0];
i({
errMsg: "input location",
latitude: t.location.split(",")[1],
longitude: n
});
} else this.getWXLocation("gcj02", i, function(t) {
e.fail(t);
}, function(t) {});
}
} ]), a;
}();
module.exports.BMapWX = a;
\ No newline at end of file
import Vue from 'vue' import Vue from 'vue'
import App from './App' import App from './App'
import store from '@/store' import store from '@/store'
import vuexStore from "@/store/$u.mixin.js" import vuexStore from '@/store/$u.mixin.js'
import { router, RouterMount } from './router.js'
Vue.use(router)
Vue.config.productionTip = false Vue.config.productionTip = false
App.mpType = 'app' App.mpType = 'app'
...@@ -10,13 +11,17 @@ Vue.mixin(vuexStore) ...@@ -10,13 +11,17 @@ Vue.mixin(vuexStore)
// 引入全局uView // 引入全局uView
import uView from 'uview-ui' import uView from 'uview-ui'
Vue.use(uView); Vue.use(uView)
const app = new Vue({ const app = new Vue({
store, store,
...App ...App,
}) })
// 引入uView对小程序分享的mixin封装
let mpShare = require('uview-ui/libs/mixin/mpShare.js')
Vue.mixin(mpShare)
import httpInterceptor from '@/common/http.interceptor.js' import httpInterceptor from '@/common/http.interceptor.js'
Vue.use(httpInterceptor, app) Vue.use(httpInterceptor, app)
...@@ -24,4 +29,10 @@ Vue.use(httpInterceptor, app) ...@@ -24,4 +29,10 @@ Vue.use(httpInterceptor, app)
import httpApi from '@/common/http.api.js' import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app) Vue.use(httpApi, app)
// #ifdef H5
RouterMount(app, router, '#app')
// #endif
// #ifndef H5
app.$mount() app.$mount()
// #endif
{ {
"name": "", "name" : "模考大师",
"appid": "", "appid" : "",
"description": "", "description" : "",
"versionName": "1.0.0", "versionName" : "1.0.0",
"versionCode": "100", "versionCode" : "100",
"transformPx": false, "transformPx" : false,
"app-plus": { /* 5+App特有相关 */ "app-plus" : {
"usingComponents": true, /* 5+App特有相关 */
"splashscreen": { "usingComponents" : true,
"alwaysShowBeforeRender": true, "splashscreen" : {
"waiting": true, "alwaysShowBeforeRender" : true,
"autoclose": true, "waiting" : true,
"delay": 0 "autoclose" : true,
}, "delay" : 0
"modules": { /* 模块配置 */ },
"modules" : {},
}, /* 模块配置 */
"distribute": { /* 应用发布信息 */ "distribute" : {
"android": { /* android打包配置 */ /* 应用发布信息 */
"permissions": ["<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>", "android" : {
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>", /* android打包配置 */
"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>", "permissions" : [
"<uses-permission android:name=\"android.permission.VIBRATE\"/>", "<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>", "<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>", "<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>", "<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>", "<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>", "<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>", "<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>", "<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>", "<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>", "<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>", "<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>", "<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>", "<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>", "<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>", "<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>", "<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-feature android:name=\"android.hardware.camera\"/>", "<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>", "<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>" "<uses-permission android:name=\"android.permission.ACCESS_COARSE_LOCATION\"/>",
] "<uses-feature android:name=\"android.hardware.camera\"/>",
}, "<uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\"/>",
"ios": { /* ios打包配置 */ "<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
}, },
"sdkConfigs": { /* SDK配置 */ "ios" : {},
/* ios打包配置 */
} "sdkConfigs" : {}
} }
}, },
"quickapp": { /* 快应用特有相关 */ /* SDK配置 */
"quickapp" : {},
}, /* 快应用特有相关 */
"mp-weixin": { /* 微信小程序特有相关 */ "mp-weixin" : {
"appid": "", /* 微信小程序特有相关 */
"setting": { "appid" : "wx4bd80cf10c2a1d14",
"urlCheck": false, "setting" : {
"es6" : true "urlCheck" : false,
}, "es6" : true
"usingComponents": true },
}, "usingComponents" : true,
"mp-alipay" : { "permission" : {
"usingComponents" : true "scope.userLocation" : {
}, "desc" : "您的位置信息将用于默认对应区域题库的选择"
"mp-baidu" : { }
"usingComponents" : true }
}, },
"mp-toutiao" : { "mp-alipay" : {
"usingComponents" : true "usingComponents" : true
}, },
"mp-qq" : { "mp-baidu" : {
"usingComponents" : true "usingComponents" : true
} },
} "mp-toutiao" : {
"usingComponents" : true
},
"mp-qq" : {
"usingComponents" : true
}
}
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages "pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
{ {
"path": "pages/index/index", "path": "pages/index/index",
"name": "index",
"style": { "style": {
"navigationBarTitleText": "题库", "navigationBarTitleText": "题库",
"navigationStyle": "custom", "navigationStyle": "custom",
...@@ -13,6 +14,7 @@ ...@@ -13,6 +14,7 @@
}, },
{ {
"path": "pages/index/cert", "path": "pages/index/cert",
"name": "cert",
"style": { "style": {
"navigationBarTitleText": "证书", "navigationBarTitleText": "证书",
"navigationStyle": "custom", "navigationStyle": "custom",
...@@ -21,20 +23,203 @@ ...@@ -21,20 +23,203 @@
}, },
{ {
"path": "pages/index/mine", "path": "pages/index/mine",
"name": "mine",
"style": { "style": {
"navigationBarTitleText": "个人中心", "navigationBarTitleText": "个人中心",
"navigationStyle": "custom",
"disableScroll": true "disableScroll": true
} }
} }
], ],
"subPackages": [ "subPackages": [
{
"root": "pages/login",
"pages": [
{
"path": "index",
"name": "login",
"style": {
"navigationBarTitleText": "授权登录",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
}
]
},
{
"root": "pages/search",
"pages": [
{
"path": "index",
"name": "searchIndex",
"style": {
"navigationBarTitleText": "搜索",
"navigationStyle": "custom",
"disableScroll": true
}
},
{
"path": "detail",
"name": "searchDetail",
"style": {
"navigationBarTitleText": "搜索结果",
"navigationStyle": "custom"
}
}
]
},
{ {
"root": "pages/learn", "root": "pages/learn",
"pages": [ "pages": [
{
"path": "answer",
"name": "learnAnswer",
"style": {
"navigationBarTitleText": "答题",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "answerBackup",
"name": "learnAnswerrBackup",
"style": {
"navigationBarTitleText": "答题-备份",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "selectCategory",
"name": "learnSelectCategory",
"style": {
"navigationBarTitleText": "题库选择",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "record",
"name": "learnRecord",
"style": {
"navigationBarTitleText": "学练记录",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "addExam",
"name": "learnAddExam",
"style": {
"navigationBarTitleText": "选择题库",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "examSetting",
"name": "learnExamSetting",
"style": {
"navigationBarTitleText": "选择题库-设置",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "selectedList",
"name": "learnSelectedList",
"style": {
"navigationBarTitleText": "已选题库",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "selectSpecial",
"name": "learnSelectSpecial",
"style": {
"navigationBarTitleText": "专项练习",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{ {
"path": "detail", "path": "detail",
"name": "learnDetail",
"style": {
"navigationBarTitleText": "", // 题库详情绑卡首页
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "beginAnswer",
"name": "learnBeginAnswer",
"style": {
"navigationBarTitleText": "模拟考试-开始",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "score",
"name": "learnScore",
"style": {
"navigationBarTitleText": "考试成绩",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "boundTest",
"name": "learnBoundTest",
"style": {
"navigationBarTitleText": "绑定试题",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "boundQuestions",
"name": "learnBoundQuestions",
"style": {
"navigationBarTitleText": "绑定题库",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "manualBinding",
"name": "learnManualBinding",
"style": {
"navigationBarTitleText": "手动绑定",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "sweepResults",
"name": "learnSweepResults",
"style": { "style": {
"navigationBarTitleText": "题库详情" "navigationBarTitleText": "绑定试题", // 扫码结果
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
} }
} }
] ]
...@@ -44,8 +229,12 @@ ...@@ -44,8 +229,12 @@
"pages": [ "pages": [
{ {
"path": "detail", "path": "detail",
"name": "certDetail",
"style": { "style": {
"navigationBarTitleText": "证书详情" "navigationBarTitleText": "证书详情",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": false
} }
} }
] ]
...@@ -55,9 +244,59 @@ ...@@ -55,9 +244,59 @@
"pages": [ "pages": [
{ {
"path": "customer", "path": "customer",
"name": "mineCustomer",
"style": { "style": {
"navigationStyle": "custom",
"navigationBarTitleText": "联系客服", "navigationBarTitleText": "联系客服",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "info",
"name": "mineInfo",
"style": {
"navigationBarTitleText": "个人信息",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "bank",
"name": "mineBank",
"style": {
"navigationBarTitleText": "我的题库",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "company",
"name": "mineCompany",
"style": {
"navigationBarTitleText": "工作单位",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": true
}
},
{
"path": "certify",
"name": "mineCertify",
"style": {
"navigationBarTitleText": "实名认证",
"navigationStyle": "custom",
"enablePullDownRefresh": false,
"disableScroll": false
}
},
{
"path": "setting",
"name": "mineSetting",
"style": {
"navigationBarTitleText": "设置",
"enablePullDownRefresh": false, "enablePullDownRefresh": false,
"disableScroll": true "disableScroll": true
} }
...@@ -79,20 +318,20 @@ ...@@ -79,20 +318,20 @@
"list": [ "list": [
{ {
"pagePath": "pages/index/index", "pagePath": "pages/index/index",
"iconPath": "static/logo.png", "iconPath": "static/tab/tiku0.png",
"selectedIconPath": "static/logo.png", "selectedIconPath": "static/tab/tiku1.png",
"text": "题库" "text": "题库"
}, },
{ {
"pagePath": "pages/index/cert", "pagePath": "pages/index/cert",
"iconPath": "static/logo.png", "iconPath": "static/tab/zhengshu0.png",
"selectedIconPath": "static/logo.png", "selectedIconPath": "static/tab/zhengshu1.png",
"text": "证书" "text": "证书"
}, },
{ {
"pagePath": "pages/index/mine", "pagePath": "pages/index/mine",
"iconPath": "static/logo.png", "iconPath": "static/tab/wode0.png",
"selectedIconPath": "static/logo.png", "selectedIconPath": "static/tab/wode1.png",
"text": "我的" "text": "我的"
} }
] ]
......
<template>
<view class="begin-answer">
<u-navbar
back-icon-color="#ffffff"
background="transparent"
title="证书详情"
titleColor="#ffffff"
:border-bottom="false"
title-bold
></u-navbar>
<view class="content">
<view class="cert-body">
<view class="top">
<u-image :src="topImage" height="116rpx" width="100%"></u-image>
</view>
<view class="table-list">
<view class="item">
<view class="name">低压电工证</view>
<view class="table">
<u-table>
<u-tr class="u-tr">
<u-th class="u-th">姓名</u-th>
<u-th class="u-th">年龄</u-th>
<u-th class="u-th">籍贯</u-th>
<u-th class="u-th">性别</u-th>
</u-tr>
<u-tr class="u-tr">
<u-td class="u-td">吕布</u-td>
<u-td class="u-td">22</u-td>
<u-td class="u-td">楚河</u-td>
<u-td class="u-td">男</u-td>
</u-tr>
<u-tr class="u-tr">
<u-td class="u-td">吕布</u-td>
<u-td class="u-td">22</u-td>
<u-td class="u-td">楚河</u-td>
<u-td class="u-td">男</u-td>
</u-tr>
<u-tr class="u-tr">
<u-td class="u-td">吕布</u-td>
<u-td class="u-td">22</u-td>
<u-td class="u-td">楚河</u-td>
<u-td class="u-td">男</u-td>
</u-tr>
<u-tr class="u-tr">
<u-td class="u-td">吕布</u-td>
<u-td class="u-td">22</u-td>
<u-td class="u-td">楚河</u-td>
<u-td class="u-td">男</u-td>
</u-tr>
<u-tr class="u-tr">
<u-td class="u-td">吕布</u-td>
<u-td class="u-td">22</u-td>
<u-td class="u-td">楚河</u-td>
<u-td class="u-td">男</u-td>
</u-tr>
</u-table>
</view>
</view>
<view class="item">
<view class="name">低压电工证</view>
<view class="table">
<u-table>
<u-tr class="u-tr">
<u-th class="u-th">姓名</u-th>
<u-th class="u-th">年龄</u-th>
<u-th class="u-th">籍贯</u-th>
<u-th class="u-th">性别</u-th>
</u-tr>
<u-tr class="u-tr">
<u-td class="u-td">吕布</u-td>
<u-td class="u-td">22</u-td>
<u-td class="u-td">楚河</u-td>
<u-td class="u-td">男</u-td>
</u-tr>
<u-tr class="u-tr">
<u-td class="u-td">吕布</u-td>
<u-td class="u-td">22</u-td>
<u-td class="u-td">楚河</u-td>
<u-td class="u-td">男</u-td>
</u-tr>
<u-tr class="u-tr">
<u-td class="u-td">吕布</u-td>
<u-td class="u-td">22</u-td>
<u-td class="u-td">楚河</u-td>
<u-td class="u-td">男</u-td>
</u-tr>
<u-tr class="u-tr">
<u-td class="u-td">吕布</u-td>
<u-td class="u-td">22</u-td>
<u-td class="u-td">楚河</u-td>
<u-td class="u-td">男</u-td>
</u-tr>
<u-tr class="u-tr">
<u-td class="u-td">吕布</u-td>
<u-td class="u-td">22</u-td>
<u-td class="u-td">楚河</u-td>
<u-td class="u-td">男</u-td>
</u-tr>
</u-table>
</view>
</view>
</view>
<view class="foot">
<text>证书机构:中华人民共和国应急管理部</text>
<text style="padding-top: 28rpx;">更新时间:2021.07.21</text>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
data: null,
topImage: process.uniEnv.qn_base_url + 'tezhongzuoyepingtai@2x.png',
}
},
onShow: function() {
this.data = getApp().globalData.certItemData
console.log('shoudao param', this.data)
},
}
</script>
<style scoped lang="scss">
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.begin-answer {
display: flex;
flex-direction: column;
background-color: #2953ff;
background-size: 100% 920rpx;
background-repeat: no-repeat;
height: 120vh;
position: absolute;
top: 0;
width: 100%;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 130rpx 24rpx 0rpx 24rpx;
}
.cert-body {
width: 100%;
background-color: #ffffff;
text-align: center;
border-radius: 12rpx;
padding: 30rpx;
position: relative;
.top {
height: 116rpx;
background-color: #000000;
}
.table-list {
margin-top: 20rpx;
margin-bottom: 200rpx;
.name {
font-size: 24rpx;
text-align: left;
padding: 30rpx 0;
}
.table {
background-color: #2953ff;
min-height: 200rpx;
}
}
.foot {
position: absolute;
bottom: 41px;
left: 0;
height: 100rpx;
width: 100%;
text-align: left;
padding-left: 24rpx;
display: flex;
flex-direction: column;
font-size: 28rpx;
color: #5a6073;
}
}
</style>
<template> <template>
<view class="content"> <view class="begin-answer">
<view> <u-navbar
<text class="title">{{title}}</text> back-icon-color="#000000"
</view> background="transparent"
</view> title="我的信息"
titleColor="#000000"
:border-bottom="false"
title-bold
></u-navbar>
<view class="study">
<u-tabs-swiper
bg-color="#F4F5F7"
inactive-color="#999999"
font-size="28"
ref="uTabs"
:list="tabs"
:current="current"
@change="tabsChange"
:is-scroll="false"
:bar-width="52"
swiperWidth="750"
></u-tabs-swiper>
<swiper
class="swiper_group"
:current="swiperCurrent"
@transition="transition"
@animationfinish="animationfinish"
>
<swiper-item @touchmove.stop.prevent="stopTouchMove">
<view class="tips-top">
<view class="all-text">
正式考试后
<text class="num">
30
</text>
个工作日后,可查询相关证书/成绩
</text>
</view>
</view>
<scroll-view scroll-y style="width:100%;">
<view class=" form">
<view class="item">
<text class="title">选择查询证书类型</text>
<u-input
v-model="value"
:type="type"
:border="border"
@click="show = true"
/>
</view>
<view class="item">
<text class="title">身份证号</text>
<u-input
class="input"
v-model="certId"
placeholder="请输入身份证号"
/>
</view>
<view class="item">
<text class="title">姓名</text>
<u-input
class="input"
v-model="certName"
placeholder="请输入姓名"
/>
</view>
<view class="tips-bottom"></view>
</view>
<button class="sub-button">查询</button>
</scroll-view>
</swiper-item>
<swiper-item @touchmove.stop.prevent="stopTouchMove">
<scroll-view
scroll-y
style="height:100%;width:100%;"
@scrolltolower="onreachBottom"
scroll-y="true"
refresher-enabled="true"
:refresher-triggered="triggered"
:refresher-threshold="100"
@refresherpulling="onPulling"
@refresherrefresh="onRefresh"
@refresherrestore="onRestore"
@refresherabort="onAbort"
>
<view class="list-view">
<view class="item" v-for="(item, key) in countryCertList" :key="key" @tap="goDetail(item)">
<u-image :src="item.bgImage" width="100%" height="100%" class="bg-image"></u-image>
<view class="name">
{{ item.certificateName }}
</view>
</view>
<view class="item" v-for="(item, key) in learnCertList" :key="key" @tap="goDetail(item)">
<u-image :src="item.bgImage" width="100%" height="100%" class="bg-image"></u-image>
<view class="learn-name">
{{ item.certificateName }}
</view>
</view>
</view>
</scroll-view>
</swiper-item>
</swiper>
</view>
<u-action-sheet
:list="actionSheetList"
v-model="show"
@click="actionSheetCallback"
></u-action-sheet>
</view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
title: '证书' // lists: [
} // {
}, // certificateName: '低压电工证',
onLoad() { // bgImage: process.uniEnv.qn_base_url + 'zhengshubeijing@2x.png'
// },
}, // {
methods: { // certificateName: '高压电工证',
// bgImage: process.uniEnv.qn_base_url + 'zhengshubeijing@2x.png'
} // },
} // {
// certificateName: '高处安装、维护、拆除作业人员',
// bgImage: process.uniEnv.qn_base_url + 'xueshizhengmingbeijing@2x.png'
// },
// ],
countryCertList: [],
learnCertList: [],
countryCertImage: process.uniEnv.qn_base_url + 'zhengshubeijing@2x.png',
learnCertImage: process.uniEnv.qn_base_url + 'xueshizhengmingbeijing@2x.png',
isEmptyList: true,//学时证和国家证都为空显示空
value: '',
type: 'select',
show: false,
border: false,
actionSheetList: [
{
text: '特种作业操作证查询',
},
],
tabs: [
{
name: '证书查询',
},
{
name: '我的证书',
},
],
certType: '',
certId: '',
certName: '',
current: 0,
swiperCurrent: 0,
params: {
start: 0,
},
loadStatus: 'loading',
isLoadMore: false,
isReflesh: true,
triggered: false,
_freshing: false,
}
},
computed: {
// lists(){
// let data = []
// if(this.countryCertList.length > 0){
// for(let j in this.countryCertList){
// data.unshift(this.countryCertList[j])
// }
// }
// if(this.learnCertList.length > 0){
// for(let k in this.learnCertList){
// data.unshift(this.learnCertList[k])
// }
// }
// console.log('data', data)
// return data
// }
},
onLoad() {
},
onShow: function(param) {
try {
if (param.tabs) {
this.current = param.tabs
this.swiperCurrent = param.tabs
}
} catch (e) {}
this.tabsChange(this.current)
},
methods: {
//获取国家证书数据
getCountryCert(){
this.$u.api.getCountryCertList().then((res)=>{
console.log('国家证',res)
if(!res || res.length == 0){
return
}
this.isEmptyList = true
let data = []
for(let key in res){
//判断是否是table数据格式,否则暂不展示,后面如果有再补充显示图片格式
if(
res[key].certificateSource != 2
|| res[key].certificateType != 2){
continue
}
data[key] = {}
data[key].certificateName = res[key].certificateName.replace('作业', '证')
data[key].bgImage = this.countryCertImage
data[key].type = 'country'
data[key].key = key
data[key].data = res[key] //传给详情页
}
this.countryCertList = JSON.parse(JSON.stringify(data))
})
},
//获取学时数据
getLearnCert(){
this.$u.api.getlearnCertList().then((res)=>{
res = [
{
"id": "1415602594134360064",
"createTime": "2021-07-15 17:41:51",
"createdBy": "1415215255998431232",
"updateTime": "2021-07-15 17:41:51",
"updatedBy": null,
"echoMap": {
"studentId": {
"id": "1414459877807357952",
"createTime": "2021-07-12 13:41:29",
"createdBy": "3",
"updateTime": "2021-07-20 20:41:13",
"updatedBy": "1414459877807357952",
"echoMap": {},
"cardCount": null,
"consumeAmount": null,
"loginTime": null,
"code": "XY20210723000001",
"unionid": "",
"nickname": "",
"name": "",
"phoneNumber": "11111111111",
"avatarPath": "",
"identityNumber": "",
"identityFrontPath": "",
"identityBackPath": "",
"certificatePhotoPath": "",
"certificateValidityDate": null,
"workUnit": "",
"address": ""
},
"questionWarehouseId": {
"id": "1",
"createTime": "2021-07-12 16:33:20",
"createdBy": null,
"updateTime": "2021-07-21 14:40:44",
"updatedBy": "1413688964405002240",
"echoMap": {},
"institutionId": "1",
"subjectId": "1413687160678121472",
"title": "测试1",
"subtitle": "侧首",
"description": "哈哈哈哈",
"effectiveTime": "1",
"provinceId": "470715",
"cityId": "475286",
"type": "1",
"price": "100.00",
"realPrice": "50.00",
"state": true,
"remark": "123231",
"version": null
}
},
"number": null,
"questionWarehouseId": "1",
"institutionId": "-1",
"studentId": "1414459877807357952",
"cardId": "1416278788987158528"
},
{
"id": "1418473748293484544",
"createTime": "2021-07-23 15:31:10",
"createdBy": "1414459877807357952",
"updateTime": "2021-07-24 14:45:15",
"updatedBy": "1414459877807357952",
"echoMap": {
"studentId": {
"id": "1414459877807357952",
"createTime": "2021-07-12 13:41:29",
"createdBy": "3",
"updateTime": "2021-07-20 20:41:13",
"updatedBy": "1414459877807357952",
"echoMap": {},
"cardCount": null,
"consumeAmount": null,
"loginTime": null,
"code": "XY20210723000001",
"unionid": "",
"nickname": "",
"name": "",
"phoneNumber": "11111111111",
"avatarPath": "",
"identityNumber": "",
"identityFrontPath": "",
"identityBackPath": "",
"certificatePhotoPath": "",
"certificateValidityDate": null,
"workUnit": "",
"address": ""
},
"questionWarehouseId": {
"id": "1414854649273384960",
"createTime": "2021-07-13 15:50:10",
"createdBy": "1413688964405002240",
"updateTime": "2021-07-23 14:41:30",
"updatedBy": "1413688964405002240",
"echoMap": {},
"institutionId": "1",
"subjectId": "1418169087225233408",
"title": "登高架设作业",
"subtitle": "大狼狗",
"description": "sad",
"effectiveTime": "0",
"provinceId": "470715",
"cityId": "475286",
"type": "1",
"price": "100.00",
"realPrice": "60.00",
"state": true,
"remark": "",
"version": "0"
}
},
"number": null,
"questionWarehouseId": "1414854649273384960",
"institutionId": "-1",
"studentId": "1414459877807357952",
"cardId": "0"
}
]
console.log('学时证', res);
if(!res || res.length == 0){
//空显示缺醒
return
}
this.isEmptyList = true
let data = []
for(let key in res){
if(!res[key].echoMap || !res[key].echoMap.questionWarehouseId){
continue
}
data[key] = {}
data[key].certificateName = res[key].echoMap.questionWarehouseId.title.replace('作业', '证')
data[key].id = res[key].echoMap.questionWarehouseId.id
data[key].bgImage = this.learnCertImage
data[key].type = 'learn'
data[key].key = key
}
console.log('学时证处理结果', data)
this.learnCertList = JSON.parse(JSON.stringify(data))
})
},
goDetail(param){
console.log('goto param', param)
if(param.type == 'learn'){
console.log('点击学时证,请求详情,组装参数再传过去')
this.$u.api.getlearnCertDetail(param.id).then((res)=>{
res = {
photo: "",头像,
name: "",名字,
idCard: "",身份证,
company: "",工作单位,
subjectName: "测试1",资格类型,
institutionName: null,培训机构名称,
startDate: "",培训开始时间,
endDate: "2021-07-24",培训结束时间,
maxPoint: 0,最高分,
time: 0,学时,
questionWarehouse: null,
}
param.data = res
getApp().globalData.certItemData = param
this.$u.route({
url: 'pages/cert/detail',
})
}).catch(err => {
console.log(err)
})
}else{
console.log('点击国家证,直接参数带过去')
getApp().globalData.certItemData = param
this.$u.route({
url: 'pages/cert/detail',
})
}
},
actionSheetCallback(index) {
this.value = this.actionSheetList[index].text
},
onPulling(e) {
return true
},
onRefresh() {
if (this._freshing) return
this.triggered = true
this._freshing = true
this.isLoadMore = false
this.loadStatus = 'loading'
},
onRestore() {
this.triggered = 'restore' // 需要重置
},
onAbort() {
console.log('onAbort')
},
transition(e) {
// swiper-item左右移动,通知tabs的滑块跟随移动
let dx = e.detail.dx
this.$refs.uTabs.setDx(dx)
},
//scroll-view到底部加载更多
onreachBottom() {
//上拉触底函数
if (!this.isLoadMore) {
this.isLoadMore = true
this.params.start += 5
}
},
stopTouchMove() {
return false
},
//tabs通知swiper切换
tabsChange(index) {
console.log('当前tabs index',index)
this.swiperCurrent = Number(index)
switch (this.swiperCurrent) {
case 1:
let lifeData = uni.getStorageSync('lifeData')
if(lifeData.vuex_token){
let token = lifeData.vuex_token;
this.$u.vuex('vuex_token', 'Bearer test')
this.getCountryCert()
this.getLearnCert()
}
break
case 2:
break
case 3:
break
}
},
animationfinish(e) {
let current = e.detail.current
this.$refs.uTabs.setFinishCurrent(current)
this.swiperCurrent = current
this.current = current
},
},
}
</script> </script>
<style scoped lang="scss">
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
page {
background-color: #f7f9fc;
}
.begin-answer {
display: flex;
flex-direction: column;
background-image: linear-gradient(to top, #f7f9fc 0%, #e9f3ff 40%);
background-color: #f7f9fc;
background-size: 100% 920rpx;
background-repeat: no-repeat;
height: 100vh;
position: absolute;
top: 0;
width: 100%;
}
.study {
height: 100vh;
background: none;
padding: 0rpx 24rpx;
}
.form {
display: flex;
flex-direction: column;
}
.study ::v-deep swiper {
height: 100%;
}
.tips-top {
width: 702rpx;
height: 72rpx;
line-height: 72rpx;
font-size: 24rpx;
background-color: #f9dfdce0;
text-align: center;
margin-bottom: 30rpx;
color: #5a6073;
.all-text {
.num {
color: #fa5a49;
}
}
}
.study ::v-deep .u-input__input {
width: 702rpx;
height: 104rpx;
background-color: #ffffff;
border-radius: 12rpx;
margin: 32rpx 0;
padding: 0 0 0 30rpx;
}
.sub-button {
margin-top: 150rpx;
height: 104rpx;
border-radius: 52rpx;
border: hidden;
background-color: #2953ff;
color: white;
font-size: 32rpx;
font-weight: bold;
line-height: 104rpx;
}
.study ::v-deep .u-input__right-icon {
position: absolute;
right: 23rpx;
top: 40%;
}
.study ::v-deep .u-tabs{
background: none !important;
}
.title {
font-size: 32rpx;
font-weight: bold;
color: #191c27;
}
.list-view {
width: 100%;
margin-bottom: 500rpx;
.item {
background-color: #2953ff;
width: 100%;
height: 444rpx;
margin-top: 30rpx;
border-radius: 24rpx;
position: relative;
.name {
width: 100%;
height: 100%;
text-align: center;
line-height: 444rpx;
position: absolute;
top: 0;
font-size: 60rpx;
font-weight: bold;
color: white;
}
.learn-name {
width: 100%;
height: 100%;
text-align: center;
line-height: 444rpx;
position: absolute;
top: 0;
font-weight: bold;
color: #A06F40;
padding-top: 50rpx;
font-size: 28rpx;
}
}
}
</style>
<template> <template>
<view class="content"> <view class="page-index">
<image class="logo" src="/static/logo.png"></image> <u-navbar
<view> back-icon-color="#333333"
<text class="title">{{title}}</text> background="transparent"
</view> title="题库平台"
</view> titleColor="#191C27"
:border-bottom="false"
title-bold
:is-back="false"
><slot
><image
:src="quanbutikuImage"
class="left-image"
@click="handleClickLeftTop"
></image></slot
></u-navbar>
<view class="content">
<view class="exam-title-view" @click="$u.throttle(handleSelect, 500)">
<view class="title-loading" v-if="loading">
<u-loading mode="flower"></u-loading>
</view>
<text v-else>{{ title }}</text>
<u-icon class="icon-view" name="arrow-up-fill"></u-icon>
</view>
<view v-if="noExam" class="tip-view">
<text>您还未选择题库,请先选择题库</text>
</view>
<view
v-else-if="!info.cardId"
class="card-tip-view"
@click="$u.throttle(handleSelectTip, 500)"
>
题库未激活,请通过<text class="blue-text">“绑卡”</text>或<text
class="blue-text"
>“购买”</text
>激活
</view>
<view v-else class="detail-view">
<view
v-for="(item, index) in detailItems"
:key="index"
:class="['detail-item', { 'pass-text': item.key == 'pass' }]"
><image
class="detail-image"
:style="item.imageStyle"
:src="item.image"
></image
><text v-if="item.title" class="detail-title">{{ item.title }}</text
><text class="detail-text">{{
item.key == 'location' ? provinceName : info[item.key]
}}</text></view
>
</view>
<SubjectStatistics
:info="info"
@answer="handleAnswer"
@click="handleClickItem"
></SubjectStatistics>
<view class="exam-mark">
<view
v-for="(item, index) in marks"
:key="index"
class="list-view"
@click="handleClickExam(index)"
>
<image class="exam-image" :src="item.image"></image>
<view class="right-view">
<view>{{ item.name }}</view>
<view class="label-view"
><text class="left-label" v-if="item.leftLabel">{{
item.leftLabel
}}</text
><text>{{ item.label }}</text></view
>
</view>
</view>
<view class="line-view"></view>
</view>
<view class="sub-content">
<view
v-for="(item, index) in subItems"
:key="index"
class="sub-content-item"
@click="handleClick(item.pathName, item.params)"
>
<view class="sub-image">
<image :src="item.icon" :style="item.imageStyle"></image>
</view>
<view>{{ item.title }}</view>
</view>
</view>
<view class="bottom-view">
<image class="bottom-image" :src="mokaodashiImage"></image>
<view>想要轻松考过,首选模考大师</view>
</view>
</view>
<view class="experience-pop-view">
<ExperiencePop :visible.sync="visible" @click="handleClickExperience" />
</view>
<ToastPop :visible.sync="show" :type="type" @click="handleClickToast" />
<view>
<u-toast ref="uToast" />
</view>
</view>
</template> </template>
<script> <script>
export default { import SubjectStatistics from '@/components/subject-statistics'
data() { import ExperiencePop from '@/components/experience-pop'
return { import ToastPop from '@/components/toast-pop'
title: 'Hello'
} export default {
}, components: { SubjectStatistics, ExperiencePop, ToastPop },
onLoad() { data() {
return {
}, visible: false, // 免费体验弹窗
methods: { show: false,
type: 'select',
} provinceList: [],
} detail: { questionWarehouse: {} },
selected: {},
data: {},
// relationId: 0, // 绑卡用
loading: false,
canExperience: false, // 体验资格
finishCount: 0,
}
},
computed: {
title() {
return this.selected.title || '请选择题库'
},
imageUrl() {
return '/static/logo.png'
},
noExam() {
return this.$u.test.isEmpty(this.selected.title)
},
mokaodashiImage() {
return process.uniEnv.qn_base_url + 'mokaodashi.png'
},
quanbutikuImage() {
return process.uniEnv.qn_base_url + 'quanbutiku.png'
},
marks() {
return [
{
name: '全部试题',
label: this.examText,
leftLabel: String(this.finishCount), // 已做题目数
image: process.uniEnv.qn_base_url + 'quanbushiti.png',
},
{
name: '模拟考试',
label: '真题模拟强化',
image: process.uniEnv.qn_base_url + 'monishiti.png',
},
]
},
examText() {
return this.info.cardId ? '/' + this.info.totalExam : '题库进阶练习'
},
info() {
return {
id: this.selected.id,
cardId:
this.detail.questionWarehouse && this.detail.questionWarehouse.cardId,
provinceName: this.provinceName,
experience: this.canExperience,
pass: this.$u.random(95, 99) + '%',
days: this.detail.totalDayCount || 0,
today: this.detail.todayCount || 0,
total: this.detail.totalCount || 0,
totalExam: this.data.totalCount || 0,
}
},
subItems() {
return [
{
pathName: 'pages/learn/selectSpecial',
title: '专项练习',
value: '',
icon: process.uniEnv.qn_base_url + 'zhuanxiang.png',
imageStyle: 'width:72rpx;height:64rpx',
params: this.data,
},
{
pathName: '/pages/learn/answer?source=5',
title: '错题记录',
value: '',
icon: process.uniEnv.qn_base_url + 'cuotijilu.png',
imageStyle: 'width:62rpx;height:64rpx',
},
{
pathName: '/pages/learn/answer?source=4',
title: '收藏的题',
value: '',
icon: process.uniEnv.qn_base_url + 'shoucangdeti.png',
imageStyle: 'width:76rpx;height:64rpx',
},
{
pathName: '/pages/search/index',
title: '试题搜索',
value: '',
icon: process.uniEnv.qn_base_url + 'sousuoshiti.png',
imageStyle: 'width:62rpx;height:64rpx',
},
]
},
provinceName() {
for (var item of this.provinceList) {
if (item.id == this.selected.provinceId) {
return item.fullName + '题'
}
}
return ''
},
detailItems() {
return [
{
title: '',
key: 'location',
image: process.uniEnv.qn_base_url + 'quyu.png',
imageStyle: 'width:24rpx;height:28rpx',
},
{
title: '通过率:',
key: 'pass',
image: process.uniEnv.qn_base_url + 'gailv.png',
imageStyle: 'width:28rpx;height:28rpx',
},
{
title: '题目数:',
key: 'totalExam',
image: process.uniEnv.qn_base_url + 'timushu.png',
imageStyle: 'width:28rpx;height:30rpx',
},
]
},
},
watch: {
vuex_token(val, oldVal) {
// 监听token变化,如果更新则重新加载页面数据
val && !oldVal && this.initData()
},
},
onLoad() {
this.loading = true
this.getProvinceList()
},
onShow() {
let pages = getCurrentPages()
let page = pages[pages.length - 1]
let info = page.info
if (info) {
this.selected = info
page.info = null
this.visible = info.state
this.queryMyQuestionWarehouseDetail(this.selected.id)
} else {
this.queryMyQuestionWarehouseDetail(this.info.id || 0)
}
this.chagefinishCount()
},
methods: {
initData() {
this.getProvinceList()
this.queryMyQuestionWarehouseDetail('0')
},
// 检查是否具有体验资格
checkGetQuestion(id) {
this.$u.api
.checkGetQuestion(id)
.then((res) => {
this.canExperience = res <= 0
})
.catch((err) => {
console.log(err)
})
},
// 题库详情
queryQuestionWarehouseById(id) {
this.$u.api
.queryQuestionWarehouseById(id)
.then((res) => {
this.loading = false
this.data = res || { questionWarehouse: {} }
this.selected = this.data.questionWarehouse
})
.catch((err) => {
this.loading = false
console.log(err)
})
// this.$u.vuex(
// 'experience',
// this.selected.state && !this.detail.questionWarehouse.cardId
// ? true
// : false
// )
},
// 学生查询题库首页
queryMyQuestionWarehouseDetail(id) {
this.$u.api
.queryMyQuestionWarehouseDetail(id)
.then((res) => {
this.detail = res || { questionWarehouse: {} }
// this.relationId = res.questionWarehouse.id
if (res.questionWarehouse.id) {
this.$u.vuex('relationId', res.questionWarehouse.id)
}
if (res.questionWarehouse.questionWarehouseId) {
this.$u.vuex(
'questionWarehouseId',
res.questionWarehouse.questionWarehouseId
)
}
this.queryQuestionWarehouseById(
res.questionWarehouse.questionWarehouseId
)
if (res.questionWarehouse.questionWarehouseId) {
this.checkGetQuestion(res.questionWarehouse.questionWarehouseId)
}
})
.catch((err) => {
this.loading = false
console.log(err)
})
},
handleSelect() {
var str = this.info.id ? 'selectedList' : 'selectCategory'
this.$u.route({
url: 'pages/learn/' + str,
})
},
// 每日一练
handleAnswer() {
if (this.info.cardId) {
// 练习
this.$u.route({
url: 'pages/learn/answer',
params: {
source: 2,
daily: true,
experience: false,
dailyCount: this.info.days,
},
})
} else if (this.info.id) {
if (this.info.experience) {
// this.selected.state = false
// this.$u.vuex('experience', false)
// 体验
// 1.顺序答题 2.随机练习 3.模拟考试 4.收藏答题 5.错题答题 6.专项练习-单选 7.专项练习-多选 8.专项练习-判断 9.专项练习-答案是
this.$u.route({
url: 'pages/learn/answer',
params: {
source: 2,
daily: true,
experience: true,
dailyCount: this.info.days,
},
})
} else {
// 绑卡提示
// this.type = 'bound'
// this.show = true
this.$u.route({
url: 'pages/learn/detail',
params: {
// relationId: this.relationId,
id: this.info.id,
},
})
}
} else {
this.$u.route({
url: 'pages/learn/selectCategory',
})
}
},
handleClickLeftTop() {
this.$u.route({
url: 'pages/learn/selectCategory',
})
},
handleClickToast(type) {
var str = type == 'select' ? 'addExam' : 'detail'
this.$u.route({
url: 'pages/learn/' + str,
params: {
// relationId: this.relationId,
id: this.info.id,
},
})
},
handleClickItem(key) {
if (this.info.id) {
// 跳转到学练记录
this.$u.route({
url: 'pages/learn/record?part=',
key,
})
} else {
this.$refs.uToast.show({
title: '暂未选题库',
type: 'warning',
})
}
},
handleClickExperience() {
// this.selected.state = false
// this.$u.vuex('experience', false)
// 体验
// 1.顺序答题 2.随机练习 3.模拟考试 4.收藏答题 5.错题答题 6.专项练习-单选 7.专项练习-多选 8.专项练习-判断 9.专项练习-答案是
this.$u.route({
url: 'pages/learn/answer',
params: {
source: 2,
daily: true,
experience: true,
dailyCount: this.info.days,
},
})
},
handleClickExam(index) {
if (this.info.cardId) {
// 已绑卡
if (index == 0) {
// 做题
this.$u.route({
url: 'pages/learn/answer',
params: {
source: 1,
},
})
} else {
// 模拟考试
this.$u.route({
url: 'pages/learn/beginAnswer',
})
}
} else if (this.info.id) {
// 已选题库
// 绑卡
// this.type = 'bound'
// this.show = true
this.$u.route({
url: 'pages/learn/detail',
params: {
// relationId: this.relationId,
id: this.info.id,
},
})
} else {
// 未选题库
this.$u.route({
url: 'pages/learn/selectCategory',
})
}
},
handleClick(path, params) {
if (this.info.cardId) {
if (params) {
this.setPageInfo(params)
}
// 已经绑卡
this.$u.route({
url: path,
})
} else if (this.info.id) {
// 已选题库未绑卡
// 绑卡
// this.type = 'bound'
// this.show = true
this.$u.route({
url: 'pages/learn/detail',
params: {
// relationId: this.relationId,
id: this.info.id,
},
})
} else {
this.$u.route({
url: 'pages/learn/selectCategory',
})
}
},
getProvinceList() {
this.$u.api
.getProvinceList()
.then((res) => {
this.provinceList = res || []
})
.catch((err) => {
console.log(err)
})
},
setPageInfo(info) {
var pages = getCurrentPages()
if (pages.length >= 1) {
var page = pages[pages.length - 1]
page.info = info
}
},
chagefinishCount() {
this.finishCount = this.questionList[this.questionWarehouseId]
? this.questionList[this.questionWarehouseId].reduce(
(accumulator, currentValue) => {
if (currentValue.submitStatus) accumulator++
return accumulator
},
0
)
: 0
},
handleSelectTip() {
this.$u.route({
url: 'pages/learn/detail',
params: {
// relationId: this.relationId,
id: this.info.id,
},
})
},
},
}
</script> </script>
<style> <style lang="scss">
.content { .experience-pop-view {
display: flex; .u-countdown-colon {
flex-direction: column; margin-left: 6rpx;
align-items: center; margin-right: 6rpx;
justify-content: center; }
} .u-mode-center-box {
background-color: transparent !important;
.logo { padding-top: 40rpx;
height: 200rpx; }
width: 200rpx; }
margin: 200rpx auto 50rpx auto; </style>
}
<style lang="scss" scope>
.text-area { ::-webkit-scrollbar {
display: flex; width: 0;
justify-content: center; height: 0;
} color: transparent;
display: none;
.title { }
font-size: 36rpx;
color: #8f8f94; .page-index {
} height: 100vh;
display: flex;
flex-direction: column;
background-color: #f7f9fc;
background-image: linear-gradient(to top, #f8fafd 0%, #e9f3ff 50%);
background-size: 100% 520rpx;
background-repeat: no-repeat;
.left-image {
width: 32rpx;
height: 32rpx;
margin-left: 22rpx;
}
.content {
height: 100%;
overflow: auto;
padding: 16rpx 24rpx 50rpx 24rpx;
.exam-title-view {
color: #191c27;
font-weight: bold;
font-size: 40rpx;
display: flex;
align-items: center;
.title-loading {
width: 240rpx;
height: 56rpx;
display: flex;
align-items: center;
justify-content: center;
}
.icon-view {
font-size: 24rpx;
color: #2953ff;
margin-left: 10rpx;
transform: rotate(90deg);
}
}
.tip-view {
color: #9ea5bb;
font-size: 28rpx;
margin-top: 22rpx;
margin-bottom: 40rpx;
}
.card-tip-view {
font-size: 28rpx;
color: #9ea5bb;
margin-top: 22rpx;
margin-bottom: 40rpx;
.blue-text {
color: #2953ff;
}
}
.detail-view {
display: flex;
align-items: flex-start;
margin-top: 14rpx;
margin-bottom: 36rpx;
.detail-item {
color: #9ea5bb;
font-size: 28rpx;
margin-right: 30rpx;
display: flex;
align-items: flex-start;
.detail-title {
color: #9ea5bb;
}
.detail-image {
margin-right: 10rpx;
margin-top: 4rpx;
}
.detail-text {
word-break: break-all;
max-width: 140rpx;
}
&.pass-text {
color: #2953ff;
}
}
}
.sub-content {
display: flex;
justify-content: space-between;
align-items: center;
margin: 60rpx 0 160rpx 0;
.sub-content-item {
color: #5a6073;
font-size: 26rpx;
display: flex;
justify-content: space-between;
flex-direction: column;
align-items: center;
width: 152rpx;
height: 176rpx;
background-color: #ffffff;
border-radius: 16rpx;
padding: 30rpx 0;
.sub-image {
margin-bottom: 20rpx;
display: flex;
justify-content: center;
align-items: center;
}
}
}
.exam-mark {
display: flex;
align-items: center;
justify-content: space-between;
.list-view {
width: 340rpx;
height: 136rpx;
border-radius: 16rpx;
display: flex;
align-items: center;
background-color: #ffffff;
.exam-image {
width: 96rpx;
height: 96rpx;
padding-left: 24rpx;
padding-right: 16rpx;
}
.right-view {
color: #191c27;
font-size: 32rpx;
font-weight: bold;
.label-view {
color: #9ea5bb;
font-weight: 400;
font-size: 26rpx;
margin-top: 4rpx;
.left-label {
color: #5a6073;
}
}
}
}
}
.bottom-view {
display: flex;
align-items: center;
justify-content: center;
font-size: 26rpx;
color: #adbdd4;
.bottom-image {
width: 56rpx;
height: 56rpx;
margin-right: 14rpx;
}
}
}
}
</style> </style>
<template> <template>
<view> <view>
<view class="u-flex user-box u-p-l-30 u-p-t-30 u-p-r-20 u-p-b-30"> <u-navbar
<view class="u-m-r-10"> back-icon-color="#333333"
<u-avatar :src="pic" size="140"></u-avatar> background="transparent"
</view> title=" "
<view class="u-flex-1"> titleColor="#191C27"
<view class="u-font-18 u-p-b-20">李开复</view> :border-bottom="false"
<view class="u-font-14 u-tips-color">累计刷题俩999次</view> title-bold
</view> :is-back="false"
</view> ></u-navbar>
<view class="top"
<view class="u-m-t-20"> ><image class="background-image" :src="backgroundImage"></image>
<u-cell-group> <view
<u-cell-item icon="star" title="个人信息" value="完善度40%"></u-cell-item> class="u-flex user-box u-p-l-30 u-p-t-30 u-p-r-20 u-p-b-30"
<u-cell-item icon="photo" title="我的题库"></u-cell-item> @tap="login"
<u-cell-item icon="coupon" title="联系客服"></u-cell-item> >
</u-cell-group> <view class="u-flex-1">
</view> <view class="u-font-18 u-p-b-20 nick-name">{{ nikeName }}</view>
</view> <view class="login-tip">
<text v-if="isLogin">
累计刷题量
<text style="color:#2953FF">
{{ loginTips }}
</text>
次
</text>
<text v-else>登录可查看答题信息</text>
</view>
</view>
<view class="u-m-r-10 avatar">
<u-avatar class="avatar-iamge" :src="avatar" size="140"></u-avatar>
</view>
</view>
<view class="">
<u-cell-group :border="false">
<u-cell-item
:border-bottom="false"
title="个人信息"
@tap="toUrl('pages/mine/info')"
:value="completeness"
:title-style="cellTitleStyle"
:value-style="{ color: '#2953FF', 'font-size': '26rpx' }"
>
<u-image
slot="icon"
width="36rpx"
height="40rpx"
:src="infoIcon"
></u-image>
</u-cell-item>
<u-cell-item
:border-bottom="false"
title="我的题库"
:title-style="cellTitleStyle"
@tap="toUrl('pages/mine/bank')"
>
<u-image
slot="icon"
width="36rpx"
height="40rpx"
:src="questionIcon"
></u-image>
</u-cell-item>
<u-cell-item
:border-bottom="false"
title="联系客服"
:title-style="cellTitleStyle"
@tap="toUrl('pages/mine/customer')"
>
<u-image
slot="icon"
width="36rpx"
height="40rpx"
:src="serviceIcon"
></u-image>
</u-cell-item>
<u-cell-item
:border-bottom="false"
title="设置"
:title-style="cellTitleStyle"
@tap="toUrl('pages/mine/setting')"
>
<u-image
slot="icon"
width="36rpx"
height="40rpx"
:src="settingIcon"
></u-image>
</u-cell-item>
</u-cell-group>
</view>
</view>
</view>
</template> </template>
<script> <script>
export default { export default {
data() { data() {
return { return {
pic:'https://uviewui.com/common/logo.png', pic: process.uniEnv.qn_base_url + '/xitongtouxiang.png',
show:true show: true,
} countItem: [
}, 'avatarPath',
onLoad() { 'certificatePhotoPath',
'identityNumber',
}, 'nickname',
methods: { 'phoneNumber',
'workUnit',
} ],
} student: {},
}
},
computed: {
infoIcon() {
return process.uniEnv.qn_base_url + '/gerenxinxi@3x.png'
},
questionIcon() {
return process.uniEnv.qn_base_url + '/wodetiku@3x.png'
},
serviceIcon() {
return process.uniEnv.qn_base_url + '/lianxikefu@3x.png'
},
settingIcon() {
return process.uniEnv.qn_base_url + '/shezhi@3x.png'
},
isLogin() {
console.log('is login', this.userInfo.nickName)
return this.userInfo.nickName != undefined
},
loginTips() {
return this.student.consumeAmount || 0
},
avatar() {
return (this.userInfo && this.userInfo.avatarUrl) || this.pic
},
nikeName() {
return (this.userInfo && this.userInfo.nickName) || '点击登录'
},
backgroundImage() {
return process.uniEnv.qn_base_url + 'wodetop@3x.png'
},
completeness() {
if (this.userInfo && this.userInfo.nickName) {
return '完善度' + this.asumeCount() + '%'
} else {
return ''
}
},
cellTitleStyle() {
return { 'font-size': '32rpx', coloe: '#191C27', 'margin-left': '26rpx' }
},
},
onLoad() {},
onShow() {
if (this.userInfo.nickName) {
this.$u.api.getUserInfo().then((res) => {
this.student = res
getApp().globalData.student = res
})
}
},
methods: {
asumeCount() {
//计算完善度
let length = this.countItem.length
let count = 0
for (let key in this.student) {
if (this.countItem.indexOf(key) != -1 && this.student[key]) {
count = count + 1
}
}
return parseInt((count / length) * 100)
},
login() {
if (this.userInfo.nickName) {
return
}
this.$u.route({
url: 'pages/login/index',
})
},
toUrl(url) {
this.$u.route({
url: url,
})
},
},
}
</script> </script>
<style lang="scss"> <style lang="scss">
page{ page {
background-color: #ededed; background-color: #ffffff;
}
.camera {
width: 54px;
height: 44px;
&:active {
background-color: #ededed;
}
}
.user-box {
background-color: #fff;
margin-top: 380rpx;
border-top-left-radius: 30rpx;
border-top-right-radius: 30rpx;
} }
.camera{ .top {
width: 54px; width: 750rpx;
height: 44px; position: absolute;
top: 0;
&:active{ .background-image {
background-color: #ededed; position: absolute;
} z-index: -1;
width: 750rpx;
height: 562rpx;
}
} }
.user-box{
background-color: #fff; .nick-name {
font-size: 48rpx;
font-weight: bold;
color: #191c27;
}
.login-tip {
font-size: 26rpx;
color: #5a6073;
}
.avatar {
position: relative;
image {
position: absolute;
top: -70rpx;
/* 登录加外边框,未登录不加边框 */
/* padding: 5rpx;
background-color: white; */
}
} }
</style> </style>
\ No newline at end of file
<template>
<view class="select-category">
<u-navbar
back-icon-color="#333333"
background="transparent"
title="选择题库"
titleColor="#191C27"
:border-bottom="false"
title-bold
></u-navbar>
<view>
<view class="category-view">
<image class="image-view" :src="shangyijiImage"></image>
<text class="category-text">{{ category.label }}</text>
</view>
</view>
<view class="label-title">
<view>题库列表</view>
</view>
<view class="add-exam-content">
<view class="label-content">
<view
v-for="(label, index) in category.list"
:key="index"
class="label-item"
>
<QuestionBankCell
:info="label"
type="add"
@action="handleClick(index)"
></QuestionBankCell>
</view>
</view>
<!-- 无数据 -->
<view class="tag-loading-view" v-if="category.list.length <= 0"
>暂无数据</view
>
</view>
</view>
</template>
<script>
import QuestionBankCell from '@/components/question-bank-cell'
const key2 = 'sub-category'
const key3 = 'sub-sub-category'
export default {
components: {
QuestionBankCell,
},
data() {
return {
selected: {},
}
},
computed: {
category() {
return this.selected[key2]
},
buttonStyle() {
return {
width: '120rpx',
height: '64rpx',
backgroundColor: '#2953FF',
color: '#FFFFFF',
fontSize: '26rpx',
borderRadius: '12rpx',
}
},
shangyijiImage() {
return process.uniEnv.qn_base_url + 'shangyiji-w.png'
},
},
onLoad(e) {
this.getPageInfo()
},
methods: {
// 点击了添加按钮
handleClick(index) {
this.selected[key3] = this.category.list[index]
this.setPageInfo(this.selected)
this.$u.route({
url: 'pages/learn/examSetting',
})
},
// 本页数据设置,用于其他页面访问本页数据
setPageInfo(info) {
var pages = getCurrentPages()
if (pages.length >= 1) {
var page = pages[pages.length - 1]
page.info = info
}
},
getPageInfo() {
var pages = getCurrentPages()
if (pages.length >= 2) {
var page = pages[pages.length - 2]
this.selected = page.info
page.info = null
}
},
},
}
</script>
<style lang="scss" scoped>
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.select-category {
height: 100vh;
display: flex;
flex-direction: column;
background-color: #f8fafd;
background-image: linear-gradient(to top, #f8fafd 0%, #e9f3ff 50%);
background-size: 100% 520rpx;
background-repeat: no-repeat;
padding: 0 24rpx 0rpx 24rpx;
.category-view {
width: 100%;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
border-radius: 12rpx;
background-color: #ffffff;
height: 112rpx;
position: relative;
color: #2953ff;
.category-text {
padding: 0 60rpx;
font-size: 28rpx;
font-weight: bold;
word-break: break-all;
z-index: 1;
}
.image-view {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
}
.label-title {
font-size: 32rpx;
font-weight: bold;
color: #9ea5bb;
margin-bottom: 30rpx;
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 40rpx;
}
.add-exam-content {
height: 100%;
overflow: auto;
.label-content {
margin-bottom: 44rpx;
.label-item {
margin-bottom: 24rpx;
}
}
}
.tag-loading-view {
display: flex;
align-items: center;
justify-content: center;
margin-top: 400rpx;
color: #999999;
text-align: center;
position: absolute;
width: 100%;
padding-right: 11rpx;
}
}
</style>
<template>
<view class="u-flex answer">
<u-navbar
back-icon-color="#333333"
background="transparent"
titleColor="#191C27"
:border-bottom="false"
title="答题"
title-bold
></u-navbar>
<view class="u-flex contents" v-if="total > 0">
<view class="head" v-if="!daily.status">
<view class="u-flex tab" v-if="type !== 2">
<view
:class="['tab-list', { active: model === 1 }]"
@click="changeModel(1)"
>答题模式</view
>
<view
:class="['tab-list', { active: model === 2 }]"
@click="changeModel(2)"
>学习模式</view
>
</view>
<view class="u-flex count-down" v-if="type === 2">
<view
>倒计时:<u-count-down
:timestamp="timestamp"
bg-color=""
:show-hours="false"
@end="timeEnd"
></u-count-down
></view>
</view>
</view>
<view class="swiper">
<swiper-limited-load
ref="swiper"
:swiperHeight="500"
:swiperDuration="swiperDuration"
:list="list"
:current="current"
:type="type"
:model="model"
:total="total"
@answerChange="answerChange"
@change="swiperChange"
>
</swiper-limited-load>
</view>
<view class="u-flex u-row-around bottom">
<view class="u-flex">
<view class="c-list">
<u-image
:src="allImg"
width="36"
height="36"
:lazy-load="false"
/>
<text>{{ currentNumber }}/{{ total }}</text>
</view>
</view>
<view class="u-flex">
<view
class="c-list"
v-if="type === 1 || type === 3"
@click="collection(collectionFlag)"
>
<u-icon v-show="!collectionFlag" name="star" color="#5A6073" size="40"></u-icon>
<u-icon v-show="collectionFlag" name="star-fill" color="#FF930D" size="40"></u-icon>
<text>{{ collectionFlag ? '已收藏' : '收藏' }}</text>
</view>
<view class="c-list" v-if="type === 2" @click="handPapers">
<u-icon name="file-text" color="#5A6073" size="40"></u-icon>
<text>交卷</text>
</view>
<view class="c-list" v-if="type === 4" @click="remove">
<u-image
:src="removeImg"
width="36"
height="40"
:lazy-load="false"
/>
<text>移出</text>
</view>
</view>
</view>
</view>
<view
class="u-flex default"
v-if="total === 0 && [3, 4].includes(type)"
>
<view>
<image :src="defaultImg" />
</view>
<view class="no-result">
{{ type === 4 ? '当前暂无错题记录' : '当前暂无收藏题目' }}
</view>
</view>
<!-- 提示 -->
<answer-operation-tips :show.sync="show" />
<!-- 考试成绩 -->
<answer-complete-pop
:numberList="complete.result"
:type="complete.type"
:visible.sync="complete.visible"
:timeout="complete.timeout"
@cancel="cancel"
@submit="submit"
>
</answer-complete-pop>
<!-- 每日一练 -->
<view class="daily">
<dailyPop
:count="daily.count"
:visible.sync="daily.visible"
:type="daily.type"
@cancel="dailyCancel"
@submit="dailySubmit"
>
</dailyPop>
</view>
</view>
</template>
<script>
import swiperLimitedLoad from '@/components/swiper-limited-load/index.vue'
import answerOperationTips from '@/components/answer-operation-tips/index.vue'
import answerCompletePop from '@/components/answer-complete-pop/index.vue'
import dailyPop from '@/components/daily-pop/index.vue'
import Utils from './utils.js'
const NO_PREV_PAGE = -1
const NO_NEXT_PAGE = -2
const app = getApp()
export default {
components: {
swiperLimitedLoad,
answerOperationTips,
answerCompletePop,
dailyPop,
},
data() {
return {
show: false,
// 1 练习 or 每日一练 2 考试 3 收藏记录 4 错题记录
type: 1,
// 1 答题模式 2 学习模式
model: 1,
// 每日一练
daily: {
status: false,
count: 0,
visible: false,
type: 'normal'
},
// 考试成绩弹框
complete: {
type: 'pass',
result: [],
visible: false,
timeout: false
},
timestamp: 60 * 60,
list: [],
// key为currentPage,value为此页list数据
cachePageDataMap: null,
// 改变此值可控制swiper的位置
current: 0,
// 仅仅记录swiper的位置
currentIndex: 0,
swiperDuration: '0',
// 分页数据
currentPage: 1,
pageSize: 100,
total: 0,
requesting: false,
// 1.顺序答题 2.随机练习 3.模拟考试 4.收藏答题 5.错题答题 6.专项练习-单选 7.专项练习-多选 8.专项练习-判断 9.专项练习-答案是
source: 1,
recordId: 0,
// 合格分数
passPoint: 60,
// 考试题数
totalPoint: 100,
}
},
computed: {
defaultImg() {
let name = ''
if (this.type === 4) {
name = 'no-error.png'
} else if (this.type === 5) {
name = 'no-collect.png'
}
return process.uniEnv.qn_base_url + name
},
allImg() {
return process.uniEnv.qn_base_url + 'all.png'
},
removeImg() {
return process.uniEnv.qn_base_url + 'remove-error.png'
},
currentNumber() {
let index = this.currentIndex
return index === -2 ? this.total : index + 1
},
collectionFlag() {
const info = this.list.find(v => v.index === this.currentIndex)
return info ? info.collectionFlag : false
}
},
onLoad(e) {
if (e?.experience) this.experience = Boolean(e.experience) // 体验资格
if (e?.daily) this.daily.status = true // 每日一练
if (e?.dailyCount) this.daily.count = parseInt(e.dailyCount) // 打卡天数
if (e?.source) this.source = parseInt(e.source) // 来源
if (e?.recordId) this.recordId = e.recordId // 考试ID
if (e?.passPoint) this.passPoint = parseInt(e.passPoint) // 合格分数
if (e?.totalPoint) this.totalPoint = parseInt(e.totalPoint) // 考试总分/总条数
if (e?.duration) this.timestamp = parseInt(e.duration) * 60 // 考试时间
switch (this.source) {
case 1:
case 2:
case 6:
case 7:
case 8:
case 9:
this.type = 1
break;
case 3:
this.type = 2
break;
case 4:
this.type = 3
break;
case 5:
this.type = 4
break;
default:
this.type = 1
break;
}
if(this.source === 1){ // 顺序答题,如果答满则清空数据
const check = this.questionList[this.questionWarehouseId] ? this.questionList[this.questionWarehouseId].every(v => v.submitStatus) : false
if (check) {
this.$u.vuex(`lastIndex.${this.questionWarehouseId}`, 0)
this.$u.vuex(`questionList.${this.questionWarehouseId}`, [])
}
}
this.init()
},
methods: {
// 初始化数据
init() {
const params = {
questionWarehouseId: this.questionWarehouseId,
recordId: this.recordId,
source: this.source
}
uni.showLoading({
title: '加载中'
})
this.$u.api.getQuestionTotal(params).then(res => {
uni.hideLoading()
// 列表总长度,一定要在第一次请求列表数据前明确该值
// 否则无法知道下一页是否还有数据
let total = parseInt(res) || 0
// 考试
if (this.type === 2) {
this.pageSize = this.totalPoint
total = this.totalPoint
}
this.total = total
// 练习模式-初始化答题卡列表
if (this.source === 1) Utils.initAnswerCardList(total, this)
this.cachePageDataMap = new Map()
// 上次答到了第几题
let index = this.source === 1 ? (this.lastIndex[this.questionWarehouseId] || 0) : 0
this.refresh(index)
})
},
// 切换
swiperChange(e) {
let current = e.current
this.currentIndex = current
if (current == NO_PREV_PAGE || current == NO_NEXT_PAGE) {
if (this.requesting) {
return this.$u.toast('数据加载中')
}
if (current == NO_PREV_PAGE) {
return this.$u.toast('已经是第一道试题')
}
if (current == NO_NEXT_PAGE) {
return this.$u.toast('已经是最后一道试题')
}
}
this.loadMore(current)
},
loadMore(current) {
let list = this.list
if (this.requesting || current == 0 || current == this.total - 1) return
// 加载上一页
if (current == list[0].index) {
this.judgeLoadWay(list[0].currentPage - 1, current)
}
// 加载下一页
if (current == list[list.length - 1].index) {
this.judgeLoadWay(list[list.length - 1].currentPage + 1, current)
}
},
judgeLoadWay(currentPage, currentIndex) {
let cachePageDataMap = this.cachePageDataMap
if (cachePageDataMap.has(currentPage)) {
this.loadCacheOnePageInfo(currentPage, currentIndex)
return
}
this.requestOnePageInfo(currentPage, currentIndex)
},
loadCacheOnePageInfo(currentPage, currentIndex) {
let list = this.cachePageDataMap.get(currentPage)
this.handleOnePageInfo(list, currentIndex)
},
requestOnePageInfo(currentPage, currentIndex) {
this.requesting = true
Utils.request({
currentPage: currentPage,
size: this.pageSize,
onSuccess: (info) => {
this.requesting = false
this.cachePageDataMap.set(info.currentPage, info.questionList)
this.handleOnePageInfo(info.questionList, currentIndex)
},
onFailed: (msg) => {
this.requesting = false
},
},this)
},
handleOnePageInfo(list, currentIndex) {
let currentList = this.list
if (list == null || list.length == 0) return
if (currentList == null || currentList.length == 0) {
this.list = list
this.$nextTick(() => {
this.$refs.swiper.init(currentIndex)
})
return
}
if (list[0].currentPage == currentList[0].currentPage) return
// 看是需要将新的list往前插还是往后插
let resultList =
list[0].currentPage < currentList[0].currentPage
? list.concat(currentList)
: currentList.concat(list)
this.list = resultList
this.$nextTick(() => {
this.$refs.swiper.init(currentIndex)
})
},
changeModel(i) {
this.model = i
if (this.model === 2) {
this.showTip()
}
},
timeEnd() {
this.complete.timeout = true
this.handPapers()
},
showTip() {
if (!this.tipStatus) {
this.$u.vuex('tipStatus', true)
this.show = true
}
},
// 作答完毕
answerChange(status, lists, userAnswer) {
// 保存答题状态
const item = this.list.find(v => v.index === this.currentIndex)
item.submitStatus = true
item.answerList = lists
item.result = status
item.errShow = this.type === 2 ? true : status === 'fail'
item.userAnswer = userAnswer
// 保存答案
if(this.model === 1) this.saveAnswer(item)
// 滑动提示
if (status === 'fail') {
this.showTip()
}
// 顺序练习,更新答题卡
if (this.source === 1){
this.questionList[this.questionWarehouseId][this.currentIndex] = item
this.$u.vuex(`questionList.${this.questionWarehouseId}`, this.questionList[this.questionWarehouseId])
this.$u.vuex(`lastIndex.${this.questionWarehouseId}`, this.currentIndex)
// 统计是否达满所有试题
const count = this.questionList[this.questionWarehouseId].reduce((accumulator, currentValue) => {
if (currentValue.submitStatus) accumulator++
return accumulator
}, 0)
if (count === this.total) {
return this.$u.toast('您已经答完全部试题')
}
}
// 如果回答错误或者是考试模式,自动进入下一题
if ((status === 'pass' && this.model !== 2) || this.type === 2) {
if (this.currentIndex + 1 > this.total - 1) { // 最后一题回答后
if (this.type === 2) { // 统计分数,交卷
this.handPapers(1)
this.submit()
}
return
}
this.$nextTick(() => {
this.current = this.currentIndex + 1
})
}
},
// 保存答案
saveAnswer(info) {
const params = {
answer: info.userAnswer,
answerRight: info.result === 'pass',
questionId: info.id,
questionWarehouseId: this.questionWarehouseId,
recordId: this.recordId,
source: this.source
}
this.$u.api.answer([params]).then(res => {
if (this.source === 2) { // 每日一练
if (this.daily.status && res === 10) this.dailyComplete()
}
})
},
// 每日一练达成
dailyComplete() {
this.daily.count = this.daily.count + 1
this.daily.type = this.experience ? 'experience' : 'normal'
this.daily.status = false
this.daily.visible = true
},
// 统计分数
handPapers(type) {
const fail = this.list.filter((v) => v.result === 'fail').length // 错题数
const noStart = this.list.filter((v) => !v.result).length // 未做题数
const fraction = this.total - noStart - fail// 分数
this.complete.result = [fail, noStart, fraction]
this.complete.type = fraction < this.passPoint ? 'fail' : 'pass'
if (type !== 1) this.complete.visible = true
},
// 考试成绩弹框确认
submit() {
const data = {
id: this.recordId,
point: this.complete.result[2]
}
uni.showLoading({
title: '正在计算考试成绩'
})
this.$u.api.submitExamRecord(data).then(res => {
uni.hideLoading()
if (res) { // 交卷
this.$u.route({
type: 'redirect',
url: '/pages/learn/score',
params: {
id: this.recordId
}
})
}
})
},
// 考试成绩弹框取消
cancel() {
this.complete.visible = false
},
// 每日一练弹框确认
dailySubmit() {
if (this.experience) {
this.$u.route({
type: 'redirect',
url: '/pages/learn/detail',
})
} else {
this.daily.visible = false
}
},
// 每日一练弹框取消
dailyCancel() {
this.$u.route({
type: 'redirect',
url: '/pages/learn/record',
})
},
// 收藏
collection(status) {
const info = this.list.find(v => v.index === this.currentIndex)
const action = status ? 'removeCollection' : 'joinCollection'
this.$u.api[action]({questionId: info.id}).then(res => {
if(res) {
info.collectionFlag = !status
if (this.source === 1) { //更新缓存数据
this.questionList[this.questionWarehouseId][this.currentIndex] = info
this.$u.vuex(`questionList.${this.questionWarehouseId}`, this.questionList[this.questionWarehouseId])
}
}
})
},
// 移除
remove() {
const info = this.list.find(v => v.index === this.currentIndex)
this.$u.api.removeError({questionId: info.id}).then(res => {
if(res) this.current = this.currentIndex + 1
})
},
// 以下方法用于初始化数据
refresh(currentIndex) {
// 根据index和size计算得出数据在第几页
let currentPage = Utils.getInitcurrentPage(currentIndex, this.pageSize)
this.currentIndex = currentIndex
this.currentPage = currentPage
let { pageSize, total } = this
// 不确定我们需要请求几个列表,可能是1个,也可能是2个
// 比如一页10条,我们上次答题答到了第10题,正好在这个临界点上,我们还需要第11道题的数据
// 那么我们需要一起请求第一页和第二页的数据
let pageList = Utils.getInitPageList(
currentIndex,
pageSize,
currentPage,
total
)
this.judgeInitWay(pageList, currentIndex)
},
judgeInitWay(pageList, currentIndex) {
let cachePageDataMap = this.cachePageDataMap
let isNeedRequest = false
pageList.forEach((item) => {
if (!cachePageDataMap.has(item)) {
isNeedRequest = true
}
})
if (!isNeedRequest) {
this.loadCacheInitPageInfo(pageList, currentIndex)
return
}
this.requestInitPageInfo(pageList, currentIndex)
},
loadCacheInitPageInfo(pageList, currentIndex) {
let results = []
pageList.forEach((item) => {
let info = {}
info.currentPage = item
info.questionList = this.cachePageDataMap.get(item)
results.push(info)
})
this.handleInitInfo(results, currentIndex)
},
requestInitPageInfo(pageList, currentIndex) {
this.requesting = true
Utils.requestMulti({
pageList: pageList,
size: this.pageSize,
onSuccess: (results) => {
this.requesting = false
this.handleInitInfo(results, currentIndex)
},
onFailed: (msg) => {
this.requesting = false
},
},this)
},
handleInitInfo(results, currentIndex) {
let list = []
results.forEach((resultItem, index) => {
this.cachePageDataMap.set(
resultItem.currentPage,
resultItem.questionList
)
list = list.concat(resultItem.questionList)
})
this.list = list
if (this.list.length === 0) {
this.$u.toast('暂无数据')
setTimeout(() => {
this.$u.route({
delta: 1,
type: 'back'
})
}, 1500)
} else {
this.$nextTick(() => {
this.$refs.swiper.init(currentIndex)
})
}
}
},
}
</script>
<style lang="scss">
.daily{
.u-mode-center-box {
background-color: transparent !important;
padding-top: 40rpx;
}
}
</style>
<style lang="scss" scoped>
.answer {
height: 100vh;
flex-direction: column;
background-color: #f8fafd;
background-image: linear-gradient(to top, #f8fafd 0%, #e9f3ff 50%);
background-size: 100% 520rpx;
background-repeat: no-repeat;
.contents {
width: 100%;
flex: 1;
flex-direction: column;
.head {
width: 100%;
.tab {
margin: 10rpx auto;
border: 2rpx solid #2953ff;
border-radius: 10rpx;
width: 300rpx;
.tab-list {
flex: 1;
padding: 10rpx 25rpx;
font-size: 24rpx;
color: #191c27;
}
.active {
background: #2953ff;
color: #fff;
}
}
.count-down {
color: #5a6073;
font-size: 32rpx;
margin: 10rpx auto;
width: 230rpx;
}
}
.swiper {
width: 100%;
flex: 1;
}
.bottom {
width: 100%;
height: 150rpx;
border-top: 2rpx solid #ccc;
color: #5a6073;
font-size: 28rpx;
.c-list {
display: flex;
text {
padding-left: 10rpx;
}
}
}
}
.default {
flex-flow: column;
flex: 1;
justify-content: center;
.no-result {
color: #9ea5bb;
font-size: 28rpx;
}
}
}
</style>
<template>
<view class="u-flex answer">
<u-navbar
back-icon-color="#333333"
background="transparent"
titleColor="#191C27"
:border-bottom="false"
title="答题"
title-bold
></u-navbar>
<view class="head" v-if="type !== 3">
<view class="u-flex tab" v-if="type === 1">
<view
:class="['tab-list', { active: model === 1 }]"
@click="changeModel(1)"
>答题模式</view
>
<view
:class="['tab-list', { active: model === 2 }]"
@click="changeModel(2)"
>学习模式</view
>
</view>
<view class="u-flex count-down" v-if="type === 2">
<view
>倒计时:<u-count-down
:timestamp="timestamp"
bg-color=""
:show-hours="false"
></u-count-down
></view>
</view>
</view>
<view class="swiper">
<page-swiper
ref="pageSwiper"
:dataLength="dataLength"
:initIndex="index"
@swiperChange="swiperChange"
@endChange="endChange"
style="flex: 1;"
>
<view class="u-flex subject">
<view class="title"
><text>{{ titleType[list[index].type - 1] }}</text
>{{ list[index].title }}</view
>
<view class="content">
<answer-sheet
ref="answerSheet"
:answerList="list[index].answerList"
:rightKey="list[index].rightKey"
:multiple="list[index].type === 3"
:submitStatus="list[index].submitStatus"
@change="answerChange"
></answer-sheet>
</view>
<view class="explain">
<answer-explanation
v-show="model === 2 || list[index].errShow"
:answer="list[index].answer"
:explain="list[index].explain"
></answer-explanation>
</view>
</view>
</page-swiper>
</view>
<view class="u-flex u-row-around bottom">
<view class="u-flex">
<view class="c-list">
<u-icon name="grid" color="#5A6073" size="40"></u-icon>
<text>1/2887</text>
</view>
</view>
<view class="u-flex">
<view
class="c-list"
v-if="type === 1 || type === 3"
@click="collection"
>
<u-icon name="star" color="#5A6073" size="40"></u-icon>
<text>收藏</text>
</view>
<view class="c-list" v-if="type === 2" @click="handPapers">
<u-icon name="file-text" color="#5A6073" size="40"></u-icon>
<text>交卷</text>
</view>
</view>
</view>
<answer-operation-tips :show.sync="show" />
<answer-complete-pop
:numberList="[1, 2, 3]"
type="fail"
:visible.sync="visible"
@cancel="visible = false"
@submit="submit"
>
</answer-complete-pop>
</view>
</template>
<script>
import swiperLimitedLoad from '@/components/swiper-limited-load/index.vue'
import answerOperationTips from '@/components/answer-operation-tips/index.vue'
import answerCompletePop from '@/components/answer-complete-pop/index.vue'
import pageSwiper from '@/components/page-swiper/index.vue'
import answerSheet from '@/components/answer-sheet/index.vue'
import answerExplanation from '@/components/answer-explanation/index.vue'
const app = getApp()
export default {
components: {
swiperLimitedLoad,
answerOperationTips,
answerCompletePop,
pageSwiper,
answerSheet,
answerExplanation,
},
data() {
return {
visible: false,
show: false,
// 1 练习 2 考试 3 每日一练 4 错题记录 5 收藏记录
type: 1,
// 1 答题模式 2 学习模式
model: 1,
timestamp: 60 * 60,
list: [],
index: 0,
dataLength: 0,
titleType: ['单选题', '判断题', '多选题'],
}
},
computed: {},
created() {
const lists = [
{
type: 1,
title: '采用QS1电桥测量tanδ的接线方式一般有差接线及和接线。',
answerList: [
{
sort: 'A',
text: '正确',
},
{
sort: 'B',
text: '错误',
},
],
answer: 'A',
explain:
'极性电介质在外电场作用下,由偶极子分子的转向形成的极化称为偶极子式极化。',
index: 0,
rightKey: ['A'],
},
{
type: 2,
title:
'空气间隙的操作冲击击穿电压数值大小不仅与间隙距离、电极形状、电极极性有关,而且与操作冲击电压波的波前时间的长短有关。',
answerList: [
{
sort: 'A',
text: '正确',
},
{
sort: 'B',
text: '错误',
},
],
answer: 'B',
explain:
'极性电介质在外电场作用下,由偶极子分子的转向形成的极化称为偶极子式极化。',
index: 1,
rightKey: ['B'],
},
{
type: 3,
title: '西林电桥采用正接线及反接线时,其测试原理相同',
answerList: [
{
sort: 'A',
text: '影响',
},
{
sort: 'B',
text: '影响很小',
},
{
sort: 'C',
text: '影响很大',
},
{
sort: 'D',
text: '无影响',
},
],
answer: 'B,C',
explain:
'双臂电桥是在单臂电桥的基础上增加特殊机构,以消除测试时连接线和接线柱接触电阻对测量结果的影响。',
index: 2,
rightKey: ['B', 'C'],
},
{
type: 2,
title: '测试标题测试标题测试标题测试标题',
answerList: [
{
sort: 'A',
text: '是',
},
{
sort: 'B',
text: '否',
},
],
answer: 'B',
explain: '测试内容测试内容测试内容测试内容测试内容测试内容',
index: 3,
rightKey: ['B'],
},
]
this.requestQuestionInfo(lists)
},
methods: {
swiperChange(e) {
this.index = e
// 初始化checked confirm
this.list[e].answerList = this.list[e].answerList.map((v) => {
if (!v.checked) v.checked = false
if (!v.confirm) v.confirm = false
return v
})
},
endChange(type) {
if (type === 'left') {
return uni.showToast({
title: '已经是第一题了',
icon: 'none',
})
} else if (type === 'right') {
return uni.showToast({
title: '已经是最后一题了',
icon: 'none',
})
}
},
requestQuestionInfo(lists) {
this.list = lists
this.dataLength = lists.length
app.globalData.questionList = lists
},
changeModel(i) {
this.model = i
},
collection() {
console.log('收藏')
},
// 作答完毕
answerChange(status, lists) {
// 保存答题状态
this.$set(this.list[this.index], 'submitStatus', true)
this.$set(this.list[this.index], 'answerList', lists)
this.$set(
this.list[this.index],
'errShow',
this.type === 2 ? true : status === 'fail'
)
app.globalData.questionList = this.list
// 如果回答错误或者是考试模式,自动进入下一题
if (status === 'pass' || this.type === 2) {
if (this.index + 1 === this.list.length) return
this.index++
this.$refs.pageSwiper.swiperTo(this.index)
}
},
// 交卷
handPapers() {
this.visible = true
console.log('交卷')
},
// 提前交卷
submit() {
console.log('提前交卷')
},
},
}
</script>
<style lang="scss" scoped>
.answer {
height: 100vh;
flex-direction: column;
background-color: #f8fafd;
background-image: linear-gradient(to top, #f8fafd 0%, #e9f3ff 50%);
background-size: 100% 520rpx;
background-repeat: no-repeat;
.head {
width: 100%;
height: 90rpx;
.tab {
margin: 10rpx auto;
border: 2rpx solid #2953ff;
border-radius: 10rpx;
width: 300rpx;
.tab-list {
flex: 1;
padding: 10rpx 25rpx;
font-size: 24rpx;
color: #191c27;
}
.active {
background: #2953ff;
color: #fff;
}
}
.count-down {
color: #5a6073;
font-size: 32rpx;
margin: 10rpx auto;
width: 230rpx;
}
}
.swiper {
width: 100%;
flex: 1;
display: flex;
flex-direction: column;
.subject {
flex-flow: column;
padding: 20rpx;
.type {
width: 100%;
text-align: left;
padding: 20rpx 0;
}
.title {
color: #191c27;
font-size: 32rpx;
line-height: 50rpx;
font-weight: bold;
width: 100%;
text-align: left;
text {
background: #9ea5bb;
color: #fff;
padding: 8rpx 20rpx;
margin-right: 10rpx;
font-size: 20rpx;
border-radius: 50rpx;
}
}
.content,
.explain,
.btn {
width: 100%;
padding-top: 50rpx;
}
}
}
.bottom {
width: 100%;
height: 150rpx;
border-top: 2rpx solid #ccc;
color: #5a6073;
font-size: 28rpx;
.c-list {
display: flex;
text {
padding-left: 10rpx;
}
}
}
}
</style>
<template>
<view class="begin-answer">
<u-navbar
back-icon-color="#FFFFFF"
background="transparent"
title="模拟考试"
titleColor="#FFFFFF"
:border-bottom="false"
title-bold
></u-navbar>
<view class="content">
<view class="body-view">
<view class="head-view">
<view class="image-view">
<image class="image" :src="avatar"> </image
></view>
<view>{{ nikeName }}</view>
</view>
<view class="line-view"></view>
<view class="list-view">
<view v-for="(value, key) in labels" :key="key" class="item-view">
<view class="left-view">{{ value }}</view>
<view>{{ info[key] }}</view>
</view>
</view>
<view class="line-view"></view>
<view class="tip-view"
>温馨提示:模拟考试中不能修改答案,每做错1道题扣1分,合格标准为{{ info.passPoint }}分。</view
>
<view class="bottom-view">
<u-button
:customStyle="buttonStyle"
@click="handleClick"
type="primary"
shape="circle"
>
开始模拟考试
</u-button>
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
info: {},
pic: process.uniEnv.qn_base_url + 'morentouxiang-w.png',
}
},
computed: {
avatar() {
return (this.userInfo && this.userInfo.avatarUrl) || this.pic
},
nikeName() {
return (this.userInfo && this.userInfo.nickName) || ''
},
labels() {
return {
kemu: '考试科目',
tishu: '考试题数',
biaozhun: '合格标准',
duration: '考试时间',
guize: '出题规则',
}
},
buttonStyle() {
return {
height: '104rpx',
width: '600rpx',
backgroundColor: '#2953FF',
color: '#FFFFFF',
fontSize: '32rpx',
fontWeight: 'bold',
}
},
},
onLoad() {
this.init()
},
methods: {
init() {
uni.showLoading({
title: '加载中'
})
this.$u.api.getExamPaper({questionWarehouseId: this.questionWarehouseId}).then(res => {
uni.hideLoading()
this.info = {
id: res.id,
kemu: res.echoMap?.questionWarehouseId?.title,
tishu: `${res.totalPoint}题`,
biaozhun: `${res.passPoint}分`,
passPoint: res.passPoint,
duration: `${res.duration}分钟`,
guize: '根据国家规定比例随机抽取'
}
})
},
handleClick() {
const params = {
questionWarehouseId: this.questionWarehouseId,
paperId: this.info.id
}
uni.showLoading({
title: '载入试题中'
})
this.$u.api.applyExam(params).then(res => {
uni.hideLoading()
if (res) {
this.$u.route({
url: '/pages/learn/answer',
params: {
recordId: res.id,
source: 3,
passPoint: this.info.passPoint,
totalPoint: this.info.totalPoint,
duration: this.info.duration
}
})
}
})
},
},
}
</script>
<style lang="scss" scoped>
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.begin-answer {
display: flex;
flex-direction: column;
background-image: linear-gradient(to top, #f7f9fc 0%, #2953ff 50%);
background-color: #f7f9fc;
background-size: 100% 920rpx;
background-repeat: no-repeat;
height: 100vh;
.content {
height: 100%;
overflow: auto;
padding-top: 100rpx;
.body-view {
margin: 0rpx 24rpx 44rpx 24rpx;
background-color: #ffffff;
border-radius: 12rpx;
padding: 0 30rpx 60rpx 30rpx;
.head-view {
width: 100%;
display: flex;
align-items: center;
font-size: 32rpx;
font-weight: bold;
color: #191c27;
flex-direction: column;
margin-bottom: 40rpx;
.image-view {
margin-bottom: 20rpx;
display: flex;
justify-content: center;
align-items: center;
padding: 4rpx;
width: 140rpx;
height: 140rpx;
background-color: #ffffff;
border-radius: 140rpx;
margin-top: -70rpx;
.image {
width: 136rpx;
height: 136rpx;
border-radius: 136rpx;
}
}
}
.line-view {
background-color: #e8ebf3;
height: 2rpx;
}
.list-view {
padding: 20rpx 0;
.item-view {
margin: 30rpx 0;
display: flex;
justify-content: space-between;
align-items: flex-start;
color: #5a6073;
font-size: 28rpx;
text-align: right;
word-break: break-all;
.left-view {
text-align: left;
color: #9ea5bb;
margin-right: 30rpx;
flex-shrink: 0;
}
}
}
.tip-view {
font-size: 26rpx;
color: #9ea5bb;
margin: 50rpx 0 210rpx 0;
}
.bottom-btn {
}
}
}
}
</style>
<template>
<view class="bound-questions">
<u-navbar
back-icon-color="#191C27"
background="transparent"
title="绑定题库"
titleColor="#191C27"
:border-bottom="false"
title-bold
></u-navbar>
<view class="body-view">
<view class="image-view"
><image class="image" :src="successImage"></image
></view>
<view class="content-view">
<view class="first-line">
<view class="serial-view">1</view>
<view>
持有学习卡的学员,扫描<text class="blue-text">卡背面的条码</text
>完成绑定</view
></view
>
<view class="second-line">
<view class="left-view">
<view class="serial-view">2</view>
<view>没有学习卡的学员,可在线购买题库</view>
</view>
<u-button :custom-style="buttonStyle" @click="handleClickBuy"
>购买</u-button
>
</view>
</view>
<view class="bottom-view">
<u-button
:customStyle="customStyle"
@click="handleClick"
type="primary"
shape="circle"
>
扫码自动绑定
</u-button>
<view class="change-button" @click="$u.throttle(handleChange, 500)"
>手动输入卡号、密码绑定</view
>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// relationId: 0, // 绑卡用
realPrice: null,
}
},
computed: {
customStyle() {
return {
height: '104rpx',
backgroundColor: '#2953FF',
color: '#FFFFFF',
fontSize: '32rpx',
fontWeight: 'bold',
}
},
buttonStyle() {
return {
width: '120rpx',
height: '56rpx',
background: '#FFFFFF',
color: '#2953FF',
fontSize: '26rpx',
borderRadius: '12rpx',
}
},
},
onLoad(e) {
// if (e && e.relationId) {
// this.relationId = e.relationId
// }
if (e && e.realPrice) {
this.realPrice = e.realPrice
}
},
methods: {
handleClick() {
wx.scanCode({
onlyFromCamera: true,
success: (res) => {
console.log(res)
if (res.result) {
this.$u.route({
url: 'pages/learn/boundTest',
params: {
code: res.result,
// relationId: this.relationId,
},
})
}
},
})
},
handleClickBuy() {
if (this.realPrice == null) return
const lists = [
{
questionWarehouseId: this.questionWarehouseId,
amount: this.realPrice,
count: 1,
},
]
const data = {
instrtutionId: getApp().globalData.orgId,
orders: JSON.stringify(lists),
openId: this.openId,
}
uni.showLoading({
title: '加载中',
})
this.$u.api.payOrder(data).then((res) => {
uni.hideLoading()
this.pay(res)
})
},
handleChange() {
this.$u.route({
url: 'pages/learn/manualBinding',
// params: {
// relationId: this.relationId,
// },
})
},
pay(data) {
uni.requestPayment({
provider: 'wxpay',
timeStamp: data.timeStamp,
nonceStr: data.nonce_str,
package: `prepay_id=${data.prepay_id}`,
signType: 'MD5',
paySign: data.sign,
success: (res) => {
console.log('success:' + JSON.stringify(res))
this.checkPayStatus(data.out_trade_no)
},
fail: (err) => {
console.log('fail:' + JSON.stringify(err))
if (err.errMsg === 'requestPayment:fail cancel') {
this.$u.toast('取消支付')
} else {
this.checkPayStatus(data.out_trade_no)
}
},
})
},
checkPayStatus(no) {
const params = {
outTradeNo: no,
}
uni.showLoading({
title: '支付中',
})
this.$u.api.payQuery(params).then((res) => {
uni.hideLoading()
if (res.trade_state === 'SUCCESS') {
this.$u.toast('支付成功')
uni.switchTab({
url: '/pages/index/index',
})
} else if (res.trade_state === 'NOTPAY') {
this.$u.toast('请稍后核实订单状态,不要重复发起支付')
} else if (res.trade_state === 'PAYERROR') {
this.$u.toast('支付失败')
} else {
this.$u.toast(res.trade_state_desc)
}
})
},
},
}
</script>
<style lang="scss" scoped>
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.bound-questions {
display: flex;
flex-direction: column;
background-image: linear-gradient(to top, #f7f9fc 0%, #e9f3ff 50%);
background-color: #f7f9fc;
background-size: 100% 520rpx;
background-repeat: no-repeat;
height: 100vh;
.body-view {
height: 100%;
overflow: auto;
padding: 10rpx 24rpx 44rpx 24rpx;
.image-view {
text-align: center;
.image {
width: 700rpx;
height: 360rpx;
background-color: red;
border-radius: 24rpx;
box-shadow: 0px 10px 16px rgba(29, 53, 155, 0.2);
}
}
.content-view {
margin-top: 60rpx;
.first-line {
display: flex;
align-items: center;
margin-bottom: 50rpx;
.blue-text {
color: #2953ff;
}
}
.second-line {
display: flex;
justify-content: space-between;
align-items: center;
.left-view {
display: flex;
align-items: center;
color: #5a6073;
font-size: 28rpx;
}
}
.serial-view {
background-color: #2953ff;
height: 40rpx;
width: 40rpx;
border-radius: 8rpx;
font-size: 28rpx;
line-height: 40rpx;
text-align: center;
color: #ffffff;
margin-right: 14rpx;
}
}
.bottom-view {
margin-top: 96rpx;
text-align: center;
.change-button {
color: #2953ff;
font-size: 26rpx;
height: 40rpx;
line-height: 40rpx;
margin-top: 30rpx;
}
}
}
}
</style>
<template>
<view class="bound-test">
<u-navbar
back-icon-color="#191C27"
background="transparent"
title="绑定试题"
titleColor="#191C27"
:border-bottom="false"
title-bold
></u-navbar>
<view class="body-view">
<!-- <image class="image-view" :src="successImage"></image> -->
<view class="content-view">是否绑定该学习卡</view>
<view class="tip-view">学习卡完成绑定后,不支持解绑操作</view>
<view class="bottom-view">
<u-button
:customStyle="buttonStyle"
@click="handleClick"
type="primary"
shape="circle"
:loading="loading"
>
绑定
</u-button>
</view>
</view>
<view>
<u-toast ref="uToast" />
</view>
</view>
</template>
<script>
export default {
data() {
return {
loading: false,
param: { cardNumber: '', cardSecret: '' },
}
},
computed: {
labels() {
return {
kemu: '考试科目',
tishu: '考试题数',
biaozhun: '合格标准',
guize: '出题规则',
}
},
// successImage() {
// return process.uniEnv.qn_base_url + 'shenqingtijiaochenggong.png'
// },
buttonStyle() {
return {
height: '104rpx',
width: '400rpx',
backgroundColor: '#2953FF',
color: '#FFFFFF',
fontSize: '32rpx',
fontWeight: 'bold',
}
},
},
onLoad(e) {
if (e && e.code) {
var code = e.code
this.param.cardNumber = code.slice(0, 15)
this.param.cardSecret = code.slice(15)
}
this.param.questionWarehouseId = this.relationId
},
methods: {
handleClick() {
this.loading = true
this.$u.api
.bindCard(this.param)
.then((res) => {
this.$refs.uToast.show({
title: '绑定成功',
type: 'success',
duration: 1500,
callback: () => {
this.setPageInfo()
uni.switchTab({
url: '/pages/index/index',
})
},
})
})
.catch((err) => {
this.loading = false
})
},
setPageInfo() {
var pages = getCurrentPages()
if (pages.length >= 2) {
var page = pages[pages.length - 2]
page.refresh = true
}
},
},
}
</script>
<style lang="scss" scoped>
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.bound-test {
display: flex;
flex-direction: column;
background-image: linear-gradient(to top, #f7f9fc 0%, #e9f3ff 50%);
background-color: #f7f9fc;
background-size: 100% 520rpx;
background-repeat: no-repeat;
height: 100vh;
.body-view {
height: 100%;
overflow: auto;
padding-top: 200rpx;
text-align: center;
// .image-view {
// margin-top: 100rpx;
// width: 224rpx;
// height: 224rpx;
// }
.content-view {
font-size: 40rpx;
color: #2953ff;
font-weight: bold;
}
.tip-view {
font-size: 26rpx;
color: #9ea5bb;
margin-top: 14rpx;
}
.bottom-view {
margin-top: 180rpx;
}
}
}
</style>
<template>
<view class="bound-test">
<u-navbar
back-icon-color="#FFFFFF"
background="transparent"
title=" "
titleColor="#FFFFFF"
:border-bottom="false"
title-bold
></u-navbar>
<image class="background-image" :src="zhutuImage"></image>
<view class="head-view">
<view class="head-tip">8年题库沉淀,省时省力考高分</view>
<view class="content-text">{{ info.questionWarehouse.title }}</view>
</view>
<view class="body-view">
<view class="title-view">{{ info.questionWarehouse.title }}</view>
<view class="message-view">8年题库沉淀,省时省力考高分</view>
<view class="tip-view"
>• 有效期90天,自购买或者绑卡后答题激活为起始日期</view
>
<view class="price-view">
<view class="left-view">
<view class="discount-view">
¥<text class="count-text">{{
info.questionWarehouse.realPrice
}}</text
>元/套
</view>
<view class="money-view"
><text class="money-text">
¥{{ info.questionWarehouse.price }}元/套</text
><view class="line-view"></view>
</view>
</view>
<u-button :customStyle="buyButtonStyle" @click="handleClickBuy">
立即购买
</u-button>
</view>
<view class="detail-view">
<image class="title-image" :src="tikuxinxiImage"></image>
<view class="question-bank-view">
<view class="outline-view "
>本题库共
<text class="count">{{ info.totalCount }}</text>
道教研组精编考题,专业老师会根据各地政策不断更新优化题库</view
>
<view class="items-view">
<view
v-for="(item, index) in subItems"
:key="index"
class="sub-content-item"
>
<view class="sub-image">
<image class="image" :src="item.icon"></image>
</view>
<view>{{ item.title }}</view>
<view class="value-view">{{ info[item.key] }}道</view>
</view>
</view>
</view>
<image class="title-image" :src="shiherenqunImage"></image>
<view class="crowd-view">
<view class="outline-view ">课程适合以下3类人群</view>
<image
v-for="(item, index) in images"
:src="item"
:key="index"
class="crowd-image"
></image>
</view>
</view>
</view>
<view class="bottom-view">
<u-button
:customStyle="buttonStyle"
@click="handleClick"
type="primary"
shape="circle"
>
绑定学习卡
</u-button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
// relationId: 0, // 绑卡用
info: {
questionWarehouse: {},
},
}
},
computed: {
detail01Image() {
return process.uniEnv.qn_base_url + 'detail01.png'
},
detail02Image() {
return process.uniEnv.qn_base_url + 'detail02.png'
},
detail03Image() {
return process.uniEnv.qn_base_url + 'detail03.png'
},
shiherenqunImage() {
return process.uniEnv.qn_base_url + 'shiherenqun.png'
},
tikuxinxiImage() {
return process.uniEnv.qn_base_url + 'tikuxinxi.png'
},
danxuanImage() {
return process.uniEnv.qn_base_url + 'danxuan.png'
},
duoxuanImage() {
return process.uniEnv.qn_base_url + 'duoxuan.png'
},
panduanmage() {
return process.uniEnv.qn_base_url + 'panduan.png'
},
zhutuImage() {
return process.uniEnv.qn_base_url + 'zhutu.png'
},
images() {
return [this.detail01Image, this.detail02Image, this.detail03Image]
},
buttonStyle() {
return {
height: '104rpx',
backgroundColor: '#2953FF',
color: '#FFFFFF',
fontSize: '32rpx',
fontWeight: 'bold',
}
},
buyButtonStyle() {
return {
marginRight: '12rpx',
width: '144rpx',
height: '56rpx',
background: '#FFFFFF',
color: '#2953FF',
fontSize: '26rpx',
}
},
subItems() {
return [
{
title: '单选题',
icon: this.danxuanImage,
key: 'oneAnswerCount',
},
{
title: '判断题',
icon: this.panduanmage,
key: 'trueAnswerCount',
},
{
title: '多选题',
icon: this.duoxuanImage,
key: 'anyAnswerCount',
},
]
},
},
onLoad(e) {
// if (e && e.relationId) {
// this.relationId = e.relationId
// }
if ((e && e.id) || this.questionWarehouseId) {
this.queryQuestionWarehouseById((e && e.id) || this.questionWarehouseId)
}
},
methods: {
queryQuestionWarehouseById(id) {
this.$u.api
.queryQuestionWarehouseById(id)
.then((res) => {
this.info = res || { questionWarehouse: {} }
})
.catch((err) => {
this.loading = false
console.log(err)
})
},
handleClick() {
this.$u.route({
url: 'pages/learn/boundQuestions',
params: {
// relationId: this.relationId,
realPrice: this.info.questionWarehouse.realPrice,
},
})
},
handleClickBuy() {
const lists = [
{
questionWarehouseId: this.questionWarehouseId,
amount: this.info.questionWarehouse.realPrice,
count: 1,
},
]
const data = {
instrtutionId: getApp().globalData.orgId,
orders: JSON.stringify(lists),
openId: this.openId,
}
uni.showLoading({
title: '加载中',
})
this.$u.api.payOrder(data).then((res) => {
uni.hideLoading()
this.pay(res)
})
},
pay(data) {
uni.requestPayment({
provider: 'wxpay',
timeStamp: data.timeStamp,
nonceStr: data.nonce_str,
package: `prepay_id=${data.prepay_id}`,
signType: 'MD5',
paySign: data.sign,
success: (res) => {
console.log('success:' + JSON.stringify(res))
this.checkPayStatus(data.out_trade_no)
},
fail: (err) => {
console.log('fail:' + JSON.stringify(err))
if (err.errMsg === 'requestPayment:fail cancel') {
this.$u.toast('取消支付')
} else {
this.checkPayStatus(data.out_trade_no)
}
},
})
},
checkPayStatus(no) {
const params = {
outTradeNo: no,
}
uni.showLoading({
title: '支付中',
})
this.$u.api.payQuery(params).then((res) => {
uni.hideLoading()
if (res.trade_state === 'SUCCESS') {
this.$u.toast('支付成功')
uni.switchTab({
url: '/pages/index/index',
})
} else if (res.trade_state === 'NOTPAY') {
this.$u.toast('请稍后核实订单状态,不要重复发起支付')
} else if (res.trade_state === 'PAYERROR') {
this.$u.toast('支付失败')
} else {
this.$u.toast(res.trade_state_desc)
}
})
},
},
}
</script>
<style lang="scss" scoped>
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.bound-test {
display: flex;
flex-direction: column;
height: 100vh;
position: relative;
.background-image {
position: absolute;
width: 100%;
height: 520rpx;
z-index: -1;
}
.head-view {
padding: 20rpx 180rpx 60rpx 30rpx;
.head-tip {
color: #ffffff;
font-size: 26rpx;
margin-bottom: 10rpx;
}
.content-text {
font-size: 48rpx;
font-weight: bold;
color: #ffffff;
}
}
.body-view {
border-radius: 24rpx 24rpx 0 0;
background-color: #ffffff;
height: 100%;
overflow: auto;
.title-view {
color: #191c27;
font-size: 36rpx;
font-weight: bold;
padding: 30rpx 30rpx 0 30rpx;
}
.message-view {
color: #9ea5bb;
font-size: 26rpx;
margin: 16rpx 30rpx 30rpx 30rpx;
}
.tip-view {
background-color: rgba(41, 83, 255, 0.1);
color: #2953ff;
font-size: 26rpx;
border-radius: 4rpx;
height: 56rpx;
line-height: 56rpx;
padding: 0 30rpx;
margin: 0 24rpx;
}
.price-view {
display: flex;
justify-content: space-between;
align-items: center;
margin: 40rpx 30rpx 50rpx 30rpx;
.left-view {
display: flex;
align-items: flex-end;
.discount-view {
font-size: 24rpx;
color: #fa5a49;
font-weight: bold;
.count-text {
font-size: 60rpx;
}
}
.money-view {
position: relative;
margin-left: 30rpx;
margin-bottom: 8rpx;
.money-text {
font-size: 24rpx;
color: #5a6073;
font-weight: bold;
}
.line-view {
position: absolute;
height: 2rpx;
background-color: #5a6073;
top: 22rpx;
width: 100%;
}
}
}
}
.detail-view {
background-color: #f7f9fc;
border-radius: 24rpx 24rpx 0 0;
text-align: center;
padding: 56rpx 30rpx;
.title-image {
width: 416rpx;
height: 72rpx;
}
.question-bank-view {
margin: 56rpx 0 80rpx 0;
background-color: #ffffff;
border-radius: 24rpx;
padding: 56rpx 30rpx;
.outline-view {
color: #5a6073;
font-size: 28rpx;
margin-bottom: 58rpx;
.count {
color: #2953ff;
}
}
.items-view {
display: flex;
justify-content: space-between;
align-items: center;
.sub-content-item {
color: #5a6073;
font-size: 26rpx;
display: flex;
justify-content: space-between;
flex-direction: column;
align-items: center;
background-color: rgba(41, 83, 255, 0.1);
width: 180rpx;
height: 240rpx;
border-radius: 12rpx;
padding: 40rpx 0;
.sub-image {
margin-bottom: 20rpx;
display: flex;
justify-content: center;
align-items: center;
.image {
width: 64rpx;
height: 64rpx;
}
}
.value-view {
font-size: 32rpx;
font-weight: bold;
color: #2953ff;
margin-top: 10rpx;
}
}
}
}
.crowd-view {
margin-top: 56rpx;
background-color: #ffffff;
border-radius: 24rpx;
padding: 56rpx 30rpx;
.outline-view {
font-size: 28rpx;
color: #5a6073;
margin-bottom: 32rpx;
}
.crowd-image {
width: 622rpx;
height: 120rpx;
margin-top: 24rpx;
}
}
}
}
.bottom-view {
padding: 36rpx 24rpx 44rpx 24rpx;
}
}
</style>
<template>
<view class="exam-setting">
<u-navbar
back-icon-color="#333333"
background="transparent"
titleColor="#191C27"
:border-bottom="false"
title-bold
></u-navbar>
<view>
<view class="title-view">
<text>{{ category.label }}</text>
</view>
</view>
<view class="exam-type">
<view>备考类型</view>
<view class="radio-view">
<view
v-for="(item, index) in types"
:key="index"
:class="['item-view', { selected: item.selected }]"
@click="handleClick(item.id)"
>
<view :class="['radio-item-view', { selected: item.selected }]">
<u-icon
name="checkbox-mark"
:class="['item-icon', { selected: item.selected }]"
></u-icon>
<text>{{ item.name }} </text>
</view>
</view>
</view>
</view>
<view class="exam-area">
<view class="area-title-view">
<text class="rea-title-view">包括区域</text>
<text>请确认与所在考试省份一致</text>
</view>
<picker
@change="handleConform"
range-key="label"
:value="index"
:range="range"
>
<view class="select-area">
<view @click="handleClickArea" class="area-text-view">
<text>{{ currentProvince.label }}</text>
<u-icon name="arrow-down"></u-icon>
</view>
<view class="loading-view" v-if="loading">
<u-loading mode="flower"></u-loading>
</view>
</view>
</picker>
<!-- <view class="select-area">
<view @click="handleClickArea" class="area-text-view">
<text>{{ currentProvince.label }}</text>
<u-icon name="arrow-down"></u-icon>
</view>
<view class="loading-view" v-if="loading">
<u-loading mode="flower"></u-loading>
</view>
<u-picker
mode="selector"
:range="range"
v-model="show"
:params="params"
safe-area-inset-bottom
cancel-color="#9EA5BB"
confirm-color="#2953FF"
:default-region="defaultRegion"
@confirm="handleConform"
></u-picker>
</view> -->
</view>
<view class="bottom-view">
<u-button
:customStyle="buttonStyle"
@click="handleClickSure"
shape="circle"
:disabled="buttonDisabled"
:type="buttonDisabled ? '' : 'primary'"
>
确定
</u-button>
</view>
<PopView
:visible.sync="showPop"
title="确认选择"
message="题库确认后不可更改,请查看确认"
@submit="handleClickSubmit"
>
<view v-for="(value, key) in selected" :key="key" class="pop-content">
<view :class="['pop-content-text', { last: key == thirdKey }]">{{
value.label
}}</view>
<u-icon v-if="key != thirdKey" name="arrow-downward"></u-icon>
</view>
</PopView>
<view>
<u-toast ref="uToast" />
</view>
</view>
</template>
<script>
import PopView from '@/components/pop-view'
let r = require('../../libs/bmap-wx.min.js')
let h = new r.BMapWX({
ak: process.uniEnv.bmapAK,
})
const key1 = 'category'
const key2 = 'sub-category'
const key3 = 'sub-sub-category'
export default {
components: {
PopView,
},
data() {
return {
selected: {},
list: [], // 题库列表
show: false,
value: '',
types: [
{ id: '1', name: '初训(初次考试)', selected: false },
{ id: '2', name: '复训(年审或换证)', selected: false },
],
currentProvince: { label: '北京市' },
loading: true,
showPop: false,
range: [],
index: 0,
}
},
computed: {
category() {
return this.selected[key3] || this.selected[key2] || this.selected[key1]
},
params() {
return {
province: true,
}
},
buttonStyle() {
return this.buttonDisabled
? {
height: '104rpx',
color: '#FFFFFF',
fontSize: '32rpx',
fontWeight: 'bold',
backgroundColor: '#D2D5DE',
}
: {
height: '104rpx',
color: '#FFFFFF',
fontSize: '32rpx',
fontWeight: 'bold',
backgroundColor: '#2953FF',
}
},
buttonDisabled() {
return !(this.currentProvince.label && this.selectedTypeId)
},
selectedType() {
for (var item of this.types) {
if (item.selected == true) {
return true
}
}
return false
},
thirdKey() {
return key3 || key2 || key1
},
selectedTypeId() {
for (var item of this.types) {
if (item.selected == true) {
return item.id
}
}
return null
},
},
onLoad(e) {
this.getPageInfo()
this.getLocation()
this.getProvinceList()
},
methods: {
handleClickArea() {
this.loading = false
this.show = true
},
// 点击了添加按钮
handleClick(selectedId) {
for (var item of this.types) {
console.log(item, selectedId)
item.selected = item.id == selectedId
}
},
handleConform(e) {
this.index = e.detail.value
this.currentProvince = this.range[this.index]
},
getLocation() {
this.loading = true
uni.getLocation({
type: 'wgs84',
success: (res) => {
this.baiduLocation(res.longitude, res.latitude)
},
fail: () => {
this.loading = false
},
})
},
handleClickSure() {
this.showPop = true
},
// 获取省份列表
async getProvinceList() {
let res = await this.$u.api.getProvinceList()
console.log(res)
this.range = res
},
// 学员增加自己的题库
async addQuestionWarehouse(params) {
let res = await this.$u.api.addQuestionWarehouse({ params })
console.log(res)
this.range = res
},
async handleClickSubmit() {
if (this.buttonDisabled) return
if (this.index == 0) {
this.changeIndex()
}
let param = {
provinceId: this.range[this.index].id,
type: this.selectedTypeId,
}
// 获取科目对应的题库
let res = await this.$u.api.getQuestionWarehouse(this.category.id, param)
let data = res[0]
this.setPageInfo(data)
// 学员增加自己的题库
let result = await this.$u.api
.addQuestionWarehouse({
questionWarehouseId: data.id,
})
.catch((err) => {
console.log(err)
})
if (result) {
// 成功
this.$refs.uToast.show({
title: '添加题库成功',
type: 'success',
duration: 1500,
callback: () => {
this.showPop = false
uni.switchTab({
url: '/pages/index/index',
})
},
})
} else {
this.showPop = false
}
},
changeIndex() {
for (var i = 0; i < this.range.length; i++) {
if (
this.currentProvince.label == this.range[i].fullName ||
this.currentProvince.label == this.range[i].label
) {
this.index = i
break
}
}
},
baiduLocation(long, lat) {
let a = this,
t = function() {
let t = {
success: function(res) {
let e = res.originalData.result
a.currentProvince.label = e.addressComponent.province
a.loading = false
a.changeIndex()
},
fail: function(a) {
a.loading = false
// n.error(a), console.log(a);
},
}
if (lat && long) {
let e = lat + ',' + long
t.location = e
}
h.regeocoding(t)
}
t()
},
// 本页数据设置,用于其他页面访问本页数据
setPageInfo(info) {
var pages = getCurrentPages()
if (pages.length >= 1) {
var page = pages[0]
console.log('--------setPageInfo--------', info)
page.info = info
}
},
getPageInfo() {
var pages = getCurrentPages()
if (pages.length >= 2) {
var page = pages[pages.length - 2]
this.selected = page.info
page.info = null
}
},
// 获取报考类型
// async loadList() {
// this.loading = true;
// let res = await this.$u.api.fileLabel({categoryId: this.category.id});
// this.loading = false
// if (res && res.code == 200) {
// this.list = res.data || [];
// }
// },
},
}
</script>
<style lang="scss" scoped>
.exam-setting {
height: 100vh;
display: flex;
flex-direction: column;
background-color: #f8fafd;
background-image: linear-gradient(to top, #f8fafd 0%, #e9f3ff 50%);
background-size: 100% 520rpx;
background-repeat: no-repeat;
padding: 0 24rpx;
.title-view {
width: 100%;
font-size: 48rpx;
font-weight: bold;
color: #191c27;
margin-bottom: 60rpx;
}
.exam-type {
font-size: 32rpx;
font-weight: bold;
color: #191c27;
.radio-view {
margin-top: 30rpx;
display: flex;
justify-content: space-between;
align-content: center;
margin-bottom: 50rpx;
.item-view {
display: flex;
justify-content: flex-start;
align-content: center;
.radio-item-view {
font-size: 28rpx;
color: #5a6073;
font-weight: bold;
display: flex;
align-items: center;
height: 104rpx;
width: 340rpx;
border-radius: 12rpx;
background-color: #ffffff;
padding-left: 24rpx;
&.selected {
border: 2rpx solid #2953ff;
color: #2953ff;
}
.item-icon {
border: 2rpx solid #9ea5bb;
background-color: transparent;
color: transparent;
border-radius: 36rpx;
width: 36rpx;
height: 36rpx;
display: flex;
justify-content: center;
align-items: center;
margin-right: 16rpx;
flex-shrink: 0;
&.selected {
border: 2rpx solid #2953ff;
color: #ffffff;
background-color: #2953ff;
}
}
}
}
}
}
.exam-area {
height: 100%;
overflow: auto;
.area-title-view {
display: flex;
justify-content: space-between;
align-content: flex-end;
font-size: 26rpx;
color: #9ea5bb;
margin-bottom: 30rpx;
.rea-title-view {
color: #191c27;
font-size: 32rpx;
font-weight: bold;
}
}
.select-area {
position: relative;
.area-text-view {
height: 104rpx;
background-color: #ffffff;
border-radius: 12rpx;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 28rpx;
color: #5a6073;
padding: 0 24rpx;
}
.loading-view {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
left: 24rpx;
top: 0;
height: 104rpx;
width: 100rpx;
background-color: #ffffff;
}
}
}
.bottom-view {
padding-bottom: 44rpx;
}
.pop-content {
margin-bottom: 10rpx;
text-align: center;
color: #9ea5bb;
.pop-content-text {
margin-bottom: 10rpx;
font-weight: bold;
font-size: 32rpx;
&.last {
color: #2953ff;
}
}
}
}
</style>
<template>
<view class="bound-questions">
<u-navbar
back-icon-color="#191C27"
background="transparent"
title="手动绑定"
titleColor="#191C27"
:border-bottom="false"
title-bold
></u-navbar>
<view class="body-view">
<view class="image-view"
><image class="image" :src="successImage"></image
></view>
<view class="content-view">
<view class="field-title">学习卡卡号</view>
<view class="field-view">
<input
type="number"
class="input-view"
:value="code"
placeholder="请输入卡号"
:placeholder-style="placeplaceholderStyle"
cursor-spacing="140"
:focus="focus"
adjust-position
/>
</view>
<view class="field-title">学习卡密码</view>
<view class="field-view">
<input
class="input-view"
password
:value="password"
placeholder="请输入密码"
:placeholder-style="placeplaceholderStyle"
cursor-spacing="140"
adjust-position
/>
</view>
</view>
<view class="bottom-view">
<u-button
:customStyle="customStyle"
@click="handleClick"
:loading="loading"
type="primary"
shape="circle"
>
确定
</u-button>
<view class="change-button"
><u-icon class="icon-view" name="error-circle"></u-icon
>注意:学习卡完成绑定后,不支持解绑操作</view
>
</view>
</view>
<view>
<u-toast ref="uToast" />
</view>
</view>
</template>
<script>
import uIcon from '../../uview-ui/components/u-icon/u-icon.vue'
export default {
components: { uIcon },
data() {
return {
code: '',
password: '',
focus: true,
loading: false,
// relationId: 0,
}
},
computed: {
customStyle() {
return {
height: '104rpx',
backgroundColor: '#2953FF',
color: '#FFFFFF',
fontSize: '32rpx',
fontWeight: 'bold',
}
},
buttonStyle() {
return {
width: '120rpx',
height: '56rpx',
background: '#FFFFFF',
color: '#2953FF',
fontSize: '26rpx',
borderRadius: '12rpx',
}
},
placeplaceholderStyle() {
return 'color:#9EA5BB;font-size:28rpx'
},
},
onLoad(e) {
// if (e && e.relationId) {
// this.relationId = e.relationId
// }
},
methods: {
handleClick() {
this.loading = true
this.$u.api
.bindCard({
cardNumber: this.code,
cardSecret: this.password,
questionWarehouseId: this.relationId,
})
.then((res) => {
this.$refs.uToast.show({
title: '绑定成功',
type: 'success',
duration: 1500,
callback: () => {
this.setPageInfo()
uni.switchTab({
url: '/pages/index/index',
})
},
})
})
.catch((err) => {
this.loading = false
})
},
setPageInfo() {
var pages = getCurrentPages()
if (pages.length >= 2) {
var page = pages[pages.length - 2]
page.refresh = true
}
},
},
}
</script>
<style lang="scss" scoped>
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.bound-questions {
display: flex;
flex-direction: column;
background-image: linear-gradient(to top, #f7f9fc 0%, #e9f3ff 50%);
background-color: #f7f9fc;
background-size: 100% 520rpx;
background-repeat: no-repeat;
height: 100vh;
.body-view {
height: 100%;
overflow: auto;
padding: 10rpx 24rpx 44rpx 24rpx;
.image-view {
text-align: center;
.image {
width: 700rpx;
height: 360rpx;
background-color: red;
border-radius: 24rpx;
box-shadow: 0px 10px 16px rgba(29, 53, 155, 0.2);
}
}
.content-view {
margin-top: 50rpx;
.field-title {
font-size: 32rpx;
font-weight: bold;
color: #191c27;
}
.field-view {
height: 104rpx;
background-color: #ffffff;
margin-top: 30rpx;
margin-bottom: 60rpx;
display: flex;
align-items: center;
justify-content: center;
border-right: 12rpx;
padding: 0 24rpx;
.input-view {
width: 100%;
text-align: center;
}
}
}
.bottom-view {
text-align: center;
.change-button {
color: #9ea5bb;
font-size: 24rpx;
margin-top: 20rpx;
display: flex;
align-items: center;
justify-content: center;
.icon-view {
color: #fa5a49;
font-size: 32rpx;
margin-right: 10rpx;
}
}
}
}
}
</style>
<template>
<view class="record-view">
<u-navbar
back-icon-color="#FFFFFF"
background="transparent"
title="学练记录"
titleColor="#FFFFFF"
:border-bottom="false"
title-bold
></u-navbar>
<view class="head-view">
<view class="left-view">
<view class="head-tip">学练记录</view>
<view class="content-text">Learn of punch</view>
</view>
<image class="xunzhang-image" :src="xunzhangImage"></image>
</view>
<view class="body-view">
<view class="date-view">
<view class="content-title" id="part-days">每日一练</view>
<view class="date-content"></view>
</view>
<view class="charts-view">
<view class="content-title" id="part-total">练习分析</view>
<view class="range-view">
<view class="range-title">日期范围</view>
<view
v-for="(item, index) in items"
:key="index"
:class="['range-item', { selected: item.selected }]"
@click="handleClickRange(index)"
>{{ item.title }}</view
>
</view>
<view v-if="showSelect" class="days-select-view">
<picker
mode="date"
:value="rangeDay0"
:end="rangeDay1"
@change="handleConform($event, 0)"
>
<view class="date-picker-content" hover-class="hover-class">
<view class="input-view">{{ rangeDay0 }}</view>
<u-icon name="arrow-down"></u-icon>
</view>
</picker>
<view class="line-view">-</view>
<picker
mode="date"
:value="rangeDay1"
:start="rangeDay0"
:end="getDate()"
@change="handleConform($event, 1)"
>
<view class="date-picker-content" hover-class="hover-class">
<view class="input-view">{{ rangeDay1 }}</view>
<u-icon name="arrow-down"></u-icon>
</view>
</picker>
</view>
<view class="charts-content"> </view>
</view>
<view class="list-view">
<view class="content-title" id="part-today">模考成绩</view>
<view class="list-content">
<RecordCell
v-for="(item, index) in showedList"
:key="index"
:info="item"
></RecordCell>
<view class="show-more" @click="showAll = true" v-if="!showAll">
<u-icon name="arrow-down"></u-icon>
<text>查看更多</text>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import RecordCell from '@/components/record-cell'
export default {
components: { RecordCell },
data() {
return {
lists: [],
showSelect: false,
showAll: false,
scrollId: null,
items: [
{
title: '近7天',
selected: true,
},
{
title: '近30天',
selected: false,
},
{
title: '自定义',
selected: false,
},
],
rangeDay0: this.getDate(), // 自定义开始日期
rangeDay1: this.getDate(), // 自定义结束日期
}
},
computed: {
xunzhangImage() {
return process.uniEnv.qn_base_url + 'xuelianxunzhang.png'
},
params() {
return {
year: true,
month: true,
day: true,
}
},
showedList() {
return this.showAll ? this.lists : this.lists.slice(0, 2)
},
},
onLoad(e) {
if (e && e.key) {
this.$nextTick(() => {
this.scrollId = 'part-' + e.key
})
}
this.lists = [
{ time: 36, score: 80, date: new Date().getTime },
{ time: 100, score: 40, date: new Date().getTime },
{ time: 40, score: 60, date: new Date().getTime },
]
},
methods: {
handleClick() {},
handleClickRange(index) {
for (var item of this.items) {
item.selected = false
}
this.items[index].selected = true
if (index == 2) {
this.showSelect = true
} else {
this.showSelect = false
// 修改图表
// ...
}
},
handleConform(e, index) {
this['rangeDay' + index] = e.target.value
// 修改图表
// ...
},
getDate() {
return this.$u.timeFormat(new Date().getTime(), 'yyyy-mm-dd')
},
},
}
</script>
<style lang="scss" scoped>
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.record-view {
display: flex;
flex-direction: column;
height: 100vh;
position: relative;
background-color: #f7f9fc;
background-image: linear-gradient(to top, #2272ff 0%, #2953ff 50%);
background-size: 100% 400rpx;
background-repeat: no-repeat;
.head-view {
padding: 10rpx 60rpx 50rpx 60rpx;
display: flex;
justify-content: space-between;
overflow: visible;
align-items: flex-start;
height: 220rpx;
.left-view {
margin-top: 20rpx;
.head-tip {
color: #ffffff;
font-size: 48rpx;
font-weight: bold;
margin-bottom: 16rpx;
}
.content-text {
font-size: 40rpx;
font-weight: bold;
color: #ffffff;
}
}
.xunzhang-image {
width: 182rpx;
height: 272rpx;
z-index: 1;
}
}
.body-view {
border-radius: 24rpx 24rpx 0 0;
background-color: #ffffff;
height: 100%;
overflow: auto;
padding: 24rpx 30rpx 44rpx 30rpx;
.date-view {
.date-content {
min-height: 648rpx;
}
}
.content-title {
font-size: 32rpx;
color: #191c27;
font-weight: bold;
}
.charts-view {
.range-view {
display: flex;
margin-top: 40rpx;
margin-bottom: 40rpx;
.range-title {
font-size: 28rpx;
color: #9ea5bb;
margin-right: 8rpx;
}
.range-item {
margin-left: 30rpx;
font-size: 24rpx;
color: #9ea5bb;
background-color: #e8ebf3;
border-radius: 24rpx;
padding: 0 20rpx;
line-height: 48rpx;
height: 48rpx;
&.selected {
color: #ffffff;
background-color: #2953ff;
}
}
}
.days-select-view {
margin-left: 154rpx;
display: flex;
align-items: center;
color: #9ea5bb;
.line-view {
}
.hover-class {
background-color: #2953ff;
color: #ffffff;
}
.date-picker-content {
display: flex;
align-items: center;
padding-left: 10rpx;
padding-right: 10rpx;
border-radius: 12rpx;
.input-view {
margin-right: 8rpx;
}
}
}
.charts-content {
min-height: 570rpx;
}
}
.list-view {
.list-content {
.show-more {
display: flex;
justify-content: center;
align-items: center;
color: #2953ff;
height: 80rpx;
}
}
}
}
}
</style>
<template>
<view class="score-view">
<u-navbar
back-icon-color="#191C27"
background="transparent"
title="考试成绩"
titleColor="#191C27"
:border-bottom="false"
title-bold
></u-navbar>
<view
class="top-view"
v-if="!isFull"
@click="$u.throttle(handleClickRecord, 500)"
>
考试错题已自动加入<text class="blue-text">"错题记录"</text> 方便练习</view
>
<view :class="['content', { 'is-full': isFull }]">
<view class="content-view">
<image mode="widthFix" class="back-image" :src="backImage"></image>
<view class="chart-view">
<CircleProgress
class="progress-view"
active-color="#FFFFFF"
:percent="info.score"
inactive-color="rgba(255, 255, 255, 0.3)"
width="240"
border-width="8"
bg-color="transparent"
>
<view class="progress-content">
<view class="progress-score">{{ info.score }}</view>
<view class="progress-info">{{ resultText }}</view>
<view class="percent-text">超越了{{ falsePercent }}%的学员</view>
</view>
</CircleProgress>
</view>
<view class="head-view">
<view class="image-view">
<image class="image" :src="info.image || defaultImage"> </image
></view>
<view>{{ info.name }}</view>
<view class="time-view">{{ info.time }}</view>
</view>
<view class="detail-view">
<view class="name-view">{{ info.category }}</view>
<view class="type-view">{{ info.type }}</view>
<image class="qrcode-image" :src="info.institutionLogo"></image>
</view>
</view>
<view class="bottom-view">
<u-button
:customStyle="buttonStyle"
@click="handleClick"
type="primary"
hover-class="hover-class"
>
<image :src="pengyunquanImage" class="share-image"></image>
分享朋友圈
</u-button>
<u-button :customStyle="buttonStyle" open-type="share" type="primary">
<image :src="weixinImage" class="share-image"></image>
分享给好友
</u-button>
</view>
</view>
<u-mask :show="show" @click="show = false">
<view class="tip-view">
<image class="tip-image" :src="jiantouImage"></image>
<view class="tip-message"
><text class="tip-text"
>请点击右上角可分享至朋友圈或发送给指定朋友</text
>
</view>
</view>
</u-mask>
</view>
</template>
<script>
import CircleProgress from '@/components/circle-progress'
export default {
components: {
CircleProgress,
},
data() {
return {
info: {},
show: false,
}
},
computed: {
labels() {
return {
kemu: '考试科目',
tishu: '考试题数',
biaozhun: '合格标准',
guize: '出题规则',
}
},
defaultImage() {
return process.uniEnv.qn_base_url + 'morentouxiang-w.png'
},
buttonStyle() {
return {
height: '104rpx',
width: '312rpx',
backgroundColor: '#FFFFFF',
color: '#5A6073',
fontSize: '28rpx',
fontWeight: 'bold',
borderRadius: '24rpx',
}
},
isFull() {
return this.info.score >= 100
},
isPass() {
return this.info.score >= 60
},
resultText() {
return this.isPass ? '合格' : '不合格'
},
backImage() {
return this.isPass ? this.hegechengjiImage : this.buhegechengjiImage
},
hegechengjiImage() {
return process.uniEnv.qn_base_url + 'hegechengji.png'
},
buhegechengjiImage() {
return process.uniEnv.qn_base_url + 'buhegechengji.png'
},
pengyunquanImage() {
return process.uniEnv.qn_base_url + 'pengyunquan.png'
},
weixinImage() {
return process.uniEnv.qn_base_url + 'weixin.png'
},
jiantouImage() {
return process.uniEnv.qn_base_url + 'jiantou.png'
},
// 模考成绩60分以下则百分数在55%—65% 区间内取随机值;
// 模考成绩大于60分小于80分则百分数在66%—85% 区间内取随机值;
// 模考成绩大于80分小于90分则百分数在86%—93% 区间内取随机值;
// 模考成绩大于90分小于100分则百分数在94%—99% 区间内取随机值)
falsePercent() {
var random = [94, 99]
if (this.info.score < 60) {
random = [55, 65]
} else if (this.info.score >= 60 && this.info.score < 80) {
random = [66, 85]
} else if (this.info.score >= 80 && this.info.score < 90) {
random = [86, 93]
} else if (this.info.score >= 90) {
random = [94, 99]
}
return this.$u.random(random[0], random[1])
},
},
onLoad(e) {
if (!e) {
this.$u.route({
url: 'pages/index/index',
type: 'tab',
})
}
this.init(e?.id)
},
methods: {
init(id) {
uni.showLoading({
title: '加载中',
})
this.$u.api.queryExamRecordOne({ id: id }).then((res) => {
uni.hideLoading()
if (res) {
const echoMap = res.echoMap
this.info = {
institutionLogo:
echoMap?.institutionId?.wxQrcodePath ||
process.uniEnv.qn_base_url + 'applets.jpg',
name: echoMap.studentId.nickname,
image: echoMap.studentId.avatarPath,
score: res.point,
time: res.endDatetime,
category: echoMap.questionWarehouseId.title,
type: '模拟考试',
}
}
})
},
handleClickRecord() {
console.log("11", 11)
this.$u.route({
url: 'pages/learn/answer',
params: {
source: 5,
}
})
},
handleClick() {
this.show = true
setTimeout(() => {
this.show = false
}, 2500)
},
},
}
</script>
<style lang="scss" scoped>
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.score-view {
display: flex;
flex-direction: column;
height: 100vh;
background-color: #f7f9fc;
.top-view {
background-color: rgba(250, 90, 73, 0.1);
color: #5a6073;
font-weight: 28rpx;
height: 72rpx;
text-align: center;
line-height: 72rpx;
.blue-text {
color: #2953ff;
}
}
.content {
height: 100%;
overflow: auto;
padding: 64rpx 48rpx 44rpx 48rpx;
&.is-full {
padding-top: 0rpx;
border-radius: 24rpx;
}
.content-view {
background-color: #ffffff;
border-radius: 24rpx;
position: relative;
overflow: hidden;
z-index: 1;
padding-bottom: 36rpx;
.back-image {
position: absolute;
width: 100%;
z-index: -1;
}
.chart-view {
text-align: center;
margin-top: 76rpx;
.progress-view {
.progress-content {
margin-top: 50rpx;
.progress-score {
font-size: 80rpx;
font-weight: bold;
color: #ffffff;
}
.progress-info {
font-size: 28rpx;
color: #ffffff;
}
.percent-text {
margin-top: 6px;
font-size: 28rpx;
color: #ffffff;
}
}
}
}
.head-view {
width: 100%;
display: flex;
align-items: center;
font-size: 32rpx;
font-weight: bold;
color: #191c27;
flex-direction: column;
margin-bottom: 50rpx;
margin-top: 58rpx;
.image-view {
margin-bottom: 24rpx;
display: flex;
justify-content: center;
align-items: center;
padding: 4rpx;
width: 140rpx;
height: 140rpx;
background-color: #ffffff;
border-radius: 140rpx;
.image {
width: 136rpx;
height: 136rpx;
border-radius: 136rpx;
}
}
.time-view {
margin-top: 6rpx;
color: #5a6073;
font-size: 26rpx;
}
}
.detail-view {
padding: 20rpx 0;
text-align: center;
.name-view {
font-size: 36rpx;
font-weight: bold;
color: #191c27;
margin-bottom: 16rpx;
}
.type-view {
font-size: 28rpx;
color: #5a6073;
margin-bottom: 30rpx;
}
.qrcode-image {
width: 160rpx;
height: 160rpx;
}
}
.tip-view {
font-size: 26rpx;
color: #9ea5bb;
margin: 50rpx 0 210rpx 0;
}
}
.bottom-view {
margin-top: 30rpx;
display: flex;
justify-content: space-between;
align-content: center;
.share-image {
width: 48rpx;
height: 48rpx;
margin-right: 20rpx;
}
}
}
.tip-view {
margin-top: 116rpx;
display: flex;
flex-direction: column;
align-items: flex-end;
.tip-image {
width: 96rpx;
height: 282rpx;
margin-right: 200rpx;
margin-bottom: 24rpx;
}
.tip-message {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
.tip-text {
color: #ffffff;
font-size: 32rpx;
font-weight: bold;
text-align: left;
width: 420rpx;
}
}
}
}
</style>
<template>
<view class="select-category">
<u-navbar
back-icon-color="#333333"
background="transparent"
title="题库选择"
titleColor="#191C27"
:border-bottom="false"
title-bold
></u-navbar>
<!-- 标签列表 -->
<scroll-view
class="select-category-content"
scroll-y
:scroll-into-view="scrollId"
>
<view v-for="(items, key) in labels" :key="key" class="label-list">
<view
v-for="(list, index) in items"
:key="index"
class="label-list"
:style="{
'min-height':
key == secondKey && index + 1 == list.length
? minHeight + 'px'
: 0,
}"
>
<view class="label-title" :id="key + index">
<!-- 品类title -->
<view>{{
key == secondKey ? labels[firstKey][0][index].label : '非煤矿类'
}}</view>
</view>
<view class="label-content">
<view v-for="(label, ind) in list" :key="ind" class="label-item">
<!-- 选中为蓝底,非选中状态为白底 -->
<view
:class="[
'label-normal',
{
selected: label.id == selected[key].id,
wide: key == secondKey,
},
]"
@click="handleClick(key, index, ind, label)"
>
<text class="label-text">{{ label.label }}</text>
</view>
</view>
</view>
</view>
</view>
<!-- 标签加载中 -->
<view class="tag-loading-view" v-if="tapLoading">
<u-loading mode="flower"></u-loading>
</view>
</scroll-view>
</view>
</template>
<script>
const key1 = 'category'
const key2 = 'sub-category'
export default {
data() {
return {
labels: {
// 标签列表
[key1]: [[]], // 一级品类列表
[key2]: [[], [], []], // 二级品类列表
},
selected: {
// 选中的标签
[key1]: {}, // 选中的一级品类
[key2]: {}, // 选中的二级品类
},
tapLoading: true,
scrollId: '',
minHeight: 0,
result: [],
}
},
computed: {
firstKey() {
return key1
},
secondKey() {
return key2
},
},
onLoad(e) {
this.loadLabel() // 获取标签
},
methods: {
// 选中标签
handleClick(key, index, ind, label) {
this.selected[key] = label
if (key == key1) {
// 选中一级标签
this.scrollId = ''
if (
this.labels[key2] &&
this.labels[key2][index] &&
this.labels[key2][index].length > 0
) {
this.selected[key2] = {}
const query = uni.createSelectorQuery().in(this)
query
.select('.select-category-content')
.boundingClientRect((data) => {
this.minHeight = data.height - 22 // 去掉margin、padding
this.$nextTick(() => {
this.scrollId = key2 + ind
console.log(this.scrollId)
})
})
.exec()
} else {
this.selected[key2] = null
this.setPageInfo(this.selected)
this.$u.route({
url: 'pages/learn/examSetting',
})
}
} else {
// 选中二级标签
this.selected[key1] = this.labels[key1][0][index]
this.selected[key2].list =
this.result.filter((item) => {
return item.parentId == label.id
}) || []
var path = 'addExam'
if (this.selected[key2].list.length <= 0) {
path = 'examSetting'
}
this.setPageInfo(this.selected)
this.$u.route({
url: 'pages/learn/' + path,
})
}
},
// 获取品类
async loadLabel() {
this.tapLoading = true
let param = {}
let res = await this.$u.api.subjectList(param)
this.tapLoading = false
this.result = res
var filterItems = res.filter((item) => {
return item.parentId == 0
})
var mItem = filterItems[0]
this.labels[key1][0] = []
for (var item of res) {
if (item.parentId == mItem.id) {
this.labels[key1][0].push(item)
}
}
for (var i = 0; i < this.labels[key1].length; i++) {
var data = this.labels[key1][0][i]
this.labels[key2][i] = []
for (var item of res) {
if (item.parentId == data.id) {
this.labels[key2][i].push(item)
}
}
}
},
// 本页数据设置,用于其他页面访问本页数据
setPageInfo(info) {
var pages = getCurrentPages()
if (pages.length >= 1) {
var page = pages[pages.length - 1]
page.info = info
}
},
},
}
</script>
<style lang="scss" scoped>
.select-category {
height: 100vh;
display: flex;
flex-direction: column;
background-color: #f8fafd;
background-image: linear-gradient(to top, #f8fafd 0%, #e9f3ff 50%);
background-size: 100% 520rpx;
background-repeat: no-repeat;
.select-category-content {
padding: 0 0 24rpx 24rpx;
height: 100%;
overflow: auto;
position: relative;
.label-list {
margin-bottom: 20rpx;
.label-title {
font-size: 32rpx;
font-weight: bold;
color: #191c27;
margin-bottom: 30rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
.label-content {
.label-item {
padding-right: 22rpx;
padding-bottom: 24rpx;
flex-shrink: 0;
display: inline-block;
.label-normal {
height: 104rpx;
width: 200rpx;
font-size: 26rpx;
color: #9ea5bb;
background-color: #ffffff;
border-radius: 12rpx;
padding-left: 48rpx;
padding-right: 48rpx;
text-align: center;
display: flex;
justify-content: center;
align-items: center;
font-weight: bold;
.label-text {
word-break: break-all;
}
&.wide {
padding-left: 24rpx;
padding-right: 24rpx;
width: 340rpx;
height: 128rpx;
color: #5a6073;
}
&.selected {
color: #ffffff;
background-color: #2953ff;
}
}
}
}
}
.tag-loading-view {
display: flex;
position: absolute;
align-items: center;
justify-content: center;
top: 400rpx;
color: #999999;
text-align: center;
width: 100%;
padding-right: 11rpx;
}
}
}
</style>
<template>
<view class="selected-special">
<u-navbar
back-icon-color="#333333"
background="transparent"
title="已选题库"
titleColor="#191C27"
:border-bottom="false"
title-bold
></u-navbar>
<view class="selected-list-content">
<view class="label-content">
<view
v-for="(item, index) in lables"
:key="index"
class="special-item"
hover-class="hover-class"
@click="handleClick(item.source)"
>
<view class="left-view">
<image :src="item.image" class="item-image"></image>
<view class="item-title">{{ item.title }}</view>
<view
>共<text class="item-count">{{ info[item.key] }}</text
>道</view
>
</view>
<u-icon name="arrow-right" class="item-icon"></u-icon>
</view>
</view>
<!-- 无数据 -->
<view class="tag-loading-view" v-if="list.length <= 0">暂无数据</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
info: {}, // 已选题库列表
}
},
computed: {
// 1.顺序答题 2.随机练习 3.模拟考试 4.收藏答题 5.错题答题 6.专项练习-单选 7.专项练习-多选 8.专项练习-判断 9.专项练习-答案是
lables() {
return [
{
key: 'oneAnswerCount',
title: '单选题',
source: 6,
image: process.uniEnv.qn_base_url + 'danxuan.png',
},
{
key: 'anyAnswerCount',
title: '多选题',
source: 7,
image: process.uniEnv.qn_base_url + 'duoxuan.png',
},
{
key: 'trueOrFalseCount',
title: '判断题',
source: 8,
image: process.uniEnv.qn_base_url + 'panduan.png',
},
{
key: 'trueAnswerCount',
title: '判断题(结果为正确)',
source: 9,
image: process.uniEnv.qn_base_url + 'zhengquepanduanti.png',
},
]
},
},
onLoad(e) {
this.getPageInfo()
},
methods: {
getPageInfo() {
var pages = getCurrentPages()
if (pages.length >= 2) {
var page = pages[pages.length - 2]
this.info = page.info
page.info = null
}
},
// 点击了添加按钮
handleClick(source) {
// 1.顺序答题 2.随机练习 3.模拟考试 4.收藏答题 5.错题答题 6.专项练习-单选 7.专项练习-多选 8.专项练习-判断 9.专项练习-答案是
this.$u.route({
url: 'pages/learn/answer',
params: {
source: source,
},
})
},
},
}
</script>
<style lang="scss" scoped>
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.selected-special {
height: 100vh;
display: flex;
flex-direction: column;
background-color: #f8fafd;
background-image: linear-gradient(to top, #f8fafd 0%, #e9f3ff 50%);
background-size: 100% 520rpx;
background-repeat: no-repeat;
padding: 0 24rpx;
.selected-list-content {
height: 100%;
overflow: auto;
.label-content {
margin-bottom: 44rpx;
.special-item {
margin-top: 24rpx;
background-color: #ffffff;
border-radius: 12rpx;
padding: 0 24rpx 0 30rpx;
display: flex;
align-items: center;
justify-content: space-between;
height: 142rpx;
.left-view {
display: flex;
align-items: center;
color: #5a6073;
font-size: 32rpx;
.item-image {
width: 48rpx;
height: 48rpx;
}
.item-title {
font-size: 36rpx;
font-weight: bold;
color: #191c27;
padding: 0 16rpx 0 24rpx;
}
.item-count {
color: #2953ff;
padding: 0 4rpx;
}
}
.item-icon {
color: #9ea5bb;
font-size: 34rpx;
}
}
.hover-class {
background-color: #dddddd;
}
}
}
}
</style>
<template>
<view class="selected-list">
<u-navbar
back-icon-color="#333333"
background="transparent"
title="已选题库"
titleColor="#191C27"
:border-bottom="false"
title-bold
></u-navbar>
<view class="selected-list-content">
<view class="label-content">
<view v-for="(label, index) in list" :key="index" class="label-item">
<QuestionBankCell
:info="label && label.echoMap && label.echoMap.questionWarehouseId"
:type="type"
@action="handleAction"
></QuestionBankCell>
</view>
</view>
<!-- 标签加载中 -->
<view class="tag-loading-view" v-if="loading">
<u-loading mode="flower"></u-loading>
</view>
<!-- 无数据 -->
<view class="tag-loading-view" v-else-if="list.length <= 0"
>暂无数据</view
>
</view>
<view class="bottom-view">
<u-button
:customStyle="buttonStyle"
@click="handleClick"
type="primary"
shape="circle"
>
<u-icon class="button-icon" name="plus-circle"></u-icon>添加新题库
</u-button>
</view>
</view>
</template>
<script>
import QuestionBankCell from '@/components/question-bank-cell'
export default {
components: {
QuestionBankCell,
},
data() {
return {
list: [], // 已选题库列表
loading: true,
}
},
computed: {
buttonStyle() {
return {
height: '104rpx',
backgroundColor: '#2953FF',
color: '#FFFFFF',
fontSize: '32rpx',
fontWeight: 'bold',
}
},
type() {
return this.list.length > 1 ? 'change' : 'none'
},
},
onLoad(e) {
this.loadList() // 获取已选题库列表
},
methods: {
// 点击了添加按钮
handleClick() {
this.$u.route({
url: 'pages/learn/selectCategory',
})
},
handleAction(info) {
this.setPageInfo(info)
this.$u.route({
type: 'back',
})
},
// 获取题库列表
loadList() {
this.loading = true
let param = {}
this.$u.api
.getMyQuestionWarehouseList(param)
.then((res) => {
this.loading = false
this.list = res
})
.catch((err) => {
this.loading = false
console.log(err)
})
},
setPageInfo(info) {
var pages = getCurrentPages()
if (pages.length >= 2) {
var page = pages[pages.length - 2]
page.info = info
}
},
},
}
</script>
<style lang="scss" scoped>
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.selected-list {
height: 100vh;
display: flex;
flex-direction: column;
background-color: #f8fafd;
background-image: linear-gradient(to top, #f8fafd 0%, #e9f3ff 50%);
background-size: 100% 520rpx;
background-repeat: no-repeat;
padding: 0 24rpx 0rpx 24rpx;
.selected-list-content {
height: 100%;
overflow: auto;
.label-content {
margin-bottom: 44rpx;
.label-item {
margin-bottom: 24rpx;
}
}
}
.tag-loading-view {
display: flex;
align-items: center;
justify-content: center;
margin-top: 400rpx;
color: #999999;
text-align: center;
position: absolute;
width: 100%;
padding-right: 11rpx;
}
.bottom-view {
margin-bottom: 44rpx;
.button-icon {
margin-right: 10rpx;
font-size: 46rpx;
font-weight: bold;
}
}
}
</style>
<template>
<view class="bound-test">
<u-navbar
back-icon-color="#191C27"
background="transparent"
title="绑定试题"
titleColor="#191C27"
:border-bottom="false"
title-bold
></u-navbar>
<view class="body-view">
<view class="title-view">学习卡号为</view>
<view class="content-view">{{ code }}</view>
<view class="tip-view">是否绑定该学习卡</view>
<view class="message-view">学习卡完成绑定后,不支持解绑操作</view>
<view class="bottom-view">
<u-button
:customStyle="buttonStyle"
@click="handleClick"
type="primary"
shape="circle"
>
绑定
</u-button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
code: '01458965',
}
},
computed: {
labels() {
return {
kemu: '考试科目',
tishu: '考试题数',
biaozhun: '合格标准',
guize: '出题规则',
}
},
successImage() {
return process.uniEnv.qn_base_url + 'shenqingtijiaochenggong.png'
},
buttonStyle() {
return {
height: '104rpx',
width: '400rpx',
backgroundColor: '#2953FF',
color: '#FFFFFF',
fontSize: '32rpx',
fontWeight: 'bold',
}
},
},
onLoad(e) {
if (e & e.result) {
this.computed = e.result
}
},
methods: {
handleClick() {
uni.switchTab({
url: '/pages/index/index',
})
},
},
}
</script>
<style lang="scss" scoped>
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.bound-test {
display: flex;
flex-direction: column;
background-image: linear-gradient(to top, #f7f9fc 0%, #e9f3ff 50%);
background-color: #f7f9fc;
background-size: 100% 520rpx;
background-repeat: no-repeat;
height: 100vh;
.body-view {
height: 100%;
overflow: auto;
padding-top: 40rpx;
text-align: center;
.title-view {
color: #5a6073;
font-size: 32rpx;
}
.content-view {
color: #2953ff;
font-size: 72rpx;
font-weight: bold;
margin-top: 50rpx;
margin-bottom: 120rpx;
letter-spacing: 20rpx;
}
.tip-view {
color: #2953ff;
font-size: 40rpx;
font-weight: bold;
}
.message-view {
color: #9ea5bb;
font-size: 26rpx;
margin-top: 20rpx;
}
.bottom-view {
margin-top: 180rpx;
}
}
}
</style>
// 分页为如下格式:
// {
// "total": 300,
// "currentPage": 1,
// "list": []
// }
const TOTAL = 100
const lists = [
{
type: 1,
title: '采用QS1电桥测量tanδ的接线方式一般有差接线及和接线。',
answerList: [
{
sort: 'A',
text: '正确',
},
{
sort: 'B',
text: '错误',
},
],
answer: 'A',
explain:
'极性电介质在外电场作用下,由偶极子分子的转向形成的极化称为偶极子式极化。',
index: 0,
rightKey: ['A'],
},
{
type: 2,
title:
'空气间隙的操作冲击击穿电压数值大小不仅与间隙距离、电极形状、电极极性有关,而且与操作冲击电压波的波前时间的长短有关。',
answerList: [
{
sort: 'A',
text: '正确',
},
{
sort: 'B',
text: '错误',
},
],
answer: 'B',
explain:
'极性电介质在外电场作用下,由偶极子分子的转向形成的极化称为偶极子式极化。',
index: 1,
rightKey: ['B'],
},
{
type: 3,
title: '西林电桥采用正接线及反接线时,其测试原理相同',
answerList: [
{
sort: 'A',
text: '影响',
},
{
sort: 'B',
text: '影响很小',
},
{
sort: 'C',
text: '影响很大',
},
{
sort: 'D',
text: '无影响',
},
],
answer: 'B,C',
explain:
'双臂电桥是在单臂电桥的基础上增加特殊机构,以消除测试时连接线和接线柱接触电阻对测量结果的影响。',
index: 2,
rightKey: ['B', 'C'],
},
{
type: 2,
title: '测试标题测试标题测试标题测试标题',
answerList: [
{
sort: 'A',
text: '是',
},
{
sort: 'B',
text: '否',
},
],
answer: 'B',
explain: '测试内容测试内容测试内容测试内容测试内容测试内容',
index: 3,
rightKey: ['B'],
},
]
// 请求一页数据
function request({ currentPage, size, onSuccess, onFailed }, vm) {
const params = {
current: currentPage,
size: size,
model: {
questionWarehouseId: vm.questionWarehouseId,
recordId: vm.recordId,
source: vm.source
}
}
uni.showLoading({
title: '加载中'
})
vm.$u.api.getQuestion(params).then(res => {
uni.hideLoading()
const list = res.records
let data = {}
data.total = res.total
data.currentPage = currentPage
let questionList = []
for (let i = 0; i < size; i++) {
const info = list[i]
if (info) {
const content = JSON.parse(info.content)
const answerList = content.choiceList.map(v => {
return {
sort: v.value,
text: v.label
}
})
let type
switch (info.echoMap.questionTypeId) {
case '单选题':
type = 1
break;
case '判断题':
type = 2
break;
case '多选题':
type = 3
break;
}
let item = {
index: i + (currentPage - 1) * size,
id: info.id,
currentPage: currentPage,
total: data.total,
title: content.title,
answerList: answerList,
answer: info.answer,
rightKey: info.answer.split(','),
explain: info.analysis,
type: type,
collectionFlag: info.collectionFlag
}
// 回显已答题目
if (vm.source === 1) { // 练习模式回显
const ansItem = vm.questionList[vm.questionWarehouseId].find(v => v.index === item.index)
questionList.push(ansItem ? ansItem : item)
} else {
questionList.push(item)
}
}
}
data.questionList = questionList
onSuccess(data)
})
}
// 同时请求多页数据
function requestMulti({ pageList, size, onSuccess, onFailed }, vm) {
console.log('请求哪几页数据?', pageList)
uni.showLoading({
title: '加载中',
})
let promise = Promise.all(
pageList.map(function(pageNum) {
return new Promise(function(resolve, reject) {
request({
currentPage: pageNum,
size: size,
onSuccess: function(res) {
resolve(res)
},
onFailed: function(msg) {
reject(new Error('failed to request'))
},
},vm)
})
})
)
promise
.then(function(results) {
uni.hideLoading()
onSuccess(results)
})
.catch(function(err) {
uni.hideLoading()
onFailed(err)
})
}
// 根据初始index和每页item的数量获取当前是第几页
const getInitcurrentPage = function(index, size) {
let pageNum = parseInt((index + 1) / size)
let remain = (index + 1) % size
return remain == 0 ? pageNum : pageNum + 1
}
// 获取初始的pageList, 可能一页,可能两页
const getInitPageList = function(currentIndex, size, currentPage, total) {
if ((currentIndex + 1) % size == 1 && currentIndex != 0) {
return [currentPage - 1, currentPage]
}
if ((currentIndex + 1) % size == 0 && currentIndex != total - 1) {
return [currentPage, currentPage + 1]
}
return [currentPage]
}
function initAnswerCardList(total, vm) {
if (!vm.questionList[vm.questionWarehouseId] || vm.questionList[vm.questionWarehouseId].length === 0) {
let list = []
for (let i = 0; i < total; i++) {
list.push({})
}
vm.$u.vuex(`questionList.${vm.questionWarehouseId}`, list)
}
}
module.exports = {
TOTAL: TOTAL,
request: request,
requestMulti: requestMulti,
getInitcurrentPage: getInitcurrentPage,
getInitPageList: getInitPageList,
initAnswerCardList: initAnswerCardList,
}
<template>
<view class="begin-answer">
<u-navbar
back-icon-color="#000000"
background="transparent"
titleColor="#000000"
:border-bottom="false"
title-bold
></u-navbar>
<view class="content">
<view>
<uni-icons type="weixin" size="120" color="#04BE02"></uni-icons>
</view>
<view class="view-image">
<u-image
:src="targetImage"
class="target-image"
width="160"
height="160"
></u-image>
</view>
<view class="target">
<text class="tips">想要轻松考过,首选模考大师</text>
</view>
<view class="text-area">
<button class="bottom" type="primary" @tap="wxLogin">授权登录</button>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: '微信授权登录',
host: '', //配置为自己的额服务器即可
}
},
computed: {
targetImage() {
return process.uniEnv.qn_base_url + 'LOGO@3x.png'
},
},
onShow() {},
methods: {
wxLogin() {
// 获取code 小程序专有,用户登录凭证。
uni.getUserProfile({
desc: '获取用户基本资料',
lang: 'zh_CN',
success: (user) => {
// 获取成功基本资料后开启登录,因为基本资料首先要授权
uni.login({
provider: 'weixin',
success: (code_res) => {
if (code_res.errMsg == 'login:ok') {
const code = code_res.code
const userInfo = user.userInfo
const data = {
code: code,
avatar: userInfo.avatarUrl,
nickname: userInfo.nickName,
orgId: getApp().globalData.orgId,
}
uni.showLoading({
title: '加载中',
})
this.$u.api.loginWechatAuth(data).then((res) => {
uni.hideLoading()
this.$u.vuex('vuex_token', res.token)
this.$u.vuex('openId', res.openId)
this.$u.vuex('userInfo', userInfo)
this.$u.route({
url: '/pages/index/index',
type: 'tab',
})
})
}
},
})
},
fail: (res) => {
uni.showModal({
title: '用户拒绝授权',
showCancel: false,
})
},
})
},
},
}
</script>
<style>
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.begin-answer {
display: flex;
flex-direction: column;
background-color: #ffffff;
background-size: 100% 920rpx;
background-repeat: no-repeat;
height: 120vh;
position: absolute;
top: 0;
width: 100%;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
.text-area {
display: flex;
justify-content: center;
position: relative;
margin-top: 500rpx;
}
.bottom {
width: 600rpx;
height: 104rpx;
border-radius: 52rpx;
background-color: #2953ff !important;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
.target {
position: relative;
display: flex;
flex-direction: column;
}
.tips {
font-size: 40rpx;
color: #adbdd4;
margin-top: 64rpx;
}
.target-image {
margin: auto;
padding-top: 450rpx;
}
.view-image {
padding-top: 200rpx;
}
</style>
<template>
<view class="begin-answer">
<u-navbar
back-icon-color="#000000"
background="transparent"
title="我的题库"
titleColor="#000000"
:border-bottom="false"
title-bold
></u-navbar>
<view class="content" v-if="lists.length > 0">
<!-- <text class="title">{{ title }}</text> -->
<my-subject
class="subject-item"
v-for="(item, index) in lists"
:key="index"
:time="item.time"
:status="item.status"
:title="item.title"
:subtitle="item.subtitle"
:statusStyle="item.statusStyle"
></my-subject>
</view>
<view class="content" v-else>
<u-image
width="374rpx"
height="322rpx"
:src="nothing"
style="margin-top: 100rpx;"
></u-image>
<text style="margin-top: 20rpx;font-size: 28rpx;color: #9EA5BB;"
>当前暂无题库内容</text
>
</view>
</view>
</template>
<script>
import mySubject from '@/components/my-subject/index.vue'
export default {
components: {
mySubject,
},
data() {
return {
title: '我的题库',
nothing: process.uniEnv.qn_base_url + 'zanwucuoti@3x.png',
lists: [],
}
},
onLoad() {
this.$u.api.getUserQuestionWareHouse().then((res) => {
res = [
{
id: '1415266126815821824',
createTime: '2021-07-14 19:05:14',
createdBy: '1415215255998431232',
updateTime: '2021-07-14 19:05:14',
updatedBy: '1415215255998431232',
echoMap: {
studentId: {
id: '1414459877807357952',
createTime: '2021-07-12 13:41:29',
createdBy: '3',
updateTime: '2021-07-20 20:41:13',
updatedBy: '1414459877807357952',
echoMap: {},
cardCount: null,
consumeAmount: null,
loginTime: null,
unionid: '',
nickname: '',
name: '',
phoneNumber: '11111111111',
avatarPath: '',
identityNumber: '',
identityFrontPath: '',
identityBackPath: '',
certificatePhotoPath: '',
certificateValidityDate: null,
workUnit: '',
address: '',
},
questionWarehouseId: {
id: '1414854649273384960',
createTime: '2021-07-13 15:50:10',
createdBy: '1413688964405002240',
updateTime: '2021-07-22 19:21:00',
updatedBy: '1413688964405002240',
echoMap: {},
institutionId: '1',
subjectId: '1418169087225233408',
title: '测试题库',
subtitle: '大狼狗',
description: 'sad',
effectiveTime: '0',
provinceId: '470715',
cityId: '475286',
type: '1',
price: '100.00',
realPrice: '60.00',
state: true,
remark: '',
version: '0',
},
cardId: {
id: '1416278788987158528',
createTime: '2021-07-17 14:09:11',
createdBy: '1410776147574128640',
updateTime: '2021-07-17 14:09:11',
updatedBy: '1410776147574128640',
echoMap: {},
unitPrice: null,
buyTime: null,
subjectNames: null,
instrtutionId: '1',
studentId: null,
questionWarehouseId: '1',
cardType: '02',
cardNumber: '621001200010719',
cardSecret: '9923sibv',
cardStatus: 5,
isEnable: 1,
effectiveDay: 30,
bindingTime: null,
activationTime: null,
sourceType: {
code: 'INSTRTUTION_SEND',
desc: '机构发卡',
},
sourceOrderId: '1416278788521590784',
},
},
questionWarehouseId: '1414854649273384960',
studentId: '1414459877807357952',
cardId: '1416278788987158528',
},
{
id: '1415602594134360064',
createTime: '2021-07-15 17:41:51',
createdBy: '1415215255998431232',
updateTime: '2021-07-15 17:41:51',
updatedBy: null,
echoMap: {
studentId: {
id: '1414459877807357952',
createTime: '2021-07-12 13:41:29',
createdBy: '3',
updateTime: '2021-07-20 20:41:13',
updatedBy: '1414459877807357952',
echoMap: {},
cardCount: null,
consumeAmount: null,
loginTime: null,
unionid: '',
nickname: '',
name: '',
phoneNumber: '11111111111',
avatarPath: '',
identityNumber: '',
identityFrontPath: '',
identityBackPath: '',
certificatePhotoPath: '',
certificateValidityDate: null,
workUnit: '',
address: '',
},
questionWarehouseId: {
id: '1',
createTime: '2021-07-12 16:33:20',
createdBy: null,
updateTime: '2021-07-21 14:40:44',
updatedBy: '1413688964405002240',
echoMap: {},
institutionId: '1',
subjectId: '1413687160678121472',
title: '测试1',
subtitle: '侧首',
description: '哈哈哈哈',
effectiveTime: '1',
provinceId: '470715',
cityId: '475286',
type: '1',
price: '100.00',
realPrice: '50.00',
state: true,
remark: '123231',
version: null,
},
cardId: {
id: '1416278788987158528',
createTime: '2021-07-17 14:09:11',
createdBy: '1410776147574128640',
updateTime: '2021-07-17 14:09:11',
updatedBy: '1410776147574128640',
echoMap: {},
unitPrice: null,
buyTime: null,
subjectNames: null,
instrtutionId: '1',
studentId: null,
questionWarehouseId: '1',
cardType: '02',
cardNumber: '621001200010719',
cardSecret: '9923sibv',
cardStatus: 15,
isEnable: 1,
effectiveDay: 30,
bindingTime: null,
activationTime: null,
sourceType: {
code: 'INSTRTUTION_SEND',
desc: '机构发卡',
},
sourceOrderId: '1416278788521590784',
},
},
questionWarehouseId: '1',
studentId: '1414459877807357952',
cardId: '1416278788987158528',
},
]
let length = res.length
if (res.length <= 0) {
this.lists = []
}
let data = []
for (let i = 0; i < length; i++) {
data[i] = {}
if (
!res[i].echoMap ||
!res[i].echoMap.questionWarehouseId ||
!res[i].echoMap.cardId
) {
continue
}
//绑卡或支付时间
data[i].title = res[i].echoMap.questionWarehouseId.title
data[i].subtitle = res[i].echoMap.questionWarehouseId.subtitle
data[i].time =
res[i].echoMap.cardId.bindingTime ||
res[i].echoMap.cardId.buyTime ||
''
let status = ''
switch (res[i].echoMap.cardId.cardStatus) {
case 0:
status = '未绑定'
data[i].statusStyle = { color: '#9EA5BB' }
break
case 5:
status = '已绑定'
data[i].statusStyle = { color: '#2953FF' }
break
case 10:
status = '已激活'
data[i].statusStyle = { color: '#2953FF' }
break
case 15:
status = '已失效'
data[i].statusStyle = { color: '#9EA5BB' }
break
default:
break
}
data[i].status = status
}
this.lists = data
console.log(data)
})
},
}
</script>
<style scoped lang="scss">
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
page {
background-color: #f7f9fc;
}
.begin-answer {
display: flex;
flex-direction: column;
background-image: linear-gradient(to top, #f7f9fc 0%, #e9f3ff 20%);
background-color: #f7f9fc;
background-size: 100% 920rpx;
background-repeat: no-repeat;
height: 120vh;
position: absolute;
top: 0;
width: 100%;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 30rpx;
}
.subject-item {
width: 100%;
margin-bottom: 30rpx;
}
.logo {
height: 200rpx;
width: 200rpx;
margin: 200rpx auto 50rpx auto;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
font-weight: bold;
}
.content ::v-deep .u-flex {
border-radius: 12rpx;
}
.content ::v-deep .my-details {
background-color: #ffffff !important;
}
.content ::v-deep .my-details .bottom {
padding: 0rpx 20rpx 30rpx 20rpx;
.title {
font-weight: bold;
}
}
</style>
<template>
<view class="begin-answer">
<u-navbar
back-icon-color="#000000"
background="transparent"
title="实名认证"
titleColor="#000000"
:border-bottom="false"
title-bold
></u-navbar>
<view class="content">
<u-cell-group :border="false">
<u-cell-item :arrow="false" :hover-class="none">
<view slot="label" class="tips">
<text class="line-1"
>请上传您的:<text class="name">身份证</text>
</text>
<text class="line-2">请按照下面提示依次点击上传身份证正反面</text>
<view class="upload-image">
<image
class="cert-image"
:src="certFront"
lazy-load="false"
binderror=""
bindload=""
@click="getFront"
/>
<image
class="cert-image"
:src="certBack"
lazy-load="false"
binderror=""
bindload=""
@click="getBack"
/>
</view>
</view>
</u-cell-item>
<u-cell-item
:arrow="false"
:hover-class="none"
title="姓名"
:value="name"
:title-style="certTitleStyle"
:value-style="certValueStyle"
></u-cell-item>
<u-cell-item
:arrow="false"
:hover-class="none"
title="身份证号"
:value="getIdCardNum"
:title-style="certTitleStyle"
:value-style="certValueStyle"
></u-cell-item>
<u-cell-item
:arrow="false"
:hover-class="none"
title="有效期"
:value="expire"
:title-style="certTitleStyle"
:value-style="certValueStyle"
></u-cell-item>
<u-cell-item :arrow="false" :hover-class="none">
<view slot="label" style="display:flex;flex-direction: column;">
<button class="sub-input" @click="submit">确定</button>
</view>
</u-cell-item>
</u-cell-group>
</view>
</view>
</template>
<script>
import upload from '@/common/upload'
export default {
data() {
return {
student: {},
token: '',
}
},
computed: {
certTitleStyle() {
return {
width: '115rpx',
}
},
certValueStyle() {
return {
'padding-left': '136rpx',
color: '#191C27',
'font-weight': 'bold',
'text-align': 'left',
}
},
certFront() {
return this.student.identityFrontPath
? process.uniEnv.qn_asset_url + this.student.identityFrontPath
: process.uniEnv.qn_base_url + 'shangchuanzhaopianfront@3x.png'
},
certBack() {
return this.student.identityBackPath
? process.uniEnv.qn_asset_url + this.student.identityBackPath
: process.uniEnv.qn_base_url + 'shangchuanzhaopianback@3x.png'
},
name() {
return this.student.name || ''
},
expire() {
return this.student.certificateValidityDate || ''
},
getIdCardNum() {
return this.student.identityNumber || ''
},
},
onLoad() {
this.student = getApp().globalData.student
this.token = getApp().globalData.qiNiuToken
},
methods: {
submit() {
if (
!this.student.identityNumber ||
!this.student.certificateValidityDate
) {
this.$u.toast('请上传身份证正反面信息')
return
}
this.$u.api
.updateUserInfo({
identityFrontPath: this.student.identityFrontPath,
identityBackPath: this.student.identityBackPath,
identityNumber: this.student.identityNumber,
certificateValidityDate: this.student.certificateValidityDate,
name: this.student.name,
})
.then((res) => {
this.$u.toast('认证成功')
this.student.isCertify = true
setTimeout(() => {
this.$u.route({
type: 'back',
})
}, 1500)
})
},
getFront() {
//身份证正面图片识别
upload.getPhoto(1, this.token).then((res) => {
this.student.identityFrontPath = res.key
this.$u.api
.checkIdCardFront({ id_card_front: res.key })
.then(() => {})
.catch((data) => {
if (data.errMsg == 'request:ok') {
this.student.name = data.data.id_card_name
this.student.identityNumber = data.data.id_card_number
} else {
this.$u.toast('识别身份证信息错误')
}
})
})
},
getBack() {
//身份证反面图片识别
upload.getPhoto(1, this.token).then((res) => {
this.student.identityBackPath = res.key
this.$u.api
.checkIdCardBack({ id_card_back: res.key })
.then(() => {})
.catch((data) => {
if (data.errMsg == 'request:ok') {
this.student.certificateValidityDate = data.data.id_card_expire
} else {
this.$u.toast('识别身份证信息错误')
}
})
})
},
},
}
</script>
<style scoped lang="scss">
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
page {
background-color: #f7f9fc;
}
.begin-answer {
display: flex;
flex-direction: column;
background-image: linear-gradient(to top, #f7f9fc 0%, #e9f3ff 40%);
background-color: #f7f9fc;
background-size: 100% 920rpx;
background-repeat: no-repeat;
height: 120vh;
position: absolute;
top: 0;
width: 100%;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
}
.upload-image {
padding: 0 28rpx;
}
.cert-image {
width: 630rpx;
height: 400rpx;
}
.tips {
display: flex;
flex-direction: column;
.line-1 {
font-size: 32rpx;
color: #191c27;
font-weight: bold;
.name {
color: #2953ff;
}
}
.line-2 {
font-size: 24rpx;
color: #5a6073;
padding: 30rpx 0;
}
}
.content ::v-deep .u-cell-item-box {
background: none !important;
}
.sub-input {
margin-top: 26rpx;
width: 702rpx;
height: 104rpx;
border-radius: 52rpx;
border: hidden;
background-color: #2953ff;
color: white;
font-size: 32rpx;
font-weight: bold;
line-height: 104rpx;
}
</style>
<template>
<view class="begin-answer">
<u-navbar
back-icon-color="#000000"
background="transparent"
title="工作单位"
titleColor="#000000"
:border-bottom="false"
title-bold
></u-navbar>
<view class="content">
<view class="company-title">工作单位名称</view>
<view class="input-view">
<input
class="company-input"
type="text"
placeholder="请填写"
v-model="student.workUnit"
/>
</view>
<button @click="submit" class="sub-input">提交</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
student: {
workUnit: '',
},
}
},
computed: {},
onLoad() {
this.student = getApp().globalData.student
},
methods: {
submit() {
if (this.student.workUnit == '') {
this.$u.toast('请输入工作单位名称')
return
}
this.$u.api
.updateUserInfo({
workUnit: this.student.workUnit,
})
.then((res) => {
this.$u.toast('保存成功')
setTimeout(() => {
this.$u.route({
type: 'back',
})
}, 1500)
})
},
},
}
</script>
<style scoped lang="scss">
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
page {
background-color: #f7f9fc;
}
.begin-answer {
display: flex;
flex-direction: column;
background-image: linear-gradient(to top, #f7f9fc 0%, #e9f3ff 40%);
background-color: #f7f9fc;
background-size: 100% 920rpx;
background-repeat: no-repeat;
height: 100vh;
position: absolute;
top: 0;
width: 100%;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
padding: 0 30rpx;
}
.company-title {
width: 100%;
height: 60rpx;
padding-top: 30rpx;
margin-bottom: 30rpx;
font-size: 32rpx;
font-weight: bold;
}
.company-input {
height: 104rpx;
border-radius: 12rpx;
padding-left: 24rpx;
background-color: white;
}
.input-view {
width: 100%;
}
.sub-input {
margin-top: 432rpx;
width: 702rpx;
height: 104rpx;
border-radius: 52rpx;
border: hidden;
background-color: #2953ff;
color: white;
font-size: 32rpx;
font-weight: bold;
line-height: 104rpx;
}
</style>
<template>
<view class="begin-answer">
<u-navbar
back-icon-color="#ffffff"
background="transparent"
title="联系客服"
titleColor="#ffffff"
:border-bottom="false"
title-bold
></u-navbar>
<view class="content">
<view class="kf-body">
<view class="kf-image">
<u-image width="436rpx" height="436rpx" :src="erweima"></u-image>
</view>
<view class="tips">
长按识别二维码添加官方客服
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
erweima: process.uniEnv.qn_base_url + 'kefuerweima@3x.png',
}
},
}
</script>
<style scoped lang="scss">
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
.begin-answer {
display: flex;
flex-direction: column;
background-color: #2953ff;
background-size: 100% 920rpx;
background-repeat: no-repeat;
height: 120vh;
position: absolute;
top: 0;
width: 100%;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
padding: 130rpx 24rpx 0rpx 24rpx;
}
.kf-body {
width: 100%;
height: 880rpx;
background-color: aliceblue;
text-align: center;
border-radius: 12rpx;
}
.kf-image {
margin-left: 132rpx;
margin-top: 160rpx;
}
.tips {
color: #5a6073;
font-size: 28rpx;
margin-top: 114rpx;
}
</style>
<template>
<view class="begin-answer">
<u-navbar
back-icon-color="#000000"
background="transparent"
title="我的信息"
titleColor="#000000"
:border-bottom="false"
title-bold
></u-navbar>
<view class="content">
<u-cell-group
style="width: 100%;"
:class="{ 'background-none': true }"
:border="false"
>
<u-cell-item title="头像" @click="changeHead">
<view slot="right-icon">
<u-image
width="92"
height="92"
:src="headPhoto"
shape="circle"
></u-image>
</view>
</u-cell-item>
<u-cell-item title="证件照" @click="changeCertPhoto">
<view slot="right-icon">
<u-image
v-if="isupLoadCertPhoto"
width="92rpx"
height="120rpx"
:src="headCertPhoto"
></u-image>
<text v-else style="color:blue;">未上传</text>
</view>
</u-cell-item>
<u-cell-item title="手机号" :arrow="false" :hover-class="none">
<view slot="right-icon">
<button
hover-class="none"
class="mobile-button"
open-type="getPhoneNumber"
@getphonenumber="getPhonenumber"
>
{{ getMobile }}
</button>
</view>
</u-cell-item>
<u-cell-item
title="实名认证"
title-style="{'font':'bold','font-size':'40rpx'}"
:value="getCertifyStatus"
@click="goCertify"
>
</u-cell-item>
<u-cell-item
title="工作单位"
:value="getCompany"
@click="goCompany"
></u-cell-item>
</u-cell-group>
</view>
</view>
</template>
<script>
import upload from '@/common/upload'
import login from '@/common/login'
export default {
data() {
return {
student: {},
token: null,
code: '',
}
},
computed: {
headPhoto() {
return this.student.avatarPath || this.userInfo.avatarUrl
},
headCertPhoto() {
return (
this.student.certificatePhotoPath ||
process.uniEnv.qn_base_url + 'xitongtouxiang.png'
)
},
isupLoadCertPhoto() {
return this.student.identityNumber || false
},
getMobile() {
return this.student.phoneNumber || ''
},
getCompany() {
return this.student.workUnit || ''
},
getCertifyStatus() {
return !this.student.isCertify ? '去认证' : '已认证'
},
},
onLoad() {
this.$u.api.getQiNiuToken({ type: 'image' }).catch((data) => {
if (data.errMsg == 'request:ok') {
this.token = data.data.token //token为七牛云的token一般由后台接口提供
getApp().globalData.qiNiuToken = data.data.token
} else {
this.$u.toast('获取token失败')
}
})
this.$u.api.getUserInfo().then((res) => {
res.isCertify = res.identityNumber ? true : false
this.student = res
})
},
onShow() {
console.log('iddd', this.student)
console.log('iddd global', getApp().globalData.student)
},
methods: {
goCertify() {
getApp().globalData.student = this.student
this.$u.route({
url: 'pages/mine/certify',
})
},
goCompany() {
getApp().globalData.student = this.student
this.$u.route({
url: 'pages/mine/company',
})
},
getPhonenumber(e) {
var that = this
login.appLogin().then((res) => {
that.code = res.code
var code = that.code
if (e && e.detail) {
if (e.detail.errMsg.indexOf('user deny') > -1) {
//拒绝授权
} else if (e.detail.encryptedData && e.detail.iv) {
//允许授权-解析-更新手机号
let params = {
encryptedData: e.detail.encryptedData,
iv: e.detail.iv,
}
uni.checkSession({
success(ccc) {
//session_key 未过期,并且在本生命周期一直有效
params.code = code
that.$u.api.loginWechatAuth(params).then((res) => {
that.student.phoneNumber = res.phoneNumber
that.$u.api.updateUserInfo({
phoneNumber: res.phoneNumber,
})
})
},
fail() {
// session_key 已经失效,需要重新执行登录流程
that.toLogin()
},
})
} else {
this.$u.toast(e.detail.errMsg)
}
} else {
this.$u.toast('授权失败,请重新授权')
}
})
},
toLogin() {
uni.navigateTo({
url: 'pages/login/index',
})
},
changeHead() {
//获取图片
upload.getPhoto(2, this.token).then((res) => {
this.student.avatarPath = process.uniEnv.qn_asset_url + res.key
this.$u.api.updateUserInfo({
avatarPath: this.student.avatarPath,
})
})
},
changeCertPhoto() {
//获取图片
upload.getPhoto(2, this.token).then((res) => {
//显示
this.student.certificatePhotoPath =
process.uniEnv.qn_asset_url + res.key
this.$u.api.updateUserInfo({
certificatePhotoPath: this.student.certificatePhotoPath,
})
})
},
toUrl(url) {
this.$u.route({
url: url,
})
},
},
}
</script>
<style scoped lang="scss">
::-webkit-scrollbar {
width: 0;
height: 0;
color: transparent;
display: none;
}
page {
background-color: #f7f9fc;
}
.begin-answer {
display: flex;
flex-direction: column;
background-image: linear-gradient(to top, #f7f9fc 0%, #e9f3ff 40%);
background-color: #f7f9fc;
background-size: 100% 920rpx;
background-repeat: no-repeat;
height: 100vh;
position: absolute;
top: 0;
width: 100%;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
padding: 0 30rpx;
}
.logo {
height: 200rpx;
width: 200rpx;
margin: 200rpx auto 50rpx auto;
}
.text-area {
display: flex;
justify-content: center;
}
.title {
font-size: 36rpx;
color: #8f8f94;
}
.cell-item {
display: flex;
}
.cert-image {
width: 300rpx;
height: 300rpx;
}
.upload-image {
margin-top: 30rpx;
}
.mobile-button {
width: 115px;
background: none;
font-size: 28rpx;
}
button::after {
border: none;
background-color: none;
}
.content ::v-deep .u-cell-item-box {
background: none !important;
}
.content ::v-deep .u-cell {
padding: 26rpx 0rpx;
border-color: #e8ebf3;
border-style: solid;
border-bottom-width: 2rpx;
border-left-width: 0;
border-right-width: 0;
border-top-width: 0;
}
.content ::v-deep .u-cell__value {
color: #191c27;
}
</style>
<template>
<view class="content">
<u-cell-group class="cell-group" :border="false">
<u-cell-item
title="版本更新"
value="当前版本v1.1.0"
:border-bottom="false"
></u-cell-item>
</u-cell-group>
<view class="logout" @tap="logout">退出登录</view>
</view>
</template>
<script>
export default {
data() {
return {}
},
computed: {},
onLoad() {},
methods: {
logout() {
this.$u.vuex('vuex_token', '')
this.$u.vuex('openId', '')
this.$u.vuex('userInfo', {})
setTimeout(() => {
this.$u.route({
type: 'back',
})
}, 1000)
},
},
}
</script>
<style>
page {
background-color: #f7f9fc;
}
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 100%;
}
.cell-group {
width: 100%;
margin-top: 20rpx;
}
.logout {
width: 100%;
height: 100rpx;
margin-top: 16rpx;
background-color: white;
text-align: center;
line-height: 100rpx;
color: #fa5a49;
font-size: 32rp;
}
</style>
<template>
<view class="u-flex search">
<u-navbar
back-icon-color="#333333"
background="transparent"
title=" "
titleColor="#191C27"
:border-bottom="false"
title-bold
></u-navbar>
<view class="search-bar">
<u-search
:clearabled="true"
:action-style="searchStyle"
bg-color="#fff"
v-model="keyword"
:show-action="false"
@custom="search"
@search="search"
></u-search>
</view>
<view v-if="lists.length > 0">
<view class="title"
>共找到含有<text>“{{ keyword }}”</text>相关试题<text>{{ count }}</text>道</view
>
<view class="result">
<u-collapse :item-style="itemStyle" event-type="close">
<uni-list :border="false">
<u-collapse-item
:ref="`collapse${index}`"
:index="index"
@change="itemChange"
v-for="(item, index) in lists"
:key="index"
>
<view slot="title-all" :class="['u-flex','head', {'selected': index === arrIndex}]">
<view class="titles">
<text>{{ item.type }}</text
>{{ item.title }}
</view>
<view class="u-flex arrow" v-show="index !== arrIndex">
<text>展开</text>
<u-icon name="arrow-down" color="#9EA5BB"></u-icon>
</view>
</view>
<view class="u-flex subject">
<view class="content">
<answer-sheet
ref="answerSheet"
:answerList="item.answerList"
:rightKey="item.rightKey"
:multiple="item.type === 3"
:submitStatus="item.submitStatus"
:btnStatus="false"
@change="answerChange"
></answer-sheet>
</view>
<view class="explain">
<answer-explanation
:answer="item.answer"
:explain="item.explain"
></answer-explanation>
</view>
</view>
<view class="u-flex opera">
<view class="opera-list" @click="collection(item)">
<u-icon v-show="!collectionFlag" name="star" color="#5A6073" size="40"></u-icon>
<u-icon v-show="collectionFlag" name="star-fill" color="#FF930D" size="40"></u-icon>
<text>{{ collectionFlag ? '已收藏' : '收藏' }}</text>
</view>
<view class="opera-list" @click="arrowUp(index)">
<text>收起</text>
<u-icon name="arrow-up" color="#9EA5BB"></u-icon>
</view>
</view>
</u-collapse-item>
</uni-list>
</u-collapse>
</view>
</view>
<view class="u-flex default" v-if="count === 0">
<view>
<image :src="defaultImg" />
</view>
<view class="no-result">
当前暂无搜索结果
</view>
</view>
</view>
</template>
<script>
import answerSheet from '@/components/answer-sheet/index.vue'
import answerExplanation from '@/components/answer-explanation/index.vue'
import uniList from '@/components/uni-list/uni-list.vue'
export default {
components: {
answerSheet,
answerExplanation,
uniList
},
data() {
return {
itemStyle: {
background: '#fff',
padding: '0rpx 20rpx',
margin: '10rpx 0',
'border-radius': '30rpx 30rpx 0 0'
},
keyword: '',
lists: [],
arrIndex: null,
}
},
onLoad(e) {
this.keyword = e ? decodeURIComponent(e.keyword) : ''
this.init()
},
computed: {
defaultImg() {
return process.uniEnv.qn_base_url + 'no-search.png'
},
count() {
return this.lists.length
},
collectionFlag() {
const info = this.lists.find(v => v.index === this.arrIndex)
return info ? info.collectionFlag : false
}
},
methods: {
init() {
const data = {
questionWarehouseId: this.questionWarehouseId,
keyWord: this.keyword
}
uni.showLoading({
title: '加载中'
})
this.$u.api.searchQuestion(data).then(res => {
uni.hideLoading()
this.lists = res.length > 0 ? res.map((v, i) => {
const rightKey = v.answer.split(',')
const content = JSON.parse(v.content)
const answerList = content.choiceList.map(item => {
return {
sort: item.value,
text: item.label,
checked: rightKey.includes(item.value),
confirm: rightKey.includes(item.value)
}
})
return {
id: v.id,
index: i,
answer: v.answer,
title: content.title,
type: v.echoMap.questionTypeId,
answerList: answerList,
explain: v.analysis,
rightKey: rightKey,
collectionFlag: v.collectionFlag,
submitStatus: true
}
}) : []
})
},
itemChange(e) {
this.arrIndex = e.show ? e.index : null
},
search(val) {
this.keyword = val
let history = this.searchHistory
history.unshift(val)
if (history.length > 9) {
history.splice(9, 1)
}
this.$u.vuex('searchHistory', history)
},
collection(item) {
const action = item.collectionFlag ? 'removeCollection' : 'joinCollection'
this.$u.api[action]({questionId: item.id}).then(res => {
if(res) item.collectionFlag = !item.collectionFlag
})
},
arrowUp(index) {
this.$refs[`collapse${index}`][0].headClick()
}
},
}
</script>
<style lang="scss" scoped>
.search {
height: 100vh;
flex-direction: column;
background-color: #f8fafd;
background-image: linear-gradient(to top, #f8fafd 0%, #e9f3ff 50%);
background-size: 100% 520rpx;
background-repeat: no-repeat;
.search-bar {
width: 100%;
padding: 0 20rpx;
}
.title {
width: 100%;
color: #191c27;
font-size: 32rpx;
font-weight: bold;
margin-top: 30rpx;
padding: 0 20rpx;
text {
color: #2953ff;
}
}
.result {
margin-top: 30rpx;
width: 100%;
.head {
width: 100%;
height: 60rpx;
overflow: hidden;
.titles {
color: #191c27;
font-size: 32rpx;
line-height: 50rpx;
font-weight: bold;
flex: 1;
height: 60rpx;
overflow: hidden;
text {
background: #9ea5bb;
color: #fff;
padding: 8rpx 20rpx;
margin-right: 10rpx;
font-size: 20rpx;
border-radius: 50rpx 0 50rpx 50rpx;
}
}
.arrow {
padding-left: 20rpx;
text {
color: #2953ff;
font-size: 28rpx;
padding-right: 10rpx;
}
}
}
.selected {
height: auto;
overflow: auto;
.titles {
height: auto;
overflow: auto;
}
}
.subject {
flex-flow: column;
.type {
width: 100%;
text-align: left;
padding: 20rpx 0;
}
.content {
width: 100%;
}
.explain,
.btn {
width: 100%;
padding-top: 50rpx;
}
}
.opera {
padding: 30rpx 0;
justify-content: space-between;
color: #5a6073;
font-size: 28rpx;
.opera-list {
display: flex;
&:nth-of-type(1) {
text {
padding-left: 10rpx;
}
}
&:nth-of-type(2) {
text {
padding-right: 10rpx;
color: #2953ff;
}
}
}
}
}
.default {
flex-flow: column;
flex: 1;
justify-content: center;
.no-result {
color: #9EA5BB;
font-size: 28rpx;
}
}
}
</style>
<template>
<view class="search">
<u-navbar
back-icon-color="#333333"
background="transparent"
title=" "
titleColor="#191C27"
:border-bottom="false"
title-bold
></u-navbar>
<view class="search-bar">
<u-search
:clearabled="true"
:action-style="searchStyle"
bg-color="#fff"
v-model="keyword"
@custom="search"
@search="search"
></u-search>
</view>
<view class="title">搜索历史</view>
<view class="u-flex history">
<view
class="history-list"
v-for="(item, index) in history"
:key="index"
@click="toSearchDetail(item)"
>{{ item }}</view
>
</view>
<view class="u-flex clear" @click="removeHistory">
<image :src="deleteImg"></image>
<view>清空搜索历史记录</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
keyword: '',
history: [],
}
},
computed: {
searchStyle() {
return {
color: '#2272FF',
}
},
deleteImg() {
return process.uniEnv.qn_base_url + 'delete.png'
},
},
created() {
this.history = this.searchHistory
},
methods: {
search(val) {
this.keyword = val
this.history.unshift(val)
if(this.history.length > 9){
this.history.splice(9, 1)
}
this.$u.vuex('searchHistory', this.history)
this.toSearchDetail(val)
},
toSearchDetail(keyword) {
this.$u.route({
url: 'pages/search/detail',
params: {
keyword: keyword
}
})
},
removeHistory() {
uni.showModal({
title: '提示',
content: '确认要清空搜索历史记录?',
success: (res) => {
if (res.confirm) {
this.history = []
this.$u.vuex('searchHistory', [])
}
},
})
},
},
}
</script>
<style lang="scss" scoped>
.search {
height: 100vh;
flex-direction: column;
background-color: #f8fafd;
background-image: linear-gradient(to top, #f8fafd 0%, #e9f3ff 50%);
background-size: 100% 520rpx;
background-repeat: no-repeat;
padding: 0 20rpx;
.title {
color: #191c27;
font-size: 32rpx;
font-weight: bold;
margin-top: 30rpx;
}
.history {
margin-top: 20rpx;
flex-wrap: wrap;
.history-list {
padding: 20rpx 25rpx;
background: #fff;
color: #5a6073;
margin: 10rpx 20rpx 10rpx 0;
font-size: 26rpx;
border-radius: 10rpx;
}
}
.clear {
margin-top: 30rpx;
justify-content: center;
image {
width: 28rpx;
height: 32rpx;
padding-right: 10rpx;
}
}
}
</style>
import { RouterMount, createRouter } from 'uni-simple-router'
import store from '@/store/index.js'
const router = createRouter({
platform: process.env.VUE_APP_PLATFORM,
routes: [...ROUTES],
})
// 检测登录白名单,无需登录也可访问的页面
const whiteList = ['index', 'cert', 'mine', 'login', 'learnScore']
// 全局路由前置守卫
router.beforeEach((to, from, next) => {
const token = store.state.vuex_token
// 进入需要授权的页面,未登录跳转
if (!whiteList.includes(to.name) && !token) {
next({ name: 'login', NAVTYPE: 'push' })
}
next()
})
// 全局路由后置守卫
router.afterEach((to, from) => {
console.log('跳转结束')
})
export { router, RouterMount }
...@@ -2,63 +2,80 @@ import Vue from 'vue' ...@@ -2,63 +2,80 @@ import Vue from 'vue'
import Vuex from 'vuex' import Vuex from 'vuex'
Vue.use(Vuex) Vue.use(Vuex)
let lifeData = {}; let lifeData = {}
try{ try {
// 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的 // 尝试获取本地是否存在lifeData变量,第一次启动APP时是不存在的
lifeData = uni.getStorageSync('lifeData'); lifeData = uni.getStorageSync('lifeData')
}catch(e){ } catch (e) {}
}
// 需要永久存储,且下次APP启动需要取出的,在state中的变量名 // 需要永久存储,且下次APP启动需要取出的,在state中的变量名
let saveStateKeys = ['vuex_user', 'vuex_token']; let saveStateKeys = [
'userInfo',
'vuex_token',
'openId',
'searchHistory',
'questionList',
'lastIndex',
'tipStatus',
'questionWarehouseId',
'relationId', // 绑卡用
]
// 保存变量到本地存储中 // 保存变量到本地存储中
const saveLifeData = function(key, value){ const saveLifeData = function(key, value) {
// 判断变量名是否在需要存储的数组中 // 判断变量名是否在需要存储的数组中
if(saveStateKeys.indexOf(key) != -1) { if (saveStateKeys.indexOf(key) != -1) {
// 获取本地存储的lifeData对象,将变量添加到对象中 // 获取本地存储的lifeData对象,将变量添加到对象中
let tmp = uni.getStorageSync('lifeData'); let tmp = uni.getStorageSync('lifeData')
// 第一次打开APP,不存在lifeData变量,故放一个{}空对象 // 第一次打开APP,不存在lifeData变量,故放一个{}空对象
tmp = tmp ? tmp : {}; tmp = tmp ? tmp : {}
tmp[key] = value; tmp[key] = value
// 执行这一步后,所有需要存储的变量,都挂载在本地的lifeData对象中 // 执行这一步后,所有需要存储的变量,都挂载在本地的lifeData对象中
uni.setStorageSync('lifeData', tmp); uni.setStorageSync('lifeData', tmp)
} }
} }
const store = new Vuex.Store({ const store = new Vuex.Store({
// 下面这些值仅为示例,使用过程中请删除 // 下面这些值仅为示例,使用过程中请删除
state: { state: {
// 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量 // 如果上面从本地获取的lifeData对象下有对应的属性,就赋值给state中对应的变量
// 加上vuex_前缀,是防止变量名冲突,也让人一目了然 // 加上vuex_前缀,是防止变量名冲突,也让人一目了然
vuex_user: lifeData.vuex_user ? lifeData.vuex_user : {name: '明月'}, userInfo: lifeData.userInfo ? lifeData.userInfo : {},
vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '', vuex_token: lifeData.vuex_token ? lifeData.vuex_token : '',
// 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式 openId: lifeData.openId ? lifeData.openId : '',
vuex_version: '1.0.1', relationId: lifeData.relationId ? lifeData.relationId : '', // 绑卡用
}, searchHistory: lifeData.searchHistory ? lifeData.searchHistory : [], // 搜索历史记录
mutations: { questionList: lifeData.questionList ? lifeData.questionList : {}, // 练习列表
$uStore(state, payload) { lastIndex: lifeData.lastIndex ? lifeData.lastIndex : {}, // 上次做到第几题
// 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1 tipStatus: lifeData.tipStatus ? lifeData.tipStatus : false, // 滑动提示
let nameArr = payload.name.split('.'); questionWarehouseId: lifeData.questionWarehouseId
let saveKey = ''; ? lifeData.questionWarehouseId
let len = nameArr.length; : '1414854649273384960', // 科目ID
if(nameArr.length >= 2) { // 如果vuex_version无需保存到本地永久存储,无需lifeData.vuex_version方式
let obj = state[nameArr[0]]; vuex_version: '1.0.0',
for(let i = 1; i < len - 1; i ++) { },
obj = obj[nameArr[i]]; mutations: {
} $uStore(state, payload) {
obj[nameArr[len - 1]] = payload.value; // 判断是否多层级调用,state中为对象存在的情况,诸如user.info.score = 1
saveKey = nameArr[0]; let nameArr = payload.name.split('.')
} else { let saveKey = ''
// 单层级变量,在state就是一个普通变量的情况 let len = nameArr.length
state[payload.name] = payload.value; if (nameArr.length >= 2) {
saveKey = payload.name; let obj = state[nameArr[0]]
} for (let i = 1; i < len - 1; i++) {
// 保存变量到本地,见顶部函数定义 obj = obj[nameArr[i]]
saveLifeData(saveKey, state[saveKey]) }
} obj[nameArr[len - 1]] = payload.value
} saveKey = nameArr[0]
} else {
// 单层级变量,在state就是一个普通变量的情况
state[payload.name] = payload.value
saveKey = payload.name
}
// 保存变量到本地,见顶部函数定义
saveLifeData(saveKey, state[saveKey])
},
},
}) })
export default store export default store
\ No newline at end of file
<template> <template>
<view class="u-cell-box"> <view class="u-cell-box">
<view class="u-cell-title" v-if="title" :style="[titleStyle]"> <view class="u-cell-title" v-if="title" :style="[titleStyle]">
{{title}} {{ title }}
</view> </view>
<view class="u-cell-item-box" :class="{'u-border-bottom u-border-top': border}"> <view
<slot /> class="u-cell-item-box"
</view> :class="{ 'u-border-bottom u-border-top': border }"
</view> >
<slot />
</view>
</view>
</template> </template>
<script> <script>
/** /**
* cellGroup 单元格父组件Group * cellGroup 单元格父组件Group
* @description cell单元格一般用于一组列表的情况,比如个人中心页,设置页等。搭配u-cell-item * @description cell单元格一般用于一组列表的情况,比如个人中心页,设置页等。搭配u-cell-item
* @tutorial https://www.uviewui.com/components/cell.html * @tutorial https://www.uviewui.com/components/cell.html
* @property {String} title 分组标题 * @property {String} title 分组标题
* @property {Boolean} border 是否显示外边框(默认true) * @property {Boolean} border 是否显示外边框(默认true)
* @property {Object} title-style 分组标题的的样式,对象形式,如{'font-size': '24rpx'} 或 {'fontSize': '24rpx'} * @property {Object} title-style 分组标题的的样式,对象形式,如{'font-size': '24rpx'} 或 {'fontSize': '24rpx'}
* @example <u-cell-group title="设置喜好"> * @example <u-cell-group title="设置喜好">
*/ */
export default { export default {
name: "u-cell-group", name: 'u-cell-group',
props: { props: {
// 分组标题 // 分组标题
title: { title: {
type: String, type: String,
default: '' default: '',
}, },
// 是否显示分组list上下边框 // 是否显示分组list上下边框
border: { border: {
type: Boolean, type: Boolean,
default: true default: true,
}, },
// 分组标题的样式,对象形式,注意驼峰属性写法 // 分组标题的样式,对象形式,注意驼峰属性写法
// 类似 {'font-size': '24rpx'} 和 {'fontSize': '24rpx'} // 类似 {'font-size': '24rpx'} 和 {'fontSize': '24rpx'}
titleStyle: { titleStyle: {
type: Object, type: Object,
default () { default() {
return {}; return {}
} },
} },
}, },
data() { data() {
return { return {
index: 0, index: 0,
} }
}, },
} }
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
@import "../../libs/css/style.components.scss"; @import '../../libs/css/style.components.scss';
.u-cell-box {
width: 100%;
}
.u-cell-title { .u-cell-box {
padding: 30rpx 32rpx 10rpx 32rpx; width: 100%;
font-size: 30rpx; }
text-align: left;
color: $u-tips-color;
}
.u-cell-item-box { .u-cell-title {
background-color: #FFFFFF; padding: 30rpx 32rpx 10rpx 32rpx;
flex-direction: row; font-size: 30rpx;
} text-align: left;
color: $u-tips-color;
}
.u-cell-item-box {
background-color: #ffffff;
flex-direction: row;
}
</style> </style>
const TransformPages = require('uni-read-pages')
const {webpack} = new TransformPages()
module.exports = {
configureWebpack: {
plugins: [
new webpack.DefinePlugin({
ROUTES: webpack.DefinePlugin.runtimeValue(() => {
const tfPages = new TransformPages({
includes: ['path', 'name', 'aliasPath']
});
return JSON.stringify(tfPages.routes)
}, true )
})
]
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment