From 6171e514cd94800f718e316555786db8726a8b82 Mon Sep 17 00:00:00 2001 From: Abin Date: Wed, 14 Jan 2026 13:02:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=87=E5=AD=97=E4=BF=A1=E6=81=AF=E8=B5=B0?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Api/api.js | 19 +++++++++++++++++++ app.js | 10 ++++++++++ pages/index/index.js | 27 +++++++++++++++++++++++++++ pages/index/index.wxml | 8 ++++---- pages/wode/wode.js | 8 ++++++-- pages/wode/wode.wxml | 8 ++++---- 6 files changed, 70 insertions(+), 10 deletions(-) diff --git a/Api/api.js b/Api/api.js index 24baf24..ad6b0f2 100644 --- a/Api/api.js +++ b/Api/api.js @@ -264,6 +264,24 @@ function ApiGetBannerImg() { } +function ApiGetConfig() { + return new Promise((resolve, reject) => { + wx.request({ + url: baseurl+'/API/ApiGetConfig.php', + method: 'GET', // 或 'POST' + data: { + }, + success: res => { + resolve(res.data); // 将获取的结果通过Promise的resolve传递 + }, + fail: err => { + reject(err); // 如果请求失败,传递错误给Promise的reject + } + }); + }); + +} + function ApiAddPasswordCode(openid,courseID,courseName,coursePswdCode,courseEndDate,courseInfo,courseCount) { return new Promise((resolve, reject) => { wx.request({ @@ -403,6 +421,7 @@ function ApiGetTips() { ApiGetIndexCourseList, ApiGetIndexFreeCourseList, ApiGetBannerImg, + ApiGetConfig, ApiAddPasswordCode, ApiAddPasswordCodeBefor, ApiGetPasswordCode, diff --git a/app.js b/app.js index f4beef2..36b8ca4 100644 --- a/app.js +++ b/app.js @@ -12,6 +12,16 @@ App({ 内存大小: deviceInfo.memorySize + "MB" }); + MyApi.ApiGetConfig() + .then(result => { + // 将信息存储到本地缓存中 + wx.setStorageSync('Config', result); + }) + .catch(err => { + // 失败后执行的代码 + console.error("请求失败:"+err); + }); + MyApi.ApiGetUserOpenID() .then(result => { // 获取code成功后执行的代码 diff --git a/pages/index/index.js b/pages/index/index.js index 2c4ff33..ca6fdca 100644 --- a/pages/index/index.js +++ b/pages/index/index.js @@ -15,12 +15,27 @@ Page({ webPageCount: 1, hasTouchBottom:false, bannerImgName:[], + text1: wx.getStorageSync('Config')[2].value, + text2: wx.getStorageSync('Config')[3].value, + text3: wx.getStorageSync('Config')[4].value, + text4: wx.getStorageSync('Config')[11].value, }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { + //获取配置 + MyApi.ApiGetConfig() + .then(result => { + // 将信息存储到本地缓存中 + wx.setStorageSync('Config', result); + }) + .catch(err => { + // 失败后执行的代码 + console.error("请求失败:"+err); + }); + //获取首页banner图片 MyApi.ApiGetBannerImg() .then(result => { @@ -130,6 +145,18 @@ updateManager.onUpdateFailed(function () { */ onPullDownRefresh() { //逻辑同onLoad()一样,略有修改 + //获取配置 + MyApi.ApiGetConfig() + .then(result => { + // 将信息存储到本地缓存中 + wx.setStorageSync('Config', result); + }) + .catch(err => { + // 失败后执行的代码 + console.error("请求失败:"+err); + }); + + //获取小知识 MyApi.ApiGetTips() .then(result => { diff --git a/pages/index/index.wxml b/pages/index/index.wxml index ba9566e..e950eac 100644 --- a/pages/index/index.wxml +++ b/pages/index/index.wxml @@ -25,7 +25,7 @@ -  新课上线 +  {{text1}} @@ -39,7 +39,7 @@ -  自我学习 +  {{text2}} @@ -52,7 +52,7 @@ -  知识速通 +  {{text3}} @@ -67,7 +67,7 @@ - 已经到底啦! + {{text4}} diff --git a/pages/wode/wode.js b/pages/wode/wode.js index b94ba58..5a20d3b 100644 --- a/pages/wode/wode.js +++ b/pages/wode/wode.js @@ -13,7 +13,6 @@ Page({ intervalId: null, headiconurl: '/static/image/user.png', urlstring: getApp().globalData.BaseURL + "/Images/ToolsIcon/toolsicon", - CodeURL:getApp().globalData.BaseURL + "/Images/WXCode/Yeomai.png", LoginBtnText: '登录注册', UserNameText: '未登录', user_openid: null, @@ -22,7 +21,12 @@ Page({ IsAdministor: null, LastLoginDate: null, UserName: null, - NewUser: null + NewUser: null, + text2: wx.getStorageSync('Config')[7].value, + text3: wx.getStorageSync('Config')[8].value, + text4: wx.getStorageSync('Config')[9].value, + text5: wx.getStorageSync('Config')[10].value, + CodeURL:getApp().globalData.BaseURL + "/Images/WXCode/"+wx.getStorageSync('Config')[5].value+".png", }, showdialog() { if (wx.getStorageSync('UserInfoCache').IsLogin ) { diff --git a/pages/wode/wode.wxml b/pages/wode/wode.wxml index ad2756c..1067f26 100644 --- a/pages/wode/wode.wxml +++ b/pages/wode/wode.wxml @@ -63,22 +63,22 @@