luffy之前端调用后端接口,动态显示页面内容
luffy之前端调用后端接口,动态显示页面内容
复习
1 设计课程相关表(开发阶段,字段的增减很正常)
-课程分类
-课程(每个课程一个表)
-章节表
-课时表
-老师表
# 关系型数据库中 其实就只有一种关系,就是外键关系:一对一,一对多,多对多
2 录入数据
3 所有课程分类接口
4 查询所有课程:排序(人气,价格,id),过滤(课程分类),分页
-?course_category=2
-序列化字段比较多
-在models中写
-在序列化类中写
-子序列化
5 查询课程详情
6 查询所有章节及课时接口(带通过课程过滤)
filter_backends = [DjangoFilterBackend]
filter_fields = ('course',)
今日内容
1 课程列表前端
- 课程分类:
- 全部
- {{category.name}}
- 筛 选:
- 默认
- 人气
- 价格
共{{course_total}}个课程
{{course.name}}
{{course.students}}人已加入学习
{{course.teacher.name}} {{course.teacher.title}} {{course.teacher.signature}}
共{{course.sections}}课时/已更新{{course.pub_sections}}课时
共{{course.sections}}课时/更新完成
- 0{{key+1}} | {{section.name}}
免费
{{course.discount_type}}
¥{{course.real_price}}元
原价:{{course.price}}元
¥{{course.price}}元
立即购买
#
#####path: '/course/detail/:id', 这样设置取id在parms里取
this.$route # 是当前路由对象,parmas :绑定的值都传给她了 query:?拼接的值
this.$router # 全局路由
this.$router.go(-1) # 回退到上一个地址 比如输入了一个非法地址 不让他进去,然后回退到上一个页面
2 课程详情前端设置
# 视频播放组件
###第一步:安装
cnpm install vue-video-player
###第二步:main.js 配置
// vue-video播放器
require('video.js/dist/video-js.css');
require('vue-video-player/src/custom-theme.css');
import VideoPlayer from 'vue-video-player'
Vue.use(VideoPlayer);
### 第三步使用:修改成自己的端口查询的字段
# 视频托管
-放在自己的服务器(media文件夹)
-自己搭建文件服务器(fastdfs,ceph,minio)
-minio 搭建,
-第三方文件存储:阿里oss,七牛云存储
-咱么放在了七牛云上
# python 操作fastdfs
https://zhuanlan.zhihu.com/p/372286804
# minio搭建
http://docs.minio.org.cn/docs/master/minio-monitoring-guide
{{course_info.name}}
{{course_info.students}}人在学 课程总时长:{{course_info.sections}}课时/{{course_info.pub_sections}}小时 难度:{{course_info.level_name}}
价格 ¥{{course_info.price}}
- 详情介绍
- 课程章节 (试学)
- 用户评论
- 常见问题
课程章节
共{{course_chapters.length}}章 {{course_info.sections}}个课时
第{{chapter.chapter}}章·{{chapter.name}}
-
{{chapter.chapter}}-{{section.orders}}
{{section.name}}免费
{{section.duration}} 
用户评论
常见问题
授课老师
{{course_info.teacher.name}}
{{course_info.teacher.title}}
{{course_info.teacher.signature}}
{{course_info.teacher.brief}}
3 搜索课程接口
### 搜索接口
class CourseSearchView(GenericViewSet, ListModelMixin, RetrieveModelMixin):
serializer_class = CourseSerializer
queryset = Course.objects.filter(is_show=True, is_delete=False).order_by('orders')
filter_backends = [OrderingFilter, DjangoFilterBackend,SearchFilter]
ordering_fields = ['price', 'students', 'id'] # 按price,student,id排序
filter_fields = ('course_category',) # 按课程分类过滤
search_fields=['name','price']
# 分页
pagination_class = CommonPageNumberPagination
# # 免费,实战,轻课
# def list(self, request, *args, **kwargs):
# res=super().list(request, *args, **kwargs) #实战课
# # 后期需要使用专门的搜索引擎---》es
# # 用户画像:
# return APIResponse(shizhanke=res.data) # {code:100,msg:成功,shizhanke:[],mianfeike:[],qingke:[]}
#
4 搜索功能前端
{{course.name}}
{{course.students}}人已加入学习
{{course.teacher.name}} {{course.teacher.title}} {{course.teacher.signature}}
共{{course.sections}}课时/已更新{{course.pub_sections}}课时
共{{course.sections}}课时/更新完成
- 0{{key+1}} | {{section.name}}
免费
{{course.discount_type}}
¥{{course.real_price}}元
原价:{{course.price}}元
¥{{course.price}}元
立即购买
没有搜索结果
5 支付宝介绍
# 支付:支付宝,微信,云闪付
# 咱们使用支付宝:
-真实支付:营业执照
-测试:沙箱环境:https://openhome.alipay.com/platform/appDaily.htm?tab=info
# 支付流程
https://opendocs.alipay.com/open/270/105898
-用户在我的网站点击 立即购买---》向后端发送下单请求---》返回数据中带支付链接(支付宝)-->前端跳转到支付链接(支付宝)---》扫码支付(支付宝)---》支付宝收到钱会回调回我的网站---》显示购买成功