123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050 |
- <template>
- <div class="mine">
- <!--<navbar />-->
- <div class="mine-page">
- <div class="left-max-box">
- <p class="left-title">个人中心</p>
- <div class="left-user-img">
- <userAvatar :user="user" />
- </div>
- <p class="left-name">{{user.nickName}}</p>
- <p class="left-num">{{user.userType=='11'?'工号:':(user.userType=='22'?'学号:':'其他:')}}{{user.userName}}</p>
- <div class="left-text-max-box">
- <div class="left-text-big-box">
- <div class="left-text-big-box-left">
- <img v-if="user.userType == '22'" src="@/assets/ZDimages/mine/icon_grzx_xl.png">
- <img v-else src="@/assets/ZDimages/mine/icon_grzx_zc.png">
- <p>{{user.education?user.education:'未设置'}}</p>
- </div>
- <div class="left-text-big-box-right">
- <img class="img-two" v-if="user.userType == '22'" src="@/assets/ZDimages/mine/icon_grzx_zy.png">
- <img class="img-one" v-else src="@/assets/ZDimages/mine/icon_grzx_zw.png">
- <p>{{user.major?user.major:'未设置'}}</p>
- </div>
- </div>
- <div class="left-text-min-box">
- <img src="@/assets/ZDimages/mine/icon_grzx_sjh.png">
- <p>{{user.phonenumber?user.phonenumber:'未设置'}}</p>
- </div>
- <div class="left-text-min-box">
- <img src="@/assets/ZDimages/mine/icon_grzx_yx.png">
- <p>{{user.email?user.email:'未设置'}}</p>
- </div>
- <div class="left-text-min-box">
- <img src="@/assets/ZDimages/mine/icon_grzx_bgl.png">
- <p>{{user.deptName?user.deptName:'未设置'}}</p>
- </div>
- </div>
- <div class="left-type-text-max-box">
- <div>
- <p>手机号码</p>
- <p :class="user.phonenumber?'p-color-a':'p-color-b'">{{user.phonenumber?'已设置':'未设置'}}</p>
- </div>
- <div>
- <p>系统头像</p>
- <p :class="user.avatar?'p-color-a':'p-color-b'">{{user.avatar?'已设置':'未设置'}}</p>
- </div>
- <div>
- <p>人脸照片</p>
- <p :class="user.faceImg?'p-color-a':'p-color-b'">{{user.faceImg?'已设置':'未设置'}}</p>
- </div>
- <!--<div>-->
- <!--<p>电子签名</p>-->
- <!--<p :class="user.signature?'p-color-a':'p-color-b'">{{user.signature?'已设置':'未设置'}}</p>-->
- <!--</div>-->
- </div>
- </div>
- <div class="right-max-box">
- <div class="right-title-box">
- <div class="title-button-min-box">
- <p :class="buttonType == '1'?'bottomColor':''">基本资料</p>
- <p :class="buttonType == '1'?'bottomBack':''"></p>
- </div>
- <!--<div class="title-button-min-box" @click="buttonTypeClick(2)">-->
- <!--<p :class="buttonType == '2'?'bottomColor':''">安全设置</p>-->
- <!--<p :class="buttonType == '2'?'bottomBack':''"></p>-->
- <!--</div>-->
- <p class="right-null-p"></p>
- <!--<p class="reset-button-one right-out-button" @click="outButton">返回</p>-->
- </div>
- <div v-if="buttonType == 1">
- <el-form :model="userform" ref="userform" :rules="rules" :inline="true" >
- <div>
- <el-form-item class="form-item-min" label="手机号码:" prop="phonenumber" label-width="120px">
- <el-input
- maxlength="11"
- disabled
- v-model="userform.phonenumber"
- placeholder="未填写"
- clearable
- size="small"
- onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"
- />
- <span style="color:#0183FA;margin-left:20px;cursor: pointer;" @click="showPhone(1)">修改手机号</span>
- </el-form-item>
- <el-form-item class="form-item-min" label="邮箱:" prop="email" label-width="120px">
- <el-input
- maxlength="30"
- v-model="userform.email"
- placeholder="请输入邮箱"
- clearable
- size="small"
- />
- </el-form-item>
- <el-form-item class="form-item-min" label="出生年月:" prop="dateBirth" label-width="120px">
- <el-date-picker
- v-model="userform.dateBirth"
- value-format="yyyy-MM-dd"
- type="date"
- placeholder="请选择出生日期">
- </el-date-picker>
- </el-form-item>
- </div>
- <div>
- <el-form-item class="form-item-min" label="人脸照片:" prop="searchValue" label-width="120px">
- <div class="up-data-box" style="width:210px;">
- <div class="up-data-min-box" style="display: flex;">
- <div class="up-data-button" v-if="!user.faceImg" @click="upFaceOpenClick(2)">
- <p>+</p>
- <p>上传</p>
- </div>
- <img class="img-one" :src="user.faceImg" v-if="user.faceImg" @click="upFaceOpenClick(2)">
- </div>
- </div>
- </el-form-item>
- <!--<el-form-item class="form-item-min" label="电子签名:" prop="searchValue" label-width="120px">-->
- <!--<div class="up-data-box">-->
- <!--<div class="up-data-min-box" style="display: flex;">-->
- <!--<el-upload-->
- <!--class="position-button"-->
- <!--:action="uploadImgUrlTwo"-->
- <!--:show-file-list="false"-->
- <!--:auto-upload="false"-->
- <!--:on-change="signatureChange"-->
- <!--accept="image/jpeg,image/gif,image/png"-->
- <!--:headers="headers"-->
- <!--:before-upload="beforeAvatarUpload">-->
- <!--<div class="up-data-button" v-if="!user.signature">-->
- <!--<p>+</p>-->
- <!--<p>上传</p>-->
- <!--</div>-->
- <!--<img class="img-two" :src="user.signature" v-if="user.signature">-->
- <!--</el-upload>-->
- <!--</div>-->
- <!--</div>-->
- <!--</el-form-item>-->
- </div>
- </el-form>
- <p class="type-one-max-box add-button-one-120" @click="upDataProfile">保存</p>
- </div>
- <div v-if="buttonType == 2">
- <el-form :model="form" ref="form" :inline="true" :rules="rules">
- <div>
- <el-form-item class="form-item-min" label="原始密码:" prop="oldPassword" label-width="120px">
- <el-input
- maxlength="16"
- type="password"
- v-model.trim="form.oldPassword"
- placeholder="请输入原始密码"
- clearable
- size="small"
- />
- </el-form-item>
- <el-form-item class="form-item-min" label="新密码:" prop="newPassword" label-width="110px">
- <el-input
- maxlength="16"
- type="password"
- v-model.trim="form.newPassword"
- placeholder="请输入新密码"
- clearable
- size="small"
- />
- </el-form-item>
- <el-form-item class="form-item-min" label="确认密码:" prop="confirmPassword" label-width="120px">
- <el-input
- maxlength="16"
- type="password"
- v-model.trim="form.confirmPassword"
- placeholder="请确认密码"
- clearable
- size="small"
- />
- </el-form-item>
- <span class="type-one-max-box add-button-one-120" style="margin-left:20px;display: inline-block;" @click="submit">保存</span>
- </div>
- </el-form>
- </div>
- </div>
- </div>
- <!--电子签名-->
- <el-dialog class="up-img-box" title="上传电子签名" :visible.sync="upImgOpen" width="600px" append-to-body>
- <p>示例</p>
- <img class="img-one" src="@/assets/ZDimages/icon_scdzqm_sl.png">
- <p>正楷签名</p>
- <div class="cropper-box">
- <vueCropper
- ref="cropper"
- :img="option.img"
- :outputSize="option.outputSize"
- :outputType="option.outputType"
- :info="option.info"
- :canScale="option.canScale"
- :autoCrop="option.autoCrop"
- :autoCropWidth="option.autoCropWidth"
- :autoCropHeight="option.autoCropHeight"
- :fixed="option.fixed"
- :fixedNumber="option.fixedNumber"
- :full="option.full"
- :fixedBox="option.fixedBox"
- :canMove="option.canMove"
- :canMoveBox="option.canMoveBox"
- :original="option.original"
- :centerBox="option.centerBox"
- :height="option.height"
- :infoTrue="option.infoTrue"
- :maxImgSize="option.maxImgSize"
- :enlarge="option.enlarge"
- :mode="option.mode"
- @realTime="realTime"
- @imgLoad="imgLoad"
- ></vueCropper>
- <p class="cropper-button" @click="upImgButton">保存查看</p>
- <el-upload
- class="position-button"
- :action="uploadImgUrl"
- :show-file-list="false"
- :auto-upload="false"
- :on-change="signatureChange"
- accept="image/jpeg,image/gif,image/png"
- :headers="headers"
- :before-upload="beforeAvatarUpload">
- <p style="position: absolute;right:100px;top:10px;z-index:1;color:#fff;background:#14AE10;cursor: pointer;padding:5px 10px;margin:0;border-radius:6px;">选择签名</p>
- </el-upload>
- </div>
- <p style="color:#999;">请将签名置于选择框内以便提高识别度</p>
- <img class="cropper-img" v-if="signatureData" :src="signatureData">
- <div slot="footer" class="dialog-footer">
- <el-button @click="upImgOpenClick(1)">取 消</el-button>
- <el-button type="primary" @click="upSignatureData">确 定</el-button>
- </div>
- </el-dialog>
- <!--上传照片-->
- <el-dialog class="up-img-box" title="上传照片" :visible.sync="upFaceOpen" width="600px" append-to-body>
- <el-upload
- ref="faceUpLoad"
- class="position-button"
- :action="uploadImgUrl"
- :show-file-list="false"
- :auto-upload="false"
- :on-change="faceChange"
- accept="image/jpeg,image/gif,image/png"
- :on-success="(res)=>handleAvatarSuccess(res)"
- :headers="headers"
- :before-upload="beforeAvatarUpload">
- <div v-if="!upFaceUrl" style="width:300px;height:300px;border: 1px dashed #E0E0E0;cursor: pointer;margin:20px 130px 0;">
- <p style="text-align: center;color:#999;font-weight:500;font-size: 20px;line-height:300px;margin:0;">+</p>
- </div>
- <div v-if="upFaceUrl" class="scrollbar-box" style="width:560px;margin:0 auto;max-height:700px;overflow-y: scroll">
- <img :src="upFaceUrl" style="max-width:560px;border: 1px dashed #E0E0E0;cursor: pointer;margin:0 auto;">
- </div>
- </el-upload>
- <div slot="footer" class="dialog-footer">
- <el-button @click="faceButton(1)">取 消</el-button>
- <el-button type="primary" @click="faceButton(2)">确 定</el-button>
- </div>
- </el-dialog>
- <!--修改手机号-->
- <el-dialog class="revise-phone-box" @close="offPhone" title="修改手机号" :visible.sync="dialogPhoneType"
- v-if="dialogPhoneType" width="400px" append-to-body>
- <el-form ref="phoneForm" :model="phoneForm" :rules="rules" label-width="0px">
- <el-form-item label="" prop="phone">
- <div class="phone-box">
- <el-input
- maxlength="11"
- v-model.trim="phoneForm.phone"
- :placeholder="phoneState == 1?'请输入旧手机号':'请输入新手机号'"
- clearable>
- <template slot="prepend">+86</template>
- </el-input>
- </div>
- </el-form-item>
- </el-form>
- <el-form ref="codeForm" :model="phoneForm" :rules="rules" label-width="0px">
- <el-form-item label="" prop="code">
- <div class="code-box">
- <el-input
- maxlength="6"
- v-model.trim="phoneForm.code"
- placeholder="请输入验证码"
- clearable>
- </el-input>
- <p class="code-button" @click="getCode">{{codeTimeText}}</p>
- </div>
- </el-form-item>
- </el-form>
- <div slot="footer" class="dialog-footer">
- <el-button style="width:100px;" @click="showPhone(2)">取 消</el-button>
- <el-button style="width:100px;" type="primary" @click="revisePhone">{{phoneState==1?'下一步':(phoneState==2?'确定':'')}}</el-button>
- </div>
- </el-dialog>
- </div>
- </template>
- <script>
- import { Navbar } from '@/layout/components'
- import userAvatar from "./userAvatar";
- import { getUserProfile,updateUserPwd,changePhone,genSign,updateSignature,upDataProfile,
- getSendCode, phoneCheckCode, putPhone} from "@/api/system/user";
- import { getToken } from "@/utils/auth";
- export default {
- name: "mine",
- components: {
- Navbar,
- userAvatar
- },
- data(){
- const equalToPassword = (rule, value, callback) => {
- if (this.form.confirmPassword !== value) {
- callback(new Error("两次输入的密码不一致"));
- } else {
- callback();
- }
- };
- const equalToPasswordTwo = (rule, value, callback) => {
- if (this.form.newPassword !== value) {
- callback(new Error("两次输入的密码不一致"));
- } else {
- callback();
- }
- };
- const validatePass = (rule, value, callback) => {
- let reg = /^(?![A-z0-9]+$)(?=.[^%&',;=?$\x22])(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).{8,16}$/
- console.log("reg.test(value)",reg.test(value))
- if(reg.test(value)){
- callback()
- }else{
- return callback(new Error('密码应在8-16位包括数字和字母与特殊字符'));
- }
- };
- return{
- buttonType:'1',
- uploadImgUrl: window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + "/laboratory/studentinfo/commit/face", // 上传的图片服务器地址
- uploadImgUrlTwo: window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + "/file/upload", // 上传的图片服务器地址
- headers: {
- Authorization: "Bearer " + getToken(),
- },
- pageType:false,
- user: {},
- roleGroup: {},
- postGroup: {},
- activeTab: "resetPwd",
- form:{
- oldPassword:"",
- newPassword:"",
- confirmPassword:""
- },
- userform:{},
- userformData:{},
- open:false,
- // 表单校验
- rules: {
- oldPassword: [
- { required: true, message: "旧密码不能为空", trigger: "blur" },
- ],
- newPassword: [
- { required: true, message: "新密码不能为空", trigger: "blur" },
- { min: 8, max: 16, message: "长度在 8 到 16 个字符", trigger: "blur" },
- { required: true, validator: equalToPassword, trigger: "blur" },
- { required: true, message: "请输入8-16位密码,不能输入连续性和重复性的密码,密码中需要包含:大写字母、小写字符、数字和字符", validator: validatePass, trigger: "blur" }
- ],
- confirmPassword: [
- { required: true, message: "确认密码不能为空", trigger: "blur" },
- { min: 8, max: 16, message: "长度在 8 到 16 个字符", trigger: "blur" },
- { required: true, validator: equalToPasswordTwo, trigger: "blur" },
- { required: true, message: "请输入8-16位密码,不能输入连续性和重复性的密码,密码中需要包含:大写字母、小写字符、数字和字符", validator: validatePass, trigger: "blur" }
- ],
- phone: [
- { required: true, message: "请输入手机号码", trigger: "blur" },
- { validator: this.checkPhone, trigger: 'blur' },
- { min: 11, max: 11, message: "请输入11位手机号码", trigger: "blur" },
- { required: true, message: "请输入手机号码", validator: this.spaceJudgment, trigger: "blur" }
- ],
- // phone: [
- // { required: true, message: "请输入手机号码", trigger: "blur" },
- // { required: true, message: "请输入手机号码", validator: this.spaceJudgment, trigger: "blur" }
- // ],
- code: [
- { required: true, message: "请输入验证码", trigger: "blur" },
- { required: true, message: "请输入验证码", validator: this.spaceJudgment, trigger: "blur" }
- ],
- // email: [
- // { required: true, message: "请输入邮箱地址", trigger: "blur" },
- // { required: true, message: "请输入正确的邮箱地址", type: 'email'},
- // { required: true, message: "请输入邮箱地址", validator: this.spaceJudgment, trigger: "blur" }
- // ],
- // dateBirth: [
- // { required: true, message: "请选择出生日期", trigger: "blur" }
- // ],
- },
- //上传签名开关
- upImgOpen:false,
- option:{
- img: '', // 裁剪图片的地址
- outputSize: 1, //裁剪生成图片的质量(可选0.1 - 1)
- outputType: 'png', //裁剪生成图片的格式(jpeg || png || webp)
- info: true, //图片大小信息
- canScale: true, //图片是否允许滚轮缩放
- autoCrop: true, //是否默认生成截图框
- autoCropWidth: 240, //默认生成截图框宽度
- autoCropHeight: 80, //默认生成截图框高度
- fixed: true, //是否开启截图框宽高固定比例
- fixedNumber: [3, 1], //截图框的宽高比例
- full: false, //false按原比例裁切图片,不失真
- fixedBox: true, //固定截图框大小,不允许改变
- canMove: false, //上传图片是否可以移动
- canMoveBox: true, //截图框能否拖动
- original: false, //上传图片按照原始比例渲染
- centerBox: false, //截图框是否被限制在图片里面
- height: true, //是否按照设备的dpr 输出等比例图片
- infoTrue: false, //true为展示真实输出图片宽高,false展示看到的截图框宽高
- maxImgSize: 3000, //限制图片最大宽度和高度
- enlarge: 1, //图片根据截图框输出比例倍数
- mode: '560px 400px' //图片默认渲染方式
- },
- previews:{},
- //上传人脸
- upFaceOpen:false,
- upFaceUrl:"",
- //临时签名数据
- signatureData:"",
- //修改手机号相关
- dialogPhoneType:false,
- phoneForm:{
- phone:"",
- code:"",
- },
- codeTime:"",
- codeTimeText:"获取验证码",
- phoneState:1,
- newPhoneData:{},
- }
- },
- created() {
- this.getUser();
- },
- methods: {
- //下一步/修改手机号码
- revisePhone(){
- this.$refs["phoneForm"].validate((valid) => {
- if (valid) {
- this.$refs["codeForm"].validate((valid) => {
- if (valid) {
- if(this.phoneState == 1){
- let obj = JSON.parse(JSON.stringify(this.phoneForm))
- phoneCheckCode(obj).then(response => {
- if(response.data){
- this.$set(this,'newPhoneData',JSON.parse(JSON.stringify(obj)));
- clearInterval(this.codeTime);
- this.$set(this,'phoneForm',{phone:"",code:""});
- this.$set(this,'codeTime',"");
- this.$set(this,'codeTimeText',"获取验证码");
- this.$set(this,'phoneState',2);
- }else{
- this.msgError('验证码错误')
- }
- });
- }else{
- let newObj = {
- code:this.phoneForm.code,
- newPhone:this.phoneForm.phone,
- oldPhone:this.newPhoneData.phone,
- }
- putPhone(newObj).then(response => {
- console.log('response',response);
- if(response.code==200){
- this.dialogPhoneType = false;
- clearInterval(this.codeTime);
- this.$set(this,'phoneForm',{phone:"",code:""});
- this.$set(this,'codeTime',"");
- this.$set(this,'codeTimeText',"获取验证码");
- this.$set(this,'phoneState',1);
- this.msgSuccess(response.msg)
- this.getUser();
- }else{
- this.msgError(response.msg)
- }
- });
- }
- }
- });
- }
- });
- },
- //手机号验证
- checkPhone(rule, value, callback) {
- if (!value) {
- return callback(new Error('不能为空'))
- } else {
- const reg = /^1[3|4|5|7|8|9][0-9]\d{8}$/
- if (reg.test(value)) {
- callback()
- } else {
- return callback(new Error('请输入正确的手机号码'))
- }
- }
- },
- //开启修改手机号
- showPhone(type){
- if (type == 1){
- this.$set(this,'phoneForm',{phone:"",code:""});
- this.$set(this,'codeTimeText',"获取验证码");
- this.$set(this,'phoneState',1);
- this.dialogPhoneType = true;
- } else{
- this.dialogPhoneType = false;
- }
- },
- //关闭修改手机号
- offPhone(){
- clearInterval(this.codeTime);
- this.$set(this,'codeTime',"");
- },
- //获取验证码
- getCode(){
- this.$refs["phoneForm"].validate((valid) => {
- if (valid) {
- if(!this.codeTime){
- let obj = {
- phone:this.phoneForm.phone
- }
- getSendCode(obj).then(response => {
- console.log(response.data)
- this.$set(this,'codeTimeText',30);
- this.phoneTime();
- });
- }
- }
- });
- },
- //倒计时
- phoneTime(){
- let self = this;
- let num = 30;
- this.codeTime = setInterval(refreshCount, 1000);
- function refreshCount() {
- if(num<=1){
- console.log("结束")
- clearInterval(self.codeTime);
- self.$set(self,'codeTime',"");
- self.$set(self,'codeTimeText','获取验证码');
- }else{
- num--;
- self.$set(self,'codeTimeText',num);
- console.log("持续启动中",num)
- }
- }
- },
- //修改用户信息
- upDataProfile(){
- let self = this;
- this.$refs["userform"].validate(valid => {
- if (valid) {
- if(!this.userform.email&&!this.userform.dateBirth){
- this.msgError('邮箱/出生年月,请至少填写一项进行修改')
- return
- }
- if((this.userform.email == this.userformData.email)&&
- (this.userform.dateBirth == this.userformData.dateBirth)){
- this.msgError('邮箱/出生年月,请至少修改一项再进行保存操作')
- return
- }
- let obj = {};
- if(this.userform.email){
- let regex = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
- if(!regex.test(this.userform.email)){
- this.msgError('请输入正确的邮箱地址')
- return
- }else{
- obj.email = this.userform.email;
- }
- }else {
- obj.email = '';
- }
- if(this.userform.dateBirth){
- obj.dateBirth = this.userform.dateBirth;
- }else{
- obj.dateBirth = '';
- }
- obj.userId = this.user.userId;
- this.$confirm('确定要修改吗', "警告", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(function() {
- upDataProfile(obj).then(response => {
- self.msgSuccess('操作成功');
- self.getUser();
- });
- }).then(() => {
- }).catch(() => {});
- }
- })
- },
- //修改按钮密码
- submit() {
- let self = this;
- self.$refs["form"].validate(valid => {
- if (valid) {
- this.$confirm('确定要修改吗', "警告", {
- confirmButtonText: "确定",
- cancelButtonText: "取消",
- type: "warning"
- }).then(function() {
- self.updateUserPwd();
- }).then(() => {
- }).catch(() => {});
- }
- });
- },
- //修改密码接口
- updateUserPwd(){
- updateUserPwd(this.form.oldPassword, this.form.newPassword).then(
- response => {
- this.form.oldPassword = "";
- this.form.newPassword = "";
- this.form.confirmPassword = "";
- this.msgSuccess("修改成功");
- }
- );
- },
- //返回按钮
- outButton(){
- this.$router.back()
- },
- //页面按钮点击
- buttonTypeClick(type){
- if(this.buttonType != type){
- this.buttonType = type;
- }
- },
- //获取信息
- getUser() {
- getUserProfile().then(response => {
- this.user = response.data;
- this.roleGroup = response.roleGroup;
- this.postGroup = response.postGroup;
- let obj = {
- phonenumber:response.data.phonenumber,
- email:response.data.email,
- dateBirth:response.data.dateBirth,
- }
- this.$set(this,'userform',JSON.parse(JSON.stringify(obj)));
- this.$set(this,'userformData',JSON.parse(JSON.stringify(obj)));
- this.pageType = true;
- });
- },
- //上传签名
- upSignatureData(){
- if(!this.signatureData){
- this.msgError('请先选择签名上传并保存查看')
- }
- var blob = this.dataURLtoBlob(this.signatureData);
- var file = this.blobToFile(blob, 'dx.jpg');
- let formData = new FormData();
- formData.append('file',file,"DX.jpg")
- console.log("formData",formData);
- updateSignature(formData).then(response => {
- if(response.code == 200){
- this.msgSuccess("操作成功");
- this.upImgOpen = false;
- this.getUser();
- }
- });
- },
- //照片页面开关
- upFaceOpenClick(type){
- if(type == 1){
- this.upFaceOpen = false;
- }else if (type == 2){
- this.upFaceUrl = this.user.faceImg;
- this.upFaceOpen = true;
- }
- },
- //签名页面开关
- upImgOpenClick(type){
- if(type == 1){
- this.upImgOpen = false;
- }else if (type == 2){
- this.option.img = this.user.signature;
- this.signatureData = this.user.signature;
- this.upImgOpen = true;
- }
- },
- //确定签名
- upImgButton(){
- let self = this;
- this.$refs.cropper.getCropBlob(async (data) => {
- let formData = new FormData();
- formData.append('file',data,"DX.jpg")
- genSign(formData).then(response => {
- if(response.code == 200){
- this.signatureData = 'data:image/png;base64,'+response.data;
- } else {
- this.msgError(response.msg)
- }
- });
- })
- },
- //照片选择
- faceChange(val){
- const windowURL = window.URL || window.webkitURL;
- this.upFaceUrl = windowURL.createObjectURL(val.raw)
- },
- //签名选择
- signatureChange(val){
- const windowURL = window.URL || window.webkitURL;
- this.option.img = windowURL.createObjectURL(val.raw)
- this.signatureData = "";
- this.upImgOpen = true;
- },
- // 照片上传按钮
- faceButton(type){
- if(type==1){
- this.upFaceOpen = false;
- }else if(type == 2){
- this.$refs.faceUpLoad.submit();
- }
- },
- //上传
- handleAvatarSuccess(res, type) {
- if(res.code == 200){
- this.user.faceImg = res.data.cardUrl;
- this.upFaceOpen = false;
- this.getUser();
- this.msgSuccess(res.msg)
- this.$forceUpdate()
- }else{
- this.msgError(res.msg)
- }
- },
- beforeAvatarUpload(file) {
- let type = false;
- if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif') {
- type = true;
- }else{
- this.$message.error('只能上传png/jpeg/gif格式图片');
- type = false;
- }
- return type;
- },
- // 实时预览函数
- realTime(data) {
- console.log("实时预览函数",data)
- this.previews = data;
- },
- //图片加载的回调 imgLoad 返回结果success, error
- imgLoad (msg) {
- console.log("图片加载的回调",msg)
- // console.log('imgLoad')
- // console.log(msg)
- },
- //将base64转换为blob
- dataURLtoBlob: function(dataurl) {
- var arr = dataurl.split(',')
- var mime = arr[0].match(/:(.*?);/)[1]
- var bstr = atob(arr[1])
- var n = bstr.length
- var u8arr = new Uint8Array(n)
- while (n--) {
- u8arr[n] = bstr.charCodeAt(n);
- }
- return new Blob([u8arr], { type: mime });
- },
- //将blob转换为file
- blobToFile: function(theBlob, fileName){
- theBlob.lastModifiedDate = new Date();
- theBlob.name = fileName;
- return theBlob;
- },
- },
- beforeRouteLeave(to, from, next) {
- console.log("to",to);
- if(to.name == 'IndexHome'){
- this.$router.push({ path: "/redirect"+to.fullPath });
- }else{
- next();
- }
- }
- }
- </script>
- <style scoped lang="scss">
- .mine{
- height:100%;
- width:100%;
- display: flex;
- flex-direction: column;
- *{
- margin:0;
- }
- .mine-page{
- flex:1;
- display: flex;
- .left-max-box{
- width:300px;
- margin:5px 20px 20px 20px;
- box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
- border-radius:10px;
- .left-title{
- font-size:18px;
- text-align: center;
- line-height: 30px;
- margin-top:30px;
- color:#0045af;
- }
- .left-user-img{
- width:130px;
- height:130px;
- overflow: hidden;
- border-radius:50%;
- margin:30px auto 20px;
- }
- .left-name{
- font-size:20px;
- line-height:43px;
- text-align: center;
- }
- .left-num{
- font-size:16px;
- line-height:38px;
- text-align: center;
- }
- .left-text-max-box{
- border-top:1px dashed #dedede;
- border-bottom:1px dashed #dedede;
- margin:24px 10px 0;
- padding:20px 0;
- .left-text-big-box{
- display: flex;
- .left-text-big-box-left{
- width:100px;
- height:38px;
- display: flex;
- margin-right:10px;
- img{
- width:16px;
- height:16px;
- margin:11px 10px 0;
- }
- p{
- flex:1;
- font-size:14px;
- line-height:38px;
- }
- }
- .left-text-big-box-right{
- height:38px;
- flex:1;
- display: flex;
- .img-one{
- width:16px;
- height:14px;
- margin:12px 10px 0;
- }
- .img-two{
- width:16px;
- height:16px;
- margin:11px 10px 0;
- }
- p{
- flex:1;
- font-size:14px;
- line-height:38px;
- }
- }
- }
- .left-text-min-box{
- display: flex;
- height:38px;
- img{
- width:16px;
- height:16px;
- margin:11px 10px 0;
- }
- p{
- flex:1;
- font-size:14px;
- line-height:38px;
- }
- }
- }
- .left-type-text-max-box{
- padding:20px 0;
- div{
- display: flex;
- p{
- flex:1;
- font-size:14px;
- color:#333;
- line-height:40px;
- }
- p:nth-child(1){
- text-align: left;
- margin-left:32px;
- }
- p:nth-child(2){
- text-align: right;
- margin-right:48px;
- }
- .p-color-a{
- color:#06B924;
- }
- .p-color-b{
- color:#FF9735;
- }
- }
- }
- }
- .right-max-box{
- flex:1;
- margin:5px 20px 20px 0;
- box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
- border-radius:10px;
- display: flex;
- flex-direction: column;
- .right-title-box{
- display: flex;
- border-bottom:1px solid #dedede;
- .title-button-min-box{
- height:90px;
- margin:0 20px;
- cursor: pointer;
- p:nth-child(1){
- margin-top:6px;
- line-height:78px;
- font-size:16px;
- }
- p:nth-child(2){
- height:6px;
- border-radius:4px;
- }
- .bottomColor{
- color:#0045AF;
- }
- .bottomBack{
- background:#0045AF ;
- }
- }
- .right-null-p{
- flex:1;
- }
- .right-out-button{
- margin:20px;
- }
- }
- .type-one-max-box{
- width:100px;
- margin:40px auto 0;
- }
- .up-data-box{
- display: inline-block;
- width:380px;
- line-height:20px;
- margin-bottom:30px;
- .up-data-min-box{
- .up-data-title{
- font-size:15px;
- color:#333;
- }
- .up-data-button{
- width:120px;
- height:120px;
- border: 1px dashed #E0E0E0;
- cursor: pointer;
- p{
- text-align: center;
- color:#999;
- font-weight:500;
- }
- p:nth-child(1){
- font-size: 20px;
- line-height:40px;
- margin-top:20px;
- }
- p:nth-child(2){
- font-size: 16px;
- }
- }
- .img-one{
- width:120px;
- height:120px;
- }
- .img-two{
- width: 240px;
- height:80px;
- }
- }
- }
- .form-item-min{
- margin-top:40px;
- }
- }
- }
- }
- </style>
- <style lang="scss">
- .up-img-box{
- .el-dialog__body{
- padding-top:0;
- }
- .img-one{
- width:560px;
- height:150px;
- }
- .cropper-img{
- display: block;
- border:1px solid #e0e0e0;
- width:360px;
- height:120px;
- margin:0 auto;
- }
- .cropper-box{
- width:560px;
- height:270px;
- position: relative;
- .cropper-button{
- position: absolute;
- right:10px;top:10px;
- z-index:1;
- background: #0183FA;
- color:#fff;
- cursor: pointer;
- padding:5px 10px;
- margin:0;
- border-radius:6px;
- }
- }
- }
- .revise-phone-box{
- .phone-box{
- }
- .code-box{
- display: flex;
- .code-button{
- font-size:14px;
- margin:0 0 0 20px;
- width:140px;
- text-align: center;
- color:#0045AF;
- border:1px solid #0045AF;
- line-height:38px;
- border-radius:6px;
- cursor: pointer;
- }
- }
- }
- </style>
|