async function openCourse(item){
const user = JSON.parse(localStorage.getItem("currentUser"));
if(!user){
alert("请登录");
return;
}
const cost = item.needCoin;
if(cost === 0){
location.href = item.url;
return;
}
if(user.coin < cost){
alert(`天启币不足!需要${cost}天启币,你当前:${user.coin}`);
return;
}
//扣币
user.coin -= cost;
let userList = JSON.parse(localStorage.getItem("userList"));
const uIdx = userList.findIndex(u=>u.name === user.name);
userList[uIdx].coin = user.coin;
localStorage.setItem("userList",JSON.stringify(userList));
localStorage.setItem("currentUser",JSON.stringify(user));
addCoinRecord("观看课程消耗",-cost,user.name);
location.href = item.url;
}
全部课程
Scratch图形化编程
Scratch羊了个羊
制作消除小游戏,理解列表与克隆
开始学习
Scratch塔防游戏
敌人自动寻路,炮台射击
开始学习
Scratch 3D跑酷
简易3D效果,障碍物躲避
开始学习
Python实战编程
Python飞机大战
Pygame游戏开发入门
开始学习
Python海龟画图
绘制几何图形、艺术图案
开始学习
Python生命游戏
康威生命游戏模拟细胞演化
开始学习