接入资料修改接口
This commit is contained in:
+21
@@ -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) {
|
||||
return new Promise((resolve, reject) => {
|
||||
@@ -415,6 +435,7 @@ function ApiGetTips() {
|
||||
ApiGetUserCourseDataFromDB,
|
||||
ApiLogin,
|
||||
ApiLogout,
|
||||
ApiChangeInfo,
|
||||
ApiGetCourseData,
|
||||
ApiGetFreeCourseData,
|
||||
ApiPasswordCodeValidate,
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// pages/ChangeUserInfo/ChangeUserInfo.js
|
||||
const MyApi = require('../../Api/api.js')
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
@@ -13,11 +15,19 @@ Page({
|
||||
|
||||
},
|
||||
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({
|
||||
username: event.detail,
|
||||
username: inputVal
|
||||
});
|
||||
console.log("用户名将被修改为:"+this.data.username);
|
||||
},
|
||||
|
||||
selectHeadicon(event) {
|
||||
this.setData({
|
||||
HeadiconID: event.currentTarget.dataset.index,
|
||||
@@ -41,9 +51,51 @@ Page({
|
||||
confirmColor: '#ff0000', // 确认按钮的文字颜色,默认是"#3CC51F"
|
||||
success:(res)=> {
|
||||
if (res.confirm) {
|
||||
// 用户点击了确认按钮
|
||||
// 调用函数datachange
|
||||
//this.datachange()
|
||||
// 用户点击了确认按钮,发起修改接口
|
||||
MyApi.ApiChangeInfo(wx.getStorageSync('UserInfoCache').user_openid, this.data.username, this.data.HeadiconID)
|
||||
.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) {
|
||||
// 用户点击了取消按钮
|
||||
@@ -86,25 +138,4 @@ Page({
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面相关事件处理函数--监听用户下拉动作
|
||||
*/
|
||||
onPullDownRefresh() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 页面上拉触底事件的处理函数
|
||||
*/
|
||||
onReachBottom() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 用户点击右上角分享
|
||||
*/
|
||||
onShareAppMessage() {
|
||||
|
||||
}
|
||||
})
|
||||
@@ -2,7 +2,9 @@
|
||||
<Parser html="{{html}}">加载中...</Parser>
|
||||
|
||||
<view class="fixed-btn-wrapper">
|
||||
<button class="DianJiXiangQing1" open-type="contact" bindcontact="handleContact">
|
||||
<text class="DianJiXiangQing2">点击获取详情</text>
|
||||
</button>
|
||||
<view class="btn-group">
|
||||
<button class="DianJiXiangQing1" open-type="contact" bindcontact="handleContact">
|
||||
<text class="DianJiXiangQing2">咨询客服</text>
|
||||
</button>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
@@ -1,19 +1,46 @@
|
||||
/* pages/IndexNewCourseDetails/IndexNewCourseDetails.wxss */
|
||||
@keyframes breathe {
|
||||
0%, 100% {
|
||||
transform: scale(1);
|
||||
}
|
||||
50% {
|
||||
transform: scale(0.95);
|
||||
}
|
||||
}
|
||||
|
||||
.fixed-btn-wrapper {
|
||||
position: fixed;
|
||||
left: 20rpx;
|
||||
right: 20rpx;
|
||||
bottom: 40rpx;
|
||||
border-radius: 50rpx;
|
||||
overflow: hidden;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 60rpx;
|
||||
padding: 0 20rpx; /* 调整为左右边距 */
|
||||
display: flex;
|
||||
justify-content: center; /* 水平居中 */
|
||||
z-index: 999;
|
||||
}
|
||||
.DianJiXiangQing1 {
|
||||
|
||||
.btn-group {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
max-width: 700rpx;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.DianJiXiangQing1 {
|
||||
flex: 1;
|
||||
background-color: #4CAF50;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 0; /* 内部 button 不需要圆角 */
|
||||
height: 100rpx;
|
||||
line-height: 80rpx;
|
||||
margin: 0 10rpx;
|
||||
border-radius: 45rpx;
|
||||
height: 90rpx;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
animation: breathe 1s linear infinite;
|
||||
}
|
||||
|
||||
.DianJiXiangQing2 {
|
||||
font-size: 30rpx;
|
||||
}
|
||||
@@ -26,6 +26,7 @@ Page({
|
||||
text3: wx.getStorageSync('Config')[8].value,
|
||||
text4: wx.getStorageSync('Config')[9].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",
|
||||
},
|
||||
showdialog() {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--pages/wode/wode.wxml-->
|
||||
<van-popup show="{{ showCode }}" bind:close="onCodeClose">
|
||||
<view class="code-container">
|
||||
<text class="tip-text">长按图片识别</text>
|
||||
<text class="tip-text">{{text6}}</text>
|
||||
<van-image
|
||||
show-menu-by-longpress="true"
|
||||
use-loading-slot
|
||||
|
||||
Reference in New Issue
Block a user