Commit 4023e7e7 authored by Facius's avatar Facius

Merge branch 'dev-v1.0.0' into test

parents b0cb18ff e0e0f649
const UNI_APP = {
apiUrl: 'http://192.168.1.22',
qn_base_url: 'https://qn-static.banshouhui.com/study/',
argoDebugMode: 1,
version: 'v1.0.0'
apiUrl: 'http://192.168.0.204:8760',
qn_base_url: 'https://qn-static.banshouhui.com/study/',
qn_asset_url: 'http://deudn.c.pp.cc/',
uCenterUrl: 'http://192.168.0.5:8093/', //'http://rest-u.yunya.com/'
argoDebugMode: 1,
version: 'v1.0.0',
}
module.exports = UNI_APP
(function () {
let NODE_ENV = 'test'; // dev:开发环境 | test:测试环境 | prod:生产环境
let ENV_VAR = null;
if (process.env.NODE_ENV === "development") {
if (NODE_ENV === 'dev') {
ENV_VAR = require('./.env.dev.js');
} else if (NODE_ENV === 'test') {
ENV_VAR = require('./.env.test.js');
} else if (NODE_ENV === 'prod') {
ENV_VAR = require('./.env.prod.js');
}
} else if (process.env.NODE_ENV === "production") {
if (NODE_ENV === 'test') {
ENV_VAR = require('./.env.test.js');
} else if (NODE_ENV === 'prod') {
ENV_VAR = require('./.env.prod.js');
}
}
if (ENV_VAR) {
process.uniEnv = {};
process.uniEnv['node_env'] = NODE_ENV;
for (let key in ENV_VAR) {
process.uniEnv[key] = ENV_VAR[key];
}
}
})();
;(function() {
let NODE_ENV = 'test' // dev:开发环境 | test:测试环境 | prod:生产环境
let ENV_VAR = null
if (process.env.NODE_ENV === 'development') {
if (NODE_ENV === 'dev') {
ENV_VAR = require('./.env.dev.js')
} else if (NODE_ENV === 'test') {
ENV_VAR = require('./.env.test.js')
} else if (NODE_ENV === 'prod') {
ENV_VAR = require('./.env.prod.js')
}
} else if (process.env.NODE_ENV === 'production') {
if (NODE_ENV === 'test') {
ENV_VAR = require('./.env.test.js')
} else if (NODE_ENV === 'prod') {
ENV_VAR = require('./.env.prod.js')
}
}
ENV_VAR['bmapAK'] = 'lF1HoyXdiv4uZx6TrGQEZs48F5y8kEHI'
ENV_VAR['qn_base_url'] = 'https://qn-static.banshouhui.com/study/'
if (ENV_VAR) {
process.uniEnv = {}
process.uniEnv['node_env'] = NODE_ENV
for (let key in ENV_VAR) {
process.uniEnv[key] = ENV_VAR[key]
}
}
})()
const UNI_APP = {
apiUrl: 'https://system.banshouhui.com',
qn_base_url: 'https://qn-static.banshouhui.com/study/',
argoDebugMode: 1,
version: 'v1.0.0'
apiUrl: 'https://system.banshouhui.com',
qn_base_url: 'https://qn-static.banshouhui.com/study/',
qn_asset_url: 'https://img2.banshouhui.com/',
uCenterUrl: 'http://rest-u.banshouhui.com/',
argoDebugMode: 1,
version: 'v1.0.0',
}
module.exports = UNI_APP
const UNI_APP = {
apiUrl: 'https://system.dev.banshouhui.com',
qn_base_url: 'https://qn-static.banshouhui.com/study/',
argoDebugMode: 1,
version: 'v1.0.0'
apiUrl: 'https://exam.banshouhui.com',
qn_base_url: 'https://qn-static.banshouhui.com/study/',
qn_asset_url: 'https://img2.banshouhui.com/',
uCenterUrl: 'http://rest-u.test.ibanshou.cn/',
argoDebugMode: 1,
version: 'v1.0.0',
}
module.exports = UNI_APP
......@@ -15256,6 +15256,16 @@
"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": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-1.0.4.tgz",
......
<script>
import "./../.env.js"
export default {
onLaunch: function () {
globalData: {
// 开发环境
uniEnv: process.uniEnv,
questionList: [],
orgId: -1
},
onLaunch: function(options) {
this.globalData.orgId = options?.orgId || -1
// 版本更新
this.updateApp()
},
onShow: function () {
onShow: function() {
console.log('App Show')
},
onHide: function () {
onHide: function() {
console.log('App Hide')
},
methods: {
......@@ -28,7 +36,7 @@ export default {
// }
// })
updateManager.onUpdateReady(function (res) {
updateManager.onUpdateReady(function(res) {
uni.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
......@@ -43,7 +51,7 @@ export default {
content:
'本次版本更新涉及到新的功能添加,旧版本无法正常访问的哦~',
showCancel: false,
success: function (result) {
success: function(result) {
if (result.confirm) updateManager.applyUpdate()
},
})
......@@ -52,7 +60,7 @@ export default {
})
})
updateManager.onUpdateFailed(function (res) {
updateManager.onUpdateFailed(function(res) {
// 新的版本下载失败
uni.showModal({
title: '已经有新版本了哟~',
......@@ -63,7 +71,8 @@ export default {
} else {
uni.showModal({
title: '提示',
content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。',
content:
'当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。',
showCancel: false,
})
}
......
let commonApiFun = function(vm) {
let loginWechatAuth = async (params = {}) => await vm.$u.post('/authorization', params)
const commonApi = {
loginWechatAuth
}
return commonApi
const globalUrl = process.uniEnv || {}
let uCenterApiUrl = globalUrl.uCenterUrl
let loginWechatAuth = async (params = {}) =>
await vm.$u.post('/wxapp/unify/authorization', params)
let payOrder = async (params = {}) => await vm.$u.post('/pay/order', params)
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 = {
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) {
let commonApi = commonApiFun(vm);
let apiUrl = {
...commonApi,
}
return apiUrl
let commonApi = commonApiFun(vm)
let learnApi = learnApiFun(vm)
let userApi = userApiFun(vm)
let apiUrl = {
...commonApi,
...learnApi,
...userApi,
}
return apiUrl
}
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 || {}
// 这里的vm,就是我们在vue文件里面的this,所以我们能在这里获取vuex的变量,比如存放在里面的token变量
const install = (Vue, vm) => {
const systemApiUrl = globalUrl.apiUrl
// 此为自定义配置参数,具体参数见上方说明
Vue.prototype.$u.http.setConfig({
baseUrl: systemApiUrl,
header: {
'content-type': 'application/json; charset=utf-8'
},
loadingTime: 800,
// ......
});
// 请求拦截,配置Token等参数
Vue.prototype.$u.http.interceptor.request = (config) => {
// 引用token
const token = vm.vuex_token
const reg = /\?\w+/
if(config.url.indexOf('access-token=') >=0 && config.params['access-token']){
// 给默认参数增加access-token (Java端)
if(reg.test(config.url)){
config.url += '&access-token=' + token
}else{
config.url += '?access-token=' + token
}
}
const systemApiUrl = globalUrl.apiUrl
// 此为自定义配置参数,具体参数见上方说明
Vue.prototype.$u.http.setConfig({
baseUrl: systemApiUrl,
header: {
channel: 'Applets',
tenant: 'weixiuhui',
'content-type': 'application/json; charset=utf-8',
},
loadingTime: 800,
showLoading: false,
originalData: true,
})
// 请求拦截,配置Token等参数
Vue.prototype.$u.http.interceptor.request = (config) => {
// 引用token
// const token = vm.vuex_token
config.header.token = vm.vuex_token
// const reg = /\?\w+/
// if(config.url.indexOf('access-token=') >=0 && config.params['access-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;
// 如果return一个false值,则会取消本次请求
// if(config.url == '/user/rest') return false; // 取消某次请求
}
// 响应拦截,判断状态码是否通过
Vue.prototype.$u.http.interceptor.response = (res) => {
if(res.code == 200) {
// res为服务端返回值,可能有code,result等字段
// 这里对res.result进行返回,将会在this.$u.post(url).then(res => {})的then回调中的res的到
// 如果配置了originalData为true,请留意这里的返回值
return res.result;
} else if(res.code == 201) {
// 假设201为token失效,这里跳转登录
vm.$u.toast('验证失败,请重新登录');
setTimeout(() => {
// 此为uView的方法,详见路由相关文档
vm.$u.route('/pages/user/login')
}, 1500)
return false;
} else {
// 如果返回false,则会调用Promise的reject回调,
// 并将进入this.$u.post(url).then().catch(res=>{})的catch回调中,res为服务端的返回值
return false;
}
}
// 响应拦截,判断状态码是否通过
Vue.prototype.$u.http.interceptor.response = (res) => {
const data = res.data
let pages = getCurrentPages()
let route = pages[pages.length - 1].route
if (res.statusCode === 200) {
if (data.code === 0) {
return data.data
} else if (data.code === 401) {
vm.$u.toast(data.msg)
// 如果不是在登录页,则跳转到登录页
if (route !== 'pages/login/index') {
setTimeout(() => {
vm.$u.route('/pages/login/index')
}, 1500)
}
return false
} else {
// 如果返回false,则会调用Promise的reject回调,
vm.$u.toast(data.msg)
return false
}
} else if (res.statusCode === 401) {
// 登录过期
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 {
install
}
\ No newline at end of file
install,
}
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>
This diff is collapsed.
import Vue from 'vue'
import App from './App'
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
App.mpType = 'app'
......@@ -10,13 +11,17 @@ Vue.mixin(vuexStore)
// 引入全局uView
import uView from 'uview-ui'
Vue.use(uView);
Vue.use(uView)
const app = new Vue({
store,
...App
store,
...App,
})
// 引入uView对小程序分享的mixin封装
let mpShare = require('uview-ui/libs/mixin/mpShare.js')
Vue.mixin(mpShare)
import httpInterceptor from '@/common/http.interceptor.js'
Vue.use(httpInterceptor, app)
......@@ -24,4 +29,10 @@ Vue.use(httpInterceptor, app)
import httpApi from '@/common/http.api.js'
Vue.use(httpApi, app)
// #ifdef H5
RouterMount(app, router, '#app')
// #endif
// #ifndef H5
app.$mount()
// #endif
{
"name": "",
"appid": "",
"description": "",
"versionName": "1.0.0",
"versionCode": "100",
"transformPx": false,
"app-plus": { /* 5+App特有相关 */
"usingComponents": true,
"splashscreen": {
"alwaysShowBeforeRender": true,
"waiting": true,
"autoclose": true,
"delay": 0
},
"modules": { /* 模块配置 */
},
"distribute": { /* 应用发布信息 */
"android": { /* android打包配置 */
"permissions": ["<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<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\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
"ios": { /* ios打包配置 */
},
"sdkConfigs": { /* SDK配置 */
}
}
},
"quickapp": { /* 快应用特有相关 */
},
"mp-weixin": { /* 微信小程序特有相关 */
"appid": "",
"setting": {
"urlCheck": false,
"es6" : true
},
"usingComponents": true
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"mp-qq" : {
"usingComponents" : true
}
}
{
"name" : "模考大师",
"appid" : "",
"description" : "",
"versionName" : "1.0.0",
"versionCode" : "100",
"transformPx" : false,
"app-plus" : {
/* 5+App特有相关 */
"usingComponents" : true,
"splashscreen" : {
"alwaysShowBeforeRender" : true,
"waiting" : true,
"autoclose" : true,
"delay" : 0
},
"modules" : {},
/* 模块配置 */
"distribute" : {
/* 应用发布信息 */
"android" : {
/* android打包配置 */
"permissions" : [
"<uses-permission android:name=\"android.permission.CHANGE_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.MOUNT_UNMOUNT_FILESYSTEMS\"/>",
"<uses-permission android:name=\"android.permission.READ_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.VIBRATE\"/>",
"<uses-permission android:name=\"android.permission.READ_LOGS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_WIFI_STATE\"/>",
"<uses-feature android:name=\"android.hardware.camera.autofocus\"/>",
"<uses-permission android:name=\"android.permission.WRITE_CONTACTS\"/>",
"<uses-permission android:name=\"android.permission.ACCESS_NETWORK_STATE\"/>",
"<uses-permission android:name=\"android.permission.CAMERA\"/>",
"<uses-permission android:name=\"android.permission.RECORD_AUDIO\"/>",
"<uses-permission android:name=\"android.permission.GET_ACCOUNTS\"/>",
"<uses-permission android:name=\"android.permission.MODIFY_AUDIO_SETTINGS\"/>",
"<uses-permission android:name=\"android.permission.READ_PHONE_STATE\"/>",
"<uses-permission android:name=\"android.permission.CHANGE_WIFI_STATE\"/>",
"<uses-permission android:name=\"android.permission.WAKE_LOCK\"/>",
"<uses-permission android:name=\"android.permission.CALL_PHONE\"/>",
"<uses-permission android:name=\"android.permission.FLASHLIGHT\"/>",
"<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\"/>",
"<uses-permission android:name=\"android.permission.WRITE_SETTINGS\"/>"
]
},
"ios" : {},
/* ios打包配置 */
"sdkConfigs" : {}
}
},
/* SDK配置 */
"quickapp" : {},
/* 快应用特有相关 */
"mp-weixin" : {
/* 微信小程序特有相关 */
"appid" : "wx4bd80cf10c2a1d14",
"setting" : {
"urlCheck" : false,
"es6" : true
},
"usingComponents" : true,
"permission" : {
"scope.userLocation" : {
"desc" : "您的位置信息将用于默认对应区域题库的选择"
}
}
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"mp-qq" : {
"usingComponents" : true
}
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<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>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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