66 lines
1.6 KiB
JavaScript
66 lines
1.6 KiB
JavaScript
|
|
/**
|
|||
|
|
* Soul创业派对 - 选择导师(stitch_soul)
|
|||
|
|
*/
|
|||
|
|
const app = getApp()
|
|||
|
|
|
|||
|
|
Page({
|
|||
|
|
data: {
|
|||
|
|
statusBarHeight: 44,
|
|||
|
|
mentors: [],
|
|||
|
|
loading: true,
|
|||
|
|
searchKw: '',
|
|||
|
|
filterSkill: '',
|
|||
|
|
skills: ['全部', '项目结构判断', '产品架构', 'BP梳理', '职业转型'],
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
onLoad() {
|
|||
|
|
this.setData({ statusBarHeight: app.globalData.statusBarHeight || 44 })
|
|||
|
|
this.loadMentors()
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
onSearchInput(e) {
|
|||
|
|
this.setData({ searchKw: e.detail.value })
|
|||
|
|
this.loadMentors()
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
onFilterTap(e) {
|
|||
|
|
const skill = e.currentTarget.dataset.skill
|
|||
|
|
this.setData({ filterSkill: skill === '全部' ? '' : skill })
|
|||
|
|
this.loadMentors()
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
async loadMentors() {
|
|||
|
|
this.setData({ loading: true })
|
|||
|
|
try {
|
|||
|
|
let url = '/api/miniprogram/mentors'
|
|||
|
|
const params = []
|
|||
|
|
if (this.data.searchKw) params.push(`q=${encodeURIComponent(this.data.searchKw)}`)
|
|||
|
|
if (this.data.filterSkill) params.push(`skill=${encodeURIComponent(this.data.filterSkill)}`)
|
|||
|
|
if (params.length) url += '?' + params.join('&')
|
|||
|
|
|
|||
|
|
const res = await app.request({ url, silent: true })
|
|||
|
|
if (res?.success && res.data) {
|
|||
|
|
this.setData({ mentors: res.data })
|
|||
|
|
} else {
|
|||
|
|
this.setData({ mentors: [] })
|
|||
|
|
}
|
|||
|
|
} catch (e) {
|
|||
|
|
this.setData({ mentors: [] })
|
|||
|
|
}
|
|||
|
|
this.setData({ loading: false })
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
onRefresh() {
|
|||
|
|
this.loadMentors()
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
goDetail(e) {
|
|||
|
|
const id = e.currentTarget.dataset.id
|
|||
|
|
wx.navigateTo({ url: `/pages/mentor-detail/mentor-detail?id=${id}` })
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
goBack() {
|
|||
|
|
getApp().goBackOrToHome()
|
|||
|
|
},
|
|||
|
|
})
|