Files
gemini-cs/wechat-mini-program/pages/detail/detail.js
2025-12-09 02:45:30 +08:00

70 lines
2.0 KiB
JavaScript

const app = getApp()
Page({
data: {
project: null
},
onLoad(options) {
const { id } = options;
this.fetchProject(id);
},
fetchProject(id) {
const { request } = require('../../utils/request')
request({ url: `/projects/${id}` })
.then((data) => {
this.setData({ project: data })
})
.catch(() => {
const projects = [
{
id: 1,
title: 'Python 数据分析实战',
category: '编程开发',
image:
'https://images.unsplash.com/photo-1526379095098-d400fd0bf935?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3',
students: 1205,
rating: 4.8,
duration: '12 周'
},
{
id: 2,
title: '零基础英语口语速成',
category: '语言学习',
image:
'https://images.unsplash.com/photo-1543269865-cbf427effbad?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3',
students: 850,
rating: 4.9,
duration: '8 周'
},
{
id: 3,
title: 'UI/UX 设计全能班',
category: '设计创作',
image:
'https://images.unsplash.com/photo-1561070791-2526d30994b5?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3',
students: 2340,
rating: 4.7,
duration: '16 周'
},
{
id: 4,
title: '职场高效沟通技巧',
category: '职场提升',
image:
'https://images.unsplash.com/photo-1552581234-26160f608093?w=500&auto=format&fit=crop&q=60&ixlib=rb-4.0.3',
students: 5600,
rating: 4.6,
duration: '4 周'
}
]
this.setData({ project: projects.find((p) => p.id == id) })
})
},
handleEnroll() {
wx.showToast({
title: '报名成功',
icon: 'success'
})
}
})