文字信息走配置

This commit is contained in:
Abin
2026-01-14 13:02:00 +08:00
parent c363e18fc2
commit 6171e514cd
6 changed files with 70 additions and 10 deletions
+19
View File
@@ -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) { function ApiAddPasswordCode(openid,courseID,courseName,coursePswdCode,courseEndDate,courseInfo,courseCount) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
wx.request({ wx.request({
@@ -403,6 +421,7 @@ function ApiGetTips() {
ApiGetIndexCourseList, ApiGetIndexCourseList,
ApiGetIndexFreeCourseList, ApiGetIndexFreeCourseList,
ApiGetBannerImg, ApiGetBannerImg,
ApiGetConfig,
ApiAddPasswordCode, ApiAddPasswordCode,
ApiAddPasswordCodeBefor, ApiAddPasswordCodeBefor,
ApiGetPasswordCode, ApiGetPasswordCode,
+10
View File
@@ -12,6 +12,16 @@ App({
内存大小: deviceInfo.memorySize + "MB" 内存大小: deviceInfo.memorySize + "MB"
}); });
MyApi.ApiGetConfig()
.then(result => {
// 将信息存储到本地缓存中
wx.setStorageSync('Config', result);
})
.catch(err => {
// 失败后执行的代码
console.error("请求失败:"+err);
});
MyApi.ApiGetUserOpenID() MyApi.ApiGetUserOpenID()
.then(result => { .then(result => {
// 获取code成功后执行的代码 // 获取code成功后执行的代码
+27
View File
@@ -15,12 +15,27 @@ Page({
webPageCount: 1, webPageCount: 1,
hasTouchBottom:false, hasTouchBottom:false,
bannerImgName:[], 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) { onLoad(options) {
//获取配置
MyApi.ApiGetConfig()
.then(result => {
// 将信息存储到本地缓存中
wx.setStorageSync('Config', result);
})
.catch(err => {
// 失败后执行的代码
console.error("请求失败:"+err);
});
//获取首页banner图片 //获取首页banner图片
MyApi.ApiGetBannerImg() MyApi.ApiGetBannerImg()
.then(result => { .then(result => {
@@ -130,6 +145,18 @@ updateManager.onUpdateFailed(function () {
*/ */
onPullDownRefresh() { onPullDownRefresh() {
//逻辑同onLoad()一样,略有修改 //逻辑同onLoad()一样,略有修改
//获取配置
MyApi.ApiGetConfig()
.then(result => {
// 将信息存储到本地缓存中
wx.setStorageSync('Config', result);
})
.catch(err => {
// 失败后执行的代码
console.error("请求失败:"+err);
});
//获取小知识 //获取小知识
MyApi.ApiGetTips() MyApi.ApiGetTips()
.then(result => { .then(result => {
+4 -4
View File
@@ -25,7 +25,7 @@
<view class="shouyetupianlist"> <view class="shouyetupianlist">
<view wx:if="{{CourseList.length > 0}}" 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;{{text1}}</text>
</view> </view>
<view class="shouyetupianlistcontent" wx:for="{{CourseList}}" wx:for-item="item" wx:for-index="index" wx:key="index" data-number="{{index}}" bind:tap="NavigatorToIndexNewCourseDetails"> <view class="shouyetupianlistcontent" wx:for="{{CourseList}}" wx:for-item="item" wx:for-index="index" wx:key="index" data-number="{{index}}" bind:tap="NavigatorToIndexNewCourseDetails">
<view class="hengxianglist" key="{{index}}"> <view class="hengxianglist" key="{{index}}">
@@ -39,7 +39,7 @@
<view class="shouyetupianlist"> <view class="shouyetupianlist">
<view wx:if="{{FreeCourseList.length > 0}}" class="biaoti01"> <view wx:if="{{FreeCourseList.length > 0}}" class="biaoti01">
<image class="biaoti01img" src="{{BaseURL}}/Images/Icon/ziwoxuexi.png" mode="aspectFill" /> <image class="biaoti01img" src="{{BaseURL}}/Images/Icon/ziwoxuexi.png" mode="aspectFill" />
<text decode>&nbsp;自我学习</text> <text decode>&nbsp;{{text2}}</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}}">
@@ -52,7 +52,7 @@
<view class="shouyetupianlist"> <view class="shouyetupianlist">
<view wx:if="{{WebPages.length > 0}}" 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;{{text3}}</text>
</view> </view>
<view class="shouyetupianlistcontent01" wx:for="{{WebPages}}" wx:for-item="imageshuzu" wx:for-index="index" wx:key="index" bind:tap="NavigatorToWebPageDetails" data-index="{{index}}"> <view class="shouyetupianlistcontent01" wx:for="{{WebPages}}" wx:for-item="imageshuzu" wx:for-index="index" wx:key="index" bind:tap="NavigatorToWebPageDetails" data-index="{{index}}">
@@ -67,7 +67,7 @@
</view> </view>
</view> </view>
<view style="width: auto; margin: 0px auto; margin-bottom: 10px;"> <view style="width: auto; margin: 0px auto; margin-bottom: 10px;">
<text wx:if="{{hasTouchBottom}}">已经到底啦!</text> <text wx:if="{{hasTouchBottom}}">{{text4}}</text>
</view> </view>
</view> </view>
+6 -2
View File
@@ -13,7 +13,6 @@ Page({
intervalId: null, intervalId: null,
headiconurl: '/static/image/user.png', headiconurl: '/static/image/user.png',
urlstring: getApp().globalData.BaseURL + "/Images/ToolsIcon/toolsicon", urlstring: getApp().globalData.BaseURL + "/Images/ToolsIcon/toolsicon",
CodeURL:getApp().globalData.BaseURL + "/Images/WXCode/Yeomai.png",
LoginBtnText: '登录注册', LoginBtnText: '登录注册',
UserNameText: '未登录', UserNameText: '未登录',
user_openid: null, user_openid: null,
@@ -22,7 +21,12 @@ Page({
IsAdministor: null, IsAdministor: null,
LastLoginDate: null, LastLoginDate: null,
UserName: 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() { showdialog() {
if (wx.getStorageSync('UserInfoCache').IsLogin ) { if (wx.getStorageSync('UserInfoCache').IsLogin ) {
+4 -4
View File
@@ -63,22 +63,22 @@
</button> </button>
<button wx:if="{{IsLogin}}" class="functions2" bind:tap="ChangeUserInfo"> <button wx:if="{{IsLogin}}" class="functions2" bind:tap="ChangeUserInfo">
<text class="zuobianwenzi">修改资料</text> <text class="zuobianwenzi">{{text2}}</text>
<text class="jiantou"> > </text> <text class="jiantou"> > </text>
</button> </button>
<button class="functions2" open-type="share"> <button class="functions2" open-type="share">
<text class="zuobianwenzi">好友分享</text> <text class="zuobianwenzi">{{text3}}</text>
<text class="jiantou"> > </text> <text class="jiantou"> > </text>
</button> </button>
<button class="functions2" open-type="contact" bindcontact="handleContact"> <button class="functions2" open-type="contact" bindcontact="handleContact">
<text class="zuobianwenzi">在线沟通</text> <text class="zuobianwenzi">{{text4}}</text>
<text class="jiantou"> > </text> <text class="jiantou"> > </text>
</button> </button>
<button class="functions2" bind:tap="showCode"> <button class="functions2" bind:tap="showCode">
<text class="zuobianwenzi">YelayMaths</text> <text class="zuobianwenzi">{{text5}}</text>
<text class="jiantou"> > </text> <text class="jiantou"> > </text>
</button> </button>