Commit 05a8d440 by 李君

个人信息,修改密码

1 parent 5251f39d
let http = require('../utils/request');
module.exports = {
singleUser(userId, params) {
return http.get(`/report/users/${userId}`, params);
},
getPermission(id){
return http.get(`/report/auth/api/v1/auth/users/${id}`);
},
editUserInfo(params){
return http.post(`/report/users/${params.userId}`, params);
},
editUserPwd(params){
return http.post(`/report/users/updateUser`, params);
}
}
\ No newline at end of file
......@@ -7,12 +7,10 @@
"pages/tour/list/index",
"pages/tour/gate/index",
"pages/tour/webview/index",
"pages/tour/index/index",
"pages/index/index",
"pages/me/index"
"pages/me/index",
"pages/editPwd/editPwd"
],
"subPackages": [
{
......@@ -84,7 +82,8 @@
"van-collapse-item": "@vant/weapp/collapse-item/index",
"van-empty": "@vant/weapp/empty/index",
"van-button": "@vant/weapp/button/index",
"van-divider": "@vant/weapp/divider/index"
"van-divider": "@vant/weapp/divider/index",
"van-field": "@vant/weapp/field/index"
},
"lazyCodeLoading": "requiredComponents",
"sitemapLocation": "sitemap.json"
......
// pages/editPwd.js
const App = getApp();
import basicApi from '../../api/basic.js'
Page({
/**
* 页面的初始数据
*/
data: {
navHeight: App.globalData.navHeight,
windowHeight: App.globalData.windowHeight,
windowWidth: App.globalData.windowWidth,
navTop: App.globalData.navTop,
newPwd:'',
newPwd1:"",
oldPwd:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
onGoBack: function() {
wx.switchTab({
url: '/pages/me/index'
})
},
inputBlur1(e){
this.data.oldPwd = e.detail.value
},
inputBlur2(e){
this.data.newPwd = e.detail.value
},
inputBlur3(e){
this.data.newPwd1 = e.detail.value
},
onSubmit(){
if(this.data.newPwd&&this.data.newPwd1&&this.data.oldPwd){
if(this.data.newPwd!=this.data.newPwd1){
wx.showToast({
title: '两次密码不一样',
icon:'error'
})
}else{
basicApi.editUserPwd({
loginName:wx.getStorageSync('name'),
oldPassWord:this.data.oldPwd,
password:this.data.newPwd,
}).then(res=>{
if(res.code==200){
wx.showToast({
title: '修改成功',
icon:'success',
success:res=>{
wx.getStorageInfo({
success: (res) => {
res.keys.forEach(item => {
if (item !== 'name' && item !== 'password' && item !== 'requestUrl' && item !== 'baseUrl' && item !== 'deploymentType') {
wx.removeStorage({ key: item, success: function(res) {}})
}
})
}
})
wx.reLaunch({ url: '/pages/login/index' })
}
})
}else{
wx.showToast({
title: '修改失败',
icon:'error'
})
}
})
}
}else{
wx.showToast({
title: '请输入密码',
icon:'error'
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
},
onGoBack(){
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage() {
}
})
\ No newline at end of file
{
"usingComponents": {
"navbar": "/components/navbar/index"
},
"navigationBarTitleText": "",
"navigationBarBackgroundColor": "#0268FF",
"navigationBarTextStyle": "white"
}
\ No newline at end of file
<view class="container" style="padding-top: {{navHeight}}px;height:{{windowHeight}}px;">
<navbar
page-name="修改密码"
bg-color="#fff"
navbar-color="rgba(0, 0, 0, .85)"
nav="back"
backIcon="1"
bind:onGoBack="onGoBack"
/>
<view class="zong-content">
<van-form>
<van-cell-group>
<van-field
value="{{oldPwd}}"
type='password'
name="原密码"
label="原密码"
placeholder="原密码"
bind:blur='inputBlur1'
/>
<van-field
type='password'
value="{{newPwd}}"
name="新密码"
label="新密码"
placeholder="新密码"
bind:blur='inputBlur2'
/>
<van-field
type='password'
value="{{newPwd1}}"
name="确认密码"
label="确认密码"
placeholder="确认密码"
bind:blur='inputBlur3'
/>
</van-cell-group>
<view style="margin-top: 20rpx;">
<view class="btn">
<van-button color="#1A77FF" round block type="primary" bindtap="onSubmit">确定 </van-button>
</view>
</view>
</van-form>
</view>
</view>
/* pages/editPwd.wxss */
.zong-content{
width: 100%;
margin-top: 50rpx;
padding: 10rpx 30rpx;
}
\ No newline at end of file
const App = getApp();
import basicApi from '../../api/basic.js'
// import Notify from '@vant/weapp/dist/notify/notify';
Page({
data: {
navHeight: App.globalData.navHeight,
......@@ -15,14 +16,63 @@ Page({
// name: '修改密码',
// icon: 'password'
// }
]
],
userForm:{},
rolesList:[]
},
onLoad: function(options) {
const name = wx.getStorageSync('name');
const accountName = wx.getStorageSync('accountName');
this.setData({ name: name, accountName: accountName })
this.getUserInfo()
},
All(e){
console.log(e)
},
inputBlur(e){
this.data.userForm.realName = e.detail.value
},
inputBlur2(e){
this.data.userForm.tel = e.detail.value
},
inputBlur3(e){
this.data.userForm.email = e.detail.value
},
getUserInfo(){
basicApi.singleUser(wx.getStorageSync('uid')).then(res => {
this.getRolePermission(res.data)
})
},
getRolePermission(resData){
basicApi.getPermission(resData.unid).then(res => {
let roles = []
res.roles.forEach(item=>{
roles.push(item.name)
})
resData.roles = roles.toString()
this.setData({ userForm: resData })
})
},
onSubmit(e){
basicApi.editUserInfo({
userId:this.data.userForm.id,
email:this.data.userForm.email,
loginName:this.data.userForm.loginName,
realName:this.data.userForm.realName,
tel:this.data.userForm.tel,
}).then(res => {
if(res.code==200){
wx.showToast({
title: '修改成功',
icon:'success'
})
this.getUserInfo()
}
})
},
undatePwd(){
wx.reLaunch({ url: '/pages/editPwd/editPwd' })
},
logout: () => {
wx.getStorageInfo({
success: (res) => {
......
......@@ -13,7 +13,58 @@
</view>
</view>
<view class="zong-content">
<view
<van-form>
<van-cell-group>
<van-field
value="{{userForm.loginName}}"
name="用户名"
label="用户名"
placeholder="用户名"
disabled
/>
<van-field
value="{{userForm.realName}}"
name="姓名"
label="姓名"
placeholder="姓名"
bind:blur='inputBlur'
/>
<van-field
value="{{userForm.tel}}"
name="电话号码"
label="电话号码"
placeholder="电话号码"
bind:blur='inputBlur2'
/>
<van-field
value="{{userForm.email}}"
name="邮箱"
label="邮箱"
placeholder="邮箱"
bind:blur='inputBlur3'
/>
<van-field
value="{{userForm.roles}}"
name="角色权限"
label="角色权限"
placeholder="角色权限"
disabled
/>
</van-cell-group>
<view style="margin-top: 20rpx;">
<view class="btn">
<van-button color="#1A77FF" round block type="primary" bindtap="onSubmit">修改 </van-button>
</view>
<view class="btn">
<van-button color="#1A77FF" round block type="primary" bindtap="undatePwd">修改密码 </van-button>
</view>
<view class="btn">
<van-button color="#1A77FF" round block type="primary" bindtap="logout">退出登录 </van-button>
</view>
</view>
</van-form>
<!-- <view
wx:for="{{menuItems}}"
wx:for-index="index"
wx:for-item="n"
......@@ -25,8 +76,8 @@
<image src="{{ '../../images/me/' + n.icon + '.png' }}" class="img" />
<view>{{n.name}}</view>
<image src="../../images/arrow-r.png" class="arrow" />
</view>
</view> -->
</view>
<view class="logout" bindtap="logout">退出登录</view>
</view>
\ No newline at end of file
......@@ -38,7 +38,9 @@
border: 2rpx solid rgba(171, 225, 255, .5);
font-size: 24rpx;
}
.btn{
margin-top: 20rpx;
}
.logout {
width: calc(100% - 72rpx);
height: 90rpx;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!