123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- <template>
- <view>
- <view v-for="(item, index) in requirement" :key="index">
- <view class="requires" @click="requireDetail(item)">
- <uni-row class="demo-uni-row">
- <uni-col offset="1">
- <view class="requires-col1">课程号:{{item.courseId}}</view>
- </uni-col>
- </uni-row>
- <uni-row class="demo-uni-row">
- <uni-col offset="1" :span="16">
- <view class="requires-col2">科目:{{item.subject}}</view>
- </uni-col>
- <uni-col :span="7">
- <view>
- <button @click.stop="open(item)" size="mini" :type="item.buttonType">{{item.display}}</button>
- </view>
- </uni-col>
- </uni-row>
- <view class="requires-col3">
- <uni-row class="demo-uni-row">
- <uni-col :span="4" offset="12">
- <view style="color: red;">{{item.verifyStatus}}</view>
- </uni-col>
- <uni-col :span="4" >
- <view style="color: red;">{{item.deal}}</view>
- </uni-col>
- <uni-col :span="4" >
- <view style="color: red;">{{item.locked}}</view>
- </uni-col>
- </uni-row>
- </view>
- </view>
- </view>
-
- <uni-popup ref="popup" type="message">
- <uni-popup-message :type="popupType" :message="showMessage" :duration="1000"></uni-popup-message>
- </uni-popup>
-
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- requirement: [],
- // 分页对象
- queryObj: {
- pageNum: 1,
- pageSize: 8
- },
- isloading: false,
- count: 0, // 总数量
- publishCount: 0, // 上架数量
- showMessage: '上架成功',
- popupType: 'success'
- }
- },
- created() {
- this.getPublishCounts()
- },
- methods: {
- // 查询个人上架了多少课程
- async getPublishCounts(cb) {
- // 打开节流阀
- this.isloading = true
-
- const { data: result } = await uni.$http.get('/education/teacher-courses/showPersonCourse', this.queryObj)
-
- this.isloading = false
- cb && cb()
-
- // console.log(result.data.list)
- this.publishCount = result.data.publishCounts
- this.count = result.data.count
- let courses = []
- courses = result.data.list
-
- for (let i = 0; i < courses.length; i++) {
- if (courses[i].display === '上架') {
- courses[i].display = '下架'
- courses[i].buttonType = 'warn'
- } else {
- courses[i].display = '上架'
- courses[i].buttonType = 'primary'
- }
- }
-
- this.requirement = [...this.requirement, ...courses]
- console.log(this.requirement)
- },
- // 下拉刷新的事件
- onPullDownRefresh() {
- if (this.isloading) return
- // 1.重置数据
- this.queryObj.pageNum = 1
- this.publishCount = 0
- this.requirement = []
- this.isloading = false
-
- // 2.重新发请求
- this.getPublishCounts(() => uni.stopPullDownRefresh())
- },
- // 触底的事件
- onReachBottom() {
- // 判断是否有下一页的数据
- if (this.queryObj.pageNum * this.queryObj.pageSize >= this.count)
- return uni.$showMsg('数据加载完毕!')
-
- // 是否有其他正在请求数据
- if (this.isloading) return
-
- // 页码自增
- this.queryObj.pageNum += 1
- this.getPublishCounts()
- },
- async open(item) {
- console.log(item.display)
- if (item.display === '上架') {
- if (item.verifyStatus !== '已通过') return uni.$showMsg('审核通过才能上架')
- if (item.deal === '已成交') return uni.$showMsg('已成交的课程不能上架')
- if (this.publishCount >= 4) return uni.$showMsg('最多上架4个课程')
- }
- const queryObj = {
- display: item.display,
- courseId: item.courseId
- }
- const { data: result } = await uni.$http.get('/education/teacher-courses/updatePersonDisplay', queryObj)
- if (result.code === 20000) {
- if (item.display === '上架') {
- item.display = '下架'
- this.showMessage = '上架成功'
- this.popupType = 'success'
- item.buttonType = 'warn'
- this.publishCount += 1
-
- } else if (item.display === '下架') {
- item.display = '上架'
- this.showMessage = '下架成功'
- this.popupType = 'error'
- item.buttonType = 'primary'
- this.publishCount -= 1
- }
- this.$refs.popup.open('top')
- }
- },
- requireDetail(item) {
- uni.navigateTo({
- url: '/subpkg/course_detail/course_detail?item=' + encodeURIComponent(JSON.stringify(item))
- })
- },
- }
- }
- </script>
- <style scoped lang="scss">
- .requires {
- background-color: #FFF2CC;
- border: 1px solid #41719C;
-
- .requires-col1 {
- margin-top: 15rpx;
- }
-
- .requires-col2 {
- margin: 15rpx 0;
- }
-
- .requires-col3 {
- padding-bottom: 15rpx;
- }
- }
- </style>
|