|
@@ -47,7 +47,14 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ // 分页对象
|
|
|
+ queryObj: {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 8
|
|
|
+ },
|
|
|
+ isloading: false,
|
|
|
requirement: [], // 需求列表
|
|
|
+ count: 0, // 总数量
|
|
|
publishCount: 0, // 上架数量
|
|
|
pattern: {
|
|
|
color: '#7A7E83',
|
|
@@ -69,32 +76,95 @@
|
|
|
})
|
|
|
},
|
|
|
// 查询个人上架了多少课程
|
|
|
- async getPublishCounts() {
|
|
|
- const { data: result } = await uni.$http.get('/education/student-requirements/getPublishCounts')
|
|
|
- this.publishCount = result.data.count
|
|
|
- this.requirement = result.data.list
|
|
|
- for (let i = 0; i < this.requirement.length; i++) {
|
|
|
- if (this.requirement[i].display === '上架') {
|
|
|
- this.requirement[i].display = '下架'
|
|
|
- this.requirement[i].options = [{text: '下架', style: {backgroundColor: '#E2F0D9', color: 'black'}}]
|
|
|
+ async getPublishCounts(cb) {
|
|
|
+ // 打开节流阀
|
|
|
+ this.isloading = true
|
|
|
+
|
|
|
+ const { data: result } = await uni.$http.get('/education/student-requirements/getPublishCounts', 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].options = [{text: '下架', style: {backgroundColor: '#E2F0D9', color: 'black'}}]
|
|
|
} else {
|
|
|
- this.requirement[i].display = '上架'
|
|
|
- this.requirement[i].options = [{text: '上架', style: {backgroundColor: '#E2F0D9', color: 'black'}}]
|
|
|
+ courses[i].display = '上架'
|
|
|
+ courses[i].options = [{text: '上架', style: {backgroundColor: '#E2F0D9', color: 'black'}}]
|
|
|
}
|
|
|
}
|
|
|
- // console.log(this.requirement)
|
|
|
+
|
|
|
+ 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 bindClick(item) {
|
|
|
+ console.log(item)
|
|
|
+
|
|
|
+ if (item.display === '上架') {
|
|
|
+ if (this.publishCount >= 4) return uni.$showMsg('最多发布4个需求')
|
|
|
+ if (item.verifyStatus !== '已通过') return uni.$showMsg('审核通过才能上架')
|
|
|
+ if (item.deal === '已成交') return uni.$showMsg('已成交的需求不能上架')
|
|
|
+ }
|
|
|
+
|
|
|
const queryObj = {
|
|
|
display: item.display,
|
|
|
requireId: item.requireId
|
|
|
}
|
|
|
const { data: result } = await uni.$http.get('/education/student-requirements/updatePersonDisplay', queryObj)
|
|
|
+ const that = this
|
|
|
if (result.code === 20000) {
|
|
|
uni.$showMsg(item.display + '成功')
|
|
|
- setTimeout(() => {
|
|
|
- this.getPublishCounts()
|
|
|
- }, 500)
|
|
|
+
|
|
|
+
|
|
|
+ this.queryObj.pageNum = 1
|
|
|
+ this.publishCount = 0
|
|
|
+ this.requirement = []
|
|
|
+
|
|
|
+ const { data: result } = await uni.$http.get('/education/student-requirements/getPublishCounts', this.queryObj)
|
|
|
+ this.publishCount = result.data.publishCounts
|
|
|
+ this.count = result.data.count
|
|
|
+ this.requirement = result.data.list
|
|
|
+ for (let i = 0; i < this.requirement.length; i++) {
|
|
|
+ if (this.requirement[i].display === '上架') {
|
|
|
+ this.requirement[i].display = '下架'
|
|
|
+ this.requirement[i].options = [{text: '下架', style: {backgroundColor: '#E2F0D9', color: 'black'}}]
|
|
|
+ } else {
|
|
|
+ this.requirement[i].display = '上架'
|
|
|
+ this.requirement[i].options = [{text: '上架', style: {backgroundColor: '#E2F0D9', color: 'black'}}]
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
requireDetail(item) {
|