功能新增

添加个人页面信息
添加二维码图片
添加好友分享按钮
This commit is contained in:
Abin
2026-01-13 17:54:41 +08:00
parent 0460178749
commit c363e18fc2
12 changed files with 238 additions and 45 deletions
+21
View File
@@ -169,6 +169,26 @@ function ApiLogout(openid) {
}
function ApiLogin(openid,username) {
return new Promise((resolve, reject) => {
wx.request({
url: baseurl+'/API/ApiLogin.php',
method: 'GET', // 或 'POST'
data: {
openid: openid,
username: username,
},
success: res => {
resolve(res.data); // 将获取的结果通过Promise的resolve传递
},
fail: err => {
reject(err); // 如果请求失败,传递错误给Promise的reject
}
});
});
}
function ApiPasswordCodeValidate(openid, passwordcode) {
return new Promise((resolve, reject) => {
@@ -375,6 +395,7 @@ function ApiGetTips() {
ApiGetWebPagesFromDB,
ApiGetWebPageContent,
ApiGetUserCourseDataFromDB,
ApiLogin,
ApiLogout,
ApiGetCourseData,
ApiGetFreeCourseData,
+3 -1
View File
@@ -27,6 +27,7 @@ App({
this.globalData.LastLoginDate= result1.data.最后登录日期;
this.globalData.UserName= result1.data.用户名;
this.globalData.NewUser= result1.result;
this.globalData.HeadiconID= result1.data.HeadiconID;
// 将信息存储到本地缓存中
wx.setStorageSync('UserInfoCache', this.globalData);
@@ -81,6 +82,7 @@ App({
UserName: null,
NewUser: null,
OwnedCourse: null,
Tips: null
Tips: null,
HeadiconID: null
}
})
+2 -1
View File
@@ -9,7 +9,8 @@
"pages/VideoDetailsPage/VideoDetailsPage",
"pages/IndexNewCourseDetails/IndexNewCourseDetails",
"pages/IndexFreeCourseDetails/IndexFreeCourseDetails",
"pages/SetPasswordCode/SetPasswordCode"
"pages/SetPasswordCode/SetPasswordCode",
"pages/ChangeUserInfo/ChangeUserInfo"
],
"window": {
"navigationBarTextStyle": "black",
+66
View File
@@ -0,0 +1,66 @@
// pages/ChangeUserInfo/ChangeUserInfo.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
+3
View File
@@ -0,0 +1,3 @@
{
"usingComponents": {}
}
+2
View File
@@ -0,0 +1,2 @@
<!--pages/ChangeUserInfo/ChangeUserInfo.wxml-->
<text>pages/ChangeUserInfo/ChangeUserInfo.wxml</text>
+1
View File
@@ -0,0 +1 @@
/* pages/ChangeUserInfo/ChangeUserInfo.wxss */
+56 -30
View File
@@ -58,23 +58,60 @@ Page({
console.log("用户名: "+random_username);
// 复制本地图片到用户数据路径,如果文件不存在,先复制
const UpLoadfilePath = wx.env.USER_DATA_PATH + '/defaultAvatar.png';
try {wx.getFileSystemManager().accessSync(UpLoadfilePath);}
catch (e) {
wx.getFileSystemManager().copyFileSync('static/image/defaultAvatar.png', UpLoadfilePath);
}
// // 复制本地图片到用户数据路径,如果文件不存在,先复制
// const UpLoadfilePath = wx.env.USER_DATA_PATH + '/defaultAvatar.png';
// try {wx.getFileSystemManager().accessSync(UpLoadfilePath);}
// catch (e) {
// wx.getFileSystemManager().copyFileSync('static/image/defaultAvatar.png', UpLoadfilePath);
// }
wx.uploadFile({
filePath: UpLoadfilePath,
name: "HeadIconKey",
url: getApp().globalData.BaseURL+'/API/ApiChangeUserInfo.php', //这里会在后端设置为已登录
formData:{
username: random_username,
openid: wx.getStorageSync('UserInfoCache').user_openid
},
success(res) {
//打印服务器返回数据
// wx.uploadFile({
// filePath: UpLoadfilePath,
// name: "HeadIconKey",
// url: getApp().globalData.BaseURL+'/API/ApiChangeUserInfo.php', //这里会在后端设置为已登录
// formData:{
// username: random_username,
// openid: wx.getStorageSync('UserInfoCache').user_openid
// },
// success(res) {
// //打印服务器返回数据
// wx.showToast({
// title: '成功!',
// icon: 'success',
// mask:true,
// duration: 4000
// });
// //这里修改缓存
// var tempuesrinfo=wx.getStorageSync('UserInfoCache')
// tempuesrinfo.UserName=random_username
// tempuesrinfo.IsAdministor=isAdmin
// tempuesrinfo.IsLogin="1"
// wx.setStorageSync('UserInfoCache', tempuesrinfo)
// setTimeout(function() {
// wx.hideToast();
// wx.switchTab({
// url: '/pages/wode/wode',
// })
// },3000);
// },
// fail(res) {
// //打印服务器返回数据
// console.log(res);
// setTimeout(function() {
// wx.hideToast();
// wx.switchTab({
// url: '/pages/wode/wode',
// })
// },3000);
// }
// });
MyApi.ApiLogin(wx.getStorageSync('UserInfoCache').user_openid, random_username)
.then(result1 => {
//打印服务器返回数据
wx.showToast({
title: '成功!',
icon: 'success',
@@ -94,20 +131,9 @@ Page({
url: '/pages/wode/wode',
})
},3000);
},
fail(res) {
//打印服务器返回数据
console.log(res);
setTimeout(function() {
wx.hideToast();
wx.switchTab({
url: '/pages/wode/wode',
})
},3000);
}
})
})
.catch(err => {
});
+30 -3
View File
@@ -8,10 +8,12 @@ Page({
data: {
value: '',
show: false,
showCode: false,
passwordcode: null,
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,
@@ -37,17 +39,42 @@ Page({
}
},
ChangeUserInfo() {
wx.navigateTo({
url: '/pages/ChangeUserInfo/ChangeUserInfo',
});
},
onChange(e) {
this.setData({
passwordcode: e.detail
});
},
onClose() {
this.setData({
show: false,
passwordcode: null
passwordcode: null,
});
},
showCode() {
this.setData({
showCode: true,
});
},
OnClickCodeImage() {
console.log("点击了二维码");
},
onCodeClose() {
this.setData({
showCode: false,
});
},
GetCourse() {
//点击确定后的课程获取
if (this.data.passwordcode) {
@@ -122,8 +149,8 @@ Page({
if (Storage.IsLogin === "1") {
this.setData({
IsLogin: Storage.IsLogin,
headiconurl: getApp().globalData.BaseURL + "/Images/UsersHeadIcon/" + Storage.user_openid + ".png",
LoginBtnText: "个人信息",
headiconurl: getApp().globalData.BaseURL + "/Images/Headicons/Headicon" + Storage.HeadiconID + ".png",
LoginBtnText: "退出登录",
UserNameText: Storage.UserName,
IsAdministor: Storage.IsAdministor,
});
+3 -1
View File
@@ -2,7 +2,9 @@
"usingComponents": {
"van-dialog": "@vant/weapp/dialog/index",
"van-field": "@vant/weapp/field/index",
"van-button": "@vant/weapp/button/index"
"van-button": "@vant/weapp/button/index",
"van-popup": "@vant/weapp/popup/index",
"van-image": "@vant/weapp/image/index"
},
"navigationBarTitleText": "个人中心"
}
+30 -8
View File
@@ -1,4 +1,19 @@
<!--pages/wode/wode.wxml-->
<van-popup show="{{ showCode }}" bind:close="onCodeClose">
<view class="code-container">
<text class="tip-text">长按图片识别</text>
<van-image
show-menu-by-longpress="true"
use-loading-slot
use-error-slot
bind:click="OnClickCodeImage"
width="600rpx"
height="816rpx"
src="{{CodeURL}}"
/>
<van-loading slot="loading" type="spinner" size="20" vertical />
</view>
</van-popup>
<van-dialog
use-slot
show="{{ show }}"
@@ -42,25 +57,32 @@
</view>
</view> -->
<button class="functions2" bind:tap="showdialog">
<button wx:if="{{IsLogin}}" class="functions2" bind:tap="showdialog">
<text class="zuobianwenzi">课程码</text>
<text class="jiantou"> > </text>
</button>
<button wx:if="{{IsLogin}}" class="functions2" bind:tap="ChangeUserInfo">
<text class="zuobianwenzi">修改资料</text>
<text class="jiantou"> > </text>
</button>
<button class="functions2" open-type="share">
<text class="zuobianwenzi">好友分享</text>
<text class="jiantou"> > </text>
</button>
<button class="functions2" open-type="contact" bindcontact="handleContact">
<text class="zuobianwenzi">联系客服</text>
<text class="zuobianwenzi">在线沟通</text>
<text class="jiantou"> > </text>
</button>
<button class="functions2" bind:tap="showdialog3">
<text class="zuobianwenzi">点击复制微信:YelayMaths</text>
<button class="functions2" bind:tap="showCode">
<text class="zuobianwenzi">YelayMaths</text>
<text class="jiantou"> > </text>
</button>
<button class="functions2" bind:tap="showdialog4">
<text class="zuobianwenzi">分享给朋友</text>
<text class="jiantou"> > </text>
</button>
<!-- 功能暂不开放 -->
<!-- <button class="functions2" bind:tap="function2_01">
+21 -1
View File
@@ -5,6 +5,22 @@
flex-direction:column;
justify-content:space-between;
}
.code-container {
display: flex;
flex-direction: column;
align-items: center; /* 水平居中 */
padding: 20rpx;
box-sizing: border-box;
background-color: rgb(0, 201, 77);
}
/* 文字样式:可选加粗、颜色、间距等 */
.tip-text {
font-size: 34rpx;
color: #ffffff;
margin-bottom: 20rpx; /* 与图片保持间距 */
text-align: center; /* 冗余保险,虽然 flex 已居中 */
}
.login {
display: flex;
@@ -15,7 +31,6 @@
height: 150rpx;
border-radius: 20rpx;
margin: 20rpx;
border-radius: 20rpx;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5);
}
.touxiangimg {
@@ -91,6 +106,11 @@
width: 75rpx;
height: 75rpx;
}
.functionimg002 {
width: 60rpx;
height: 60rpx;
}
.functiontext001 {
font-size: 25rpx;
}