1、调试答题器接口功能; 2、配置mainfest.json文件配置(设置自定义协议),方便第三方app调用

master
chris 4 months ago
parent 704b8ed0d0
commit 97edff90ce

@ -15,9 +15,9 @@ export function getIClickerData(data, config = {}) {
* 提交答题器数据 * 提交答题器数据
*/ */
export function submitIClickerData(data, config = {}) { export function submitIClickerData(data, config = {}) {
const { studentanswer, studentid } = data;
return request({ return request({
url: '/api/user.ashx?act=studenticlicker', url: `/api/user.ashx?act=subansweringmachine&studentanswer=${studentanswer}&studentid=${studentid}`,
method: 'POST', method: 'GET'
data
}, config) }, config)
} }

@ -47,7 +47,8 @@
"<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>" "<uses-permission android:name=\"android.permission.BLUETOOTH_ADMIN\"/>"
], ],
"minSdkVersion" : 21, "minSdkVersion" : 21,
"abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ] "abiFilters" : [ "armeabi-v7a", "arm64-v8a", "x86" ],
"schemes" : "studypen"
}, },
/* ios */ /* ios */
"ios" : { "ios" : {

@ -9,7 +9,7 @@
<ch-empty emptyText="暂无答题任务" v-if="!options.length"></ch-empty> <ch-empty emptyText="暂无答题任务" v-if="!options.length"></ch-empty>
<ch-flex class="answer-options" justify="around" items="center" @tap.native="selectOpt" v-else> <ch-flex class="answer-options" justify="around" items="center" @tap.native="selectOpt" v-else>
<block v-for="option in options" :key="option.id"> <block v-for="option in options" :key="option.id">
<view class="option" :class="{ 'selected': selectOpts.includes(option.id) }" :data-opt="option"> <view class="option" :class="{ 'selected': selectOpts.includes(option.text) }" :data-opt="option">
{{ option.text }} {{ option.text }}
</view> </view>
</block> </block>
@ -20,6 +20,7 @@
<script setup> <script setup>
import { getIClickerData, submitIClickerData } from '@/api/iClicker.js' import { getIClickerData, submitIClickerData } from '@/api/iClicker.js'
import { reactive, toRefs } from 'vue'; import { reactive, toRefs } from 'vue';
import { useUserStore } from '../../store/user';
const defaultOptions = [ const defaultOptions = [
{ {
@ -40,6 +41,9 @@ const defaultOptions = [
}, },
] ]
const userStore = useUserStore();
const userId = userStore.userId;
const data = reactive({ const data = reactive({
options: [...defaultOptions], options: [...defaultOptions],
selectOpts: [] selectOpts: []
@ -50,9 +54,9 @@ const { options, selectOpts } = toRefs(data);
function selectOpt (e) { function selectOpt (e) {
const opt = e.target.dataset.opt || null; const opt = e.target.dataset.opt || null;
if (!opt) return; if (!opt) return;
const index = selectOpts.value.findIndex(id => id == opt.id) const index = selectOpts.value.findIndex(text => text == opt.text)
selectOpts.value = index == -1 ? [...selectOpts.value, opt.id] selectOpts.value = index == -1 ? [...selectOpts.value, opt.text]
: selectOpts.value.filter(id => id !== opt.id) : selectOpts.value.filter(text => text!== opt.text)
} }
function submitAnswer () { function submitAnswer () {
@ -61,7 +65,23 @@ function submitAnswer () {
confirmText: '提交', confirmText: '提交',
cancelText: '放弃', cancelText: '放弃',
success: () => { success: () => {
const params = {
studentanswer: selectOpts.value.join(','),
studentid: userId
}
submitIClickerData(params).then(res => {
uni.showToast({
icon: 'success',
title: '已提交'
})
refresh();
}).catch(() => {
uni.showToast({
icon:'error',
title: '提交失败'
})
})
} }
}) })
} }

Loading…
Cancel
Save