Browse Source

feat: 试题接口

develop
song 4 years ago
parent
commit
f8c137a547
  1. 3
      CHANGELOG.md
  2. 15
      rest/http-client.env.json
  3. 201
      rest/project.http
  4. 7
      src/apis/yanyuan.js
  5. 25
      src/components/NotEvaluated/NotEvaluated.vue
  6. 10
      src/components/Test/TestMain.vue
  7. 10
      src/components/Test/TestTitle.vue
  8. 95
      src/components/Test/answerPage.vue
  9. 42
      src/components/Test/components/TestMain.vue
  10. 26
      src/components/Test/components/TitlePosition.vue
  11. 86
      src/components/Test/promptPage.vue
  12. 1
      src/components/TimeLine/TimeLine.vue
  13. 2
      src/pages/index/index.vue
  14. 60
      src/pagesYanyuan/assess/assess.vue
  15. 16
      src/store/yanyuan/actions.js
  16. 9
      src/store/yanyuan/mutations.js
  17. 1
      src/store/yanyuan/state.js

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 0.1.0 (2021-11-12)
# 0.1.0 (2021-11-15)
### 🌟 新功能
范围|描述|commitId
@ -230,6 +230,7 @@
- | 组件文件夹新建 | [17bb8c9](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/17bb8c9)
- | 组件文件夹新建 | [1421504](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/1421504)
- | 角色栏文字颜色修改 | [215c6b3](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/215c6b3)
- | 解决error | [cacbe7f](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/cacbe7f)
- | 解决error | [1a6e513](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/1a6e513)
- | 解决警告 | [c932b09](https://dd.tall.wiki/gitea/binbin0314/yanyuan_js/commits/c932b09)

15
rest/http-client.env.json

@ -0,0 +1,15 @@
{
"$shared": {
"version": "v1",
"identifier": "wally",
"credential": "111111"
},
"dev": {
"name": "dev",
"url": "http://192.168.0.99/gateway"
},
"local": {
"version": "v2",
"url": "http://192.168.0.99/gateway"
}
}

201
rest/project.http

@ -0,0 +1,201 @@
@localhost = http://localhost:7260/v2.0
@localhost_tall = http://localhost:7130/v3.0
@test_tall = http://192.168.0.99:7130/v3.0
@test = https://test.tall.wiki/gateway/yanyuan/v2.0/
@www_tall = http://www.tall.wiki:7130/v3.0
@www = http://www.tall.wiki/gateway/yanyuan/v2.0/
@type = content-type: application/json;charset=utf-8
### 登录
# @name login
POST {{test_tall}}/users/signin
{{type}}
{
"client": 1,
"type": 3,
"data": {
"identifier": "song",
"credential": "999999"
}
}
### debug
GET {{test}}/debug
{{type}}
Authorization: Bearer {{login.response.body.$.data.token}}
###绑定工具箱
POST {{test}}/tool/bind
{{type}}
Authorization: Bearer {{login.response.body.$.data.token}}
{
"param":{
"toolCode":"0000000003"
}
}
###查询登录用户身份
POST {{test}}/userPower/identity
{{type}}
Authorization: Bearer {{login.response.body.$.data.token}}
{
}
###添加用户信息
POST {{test}}/trainee/add
{{type}}
Authorization: Bearer {{login.response.body.$.data.token}}
{
"param":{
"userName":"李四",
"sex":"1",
"clinicHospital":"就诊医院",
"hospitalProvinceId":"1",
"hospitalCityId":"2",
"hospitalAddress":"迎泽区XXX",
"clinicOffice":"神经内科",
"clinicDoctor":"赵医生",
"birthDate":"1965-08-01",
"height":"170",
"weight":"66",
"jobTitle":"农林渔牧",
"educateStatus":"小学",
"educateDate":"6",
"abodePlace":"太原市小店区",
"appearTime":"2021-01-01",
"diagnoseTime":"2021-02-01",
"diagnoseResult":"轻度痴呆",
"minBloodPressure":"90",
"maxBloodPressure":"120",
"bloodFat":"80",
"physicalAct":"中",
"apoeGene":"1",
"diseasesRecord":"没有疾病史",
"relativeDiseasesRecord":"亲属均无老年痴呆",
"isInsomnic":0,
"insomnicPeriod":"8",
"isSmoke":1,
"quitPeriod":2,
"sustainPeriod":3,
"averageNum":5,
"isDrink":2,
"abstinencePeriod":"2年",
"drinkType":"啤酒",
"isTea":"3",
"quitTea":"",
"continuePeriod":"1年",
"teaType":"绿茶",
"teaPeriod":"每天一杯",
"isStrongFlavour":1,
"isLikeMeat":1,
"isMoreOil":0
}
}
###查询绑定者创建的患者信息(申请成为家属前调用)
POST {{test}}/trainee/create
{{type}}
Authorization: Bearer {{login.response.body.$.data.token}}
{
"param":{
"bindUserId":"1218025249493356544"
}
}
###绑定手机号后,关联用户原有的使用者
POST {{test}}/trainee/relation
{{type}}
Authorization: Bearer {{login.response.body.$.data.token}}
{
}
###生成二维码
POST {{test}}/tool/qrCode
{{type}}
Authorization: Bearer {{login.response.body.$.data.token}}
{
"param":{
"id":"1"
}
}
###体验账号升级
POST {{test}}/trainee/upgrade
{{type}}
Authorization: Bearer {{login.response.body.$.data.token}}
{
"param":{
"keyUserIds":[
"1456525052375470081"
]
}
}
###查询个人信息
POST {{test}}/family/personal
{{type}}
Authorization: Bearer {{login.response.body.$.data.token}}
{
}
###申请成为家属
POST {{test}}/family/apply
{{type}}
Authorization: Bearer {{login.response.body.$.data.token}}
{
"param":{
"keyUserIds":[
"1456525052375470080",
"1456525052375470081"
],
"age":25,
"educateLevel": "本科",
"jobTitle": "码农",
"name": "小伙伴",
"sex": 1
}
}
###查询试题
POST {{test}}/question/get
{{type}}
Authorization: Bearer {{login.response.body.$.data.token}}
{
"param":{
"code":"NLCP",
"reportId": "1458968153773838336",
"num": "1"
}
}
###保存答案
POST {{localhost}}/question/saveAnswer
{{type}}
Authorization: Bearer {{login.response.body.$.data.token}}
{
"param":{
"code":"NLCP",
"reportId": "1459057596971094016",
"questionId": "21",
"optionId": "1"
}
}
###脑力测评结果计算
POST {{localhost}}/mentalTest/calculate
{{type}}
Authorization: Bearer {{login.response.body.$.data.token}}
{
"param":{
"mentalTestId": "1459057596971094016"
}
}

7
src/apis/yanyuan.js

@ -19,12 +19,15 @@ const install = (Vue, vm) => {
vm.$u.api.applyFamily = param => vm.$u.post(`${yanyuan}/family/apply`, param);
// 查询个人信息
vm.$u.api.getPersonalInfo = () => vm.$u.post(`${yanyuan}/family/personal`);
// 绑定工具箱
vm.$u.api.bindTool = param => vm.$u.post(`${yanyuan}/tool/bind`, param);
// 用户身份判断
vm.$u.api.identityUserPower = param => vm.$u.post(`${yanyuan}/userPower/identity`, param);
// 试题查询
vm.$u.api.getQuestion = param => vm.$u.post(`${yanyuan}/question/get`, param);
// 试题答案保存
vm.$u.api.saveAnswer = param => vm.$u.post(`${yanyuan}/question/saveAnswer`, param);
};
export default { install };

25
src/components/NotEvaluated/NotEvaluated.vue

@ -18,10 +18,31 @@
</template>
<script>
import { mapActions } from 'vuex';
export default {
methods: {
startAssess() {
uni.navigateTo({ url: '/pagesYanyuan/assess/assess' });
...mapActions('yanyuan', ['handleQuestion']),
/**
* 开始测评 试题查询
* @param { string } code 题目code NLCP:脑力测评 ZARIT:照顾者负担量表
* @param { number } num 题号
* @param { string } reportId 测评ID 脑力测评ID或zaritID
*/
async startAssess() {
try {
const params = {
code: 'NLCP',
reportId: '1458968153773838336',
num: '1',
};
const data = await this.handleQuestion(params);
console.log('data: ', data);
uni.navigateTo({ url: '/pagesYanyuan/assess/assess' });
} catch (error) {
console.error('error: ', error);
}
},
},
};

10
src/components/Test/TestMain.vue

@ -1,10 +0,0 @@
<template>
<view> 测试内容 </view>
</template>
<script>
export default {};
</script>
<style scoped lang="scss">
</style>

10
src/components/Test/TestTitle.vue

@ -1,10 +0,0 @@
<template>
<view> 1.请记住以下物品 </view>
</template>
<script>
export default {};
</script>
<style scoped lang="scss">
</style>

95
src/components/Test/answerPage.vue

@ -0,0 +1,95 @@
<template>
<view class="flex flex-col">
<view v-for="(item, index) in question.positions" :key="index" class="flex flex-col">
<!-- title -->
<view v-if="item.position === 0" class="flex flex-col">
<view v-for="(con, conIndex) in item.contents" :key="conIndex">
<text v-if="questionInfo.num && turnPages">{{ questionInfo.num }}.</text>{{ con.content }}
</view>
<u-line class="my-2" color="#c8c7cc" />
</view>
<view v-if="question.positions.length === 1">
<view v-for="(option, optionIndex) in questionInfo.options" :key="optionIndex" class="flex-1">
<TestMain @setParams="setParams" v-if="option.page === 1" :options="option.positions" />
</view>
</view>
<view v-else>
<!-- 选项前 -->
<view v-if="item.position === 1" class="flex flex-col">
<TitlePosition :item="item" />
<view v-for="(option, optionIndex) in questionInfo.options" :key="optionIndex">
<TestMain @setParams="setParams" v-if="option.page === 1" :options="option.positions" />
</view>
</view>
<!-- 选项后 -->
<view v-if="item.position === 2" class="flex flex-col">
<view v-for="(option, optionIndex) in questionInfo.options" :key="optionIndex">
<TestMain @setParams="setParams" v-if="option.page === 1" :options="option.positions" />
</view>
<TitlePosition :item="item" />
</view>
<!-- 选项左 -->
<view v-if="item.position === 3" class="flex flex-nowrap">
<TitlePosition :item="item" class="flex-1" />
<view v-for="(option, optionIndex) in questionInfo.options" :key="optionIndex" class="flex-1">
<TestMain @setParams="setParams" v-if="option.page === 1" :options="option.positions" />
</view>
</view>
<!-- 选项右 -->
<view v-if="item.position === 4" class="flex flex-nowrap">
<view v-for="(option, optionIndex) in questionInfo.options" :key="optionIndex" class="flex-1">
<TestMain @setParams="setParams" v-if="option.page === 1" :options="option.positions" />
</view>
<TitlePosition :item="item" class="flex-1" />
</view>
</view>
</view>
<u-button class="mt-5" type="primary" @click="next">下一题</u-button>
</view>
</template>
<script>
import { mapState } from 'vuex';
import TitlePosition from './components/TitlePosition';
import TestMain from './components/TestMain';
export default {
components: { TitlePosition, TestMain },
props: {
turnPages: {
type: Boolean,
default: false,
},
question: {
type: Object,
default: {},
},
},
computed: mapState('yanyuan', ['questionInfo']),
methods: {
//
setParams(optionId) {
this.$emit('setParams', optionId);
},
next() {
this.$emit('nextQuestion');
},
},
};
</script>
<style scoped lang="scss">
</style>

42
src/components/Test/components/TestMain.vue

@ -0,0 +1,42 @@
<template>
<view class="grid gap-2">
<view v-for="(option, optionIndex) in options" :key="optionIndex" :class="[`row-span-${option.row}`]">
<u-radio-group v-model="value">
<u-radio
@change="radioChange"
v-for="(item, index) in option.contents"
:key="index"
:name="item.id"
:class="[`col-span-${item.col}`]"
>
{{ item.content }}
</u-radio>
</u-radio-group>
</view>
</view>
</template>
<script>
export default {
props: {
options: {
type: Array,
default: [],
},
},
data() {
return { value: '' };
},
methods: {
// radioradio-group
radioChange(e) {
this.$emit('setParams', e);
},
},
};
</script>
<style scoped lang="scss">
</style>

26
src/components/Test/components/TitlePosition.vue

@ -0,0 +1,26 @@
<template>
<view class="grid" :class="item.contents.length > 4 ? 'grid-cols-3' : item.contents.length > 1 ? 'grid-cols-2' : ''">
<view v-for="(con, conIndex1) in item.contents" :key="conIndex1">
<view v-if="con.showType === 0">
{{ con.content }}
</view>
<view v-if="con.showType === 1">
<img class="w-full" :src="con.content" />
</view>
</view>
</view>
</template>
<script>
export default {
props: {
item: {
type: Object,
default: {},
},
},
};
</script>
<style>
</style>

86
src/components/Test/promptPage.vue

@ -0,0 +1,86 @@
<template>
<view class="flex flex-col">
<view v-for="(item, index) in question.positions" :key="index" class="flex flex-col">
<!-- title -->
<view v-if="item.position === 0" class="flex flex-col">
<view v-for="(con, conIndex) in item.contents" :key="conIndex">
<text v-if="questionInfo.num">{{ questionInfo.num }}.</text>{{ con.content }}
</view>
<u-line class="my-2" color="#c8c7cc" />
</view>
<view v-if="question.positions.length === 1">
<view v-for="(option, optionIndex) in questionInfo.options" :key="optionIndex" class="flex-1">
<TestMain @setParams="setParams" v-if="option.page === 1" :options="option.positions" />
</view>
</view>
<view v-else>
<!-- 选项前 -->
<view v-if="item.position === 1" class="flex flex-col">
<TitlePosition :item="item" />
<view v-for="(option, optionIndex) in questionInfo.options" :key="optionIndex">
<TestMain @setParams="setParams" v-if="option.page === 0" :options="option.positions" />
</view>
</view>
<!-- 选项后 -->
<view v-if="item.position === 2" class="flex flex-col">
<view v-for="(option, optionIndex) in questionInfo.options" :key="optionIndex">
<TestMain @setParams="setParams" v-if="option.page === 0" :options="option.positions" />
</view>
<TitlePosition :item="item" />
</view>
<!-- 选项左 -->
<view v-if="item.position === 3" class="flex flex-nowrap">
<TitlePosition :item="item" class="flex-1" />
<view v-for="(option, optionIndex) in questionInfo.options" :key="optionIndex" class="flex-1">
<TestMain @setParams="setParams" v-if="option.page === 0" :options="option.positions" />
</view>
</view>
<!-- 选项右 -->
<view v-if="item.position === 4" class="flex flex-nowrap">
<view v-for="(option, optionIndex) in questionInfo.options" :key="optionIndex" class="flex-1">
<TestMain @setParams="setParams" v-if="option.page === 0" :options="option.positions" />
</view>
<TitlePosition :item="item" class="flex-1" />
</view>
</view>
</view>
<u-button class="mt-5" type="primary" @click="openAnswerPage">答题</u-button>
</view>
</template>
<script>
import { mapState } from 'vuex';
import TestMain from './components/TestMain';
import TitlePosition from './components/TitlePosition';
export default {
components: { TestMain, TitlePosition },
props: { question: { type: Object, default: {} } },
computed: mapState('yanyuan', ['questionInfo']),
methods: {
openAnswerPage() {
this.$emit('openAnswerPage');
},
setParams(optionId) {
this.$emit('setParams', optionId);
},
},
};
</script>
<style>
</style>

1
src/components/TimeLine/TimeLine.vue

@ -45,7 +45,6 @@ export default {
//
scroll(e) {
console.log('e: ', e);
this.top = e.detail.scrollTop;
this.setShrink(this.top > this.scrollTop);
this.setScrollTop(this.top);

2
src/pages/index/index.vue

@ -4,7 +4,7 @@
<!-- 日历 -->
<Calendar @selected-change="onDateChange" :show-back="true" ref="calendar" @handleFindPoint="handleFindPoint" />
<!-- 上传 导入wbs -->
<Upload @success="onUploadSuccess" @error="onUploadError" style="z-index: 9999" />
<Upload @success="onUploadSuccess" @error="onUploadError" style="z-index: 9999; position: absolute; right: 0; bottom: 0" />
<!-- #ifdef H5 -->
<!-- #endif -->
</view>

60
src/pagesYanyuan/assess/assess.vue

@ -1,29 +1,73 @@
<template>
<view class="flex flex-col p-3">
<TestTitle />
<u-line class="my-2" color="#c8c7cc" />
<TestMain />
<u-button class="my-10" type="primary">答题</u-button>
<u-button class="my-10" type="primary" @click="viewResults">查看测评结果</u-button>
<!-- 有一页 -->
<view v-if="questionInfo.questions.length === 1">
<answerPage :turnPages="false" @setParams="setParams" @nextQuestion="nextQuestion" />
</view>
<!-- 有两页 -->
<view v-if="questionInfo.questions.length === 2">
<promptPage @openAnswerPage="openAnswerPage" @setParams="setParams" v-if="!showAnswerPage" :question="questionInfo.questions[0]" />
<answerPage v-else :turnPages="true" :question="questionInfo.questions[1]" @setParams="setParams" @nextQuestion="nextQuestion" />
</view>
</view>
</template>
<script>
import TestTitle from 'components/Test/TestTitle';
import TestMain from 'components/Test/TestMain';
import { mapState, mapGetters, mapMutations } from 'vuex';
import promptPage from 'components/Test/promptPage';
import answerPage from 'components/Test/answerPage';
export default {
components: { TestTitle, TestMain },
components: { promptPage, answerPage },
data() {
return { showAnswerPage: false, param: {} };
},
computed: {
...mapState('project', ['project']),
...mapState('yanyuan', ['questionInfo']),
...mapGetters('user', ['userId']),
},
methods: {
...mapMutations('task', ['setIsEvaluated']),
//
openAnswerPage() {
this.showAnswerPage = true;
},
//
setParams(optionId) {
this.param = {
code: 'NLCP',
optionId: optionId ? optionId : '',
questionId: this.questionInfo.id,
reportId: '1458968153773838336',
};
},
/**
* 下一题
* @param { string } code 题目code NLCP:脑力测评 ZARIT:照顾者负担量表
* @param { string } optionId 选项ID
* @param { string } questionId 题目ID
* @param { string } reportId 测评ID 脑力测评ID或zaritID
*/
async nextQuestion() {
try {
await this.$u.api.saveAnswer(this.param);
this.$t.ui.showToast('提交成功');
uni.navigateTo({ url: '/pagesYanyuan/assess/assess' });
} catch (error) {
console.error('error: ', error);
this.$t.ui.showToast(error.msg || '提交失败');
}
},
//
viewResults() {
this.setIsEvaluated(true);

16
src/store/yanyuan/actions.js

@ -43,6 +43,22 @@ const actions = {
uni.$t.ui.showToast(error.msg || '个人信息查询失败');
}
},
/**
* 试题查询
* @param { string } code 题目code NLCP:脑力测评 ZARIT:照顾者负担量表
* @param { number } num 题号
* @param { string } reportId 测评ID 脑力测评ID或zaritID
*/
async handleQuestion({ commit }, params) {
try {
const data = await uni.$u.api.getQuestion(params);
commit('setQuestionInfo', data);
return data;
} catch (error) {
console.error('error: ', error);
}
},
};
export default actions;

9
src/store/yanyuan/mutations.js

@ -70,6 +70,15 @@ const mutations = {
setShowSetUser(state, show) {
state.showSetUser = show;
},
/**
* 设置试题信息
* @param {boolean} state
* @param {object} data
*/
setQuestionInfo(state, data) {
state.questionInfo = data;
},
};
export default mutations;

1
src/store/yanyuan/state.js

@ -8,6 +8,7 @@ const state = {
keyUserIds: [], // 所选老人的id
applyFamilyInfo: {}, // 申请家属信息
showSetUser: false, // 显示设置使用者弹框
questionInfo: {}, // 试题信息
};
export default state;

Loading…
Cancel
Save