1、优化空组件; 2、处理作业详情放回数据图片展示问题;3、添加答题器; 4、添加主页答题器入口;5、添加网络打印测试页(不可使用)

unocss
chris 6 months ago
parent 8f0855a0e7
commit 600a7b9a6e

@ -0,0 +1,23 @@
import request from '@/utils/network/request';
/**
* 获取答题器选项
*/
export function getIClickerData(data, config = {}) {
return request({
url: '/api/user.ashx?act=studenticlicker',
method: 'GET',
data
}, config)
}
/**
* 提交答题器数据
*/
export function submitIClickerData(data, config = {}) {
return request({
url: '/api/user.ashx?act=studenticlicker',
method: 'POST',
data
}, config)
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

@ -11,3 +11,4 @@
@import './cover/checkbox.scss';
@import './cover/pagination.scss';
@import './cover/load-more.scss';
@import './cover/modal.scss';

@ -0,0 +1,13 @@
.uni-modal {
max-width: 400px!important;
}
.uni-modal__bd {
max-height: 460px!important;
font-size: $uni-font-size-mini!important;
}
.uni-modal__ft {
font-size: $uni-font-size-mini!important;
line-height: 66px!important;
}

@ -1,11 +1,18 @@
<template>
<ch-flex class="ch-empty" justify="center" items="center" direction="column">
<ch-icon name="empty" :size="100" color="#bbb"></ch-icon>
<text class="ch-empty--text">暂无数据</text>
<text class="ch-empty--text">{{ emptyText }}</text>
</ch-flex>
</template>
<script setup name="ch-empty">
import { defineProps } from 'vue';
const props = defineProps({
emptyText: {
type: String,
default: '暂无数据'
}
})
</script>
<style lang="scss" scoped>

@ -60,9 +60,9 @@
"splashscreen" : {
"androidStyle" : "default",
"android" : {
"hdpi" : "assets/images/logo/ghlogo.png",
"xhdpi" : "assets/images/logo/ghlogo.png",
"xxhdpi" : "assets/images/logo/ghlogo.png"
"hdpi" : "assets/images/logo/start_bg.png",
"xhdpi" : "assets/images/logo/start_bg.png",
"xxhdpi" : "assets/images/logo/start_bg.png"
}
},
"icons" : {

@ -136,6 +136,26 @@
}
}
},
{
"path" : "pages/IClicker/IClicker",
"style" :
{
"navigationStyle": "custom",
"app-plus": {
"titleNView": false
}
}
},
{
"path" : "pages/networkPrint/networkPrint",
"style" :
{
"navigationStyle": "custom",
"app-plus": {
"titleNView": false
}
}
}
],
"globalStyle": {

@ -0,0 +1,36 @@
$optionW: 120px;
$optionH: 120px;
.answer-options {
height: calc(100vh - 66px);
}
.option {
display: flex;
justify-content: center;
align-items: center;
width: $optionW;
height: $optionH;
border-radius: 10rpx;
font-size: $uni-font-size-lg;
font-weight: bold;
background-color: $uni-bg-color-grey;
&.select {
background-color: $uni-color-primary;
color: #fff;
}
}
.handle-icon {
+ .handle-icon {
margin-left: 20px;
}
}
.option {
&.selected {
color: #fff;
background-color: $uni-color-primary;
}
}

@ -0,0 +1,76 @@
<template>
<view class="i-clicker-page">
<ch-nav-bar title="答题器" :height="66">
<template v-slot:right>
<uni-icons class="handle-icon" type="reload" size="56" color="#fff" @tap="refresh"/>
<uni-icons class="handle-icon" type="checkmarkempty" size="56" color="#fff" @tap="submitAnswer"/>
</template>
</ch-nav-bar>
<ch-empty emptyText="暂无答题任务" v-if="!options.length"></ch-empty>
<ch-flex class="answer-options" justify="around" items="center" @tap.native="selectOpt" v-else>
<block v-for="option in options" :key="option.id">
<view class="option" :class="{ 'selected': selectOpts.includes(option.id) }" :data-opt="option">
{{ option.text }}
</view>
</block>
</ch-flex>
</view>
</template>
<script setup>
import { getIClickerData, submitIClickerData } from '@/api/iClicker.js'
import { reactive, toRefs } from 'vue';
const defaultOptions = [
{
id: '001',
text: 'A'
},
{
id: '002',
text: 'B'
},
{
id: '003',
text: 'C'
},
{
id: '004',
text: 'D'
},
]
const data = reactive({
options: [...defaultOptions],
selectOpts: []
})
const { options, selectOpts } = toRefs(data);
function selectOpt (e) {
const opt = e.target.dataset.opt || null;
if (!opt) return;
const index = selectOpts.value.findIndex(id => id == opt.id)
selectOpts.value = index == -1 ? [...selectOpts.value, opt.id]
: selectOpts.value.filter(id => id !== opt.id)
}
function submitAnswer () {
uni.showModal({
content: '确定要提交答案?',
confirmText: '提交',
cancelText: '放弃',
success: () => {
}
})
}
function refresh () {
selectOpts.value = [];
}
</script>
<style lang="scss" scoped>
@import './IClicker.scss'
</style>

@ -34,8 +34,6 @@
<text>{{ item.name }}</text>
</ch-flex>
</uni-grid-item>
<uni-grid-item>
</uni-grid-item>
</uni-grid>
</view>
</template>
@ -48,6 +46,7 @@ import { reactive, toRefs } from 'vue';
import userIndex from '@/assets/images/icons/userIndex_order.png';
import myStudy from '@/assets/images/icons/my_study.png';
import task from '@/assets/images/icons/task.png';
import answer from '@/assets/images/icons/answer.png';
import { onLoad } from '@dcloudio/uni-app';
import { useUserStore } from '@/store/user.js';
@ -73,6 +72,12 @@ const data = reactive({
name: '作 业',
icon: task,
url: '/pages/task/task'
},
{
id: '004',
name: '答题器',
icon: answer,
url: '/pages/IClicker/IClicker'
}
],
})

