作者 mxd

在线答疑接口对接

... ... @@ -99,9 +99,9 @@ export const MYQUESTIONTYPE = {
'ANSWERED': 1,
/**
* 未解答
* @value 2
* @value 0
*/
'UNANSWERED': 2
'UNANSWERED': 0
}
/**
* 大咖课类型
... ... @@ -163,3 +163,19 @@ export const MESSAGETYPE = {
*/
'VOICEANSWERS': 2
}
/**
* 评分状态
*/score
export const SCORESTATE = {
/**
* 未评分
* @value 0
*/
'UNRATED': 0,
/**
* 已评分
* @value 1
*/
'RATED': 1,
}
\ No newline at end of file
... ...
... ... @@ -8,16 +8,21 @@
</view>
<view class="answer-2">
<view class="answer-2-l">
<picker @change="bindpickerChange" :value="index" :range="subjectList" range-key="title">
<picker @change="keMupickerChange" :value="keMu.value" :range="keMu.list">
<view class="answer-2-l-i">
任课科目 <u-icon size="12" name="arrow-down-fill" color="#646464"></u-icon>
{{ keMu.list[keMu.value] === '全部' ? '任课科目' : keMu.list[keMu.value] }}
<u-icon size="12" name="arrow-down-fill" color="#646464"></u-icon>
</view>
</picker>
<picker @change="bindpickerChange2" :value="index" :range="basedOnList" range-key="title">
<view class="answer-2-l-i">
用户评价 <u-icon size="12" name="arrow-down-fill" color="#646464"></u-icon>
<view
class="answer-2-l-i"
@click="sortChange"
>
用户评价
<view class="icon" :class="{asc: sort === 'asc'}">
<u-icon size="12" name="arrow-down-fill" color="#2D81FF"></u-icon>
</view>
</view>
</picker>
</view>
<view class="answer-2-r" @click="toMyQuestion">
<image class="answer-2-r-i" src="@/static/imagesV2/icon39.png" mode="widthFix"></image>
... ... @@ -36,63 +41,69 @@
<template>
<view class="answer">
<view v-if="type === PAGETYPE.ONLINE">
<view class="answer-item" v-for="item in 20" :key="item">
<view class="answer-item-tw" @click="toAnswerForm">
<view class="answer-item" v-for="d in list" :key="d.id">
<view class="answer-item-tw" @click="toAnswerForm(d)">
<image class="answer-item-tw-i" src="@/static/imagesV2/icon41.png"></image>
<text>提问</text>
</view>
<view class="answer-item-l">
<image class="answer-item-l-img" src="@/static/images/tx.png" mode="widthFix"></image>
<view class="answer-item-l-img">
<image :src="d.img_url || '/static/images/tx.png'" mode="widthFix"></image>
</view>
</view>
<view class="answer-item-r">
<view class="answer-item-r-1">程菲</view>
<view class="answer-item-r-2">笔试系统精讲班</view>
<view class="answer-item-r-1">{{d.title}}</view>
<view class="answer-item-r-2">{{d.sub_title}}</view>
<view class="answer-item-r-3">
<image class="answer-item-r-3-i" src="@/static/imagesV2/icon40.png" mode="widthFix"></image>
<text class="answer-item-r-3-la">用户评分</text>
<text class="answer-item-r-3-f">3.6</text>
<text class="answer-item-r-3-f">{{d.start}}</text>
</view>
</view>
</view>
</view>
<view v-if="type === PAGETYPE.CLASSROOM">
<view class="answer-item2">
<view class="answer-item2" v-for="d in list" :key="d.id">
<view class="myQuestion-2-i-1">
<view class="myQuestion-2-i-1-l">
<image class="myQuestion-2-i-1-l-i" src="@/static/images/tx.png" mode="widthFix"></image>
<view class="myQuestion-2-i-1-l-i">
<image :src="d.img || '/static/images/tx.png'" mode="widthFix"></image>
</view>
</view>
<view class="myQuestion-2-i-1-r">
<view class="myQuestion-2-i-1-r-1">李晋心</view>
<view class="myQuestion-2-i-1-r-2">2023-12-10发布</view>
<view class="myQuestion-2-i-1-r-1">{{d.name}}</view>
<view class="myQuestion-2-i-1-r-2">{{d.create_time}}发布</view>
</view>
</view>
<view class="myQuestion-2-i-2">
老师你好请问工商管理专业的应届生可以报考工商管理
内的二级专业吗?比如说会计学,旅游管理?
{{d.question}}
</view>
<view class="myQuestion-2-i-4">
<view class="myQuestion-2-i-4" v-if="d.imgs && d.imgs.length">
<u--image
v-for="(item, index) in []"
v-for="(item, index) in d.imgs"
:key="index"
radius="15rpx"
height="145rpx"
width="145rpx"
@click.native="seeImg(index)"
@click.native="seeImg(d.imgs, index)"
:src="item"></u--image>
</view>
<view class="myQuestion-2-i-3">
<view class="myQuestion-2-i-3" >
<view class="myQuestion-2-i-3-l">
<view class="myQuestion-2-i-3-l-1" v-if="false">已解答</view>
<view class="myQuestion-2-i-3-l-1 myQuestion-2-i-3-l-1s" v-else>已解答</view>
<view class="myQuestion-2-i-3-l-t">程菲</view>
<view class="myQuestion-2-i-3-l-1" v-if="d.answer_type != 0">已解答</view>
<view class="myQuestion-2-i-3-l-1 myQuestion-2-i-3-l-1s" v-else>未解答</view>
<view class="myQuestion-2-i-3-l-t">{{d.tname}}</view>
</view>
<view class="myQuestion-2-i-3-r">
2023-12-11
{{d.answer_time || ''}}
</view>
</view>
</view>
</view>
<u-loadmore :status="status" v-if="!notData"/>
<u-empty
v-if="notData"
mode="data"
text="暂无数据"
icon="/static/imagesV2/icon24.png"
... ... @@ -117,36 +128,162 @@
return {
PAGETYPE,
type: PAGETYPE.CLASSROOM,
subjectList: [
{
title: '科目',
id: 1
}
],
basedOnList: [
{
title: '用户评价',
id: 1
keMu: {
list: [],
value: 0
},
// 分页
page: 1,
// 排序 asc-升序,desc-降序
sort: 'desc',
title: '',
list: [],
// 加载前值为loadmore,加载中为loading,没有数据为nomore
status: 'loadmore',
}
]
},
computed: {
notData() {
return this.status === 'nomore' && !this.list.length
}
},
mounted() {
onShow() {
this.onRetry()
},
onReachBottom() {
debugger
this.getData()
},
onLoad() {
this.getKeMuList();
},
methods: {
toAnswerForm() {
// tab切换
switchItem(type) {
this.type = type;
this.onRetry();
},
// 科目选择修改
keMupickerChange(e) {
this.keMu.value = e.detail.value;
this.onRetry();
},
// 排序切换
sortChange() {
this.sort = this.sort === 'asc' ? 'desc' : 'asc';
this.onRetry();
},
confirm(e) {
this.title = e;
this.onRetry();
},
// 获取科目列表
getKeMuList() {
uni.showLoading({
title: '加载中',
mask: true
})
this.$service.P_get('/question/kemu').then(res => {
uni.hideLoading();
if (res.code == 1) {
this.keMu.list = [
'全部',
...res.data
];
}else {
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '获取数据失败'
})
}
}
}).catch(e => {
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '获取数据失败,请检查您的网络连接'
})
})
},
// 列表分页初始化
onRetry(){
this.page= 1;
this.list = [];
this.status = 'loadmore';
this.getData()
},
// 获取数据
getData() {
if(this.status === 'loading' || this.status === 'nomore') return;
this.status = 'loading';
uni.showLoading({
title: '加载中',
mask: true
})
const { keMu, page, sort, type, title } = this;
let api = '';
if(type === PAGETYPE.CLASSROOM) {
api = '/question/all'
}else {
api = '/question/lecturer'
}
this.$service.P_get(api, {
page,
order_sort: sort,
sub_tilte: keMu.list[keMu.value] === '全部' || !keMu.list[keMu.value] ? '' : keMu.list[keMu.value],
title,
}).then(res => {
uni.hideLoading();
if (res.code == 1) {
this.page++;
this.list = [
...this.list,
...res.data.data
];
this.status = res.data.data.length < res.data.per_page ? 'nomore' : 'loadmore'
}else {
this.status = 'loadmore';
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '获取数据失败'
})
}
}
}).catch(e => {
this.status = 'loadmore';
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '获取数据失败,请检查您的网络连接'
})
})
},
// 提问
toAnswerForm(data) {
uni.navigateTo({
url: '/pagesStu/answerForm/answerForm'
url: '/pagesStu/answerForm/answerForm?id=' + data.id
})
},
seeImg(index) {
seeImg(urls, current = 0) {
uni.previewImage({
current: index, // 当前显示图片的链接,不填则默认为 urls 的第一张图片
urls: this.info.imgs // 需要预览的图片链接列表
current, // 当前显示图片的链接,不填则默认为 urls 的第一张图片
urls // 需要预览的图片链接列表
})
},
toMyQuestion() {
... ... @@ -158,18 +295,9 @@
let result = this.$refs.searchTopRef.getOtherHeight()
this.$refs.paddingTopBRef.setOtherHeight(result, 'px')
},
bindpickerChange(e) {
},
bindpickerChange2(e) {
},
switchItem(type) {
this.type = type
},
confirm(e) {
console.log(e)
}
}
}
</script>
... ... @@ -219,6 +347,9 @@
padding-right: 25rpx;
display: flex;
align-items: center;
.asc {
transform: scaleY(-1);
}
}
}
.answer-2-r{
... ... @@ -283,7 +414,8 @@
.answer-item-l-img{
height: 110rpx;
width: 110rpx;
border-radius: 200rpx;
border-radius: 50%;
overflow: hidden;
}
}
.answer-item-r{
... ... @@ -328,6 +460,7 @@
background-color: #FFFFFF;
box-sizing: border-box;
border-radius: 20rpx;
margin-bottom: 20rpx;
.myQuestion-2-i-1{
display: flex;
align-items: center;
... ... @@ -335,7 +468,8 @@
.myQuestion-2-i-1-l-i{
height: 60rpx;
width: 60rpx;
border-radius: 100%;
border-radius: 50%;
overflow: hidden;
}
}
.myQuestion-2-i-1-r{
... ... @@ -364,8 +498,10 @@
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 20rpx;
.myQuestion-2-i-3-l{
display: flex;
align-items: center;
.myQuestion-2-i-3-l-1{
border-radius: 20rpx 20rpx 0px 20rpx;
height: 40rpx;
... ...
... ... @@ -3,53 +3,61 @@
<view class="answerDetails-c">
<view class="myQuestion-2-i-1">
<view class="myQuestion-2-i-1-l">
<image class="myQuestion-2-i-1-l-i" src="@/static/images/tx.png" mode="widthFix"></image>
<view class="myQuestion-2-i-1-l-i">
<image :src="info.img || '/static/images/tx.png'" mode="widthFix"></image>
</view>
</view>
<view class="myQuestion-2-i-1-r">
<view class="myQuestion-2-i-1-r-1">李晋心</view>
<view class="myQuestion-2-i-1-r-2">2023-12-10发布</view>
<view class="myQuestion-2-i-1-r-1">{{info.name}}</view>
<view class="myQuestion-2-i-1-r-2">{{info.create_time}}发布</view>
</view>
</view>
<view class="myQuestion-2-i-2">
老师你好请问工商管理专业的应届生可以报考工商管理
内的二级专业吗?比如说会计学,旅游管理?
{{info.question}}
</view>
<view class="myQuestion-2-i-5"></view>
<view class="myQuestion-2-i-4">
<u--image
v-for="(item, index) in []"
v-for="(item, index) in info.imgs"
:key="index"
radius="15rpx"
height="145rpx"
width="145rpx"
@click.native="seeImg(index)"
@click.native="seeImg(info.imgs,index)"
:src="item"></u--image>
</view>
<view class="myQuestion-2-i-3">
<view class="myQuestion-2-i-5"></view>
<view class="myQuestion-2-i-3" v-if="isAnswered">
<view class="myQuestion-2-i-3-c">
<view class="myQuestion-2-i-3-c-1">
<view class="myQuestion-2-i-3-c-1-l">
<image class="myQuestion-2-i-3-c-1-l-i" src="@/static/images/tx.png" mode="widthFix"></image>
<text class="myQuestion-2-i-3-c-1-l-t">程菲老师回复</text>
<text class="myQuestion-2-i-3-c-1-l-t">{{info.lecturer.title}}老师回复</text>
</view>
<view class="myQuestion-2-i-3-c-1-r">2023-12-10</view>
<view class="myQuestion-2-i-3-c-1-r">{{info.answer_time}}</view>
</view>
<view class="myQuestion-2-i-3-c-2">
同学你好,这个问题问的好,你说的这些都是不可以报的!
<view class="myQuestion-2-i-3-c-2" v-if="isTextReply">
{{info.answer}}
</view>
<view style="margin-top: 28rpx;">
<VoicePlayback />
<view style="margin-top: 28rpx;" v-if="isVoiceReply">
<VoicePlayback
ref="voicePlayback"
/>
</view>
</view>
</view>
<u-empty
v-else
mode="data"
text="暂无回复"
icon="/static/imagesV2/icon43.png"
>
</u-empty>
</view>
</view>
</view>
<view class="answerDetails-b">
<view class="answerDetails-b" v-if="isAnswered && isUnRated">
<view class="answerDetails-b-c">
<view class="answerDetails-b-c-l">
<view class="answerDetails-b-c-l-1">请对本次答复</view>
... ... @@ -57,7 +65,7 @@
</view>
<view class="answerDetails-b-c-r">
<u-rate :count="5" v-model="score" size="20"></u-rate>
<view class="answerDetails-b-c-r-c">提交</view>
<view class="answerDetails-b-c-r-c" @click="submit">提交</view>
</view>
</view>
</view>
... ... @@ -66,24 +74,150 @@
<script>
import VoicePlayback from "@/components/VoicePlayback/index.vue"
import { MESSAGETYPE, SCORESTATE } from "@/emit/index.js"
export default {
components: {
VoicePlayback
},
data() {
return {
id: '',
info: {},
score: 5
}
},
computed: {
// 是否已解答
isAnswered() {
return this.isVoiceReply || this.isTextReply;
},
// 是否文字回复
isTextReply() {
const { answer_type } = this.info;
return answer_type === MESSAGETYPE.TEXTANSWER
},
// 是否语音回复
isVoiceReply() {
const { answer_type } = this.info;
return answer_type === MESSAGETYPE.VOICEANSWERS
},
//语音回复数据
voiceReplyData() {
let obj = null;
if(this.isVoiceReply) {
obj = JSON.parse(this.info.answer);
}
return obj
},
// 是否未评分
isUnRated() {
return this.info.is_score === SCORESTATE.UNRATED
}
},
onLoad(option) {
this.id = option.id;
this.getInfo();
},
methods: {
getInfo() {
uni.showLoading({
title: '加载中',
mask: true
})
this.$service.P_get('/question/info', {
id: this.id
}).then(res => {
uni.hideLoading();
if (res.code == 1) {
this.info = res.data;
if(typeof res.data.imgs === 'string') {
this.info.imgs = res.data.imgs.split(',');
}
this.$nextTick(() => {
if(this.isVoiceReply) {
this.$refs.voicePlayback.init(this.voiceReplyData)
}
})
}else {
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '获取数据失败'
})
}
}
}).catch(e => {
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '获取数据失败,请检查您的网络连接'
})
})
},
seeImg(urls, current = 0) {
uni.previewImage({
current, // 当前显示图片的链接,不填则默认为 urls 的第一张图片
urls // 需要预览的图片链接列表
})
},
// 提交评分
submit() {
uni.showLoading({
title: '提交中',
mask: true
})
this.$service.P_get('/question/score', {
id: this.id,
score: this.score
}).then(res => {
uni.hideLoading();
if (res.code == 1) {
uni.showToast({
icon:'none',
title:'保存成功'
})
this.info.is_score = SCORESTATE.RATED;
}else {
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '获取数据失败'
})
}
}
}).catch(e => {
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '获取数据失败,请检查您的网络连接'
})
})
}
}
}
</script>
<style lang="scss" scoped>
.answerDetails{
padding: 20rpx 25rpx;
padding: 20rpx 25rpx 140rpx;
.answerDetails-b{
position: fixed;
left: 0;
... ... @@ -148,7 +282,8 @@
.myQuestion-2-i-1-l-i{
height: 60rpx;
width: 60rpx;
border-radius: 100%;
border-radius: 50%;
overflow: hidden;
}
}
.myQuestion-2-i-1-r{
... ...
... ... @@ -30,10 +30,14 @@
export default {
data() {
return {
id: '',
fileList: [],
content: ''
};
},
onLoad(option) {
this.id = option.id;
},
methods: {
imgdel(e){
var that =this
... ... @@ -131,21 +135,48 @@
},
submit() {
console.log(this.fileList);
uni.showLoading({
title: '提交中',
mask: true
})
var datas = {
content: this.content,
tid: this.id,
question: this.content,
imgs: this.fileList
}
var jkurl = '/praise/add'
var jkurl = '/question/add';
this.$service.P_post(jkurl, datas).then(res => {
uni.hideLoading();
if (res.code == 1) {
uni.showToast({
icon:'none',
title: '上传成功'
title:'保存成功'
})
setTimeout(function(){
uni.navigateBack()
},1000)
}else {
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
setTimeout(() => {
uni.navigateBack({
delta: 1
} else {
uni.showToast({
icon: 'none',
title: '获取数据失败'
})
}
}
}).catch(e => {
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '获取数据失败,请检查您的网络连接'
})
}, 1500)
})
},
async afterRead(event) {
... ...
... ... @@ -5,42 +5,52 @@
<view @click="switchItem(MYQUESTIONTYPE.UNANSWERED)" :class="{'myQuestion-i': true, 'myQuestion-is': type === MYQUESTIONTYPE.UNANSWERED}">未解答</view>
</view>
<view class="myQuestion-2">
<view class="myQuestion-2-i" @click="toAnswerDetails">
<view class="myQuestion-2-i" v-for="d in list" :key="d.id" @click="toAnswerDetails(d)">
<view class="myQuestion-2-i-1">
<view class="myQuestion-2-i-1-l">
<image class="myQuestion-2-i-1-l-i" src="@/static/images/tx.png" mode="widthFix"></image>
<view class="myQuestion-2-i-1-l-i">
<image :src="d.img || '/static/images/tx.png'" mode="widthFix"></image>
</view>
</view>
<view class="myQuestion-2-i-1-r">
<view class="myQuestion-2-i-1-r-1">李晋心</view>
<view class="myQuestion-2-i-1-r-2">2023-12-10发布</view>
<view class="myQuestion-2-i-1-r-1">{{d.name}}</view>
<view class="myQuestion-2-i-1-r-2">{{d.create_time}}发布</view>
</view>
</view>
<view class="myQuestion-2-i-2">
老师你好请问工商管理专业的应届生可以报考工商管理
内的二级专业吗?比如说会计学,旅游管理?
{{d.question}}
</view>
<view class="myQuestion-2-i-4">
<view class="myQuestion-2-i-4" v-if="d.imgs && d.imgs.length">
<u--image
v-for="(item, index) in []"
v-for="(item, index) in d.imgs"
:key="index"
radius="15rpx"
height="145rpx"
width="145rpx"
@click.native="seeImg(index)"
@click.stop="seeImg(d.imgs, index)"
:src="item"></u--image>
</view>
<view class="myQuestion-2-i-3">
<view class="myQuestion-2-i-3-l">
<view class="myQuestion-2-i-3-l-1" v-if="false">已解答</view>
<view class="myQuestion-2-i-3-l-1 myQuestion-2-i-3-l-1s" v-else>已解答</view>
<view class="myQuestion-2-i-3-l-t">程菲</view>
<view class="myQuestion-2-i-3-l-1" v-if="type === MYQUESTIONTYPE.ANSWERED">已解答</view>
<view class="myQuestion-2-i-3-l-1 myQuestion-2-i-3-l-1s" v-else>未解答</view>
<view class="myQuestion-2-i-3-l-t">{{d.tname}}</view>
</view>
<view class="myQuestion-2-i-3-r">
2023-12-11
{{d.answer_time || ''}}
</view>
</view>
</view>
</view>
<u-loadmore :status="status" v-if="!notData"/>
<u-empty
v-if="notData"
mode="data"
text="暂无数据"
icon="/static/imagesV2/icon24.png"
>
</u-empty>
</view>
</template>
... ... @@ -53,23 +63,86 @@
return {
MYQUESTIONTYPE,
type: MYQUESTIONTYPE.ANSWERED,
page: 1,
list: [],
// 加载前值为loadmore,加载中为loading,没有数据为nomore
status: 'loadmore'
}
},
onLoad() {
this.onRetry()
},
onReachBottom() {
this.getData()
},
methods: {
toAnswerDetails() {
toAnswerDetails(data) {
uni.navigateTo({
url: '/pagesStu/answerDetails/answerDetails'
url: '/pagesStu/answerDetails/answerDetails?id=' + data.id
})
},
// 切换tab
switchItem(type) {
this.type = type
this.onRetry();
},
seeImg(index) {
seeImg(urls, current = 0) {
uni.previewImage({
current: index, // 当前显示图片的链接,不填则默认为 urls 的第一张图片
urls: [] // 需要预览的图片链接列表
current, // 当前显示图片的链接,不填则默认为 urls 的第一张图片
urls // 需要预览的图片链接列表
})
},
onRetry(){
this.page= 1;
this.list = [];
this.status = 'loadmore';
this.getData()
},
getData() {
if(this.status === 'loading' || this.status === 'nomore') return;
this.status = 'loading';
uni.showLoading({
title: '加载中',
mask: true
})
this.$service.P_get('/question/my', {
page: this.page,
type: this.type
}).then(res => {
uni.hideLoading();
if (res.code == 1) {
this.page++;
this.list = [
...this.list,
...res.data.data
];
this.status = res.data.data.length < res.data.per_page ? 'nomore' : 'loadmore'
}else {
this.status = 'loadmore';
if (res.msg) {
uni.showToast({
icon: 'none',
title: res.msg
})
} else {
uni.showToast({
icon: 'none',
title: '获取数据失败'
})
}
}
}).catch(e => {
this.status = 'loadmore';
uni.hideLoading()
uni.showToast({
icon: 'none',
title: '获取数据失败,请检查您的网络连接'
})
})
}
}
}
</script>
... ... @@ -117,6 +190,7 @@
background-color: #FFFFFF;
box-sizing: border-box;
border-radius: 20rpx;
margin-bottom: 20rpx;
.myQuestion-2-i-1{
display: flex;
align-items: center;
... ... @@ -124,7 +198,8 @@
.myQuestion-2-i-1-l-i{
height: 60rpx;
width: 60rpx;
border-radius: 100%;
border-radius: 50%;
overflow: hidden;
}
}
.myQuestion-2-i-1-r{
... ... @@ -155,6 +230,7 @@
display: flex;
justify-content: space-between;
align-items: center;
margin-top: 20rpx;
.myQuestion-2-i-3-l{
display: flex;
.myQuestion-2-i-3-l-1{
... ...