Commit 5b183a3c authored by 李苏's avatar 李苏 💬

修改个人组件,修改密码+base64

parent 2700e536
...@@ -21,6 +21,14 @@ function filter(e) { ...@@ -21,6 +21,14 @@ function filter(e) {
tip.toast(e.data.message || "操作失败") tip.toast(e.data.message || "操作失败")
} }
} }
/* userapi-查询用户信息 */
export function queryUser(params) {
return http.post('/kzzx/user/query', filterSpace(params)).then(e => {
return filter(e)
})
}
export function login(params) { export function login(params) {
return http.post('/login', filterSpace(params)).then(e => { return http.post('/login', filterSpace(params)).then(e => {
return filter(e) return filter(e)
......
...@@ -36,6 +36,14 @@ const routes = [ ...@@ -36,6 +36,14 @@ const routes = [
title: '个人中心', title: '个人中心',
}, },
}, },
/* 修改密码 */
{
path: '/pages/user/modifyPw',
name: 'modifyPw',
meta: {
title: '修改密码',
},
},
{ {
path: '/pages/user/userdetail', path: '/pages/user/userdetail',
name: 'userdetail', name: 'userdetail',
......
...@@ -109,7 +109,18 @@ ...@@ -109,7 +109,18 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
},
/* 修改密码界面 */
{
"path" : "pages/user/modifyPw",
"style" :
{
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
} }
], ],
"globalStyle": { "globalStyle": {
"navigationBarBackgroundColor": "#0081ff", "navigationBarBackgroundColor": "#0081ff",
......
<template>
<view class="bg-white" style="height: 100vh;">
<scroll-view scroll-y class="page">
<cu-custom bgColor="bg-gradual-blue" :isBack="true" >
<block slot="backText">返回</block>
<block slot="content">修改密码</block>
</cu-custom>
<view class="cu-list menu">
<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.3s'}]">
<view class="content">
<text class="text-grey">旧密码:</text>
</view>
<view class="action">
<input class="inputCenter" v-model="oldPassword" :focus="true" type="password">
</view>
</view>
<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.3s'}]">
<view class="content">
<text class="text-grey" >新密码:</text>
</view>
<view class="action">
<input class="inputCenter" type="password" v-model="newPassword">
</view>
</view>
<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.3s'}]" style="border-bottom: 1px solid #eee;">
<view class="content">
<text class="text-grey">密码确认:</text>
</view>
<view class="action">
<input class="inputCenter" v-model="newPasswordConfirm" type="password">
</view>
</view>
</view>
<view class="flex justify-center" >
<button class="cu-btn bg-blue lg margin-left shadow" style="margin-top: 30px;" @tap="confirm()">修改密码
</button>
</view>
</scroll-view>
</view>
</template>
<script>
import api from '@/api/api.js'
import http from '@/common/service/service.js';
export default{
data:function(){
return {
api:'kzzx/user/password/update',
oldPassword:"",
newPassword:"",
newPasswordConfirm:"",
}
},
methods:{
passWord(password) {
return /^(?=.*\d)(?=.*[a-zA-Z]).{6,}$/.test(password);
},
confirm(){
let that=this
if(!this.passWord(this.newPassword)){
console.log(this.newPassword)
this.$tip.toast('密码格式需要6位以上,数字字母组合');
return
}
if(this.newPassword!=this.newPasswordConfirm){
this.$tip.toast('密码确认不一致');
return
}
if(!this.oldPassword){
this.$tip.toast('请输入旧密码');
return
}
let data={
newPassword: new Buffer(this.newPassword).toString('base64'),
oldPassword:new Buffer(this.oldPassword).toString('base64'),
newPasswordConfirm:new Buffer(this.newPasswordConfirm).toString('base64')
}
that.$http.post(that.api,data).then(e=>{
if(e.data.success){
this.$tip.toast('修改成功');
uni.removeStorage({key:"ACCESS_TOKEN"})
this.$Router.replaceAll({name:"login"})
}else{
this.$tip.toast(e.data.message||"修改失败");
}
})
}
}
}
</script>
<style>
.inputCenter{
text-align: center;
}
</style>
\ No newline at end of file
...@@ -6,25 +6,60 @@ ...@@ -6,25 +6,60 @@
<image src="../../static/home/u3.png" mode="" style="height: 100%;width: 100%;"></image> <image src="../../static/home/u3.png" mode="" style="height: 100%;width: 100%;"></image>
</view> </view>
<view class="padding flex text-center text-grey bg-white shadow-warp">
<view class="flex flex-sub flex-direction solid-right animation-slide-top" :style="[{animationDelay: '0.2s'}]">
<view class="text-xl text-orange">{{personalList.username}}</view>
<view class="margin-top-sm"><text class="cuIcon-people"></text> 用户</view>
</view>
<view class="flex flex-sub flex-direction animation-slide-top" :style="[{animationDelay: '0.2s'}]">
<view class="text-xl text-green">{{personalList.post?personalList.post:'员工'}}</view>
<view class="margin-top-sm"><text class="cuIcon-news"></text> 职务</view>
</view>
</view>
<!-- 列表list-->
<view class="cu-list menu card-menu margin-top-xl margin-bottom-xl shadow-lg radius"> <view class="cu-list menu card-menu margin-top-xl margin-bottom-xl shadow-lg radius">
<view class="cu-item arrow animation-slide-bottom" :style="[{animationDelay: '0.7s'}]">
<navigator class="content" url="/pages/login/login" hover-class="none" @tap="logout"> <!-- 个人信息-->
<text class="cuIcon-exit text-cyan"></text> <view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.2s'}]">
<text class="text-grey">退出</text> <view class="content">
</navigator> <text class="text-grey">姓名</text>
</view> </view>
<view class="action">
<text class="text-grey">{{userinfo.username}}</text>
</view>
</view>
<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.3s'}]">
<view class="content">
<text class="text-grey">手机号</text>
</view>
<view class="action">
<text class="text-grey">{{userinfo.phone||"未设置"}}</text>
</view>
</view>
<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.3s'}]">
<view class="content">
<text class="text-grey">邮箱</text>
</view>
<view class="action">
<text class="text-grey">{{userinfo.email||"未设置"}}</text>
</view>
</view>
<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.3s'}]">
<view class="content">
<text class="text-grey">部门</text>
</view>
<view class="action">
<text class="text-grey">{{userinfo.bmmc||"未设置"}}</text>
</view>
</view>
<view class="cu-list menu">
<view class="cu-item animation-slide-bottom" :style="[{animationDelay: '0.5s'}]">
<view class="content">
<text class="text-grey">修改密码</text>
</view>
<view class="action">
<text class="text-grey " @tap="modify()" style="color: cornflowerblue;cursor: pointer;">{{'前往修改'}}</text>
</view>
</view>
<view class="cu-item arrow animation-slide-bottom" :style="[{animationDelay: '0.7s'}]">
<navigator class="content" url="/pages/login/login" hover-class="none" @tap="logout">
<text class="cuIcon-exit text-cyan"></text>
<text class="text-grey">退出</text>
</navigator>
</view>
</view>
<!-- 分割-->
</view> </view>
<view class="cu-tabbar-height"></view> <view class="cu-tabbar-height"></view>
</scroll-view> </scroll-view>
...@@ -34,10 +69,32 @@ ...@@ -34,10 +69,32 @@
<script> <script>
import appUpdate from 'common/util/appUpdate.js' import appUpdate from 'common/util/appUpdate.js'
import api from '@/api/api' import api from '@/api/api'
import {queryUser} from '@/api/dlapi.js'
export default { export default {
name: "people", name: "people",
mounted() {
let that=this
uni.getStorage({
key: 'login_user_info',
success: function (res) {
if(res&&res.data&&res.data.userkey){
const {userkey}=res.data
queryUser({id:userkey}).then(e=>{
that.userinfo=e.records[0]
})
}
}
})
},
data() { data() {
return { return {
userinfo:{
username:'',
phone:'',
email:'',
bmmc:''
},
personalList:{ personalList:{
avatar:'', avatar:'',
realname:'', realname:'',
...@@ -67,6 +124,10 @@ ...@@ -67,6 +124,10 @@
}, },
}, },
methods: { methods: {
/* 修改密码 */
modify(){
this.$Router.push({name:"modifyPw"})
},
remove(){ remove(){
uni.removeStorageSync('Access-Token') uni.removeStorageSync('Access-Token')
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment