Commit 866ba1df authored by 周楠's avatar 周楠

add: add price_type; wechat image

parent f7831737
Pipeline #19774 passed with stage
in 1 minute 5 seconds
...@@ -14,6 +14,7 @@ module.exports = app => { ...@@ -14,6 +14,7 @@ module.exports = app => {
institution_id: INTEGER, institution_id: INTEGER,
name: STRING, name: STRING,
price: STRING, price: STRING,
price_type: INTEGER,
mode: INTEGER, mode: INTEGER,
time: STRING, time: STRING,
channel: TEXT, channel: TEXT,
......
...@@ -21,12 +21,15 @@ class OnlineService extends Service { ...@@ -21,12 +21,15 @@ class OnlineService extends Service {
// 课程班型 // 课程班型
let type = await ctx.classModel.V4.CourseOnlineType.findAll({ where: { status: 'online', is_deleted: 0 }, attributes: [ 'id', 'name' ], raw: true }); let type = await ctx.classModel.V4.CourseOnlineType.findAll({ where: { status: 'online', is_deleted: 0 }, attributes: [ 'id', 'name' ], raw: true });
type = [{ id: 0, name: '全部' }].concat(type); type = [{ id: 0, name: '全部' }].concat(type);
// 课程类型
const price_type = [{ id: 1, name: '低价体验课' }, { id: 2, name: '公益免费课' }, { id: 3, name: '正价课' }];
const options = { const options = {
cats, cats,
ages, ages,
mode, mode,
type, // type,
price_type,
}; };
return options; return options;
} }
...@@ -105,7 +108,7 @@ class OnlineService extends Service { ...@@ -105,7 +108,7 @@ class OnlineService extends Service {
const page = Number(input.page) || 1; const page = Number(input.page) || 1;
const limit = Number(input.limit) || 10; const limit = Number(input.limit) || 10;
const offset = (page - 1) * limit; const offset = (page - 1) * limit;
const { type, mode, age, cat } = input; const { type, mode, age, cat, price_type } = input;
const filter = { where: { status: 'online', is_deleted: 0 }, order: [[ 'institution_id', 'desc' ]], limit, offset, attributes: [ 'id', 'institution_id', 'name', 'price', 'mode', 'time', 'created_time' ] }; const filter = { where: { status: 'online', is_deleted: 0 }, order: [[ 'institution_id', 'desc' ]], limit, offset, attributes: [ 'id', 'institution_id', 'name', 'price', 'mode', 'time', 'created_time' ] };
// 年龄段筛选 // 年龄段筛选
let ids = []; let ids = [];
...@@ -133,6 +136,10 @@ class OnlineService extends Service { ...@@ -133,6 +136,10 @@ class OnlineService extends Service {
if (!ctx.isEmpty(mode) && Number(mode) > 0) { if (!ctx.isEmpty(mode) && Number(mode) > 0) {
filter.where.mode = mode; filter.where.mode = mode;
} }
// 课程类型筛选
if (!ctx.isEmpty(price_type) && Number(price_type) > 0) {
filter.where.price_type = price_type;
}
// 课程班型筛选 // 课程班型筛选
if (!ctx.isEmpty(type) && Number(type) > 0) { if (!ctx.isEmpty(type) && Number(type) > 0) {
const classes = await ctx.classModel.V4.CourseOnlineClassToType.findAll({ where: { type_id: type, status: 'online', is_deleted: 0 }, attributes: [ 'class_id' ] }); const classes = await ctx.classModel.V4.CourseOnlineClassToType.findAll({ where: { type_id: type, status: 'online', is_deleted: 0 }, attributes: [ 'class_id' ] });
...@@ -213,6 +220,7 @@ class OnlineService extends Service { ...@@ -213,6 +220,7 @@ class OnlineService extends Service {
logo: ctx.isEmpty(institutions[v.institution_id]) ? '' : institutions[v.institution_id][0].logo, logo: ctx.isEmpty(institutions[v.institution_id]) ? '' : institutions[v.institution_id][0].logo,
type: ctx.isEmpty(classTypes[v.id]) ? [] : classTypes[v.id], type: ctx.isEmpty(classTypes[v.id]) ? [] : classTypes[v.id],
mode: await this.getClassModelInfo(v.mode), mode: await this.getClassModelInfo(v.mode),
price_type: this.getClassModelInfo(v.price_type),
price: v.price, price: v.price,
time: v.time, time: v.time,
created_time: v.created_time, created_time: v.created_time,
...@@ -246,10 +254,27 @@ class OnlineService extends Service { ...@@ -246,10 +254,27 @@ class OnlineService extends Service {
default: default:
break; break;
} }
return ret; return ret;
} }
// 判断课程类型
getClassModelPriceType(price_type) {
let ret = '';
switch (price_type) {
case 1:
ret = '低价体验课';
break;
case 2:
ret = '公益免费课';
break;
case 3:
ret = '正价课';
break;
default:
break;
}
return ret;
}
// 收藏在线课程 // 收藏在线课程
async collectClass(id) { async collectClass(id) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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