页面构成

This commit is contained in:
Abin
2026-01-05 18:07:57 +08:00
parent 66b2e3ddac
commit c2f0c46c4d
40 changed files with 2817 additions and 0 deletions
+98
View File
@@ -0,0 +1,98 @@
// pages/kecheng/kecheng.js
Page({
/**
* 页面的初始数据
*/
data: {
BaseURL:getApp().globalData.BaseURL,
hasCourse: false,
OwnedCourse: null,
intervalId: null
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
//每10ms获取一次数据,直到获取到个人信息数据为止
// 使用箭头函数确保正确的作用域
var longtime=0;
this.intervalId = setInterval(() => {
//不间断刷新页面
this.onShow();
if (this.data.OwnedCourse){
clearInterval(this.intervalId);
return;
};
//计时500次,即5s后如果没有任何获取到已经登录的标志,依然断开计时器
if (longtime>=500){
clearInterval(this.intervalId);
console.log('暂无已购课程!');
};
longtime=longtime+1;
}, 10);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
if ((wx.getStorageSync('UserInfoCache').OwnedCourse)&&(wx.getStorageSync('UserInfoCache').IsLogin)) {
this.setData({
hasCourse: true,
OwnedCourse: wx.getStorageSync('UserInfoCache').OwnedCourse
});
} else {
this.setData({
hasCourse: false,
OwnedCourse: null
});
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
NavigatorToVideoDetails(e) {
var index=e.currentTarget.dataset.index;
wx.navigateTo({
url: '/pages/VideoDetails/VideoDetails?index='+index,
})
}
})
+6
View File
@@ -0,0 +1,6 @@
{
"usingComponents": {
},
"navigationBarTitleText": "课程"
}
+17
View File
@@ -0,0 +1,17 @@
<scroll-view class="container" scroll-y enable-flex type="custom">
<block wx:if="{{!hasCourse}}">
<text>暂无信息</text>
</block>
<block wx:else>
<view wx:for="{{OwnedCourse}}" wx:for-item="item" wx:for-index="index" wx:key="index" class="kecheng" bind:tap="NavigatorToVideoDetails" data-index="{{index}}">
<view class="kecheng_video_up">
<image class="kecheng_img" src="{{BaseURL}}/Course/{{item['课程id']}}.png" mode="aspectFit" />
</view>
<view class="kecheng_video_right">
<text class="kecheng_title">{{item['课程']}}</text>
<text class="kecheng_details">{{item['课程介绍']}}</text>
</view>
</view>
</block>
</scroll-view>
+50
View File
@@ -0,0 +1,50 @@
/* pages/kecheng/kecheng.wxss */
.container {
padding:0;
align-items:center;
flex-direction:column;
justify-content:space-between;
}
.kecheng {
width: 710rpx;
height: 275rpx;
border-radius: 20rpx;
overflow: hidden;
display: flex;
justify-content: left;
align-items: center;
margin: 6px 0;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}
.kecheng_video_up {
width: 400rpx;
height: 225rpx;
margin-left: 10rpx;
}
.kecheng_video_right {
margin-left: 5rpx;
width: 290rpx;
height: 225rpx;
overflow: hidden;
}
.kecheng_img {
background-color: #15457b;
width: 100%;
height: 100%;
border-radius: 15rpx;
}
.kecheng_title {
display: block;
font-size: 30rpx;
text-align: center;
}
.kecheng_details {
display: block;
font-size: 25rpx;
margin-top: 15rpx;
margin-left: 15rpx;
}