@ -0,0 +1,28 @@
<template>
<view class="network-print-page">
<button type="primary" @tap="linkPrint"></button>
</view>
</template>
<script setup>
uni.onSocketOpen(function (res) {
console.log('WebSocket连接已打开');
});
function linkPrint () {
uni.connectSocket({
url: 'ws://192.168.1.15',
method: 'CONNECT',
success: (res) => {
console.log('连接打印机成功', res)
},
fail: (error) => {
console.log('连接打印机失败', error)
}
})
}
</script>
<style lang="scss">
</style>

@ -10,7 +10,7 @@
</ch-nav-btn> -->
</block>
</ch-nav-bar>
<canvas ref="canvasRef" canvas-id="imgCanvas" id="imgCanvas" :style="`width: ${canvasW}px; height: ${canvasH}px;`"/>
<!-- <canvas ref="canvasRef" canvas-id="imgCanvas" id="imgCanvas" :style="`width: ${canvasW}px; height: ${canvasH}px;`"/> -->
<uni-section title="附近打印机" type="line">
<block v-slot:right>
<button type="primary" size="mini" class="search-btn" :loading="searching" :disabled="searching" @click="searchDevices">{{ searching ? '...' : '' }}</button>
@ -46,7 +46,7 @@ import { getImgData } from '@/api/common.js';
const bluetooth = new Bluetooth();
// #endif
const canvasRef = ref(null);
// const canvasRef = ref(null);
const data = reactive({
searching: false,
@ -74,7 +74,7 @@ import { getImgData } from '@/api/common.js';
success: (res) => {
questions.value = JSON.parse(res.data)
console.log(questions.value)
getImg();
// getImg();
}
})
})
@ -167,6 +167,7 @@ import { getImgData } from '@/api/common.js';
printAnswerExplain(printerJobs, item.textArr, 'explain')
}
})
printerJobs.print('')
})
let buffer = printerJobs.buffer();

@ -67,11 +67,21 @@ onMounted(() => {
getTaskInfo(params, { loading: true }).then(info => {
task.value = info;
if (!info.studentimg) return;
files.value = [{
name: 'studentimg',
extname: 'image/png',
path: `${info.studentimg}`
}]
const imgArr = info.studentimg.split(',')
console.log(imgArr)
imgArr.forEach(item => {
if (!item) return;
files.value.push({
name: 'studentimg',
extname: 'image/png',
path: `${config.baseUrl}/${item}`
})
})
// files.value = [{
// name: 'studentimg',
// extname: 'image/png',
// path: `${config.baseUrl}/${info.studentimg}`
// }]
})
})

Loading…
Cancel
Save