<template>
|
<view class="box">
|
<!-- 自定义导航栏 -->
|
<view class="navBarBox fix">
|
<!-- 状态栏占位 -->
|
<view class="statusBar" :style="{ paddingTop: statusBarHeight + 'px' }"></view>
|
<!-- 真正的导航栏内容 -->
|
<view style="display: flex; flex-direction: column;">
|
<view class="navBar">
|
<!-- <u-icon style=" margin-left: -25px;" name="arrow-left" color="black" size="17" @click="goBack" />-->
|
<view class="barText">我的</view>
|
</view>
|
</view>
|
</view>
|
<view class="m-p-15">
|
<view class="userInfo">
|
<view class="info-l">
|
<image :src="avator" mode="aspectFill"></image>
|
<!-- <view class="info-icons">-->
|
<!-- <u-icon v-if="user.sex==0" name="man" color="#0f7ff9" bold size="24"></u-icon>-->
|
<!-- <u-icon v-else-if="user.sex==1" name="woman" color="#ff69bf" bold size="24"></u-icon>-->
|
<!-- <u-icon v-else name="question" color="#ff69bf" bold size="24"></u-icon>-->
|
<!-- </view>-->
|
</view>
|
|
<view class="info-r">
|
<view class="info-n">
|
<!-- 用户:-->
|
<span>{{username}}</span>
|
|
</view>
|
<view class="info-id" @click="resetPwd()">
|
<span>重置密码</span><u-icon name="edit-pen" color="#e6e6e6" size="16"></u-icon>
|
</view>
|
</view>
|
</view>
|
<view class="card-list">
|
<view class="paper-card">
|
<view :class="user.useProd == 1?'menu-i':'menu-i-l'" @click="toHazmat">
|
<view class="menu-l">
|
<u-icon name="warning" color="#0f7ff9" size="32"></u-icon>
|
<view><span style="color: #ed6464">危化品</span>操作记录</view>
|
</view>
|
<u-icon name="arrow-right" color="#ccc" size="20"></u-icon>
|
</view>
|
<view class="menu-i" @click="toProduct" v-if="user.useProd == 1">
|
<view class="menu-l">
|
<u-icon name="bag" color="#0f7ff9" size="32"></u-icon>
|
<view><span style="color: #5fb734">成品</span>操作记录</view>
|
</view>
|
<u-icon name="arrow-right" color="#ccc" size="20"></u-icon>
|
</view>
|
</view>
|
<!-- <u-empty v-else text="暂无已完成的考试记录" mode="list"></u-empty>-->
|
</view>
|
<view class="loginBtn">
|
<u-button @click="loginOut" type="primary" text="退出登录" style="width: 80%" shape="circle"></u-button>
|
</view>
|
</view>
|
<u-modal :show="showModal" title="重置密码" :showConfirmButton="false" :closeOnClickOverlay="true" ref="uModal" :asyncClose="true" @close="closeModal()">
|
<view>
|
<u--form labelPosition="top" labelWidth="120" :model="pwdForm" :rules="rules" ref="uForm">
|
<u-form-item
|
prop="password"
|
ref="password"
|
label="新密码"
|
>
|
<u--input
|
v-model="pwdForm.password"
|
placeholder="请输入新密码"
|
:type="codeType1"
|
>
|
<template slot="suffix">
|
<u-icon v-show="codeType1 == 'password'" name="eye" color="#999" size="20" @click="viewCode(1)"></u-icon>
|
<u-icon v-show="codeType1 == 'text'" name="eye-off" color="#999" size="20" @click="viewCode(1)"></u-icon>
|
</template>
|
</u--input>
|
</u-form-item>
|
<u-form-item
|
prop="rePassword"
|
ref="rePassword"
|
label="确认密码"
|
>
|
<u--input
|
v-model="pwdForm.rePassword"
|
placeholder="请确认密码"
|
:type="codeType2"
|
><template slot="suffix">
|
<u-icon v-show="codeType2 == 'password'" name="eye" color="#999" size="20" @click="viewCode(2)"></u-icon>
|
<u-icon v-show="codeType2 == 'text'" name="eye-off" color="#999" size="20" @click="viewCode(2)"></u-icon>
|
</template></u--input>
|
</u-form-item>
|
</u--form>
|
<u-button type="primary" style="margin-top: 20px" text="确认" @click="confirmPwd()"></u-button>
|
</view>
|
</u-modal>
|
<u-toast ref="uToast"></u-toast>
|
<tabBar :currentPagePath="page"></tabBar>
|
</view>
|
</template>
|
|
<script>
|
import tabBar from '../tabBarIndex.vue'
|
import {loginOut, postHazmatReturn, resetPwd} from "../../../api";
|
import VUE_APP_BASE_URL from 'common/constant.js'
|
import avatorPic from '../../../static/avator.png'
|
export default {
|
components:{
|
tabBar
|
},
|
data() {
|
return {
|
page: 'pages/tabBar/count/count',
|
statusBarHeight: '',
|
username: '',
|
examParams: {
|
pageNum: 1,
|
pageSize: 10,
|
completed: 1
|
},
|
examList: [],
|
totalPage: 0,
|
user: {},
|
avator: '',
|
showModal: false,
|
pwdForm:{
|
id: null,
|
password: '',
|
rePassword: ''
|
},
|
rules: {
|
password: [
|
{
|
type: 'string',
|
required: true,
|
message: '新密码不可为空',
|
trigger: ['blur', 'change']
|
},
|
{
|
validator: (rule, value, callback) => {
|
return /^(?![a-zA-Z]+$)(?!\d+$)(?![!@#$%^&\.*]+$)(?![a-zA-Z\d]+$)(?![a-zA-Z!@#$%^&\.*]+$)(?![\d!@#$%^&\.*]+$)[a-zA-Z\d!@#$%^&\.*\-_]{6,16}$/.test(value)
|
},
|
message: '密码须同时包含字母、数字和特殊字符,长度在6-16之间',
|
trigger: ['change','blur'],
|
}
|
],
|
rePassword: [
|
{
|
type: 'string',
|
required: true,
|
message: '请再次确认密码',
|
trigger: ['blur', 'change'],
|
},
|
{
|
validator: (rule, value, callback) => {
|
return value == this.pwdForm.password;
|
},
|
message: '两次输入密码不一致',
|
trigger: ['change','blur'],
|
}
|
]
|
},
|
codeType1: 'password',
|
codeType2: 'password'
|
}
|
|
},
|
created(){
|
uni.hideTabBar()
|
},
|
onLoad() {
|
this.statusBarHeight = uni.getSystemInfoSync()['statusBarHeight'];
|
this.username = uni.getStorageSync('name')
|
// uni.hideTabBar();
|
// this.getUserInfo()
|
this.user = uni.getStorageSync('userSet')
|
if(this.user.logoPath && this.user.logoPath !== ''){
|
this.avator = VUE_APP_BASE_URL + '/api/' + this.user.logoPath
|
}else{
|
this.avator = avatorPic
|
}
|
},
|
|
methods: {
|
base64Encode(str) {
|
return btoa(unescape(encodeURIComponent(str)));
|
},
|
|
toHazmat(){
|
uni.setStorageSync("prevPage", '/pages/tabBar/count/count');
|
uni.navigateTo({
|
url: '/pages/tabBar/count/countDetail'
|
})
|
},
|
|
toProduct(){
|
uni.setStorageSync("prevPage", '/pages/tabBar/count/count');
|
uni.navigateTo({
|
url: '/pages/tabBar/count/productDetail'
|
})
|
},
|
|
loginOut(){
|
uni.showModal({
|
title: '提示',
|
content: '是否确认退出该账号?',
|
success: async function (res) {
|
if (res.confirm) {
|
loginOut().then(res=>{
|
if(res.code == 200){
|
uni.showToast({
|
title: '账户已退出',
|
duration: 800
|
})
|
setTimeout(()=>{
|
uni.clearStorageSync();
|
uni.clearStorage();
|
uni.navigateTo({
|
url: '/pages/index/index'
|
})
|
},800)
|
}
|
})
|
} else if (res.cancel) {
|
console.log('用户点击取消');
|
}
|
}
|
})
|
},
|
|
resetPwd(){
|
const t = this
|
t.showModal = true
|
},
|
|
viewCode(type){
|
const t = this
|
if(type == 1){
|
if(this.codeType1 == 'password'){
|
this.codeType1 = 'text'
|
} else{
|
this.codeType1 = 'password'
|
}
|
}else{
|
if(this.codeType2 == 'password'){
|
this.codeType2 = 'text'
|
} else{
|
this.codeType2 = 'password'
|
}
|
}
|
},
|
|
confirmPwd(){
|
const t = this
|
t.$refs.uForm.validate().then(res => {
|
let data = {}
|
data.id = uni.getStorageSync("uid");
|
data.password = t.base64Encode(t.pwdForm.password)
|
resetPwd(data).then((r)=>{
|
if(r.code == 200){
|
t.$refs.uToast.show({
|
type: 'default',
|
message: '密码已重置,请重新登录',
|
duration: 1000
|
})
|
loginOut().then(res=>{
|
if(res.code == 200){
|
setTimeout(()=>{
|
uni.clearStorageSync();
|
uni.clearStorage();
|
uni.navigateTo({
|
url: '/pages/index/index'
|
})
|
},1000)
|
}
|
})
|
}else{
|
t.$refs.uToast.show({
|
type: 'default',
|
message: r.message
|
})
|
}
|
}).catch((err) => {
|
uni.showToast({
|
title: err,
|
duration: 2000
|
})
|
})
|
t.closeModal()
|
}).catch(errors => {
|
uni.$u.toast('请按要求完善信息')
|
})
|
},
|
|
closeModal(){
|
this.showModal = false
|
this.pwdForm = {
|
id: null,
|
password: '',
|
rePassword: ''
|
}
|
}
|
}
|
}
|
|
</script>
|
|
<style lang='scss' scoped>
|
.box {
|
display: flex;
|
flex-direction: column;
|
width: 100%;
|
height: 100%;
|
}
|
.u-icon{
|
margin: 0 !important;
|
}
|
.fix{
|
position: sticky;
|
top: 0;
|
left: 0;
|
right: 0;
|
width: 100%;
|
z-index: 1;
|
}
|
.navBarBox .navBar {
|
background-color:#fff;
|
height: 50px;
|
display: flex;
|
flex-direction: row;
|
justify-content: center;
|
align-items: center;
|
box-shadow: 4px 4px 12px rgba(150,150,150,.05);
|
}
|
.barText{
|
text-align: center;
|
width: 85%;
|
font-size: 16px;
|
/* text-align: center; */
|
font-weight: 600;
|
}
|
.statusBar{
|
background-color:lightgrey;
|
}
|
|
/deep/ .u-modal__title{
|
padding-top: 20px !important;
|
}
|
|
/deep/ .u-modal__content{
|
display: flex;
|
flex-direction: column !important;
|
align-items: center;
|
text-align: left;
|
padding-top: 0 !important;
|
|
&>view{
|
width: 100%;
|
}
|
}
|
|
.m-p-15{
|
width: 100%;
|
padding-top: 50rpx;
|
background: url("../../../static/my-bg.jpg") no-repeat top;
|
background-size: 100% auto;
|
|
.userInfo{
|
display: flex;
|
align-items: center;
|
width: calc(100% - 60px);
|
margin: 20rpx auto;
|
|
.info-l{
|
width: 150rpx;
|
height: 150rpx;
|
border-radius: 75rpx;
|
display: flex;
|
justify-content: center;
|
align-items: center;
|
overflow: hidden;
|
margin-right: 20px;
|
border: 2px solid #fff;
|
box-sizing: border-box;
|
image{
|
width: calc(100% + 4px) !important;
|
height: calc(100% + 4px) !important;
|
}
|
}
|
|
.info-r{
|
color: #fff;
|
.info-n{
|
display: flex;
|
align-items: center;
|
font-size: 36rpx;
|
font-weight: bold;
|
margin-bottom: 10px;
|
|
span{
|
margin-right: 10px;
|
}
|
}
|
|
.info-id{
|
display: flex;
|
align-items: center;
|
|
span{
|
font-size: 24rpx;
|
color: #e6e6e6;
|
}
|
}
|
}
|
}
|
|
.card-list{
|
width: 100%;
|
margin: 20px 0;
|
|
.paper-card{
|
width: calc(100% - 40px);
|
margin: 0 auto 15px;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
|
.menu-i,.menu-i-l{
|
width: calc(50% - 5px);
|
background: rgba(255,255,255,1);
|
border-radius: 12px;
|
display: flex;
|
align-items: center;
|
box-shadow: 0 3px 8px rgba(150,150,150,.1);
|
justify-content: space-between;
|
padding: 18px 15px;
|
box-sizing: border-box;
|
cursor: pointer;
|
|
.menu-l{
|
display: flex;
|
align-items: center;
|
font-size: 22rpx;
|
color: #999;
|
view{
|
margin-left: 6px;
|
display: flex;
|
flex-direction: column;
|
align-items: flex-start;
|
span{
|
font-size: 32rpx;
|
font-weight: bold;
|
color: #333;
|
}
|
}
|
}
|
}
|
.menu-i-l{
|
width: 100%;
|
}
|
}
|
}
|
}
|
.loginBtn{
|
width: 100%;
|
position: fixed;
|
bottom: 90px;
|
}
|
</style>
|