Files
soul-yongping/miniprogram/pages/mentors/mentors.js
2026-03-07 22:58:43 +08:00

66 lines
1.6 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 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()
},
})