V0.0.9 更新

修正IOS登录错误
This commit is contained in:
Abin committed 2026-01-07 11:01:21 +08:00
1 parent 15c82bdb46
commit a3c886146a
13 files changed
+105 -69

No files matched your search

+17 -1
View File
@@ -353,6 +353,21 @@ function ApiDeletePasswordCode(openid,coursePswdCode) {
} }
function ApiGetTips() {
return new Promise((resolve, reject) => {
wx.request({
url: baseurl+'/API/ApiGetTips.php',
method: 'GET', // 或 'POST'
success: res => {
resolve(res.data); // 将获取的结果通过Promise的resolve传递
},
fail: err => {
reject(err); // 如果请求失败,传递错误给Promise的reject
}
});
});
}
module.exports = { module.exports = {
ApiGetUserOpenID, ApiGetUserOpenID,
@@ -371,7 +386,8 @@ function ApiDeletePasswordCode(openid,coursePswdCode) {
ApiAddPasswordCodeBefor, ApiAddPasswordCodeBefor,
ApiGetPasswordCode, ApiGetPasswordCode,
ApiChangePasswordCode, ApiChangePasswordCode,
ApiDeletePasswordCode ApiDeletePasswordCode,
ApiGetTips
}; };
+22 -1
View File
@@ -4,6 +4,14 @@ const MyApi = require('./Api/api.js');
App({ App({
onLaunch() { onLaunch() {
const deviceInfo = wx.getDeviceInfo();
console.log({
登录平台: deviceInfo.platform,
设备品牌: deviceInfo.brand,
设备型号: deviceInfo.model,
内存大小: deviceInfo.memorySize + "MB"
});
MyApi.ApiGetUserOpenID() MyApi.ApiGetUserOpenID()
.then(result => { .then(result => {
// 获取code成功后执行的代码 // 获取code成功后执行的代码
@@ -22,6 +30,7 @@ App({
// 将信息存储到本地缓存中 // 将信息存储到本地缓存中
wx.setStorageSync('UserInfoCache', this.globalData); wx.setStorageSync('UserInfoCache', this.globalData);
//查询用户课程数据 //查询用户课程数据
MyApi.ApiGetUserCourseDataFromDB(result) MyApi.ApiGetUserCourseDataFromDB(result)
.then(result => { .then(result => {
@@ -50,6 +59,17 @@ App({
// 将信息存储到本地缓存中 // 将信息存储到本地缓存中
wx.setStorageSync('UserInfoCache', this.globalData); wx.setStorageSync('UserInfoCache', this.globalData);
MyApi.ApiGetTips()
.then(result => {
// 将信息存储到本地缓存中
wx.setStorageSync('Tips', result);
})
.catch(err => {
// 失败后执行的代码
console.error("请求失败:"+err);
});
}, },
globalData: { globalData: {
BaseURL:'https://api.yeomai.site', BaseURL:'https://api.yeomai.site',
@@ -60,6 +80,7 @@ App({
LastLoginDate: null, LastLoginDate: null,
UserName: null, UserName: null,
NewUser: null, NewUser: null,
OwnedCourse: null OwnedCourse: null,
Tips: null
} }
}) })
+1 -1
View File
@@ -28,7 +28,7 @@
"selectedIconPath": "static/image/shouye-selected.png" "selectedIconPath": "static/image/shouye-selected.png"
}, },
{ {
"text": "课程", "text": "知识",
"pagePath": "pages/kecheng/kecheng", "pagePath": "pages/kecheng/kecheng",
"iconPath": "static/image/kecheng.png", "iconPath": "static/image/kecheng.png",
"selectedIconPath": "static/image/kecheng-selected.png" "selectedIconPath": "static/image/kecheng-selected.png"
@@ -24,44 +24,33 @@ Page({
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
//只有当登录才有效 //获取接收到的视频序号
if (wx.getStorageSync('UserInfoCache').IsLogin) { var receivedIndex = options.number ?? null;
//获取接收到的视频序号 if (receivedIndex){
var receivedIndex = options.number ?? null;
if (receivedIndex){
MyApi.ApiGetFreeCourseData(receivedIndex) MyApi.ApiGetFreeCourseData(receivedIndex)
.then(result => { .then(result => {
this.setData({ this.setData({
VideoTitle:result.PlayData[0].课程名称, VideoTitle:result.PlayData[0].课程名称,
playdata:result.PlayData, playdata:result.PlayData,
VideoImageURL:this.data.BaseURL+"/Course/"+result.课程id+".png", VideoImageURL:this.data.BaseURL+"/Course/"+result.课程id+".png",
coursedata:result, coursedata:result,
});
})
.catch(err => {
this.setData({
playdata:[],
});
console.error("请求失败:"+err);
}); });
} else { })
wx.switchTab({ .catch(err => {
url: '/pages/index/index', this.setData({
}) playdata:[],
} });
console.error("请求失败:"+err);
});
} else { } else {
setTimeout(function() { wx.switchTab({
wx.switchTab({ url: '/pages/index/index',
url: '/pages/index/index', })
}) }
},50);
}
}, },
OnTapVideoList(e){ OnTapVideoList(e){
//只有当登录才有效
if (wx.getStorageSync('UserInfoCache').IsLogin) {
// 获取当前点击的索引 // 获取当前点击的索引
const courseindex = e.currentTarget.dataset.courseindex; const courseindex = e.currentTarget.dataset.courseindex;
@@ -72,13 +61,7 @@ Page({
HiddenVideoControl:false, HiddenVideoControl:false,
top:420, top:420,
}); });
} else {
setTimeout(function() {
wx.switchTab({
url: '/pages/index/index',
})
},50);
}
}, },
/** /**
@@ -92,13 +75,7 @@ Page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
if (!wx.getStorageSync('UserInfoCache').IsLogin) {
setTimeout(function() {
wx.switchTab({
url: '/pages/index/index',
})
},50);
}
}, },
/** /**
+1 -1
View File
@@ -68,7 +68,7 @@ Page({
wx.uploadFile({ wx.uploadFile({
filePath: UpLoadfilePath, filePath: UpLoadfilePath,
name: "HeadIconKey", name: "HeadIconKey",
url: getApp().globalData.BaseURL+'/API/ApiChangeUserInfo.php', url: getApp().globalData.BaseURL+'/API/ApiChangeUserInfo.php', //这里会在后端设置为已登录
formData:{ formData:{
username: random_username, username: random_username,
openid: wx.getStorageSync('UserInfoCache').user_openid openid: wx.getStorageSync('UserInfoCache').user_openid
+14 -2
View File
@@ -14,7 +14,7 @@ Page({
FreeCourseList: [], FreeCourseList: [],
webPageCount: 1, webPageCount: 1,
hasTouchBottom:false, hasTouchBottom:false,
bannerImgName:[] bannerImgName:[],
}, },
/** /**
@@ -129,7 +129,19 @@ updateManager.onUpdateFailed(function () {
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh() { onPullDownRefresh() {
//逻辑同onLoad()一样,略有修改\ //逻辑同onLoad()一样,略有修改
//获取小知识
MyApi.ApiGetTips()
.then(result => {
// 将信息存储到本地缓存中
wx.setStorageSync('Tips', result);
})
.catch(err => {
// 失败后执行的代码
console.error("请求失败:"+err);
});
//获取首页banner图片 //获取首页banner图片
MyApi.ApiGetBannerImg() MyApi.ApiGetBannerImg()
.then(result => { .then(result => {
+6 -6
View File
@@ -23,7 +23,7 @@
<!-- 新课上线 --> <!-- 新课上线 -->
<view class="shouyetupianlist"> <view class="shouyetupianlist">
<view class="biaoti01"> <view wx:if="{{CourseList.length > 0}}" class="biaoti01">
<image class="biaoti01img" src="{{BaseURL}}/Images/Icon/xinke.png" mode="aspectFill" /> <image class="biaoti01img" src="{{BaseURL}}/Images/Icon/xinke.png" mode="aspectFill" />
<text decode>&nbsp;新课上线</text> <text decode>&nbsp;新课上线</text>
</view> </view>
@@ -35,11 +35,11 @@
</view> </view>
<!-- 免费课程 --> <!-- 自我学习 -->
<view class="shouyetupianlist"> <view class="shouyetupianlist">
<view class="biaoti01"> <view wx:if="{{FreeCourseList.length > 0}}" class="biaoti01">
<image class="biaoti01img" src="{{BaseURL}}/Images/Icon/xinke.png" mode="aspectFill" /> <image class="biaoti01img" src="{{BaseURL}}/Images/Icon/ziwoxuexi.png" mode="aspectFill" />
<text decode>&nbsp;免费课程</text> <text decode>&nbsp;自我学习</text>
</view> </view>
<view class="shouyetupianlistcontent" wx:for="{{FreeCourseList}}" wx:for-item="item" wx:for-index="index" wx:key="index" data-number="{{item['序号']}}" bind:tap="NavigatorToIndexFreeCourseDetails"> <view class="shouyetupianlistcontent" wx:for="{{FreeCourseList}}" wx:for-item="item" wx:for-index="index" wx:key="index" data-number="{{item['序号']}}" bind:tap="NavigatorToIndexFreeCourseDetails">
<view class="hengxianglist" key="{{index}}"> <view class="hengxianglist" key="{{index}}">
@@ -50,7 +50,7 @@
<!-- 知识速通 --> <!-- 知识速通 -->
<view class="shouyetupianlist"> <view class="shouyetupianlist">
<view class="biaoti01"> <view wx:if="{{WebPages.length > 0}}" class="biaoti01">
<image class="biaoti01img" src="{{BaseURL}}/Images/Icon/sutong.png" mode="aspectFill" /> <image class="biaoti01img" src="{{BaseURL}}/Images/Icon/sutong.png" mode="aspectFill" />
<text decode>&nbsp;知识速通</text> <text decode>&nbsp;知识速通</text>
</view> </view>
+2 -2
View File
@@ -62,7 +62,7 @@ page {
padding: 0; padding: 0;
margin: 20rpx; margin: 20rpx;
height: 260rpx; height: 260rpx;
width: 100%; width: 730rpx;
overflow: hidden; overflow: hidden;
border-radius: 20rpx; border-radius: 20rpx;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
@@ -82,7 +82,7 @@ page {
.biaoti01 { .biaoti01 {
display: flex; display: flex;
width: 100%; width: 750rpx;
height: 60rpx; height: 60rpx;
align-items: center; align-items: center;
padding-left: 20rpx; padding-left: 20rpx;
+9 -2
View File
@@ -8,13 +8,20 @@ Page({
BaseURL:getApp().globalData.BaseURL, BaseURL:getApp().globalData.BaseURL,
hasCourse: false, hasCourse: false,
OwnedCourse: null, OwnedCourse: null,
intervalId: null intervalId: null,
htmlcontent: " "
}, },
/** /**
* 生命周期函数--监听页面加载 * 生命周期函数--监听页面加载
*/ */
onLoad(options) { onLoad(options) {
//设置小知识
try {
var temphtmlcontent= wx.getStorageSync('Tips');
this.setData({htmlcontent: temphtmlcontent[0].content});
} catch (error) { };
//每10ms获取一次数据,直到获取到个人信息数据为止 //每10ms获取一次数据,直到获取到个人信息数据为止
// 使用箭头函数确保正确的作用域 // 使用箭头函数确保正确的作用域
@@ -30,7 +37,7 @@ this.intervalId = setInterval(() => {
//计时500次,即5s后如果没有任何获取到已经登录的标志,依然断开计时器 //计时500次,即5s后如果没有任何获取到已经登录的标志,依然断开计时器
if (longtime>=500){ if (longtime>=500){
clearInterval(this.intervalId); clearInterval(this.intervalId);
console.log('暂无已购课程!'); console.log('暂无课程!');
}; };
longtime=longtime+1; longtime=longtime+1;
+2 -2
View File
@@ -1,6 +1,6 @@
{ {
"usingComponents": { "usingComponents": {
"Parser":"/Parser/index"
}, },
"navigationBarTitleText": "课程" "navigationBarTitleText": "知识"
} }
+5 -1
View File
@@ -1,6 +1,10 @@
<scroll-view class="container" scroll-y enable-flex type="custom"> <scroll-view class="container" scroll-y enable-flex type="custom">
<block wx:if="{{!hasCourse}}"> <block wx:if="{{!hasCourse}}">
<text>暂无信息</text> <view style="width: 100%;height: 400rpx;" >
<image style="margin-top: 30rpx; margin-left: 20rpx; height: 350rpx; box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); width: 710rpx; border-radius: 20rpx; background-color: rgb(0, 255, 255);"
src="{{BaseURL}}/Images/Banner/BGbanner.png" mode="aspectFill" />
</view>
<Parser html="{{htmlcontent}}" />
</block> </block>
<block wx:else> <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 wx:for="{{OwnedCourse}}" wx:for-item="item" wx:for-index="index" wx:key="index" class="kecheng" bind:tap="NavigatorToVideoDetails" data-index="{{index}}">
-1
View File
@@ -18,7 +18,6 @@
} }
.kecheng_video_up { .kecheng_video_up {
width: 400rpx; width: 400rpx;
height: 225rpx; height: 225rpx;
+2 -2
View File
@@ -54,8 +54,8 @@
</button> --> </button> -->
<view class="version"> <view class="version">
<text style="display: block;">Version 0.0.7</text> <text style="display: block;">Version 0.0.9</text>
<text style="font-size: 20rpx;display: block;">Copyright<text style="font-size: 15rpx;position: relative;top: -10rpx;right: 0rpx;">©</text> 2024 YelayMaths. All Rights Reserved.</text> <text style="font-size: 20rpx;display: block;">Copyright<text style="font-size: 15rpx;position: relative;top: -10rpx;right: 0rpx;">©</text> 2026 YelayMaths. All Rights Reserved.</text>
</view> </view>
</scroll-view> </scroll-view>