接入资料修改接口

This commit is contained in:
Abin
2026-01-15 19:33:56 +08:00
parent fa76d2624d
commit ac773fc1d3
6 changed files with 122 additions and 40 deletions
+21
View File
@@ -189,6 +189,26 @@ function ApiLogin(openid,username) {
} }
function ApiChangeInfo(openid,username,headiconID) {
return new Promise((resolve, reject) => {
wx.request({
url: baseurl+'/API/ApiChangeInfo.php',
method: 'GET', // 或 'POST'
data: {
openid: openid,
username: username,
headiconID: headiconID,
},
success: res => {
resolve(res.data); // 将获取的结果通过Promise的resolve传递
},
fail: err => {
reject(err); // 如果请求失败,传递错误给Promise的reject
}
});
});
}
function ApiPasswordCodeValidate(openid, passwordcode) { function ApiPasswordCodeValidate(openid, passwordcode) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@@ -415,6 +435,7 @@ function ApiGetTips() {
ApiGetUserCourseDataFromDB, ApiGetUserCourseDataFromDB,
ApiLogin, ApiLogin,
ApiLogout, ApiLogout,
ApiChangeInfo,
ApiGetCourseData, ApiGetCourseData,
ApiGetFreeCourseData, ApiGetFreeCourseData,
ApiPasswordCodeValidate, ApiPasswordCodeValidate,
+58 -27
View File
@@ -1,4 +1,6 @@
// pages/ChangeUserInfo/ChangeUserInfo.js // pages/ChangeUserInfo/ChangeUserInfo.js
const MyApi = require('../../Api/api.js')
Page({ Page({
/** /**
@@ -13,11 +15,19 @@ Page({
}, },
onChange(event) { onChange(event) {
let inputVal = event.detail;
// 第一步:只保留中英文和数字(移除所有其他字符)
inputVal = inputVal.replace(/[^\u4e00-\u9fa5a-zA-Z0-9]/g, '');
// 第二步:如果以数字开头,则去掉开头的数字(直到遇到非数字)
inputVal = inputVal.replace(/^[0-9]+/, '');
// 第三步:截取前8个字符
inputVal = inputVal.substring(0, 8);
this.setData({ this.setData({
username: event.detail, username: inputVal
}); });
console.log("用户名将被修改为:"+this.data.username);
}, },
selectHeadicon(event) { selectHeadicon(event) {
this.setData({ this.setData({
HeadiconID: event.currentTarget.dataset.index, HeadiconID: event.currentTarget.dataset.index,
@@ -41,10 +51,52 @@ Page({
confirmColor: '#ff0000', // 确认按钮的文字颜色,默认是"#3CC51F" confirmColor: '#ff0000', // 确认按钮的文字颜色,默认是"#3CC51F"
success:(res)=> { success:(res)=> {
if (res.confirm) { if (res.confirm) {
// 用户点击了确认按钮 // 用户点击了确认按钮,发起修改接口
// 调用函数datachange MyApi.ApiChangeInfo(wx.getStorageSync('UserInfoCache').user_openid, this.data.username, this.data.HeadiconID)
//this.datachange() .then(result1 => {
//打印服务器返回数据
//console.log(result1);
if (result1.result==="success") {
//这里修改缓存
var tempuesrinfo=wx.getStorageSync('UserInfoCache')
tempuesrinfo.UserName= this.data.username
tempuesrinfo.HeadiconID= this.data.HeadiconID
wx.setStorageSync('UserInfoCache', tempuesrinfo)
wx.showToast({
title: '成功!',
icon: 'success',
mask:true,
duration: 2000
});
setTimeout(function() {
wx.hideToast();
wx.switchTab({
url: '/pages/wode/wode',
})
},2000);
} else {
wx.showToast({
title: '失败!',
icon: 'error',
mask:true,
duration: 2000
});
}
})
.catch(err => {
});
} else if (res.cancel) { } else if (res.cancel) {
// 用户点击了取消按钮 // 用户点击了取消按钮
} }
@@ -86,25 +138,4 @@ Page({
onUnload() { onUnload() {
}, },
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
}) })
@@ -2,7 +2,9 @@
<Parser html="{{html}}">加载中...</Parser> <Parser html="{{html}}">加载中...</Parser>
<view class="fixed-btn-wrapper"> <view class="fixed-btn-wrapper">
<button class="DianJiXiangQing1" open-type="contact" bindcontact="handleContact"> <view class="btn-group">
<text class="DianJiXiangQing2">点击获取详情</text> <button class="DianJiXiangQing1" open-type="contact" bindcontact="handleContact">
</button> <text class="DianJiXiangQing2">咨询客服</text>
</button>
</view>
</view> </view>
@@ -1,19 +1,46 @@
/* pages/IndexNewCourseDetails/IndexNewCourseDetails.wxss */ /* pages/IndexNewCourseDetails/IndexNewCourseDetails.wxss */
@keyframes breathe {
0%, 100% {
transform: scale(1);
}
50% {
transform: scale(0.95);
}
}
.fixed-btn-wrapper { .fixed-btn-wrapper {
position: fixed; position: fixed;
left: 20rpx; left: 0;
right: 20rpx; right: 0;
bottom: 40rpx; bottom: 60rpx;
border-radius: 50rpx; padding: 0 20rpx; /* 调整为左右边距 */
overflow: hidden; display: flex;
justify-content: center; /* 水平居中 */
z-index: 999; z-index: 999;
} }
.DianJiXiangQing1 {
.btn-group {
display: flex;
width: 100%; width: 100%;
max-width: 700rpx;
justify-content: space-between;
}
.DianJiXiangQing1 {
flex: 1;
background-color: #4CAF50; background-color: #4CAF50;
color: white; color: white;
border: none; border: none;
border-radius: 0; /* 内部 button 不需要圆角 */ margin: 0 10rpx;
height: 100rpx; border-radius: 45rpx;
line-height: 80rpx; height: 90rpx;
display: flex;
justify-content: center;
align-items: center;
animation: breathe 1s linear infinite;
}
.DianJiXiangQing2 {
font-size: 30rpx;
} }
+1
View File
@@ -26,6 +26,7 @@ Page({
text3: wx.getStorageSync('Config')[8].value, text3: wx.getStorageSync('Config')[8].value,
text4: wx.getStorageSync('Config')[9].value, text4: wx.getStorageSync('Config')[9].value,
text5: wx.getStorageSync('Config')[10].value, text5: wx.getStorageSync('Config')[10].value,
text6: wx.getStorageSync('Config')[12].value,
CodeURL:getApp().globalData.BaseURL + "/Images/WXCode/"+wx.getStorageSync('Config')[5].value+".png", CodeURL:getApp().globalData.BaseURL + "/Images/WXCode/"+wx.getStorageSync('Config')[5].value+".png",
}, },
showdialog() { showdialog() {
+1 -1
View File
@@ -1,7 +1,7 @@
<!--pages/wode/wode.wxml--> <!--pages/wode/wode.wxml-->
<van-popup show="{{ showCode }}" bind:close="onCodeClose"> <van-popup show="{{ showCode }}" bind:close="onCodeClose">
<view class="code-container"> <view class="code-container">
<text class="tip-text">长按图片识别</text> <text class="tip-text">{{text6}}</text>
<van-image <van-image
show-menu-by-longpress="true" show-menu-by-longpress="true"
use-loading-slot use-loading-slot