Commit 458d8305 authored by 任国军's avatar 任国军

fix online bugs

parent 6c56e7c3
Pipeline #19449 passed with stage
in 57 seconds
......@@ -11,13 +11,14 @@ class OnlineService extends Service {
async getOption() {
const { ctx } = this;
// 分类
const cats = await ctx.classModel.V4.CourseOnlineCat.findAll({ where: { status: 'online', is_deleted: 0 }, attributes: [ 'id', 'name' ] });
const cats = await ctx.classModel.V4.CourseOnlineCat.findAll({ where: { status: 'online', is_deleted: 0 }, attributes: [ 'id', 'name' ], raw: true });
cats.push({ id: 0, name: '全部' });
// 年龄段
const ages = [ '学龄前', '幼儿园', '小学', '初中', '高中' ];
const ages = [ '全部', '学龄前', '幼儿园', '小学', '初中', '高中' ];
// 课程状态
const mode = [{ id: 0, name: '全部' }, { id: 1, name: '直播' }, { id: 2, name: '录播' }];
// 课程班型
const type = [ '1对1', '1对多', '讲座' ];
const type = [ '全部', '1对1', '1对多', '讲座' ];
const options = {
cats,
......@@ -38,10 +39,11 @@ class OnlineService extends Service {
}
// 缩略图
const imageInfo = await ctx.classModel.V4.CourseImages.findOne({ where: { type: 5, type_id: id, status: 'online', is_deleted: 0 } });
let image = {};
if (!ctx.isEmpty(imageInfo)) {
image = imageInfo.is_video > 0 ? { url: imageInfo.video_url, type: 1 } : { url: imageInfo.image_url, type: 0 };
const imageInfo = await ctx.classModel.V4.CourseImages.findAll({ where: { type: 5, type_id: id, status: 'online', is_deleted: 0 } });
const images = [];
for (const v of imageInfo) {
const image = v.is_video > 0 ? { url: v.video_url, type: 1 } : { url: v.image_url, type: 0 };
images.push(image);
}
// 机构信息
......@@ -61,10 +63,11 @@ class OnlineService extends Service {
const ret = {
id,
image,
images,
name: classInfo.name,
institution_name: ctx.isEmpty(institution) ? '' : institution.name,
institution_id: classInfo.institution_id,
institution_logo: ctx.isEmpty(institution) ? '' : institution.logo,
relation_institution_id: ctx.isEmpty(institution) ? 0 : institution.relation_id,
address: ctx.isEmpty(area) ? '' : area.address,
phone: ctx.isEmpty(area) ? '' : area.phone,
......
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