准备 AI重建
This commit is contained in:
1 parent
c36f2d60c2
commit
3429c8b402
1487 files changed
+5307
-3208
No files matched your search
@@ -0,0 +1,147 @@
|
||||
// pages/ChangeUserInfo/ChangeUserInfo.js
|
||||
const MyApi = require('../../Api/api.js')
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
BaseURL:wx.getStorageSync("UserInfoCache").BaseURL,
|
||||
activeNames: [],
|
||||
username: wx.getStorageSync("UserInfoCache").UserName,
|
||||
HeadiconID: wx.getStorageSync("UserInfoCache").HeadiconID,
|
||||
list: parseInt(wx.getStorageSync("Config")[6].value, 10), //将字符串数字解析成整数
|
||||
|
||||
},
|
||||
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: inputVal
|
||||
});
|
||||
},
|
||||
|
||||
selectHeadicon(event) {
|
||||
this.setData({
|
||||
HeadiconID: event.currentTarget.dataset.index,
|
||||
});
|
||||
},
|
||||
onChange2(event) {
|
||||
//用于切换卷展栏
|
||||
this.setData({
|
||||
activeNames: event.detail,
|
||||
});
|
||||
},
|
||||
onConfirm(event) {
|
||||
console.log("点击了确认修改!");
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定修改个人资料吗?',
|
||||
showCancel: true, // 是否显示取消按钮
|
||||
cancelText: '取消', // 取消按钮的文本,默认是"取消"
|
||||
cancelColor: '#000000', // 取消按钮的文字颜色,默认是"#000000"
|
||||
confirmText: '确认', // 确认按钮的文本,默认是"确定"
|
||||
confirmColor: '#ff0000', // 确认按钮的文字颜色,默认是"#3CC51F"
|
||||
success:(res)=> {
|
||||
if (res.confirm) {
|
||||
// 用户点击了确认按钮,发起修改接口
|
||||
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) {
|
||||
// 用户点击了取消按钮
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad(options) {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面初次渲染完成
|
||||
*/
|
||||
onReady() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面显示
|
||||
*/
|
||||
onShow() {
|
||||
|
||||
//重新赋予修改后的数值,相当于初始化
|
||||
this.setData({
|
||||
username: wx.getStorageSync("UserInfoCache").UserName,
|
||||
HeadiconID: wx.getStorageSync("UserInfoCache").HeadiconID
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面隐藏
|
||||
*/
|
||||
onHide() {
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面卸载
|
||||
*/
|
||||
onUnload() {
|
||||
|
||||
},
|
||||
})
|
||||
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"usingComponents": {
|
||||
"van-field": "@vant/weapp/field/index",
|
||||
"van-collapse": "@vant/weapp/collapse/index",
|
||||
"van-collapse-item": "@vant/weapp/collapse-item/index",
|
||||
"van-grid": "@vant/weapp/grid/index",
|
||||
"van-grid-item": "@vant/weapp/grid-item/index",
|
||||
"van-image": "@vant/weapp/image/index",
|
||||
"van-button": "@vant/weapp/button/index"
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<van-cell-group>
|
||||
<van-field
|
||||
label="用户名"
|
||||
value="{{username}}"
|
||||
placeholder="请输入用户名"
|
||||
border="true"
|
||||
bind:change="onChange"
|
||||
/>
|
||||
</van-cell-group>
|
||||
|
||||
<van-collapse value="{{ activeNames }}" bind:change="onChange2">
|
||||
<van-collapse-item title="头像" name="1">
|
||||
<view style="display: flex; justify-content: center; padding: 20rpx 0;">
|
||||
<van-image width="120rpx" height="120rpx" src="{{BaseURL}}/Images/Headicons/Headicon{{HeadiconID}}.png" />
|
||||
</view>
|
||||
<van-grid icon-size="80rpx">
|
||||
<scroll-view scroll-y style="min-height: 200rpx;max-height: 620rpx;" class="scroll-area">
|
||||
<van-grid-item wx:for="{{ list }}" wx:key="index" icon="{{BaseURL}}/Images/Headicons/Headicon{{index + 1}}.png" text="{{index + 1}}" bind:click="selectHeadicon" data-index="{{index + 1}}"/>
|
||||
</scroll-view>
|
||||
</van-grid>
|
||||
</van-collapse-item>
|
||||
</van-collapse>
|
||||
|
||||
<view class="button-container" style="text-align: center;padding: 20rpx;">
|
||||
<van-button type="primary" bind:click="onConfirm">确认修改</van-button>
|
||||
</view>
|
||||
@@ -0,0 +1 @@
|
||||
/* pages/ChangeUserInfo/ChangeUserInfo.wxss */
|
||||
Reference in new issue
Block a user