indexOne.vue 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050
  1. <template>
  2. <div class="mine">
  3. <!--<navbar />-->
  4. <div class="mine-page">
  5. <div class="left-max-box">
  6. <p class="left-title">个人中心</p>
  7. <div class="left-user-img">
  8. <userAvatar :user="user" />
  9. </div>
  10. <p class="left-name">{{user.nickName}}</p>
  11. <p class="left-num">{{user.userType=='11'?'工号:':(user.userType=='22'?'学号:':'其他:')}}{{user.userName}}</p>
  12. <div class="left-text-max-box">
  13. <div class="left-text-big-box">
  14. <div class="left-text-big-box-left">
  15. <img v-if="user.userType == '22'" src="@/assets/ZDimages/mine/icon_grzx_xl.png">
  16. <img v-else src="@/assets/ZDimages/mine/icon_grzx_zc.png">
  17. <p>{{user.education?user.education:'未设置'}}</p>
  18. </div>
  19. <div class="left-text-big-box-right">
  20. <img class="img-two" v-if="user.userType == '22'" src="@/assets/ZDimages/mine/icon_grzx_zy.png">
  21. <img class="img-one" v-else src="@/assets/ZDimages/mine/icon_grzx_zw.png">
  22. <p>{{user.major?user.major:'未设置'}}</p>
  23. </div>
  24. </div>
  25. <div class="left-text-min-box">
  26. <img src="@/assets/ZDimages/mine/icon_grzx_sjh.png">
  27. <p>{{user.phonenumber?user.phonenumber:'未设置'}}</p>
  28. </div>
  29. <div class="left-text-min-box">
  30. <img src="@/assets/ZDimages/mine/icon_grzx_yx.png">
  31. <p>{{user.email?user.email:'未设置'}}</p>
  32. </div>
  33. <div class="left-text-min-box">
  34. <img src="@/assets/ZDimages/mine/icon_grzx_bgl.png">
  35. <p>{{user.deptName?user.deptName:'未设置'}}</p>
  36. </div>
  37. </div>
  38. <div class="left-type-text-max-box">
  39. <div>
  40. <p>手机号码</p>
  41. <p :class="user.phonenumber?'p-color-a':'p-color-b'">{{user.phonenumber?'已设置':'未设置'}}</p>
  42. </div>
  43. <div>
  44. <p>系统头像</p>
  45. <p :class="user.avatar?'p-color-a':'p-color-b'">{{user.avatar?'已设置':'未设置'}}</p>
  46. </div>
  47. <div>
  48. <p>人脸照片</p>
  49. <p :class="user.faceImg?'p-color-a':'p-color-b'">{{user.faceImg?'已设置':'未设置'}}</p>
  50. </div>
  51. <!--<div>-->
  52. <!--<p>电子签名</p>-->
  53. <!--<p :class="user.signature?'p-color-a':'p-color-b'">{{user.signature?'已设置':'未设置'}}</p>-->
  54. <!--</div>-->
  55. </div>
  56. </div>
  57. <div class="right-max-box">
  58. <div class="right-title-box">
  59. <div class="title-button-min-box">
  60. <p :class="buttonType == '1'?'bottomColor':''">基本资料</p>
  61. <p :class="buttonType == '1'?'bottomBack':''"></p>
  62. </div>
  63. <!--<div class="title-button-min-box" @click="buttonTypeClick(2)">-->
  64. <!--<p :class="buttonType == '2'?'bottomColor':''">安全设置</p>-->
  65. <!--<p :class="buttonType == '2'?'bottomBack':''"></p>-->
  66. <!--</div>-->
  67. <p class="right-null-p"></p>
  68. <!--<p class="reset-button-one right-out-button" @click="outButton">返回</p>-->
  69. </div>
  70. <div v-if="buttonType == 1">
  71. <el-form :model="userform" ref="userform" :rules="rules" :inline="true" >
  72. <div>
  73. <el-form-item class="form-item-min" label="手机号码:" prop="phonenumber" label-width="120px">
  74. <el-input
  75. maxlength="11"
  76. disabled
  77. v-model="userform.phonenumber"
  78. placeholder="未填写"
  79. clearable
  80. size="small"
  81. onkeyup="this.value=this.value.replace(/\D/g,'')" onafterpaste="this.value=this.value.replace(/\D/g,'')"
  82. />
  83. <span style="color:#0183FA;margin-left:20px;cursor: pointer;" @click="showPhone(1)">修改手机号</span>
  84. </el-form-item>
  85. <el-form-item class="form-item-min" label="邮箱:" prop="email" label-width="120px">
  86. <el-input
  87. maxlength="30"
  88. v-model="userform.email"
  89. placeholder="请输入邮箱"
  90. clearable
  91. size="small"
  92. />
  93. </el-form-item>
  94. <el-form-item class="form-item-min" label="出生年月:" prop="dateBirth" label-width="120px">
  95. <el-date-picker
  96. v-model="userform.dateBirth"
  97. value-format="yyyy-MM-dd"
  98. type="date"
  99. placeholder="请选择出生日期">
  100. </el-date-picker>
  101. </el-form-item>
  102. </div>
  103. <div>
  104. <el-form-item class="form-item-min" label="人脸照片:" prop="searchValue" label-width="120px">
  105. <div class="up-data-box" style="width:210px;">
  106. <div class="up-data-min-box" style="display: flex;">
  107. <div class="up-data-button" v-if="!user.faceImg" @click="upFaceOpenClick(2)">
  108. <p>+</p>
  109. <p>上传</p>
  110. </div>
  111. <img class="img-one" :src="user.faceImg" v-if="user.faceImg" @click="upFaceOpenClick(2)">
  112. </div>
  113. </div>
  114. </el-form-item>
  115. <!--<el-form-item class="form-item-min" label="电子签名:" prop="searchValue" label-width="120px">-->
  116. <!--<div class="up-data-box">-->
  117. <!--<div class="up-data-min-box" style="display: flex;">-->
  118. <!--<el-upload-->
  119. <!--class="position-button"-->
  120. <!--:action="uploadImgUrlTwo"-->
  121. <!--:show-file-list="false"-->
  122. <!--:auto-upload="false"-->
  123. <!--:on-change="signatureChange"-->
  124. <!--accept="image/jpeg,image/gif,image/png"-->
  125. <!--:headers="headers"-->
  126. <!--:before-upload="beforeAvatarUpload">-->
  127. <!--<div class="up-data-button" v-if="!user.signature">-->
  128. <!--<p>+</p>-->
  129. <!--<p>上传</p>-->
  130. <!--</div>-->
  131. <!--<img class="img-two" :src="user.signature" v-if="user.signature">-->
  132. <!--</el-upload>-->
  133. <!--</div>-->
  134. <!--</div>-->
  135. <!--</el-form-item>-->
  136. </div>
  137. </el-form>
  138. <p class="type-one-max-box add-button-one-120" @click="upDataProfile">保存</p>
  139. </div>
  140. <div v-if="buttonType == 2">
  141. <el-form :model="form" ref="form" :inline="true" :rules="rules">
  142. <div>
  143. <el-form-item class="form-item-min" label="原始密码:" prop="oldPassword" label-width="120px">
  144. <el-input
  145. maxlength="16"
  146. type="password"
  147. v-model.trim="form.oldPassword"
  148. placeholder="请输入原始密码"
  149. clearable
  150. size="small"
  151. />
  152. </el-form-item>
  153. <el-form-item class="form-item-min" label="新密码:" prop="newPassword" label-width="110px">
  154. <el-input
  155. maxlength="16"
  156. type="password"
  157. v-model.trim="form.newPassword"
  158. placeholder="请输入新密码"
  159. clearable
  160. size="small"
  161. />
  162. </el-form-item>
  163. <el-form-item class="form-item-min" label="确认密码:" prop="confirmPassword" label-width="120px">
  164. <el-input
  165. maxlength="16"
  166. type="password"
  167. v-model.trim="form.confirmPassword"
  168. placeholder="请确认密码"
  169. clearable
  170. size="small"
  171. />
  172. </el-form-item>
  173. <span class="type-one-max-box add-button-one-120" style="margin-left:20px;display: inline-block;" @click="submit">保存</span>
  174. </div>
  175. </el-form>
  176. </div>
  177. </div>
  178. </div>
  179. <!--电子签名-->
  180. <el-dialog class="up-img-box" title="上传电子签名" :visible.sync="upImgOpen" width="600px" append-to-body>
  181. <p>示例</p>
  182. <img class="img-one" src="@/assets/ZDimages/icon_scdzqm_sl.png">
  183. <p>正楷签名</p>
  184. <div class="cropper-box">
  185. <vueCropper
  186. ref="cropper"
  187. :img="option.img"
  188. :outputSize="option.outputSize"
  189. :outputType="option.outputType"
  190. :info="option.info"
  191. :canScale="option.canScale"
  192. :autoCrop="option.autoCrop"
  193. :autoCropWidth="option.autoCropWidth"
  194. :autoCropHeight="option.autoCropHeight"
  195. :fixed="option.fixed"
  196. :fixedNumber="option.fixedNumber"
  197. :full="option.full"
  198. :fixedBox="option.fixedBox"
  199. :canMove="option.canMove"
  200. :canMoveBox="option.canMoveBox"
  201. :original="option.original"
  202. :centerBox="option.centerBox"
  203. :height="option.height"
  204. :infoTrue="option.infoTrue"
  205. :maxImgSize="option.maxImgSize"
  206. :enlarge="option.enlarge"
  207. :mode="option.mode"
  208. @realTime="realTime"
  209. @imgLoad="imgLoad"
  210. ></vueCropper>
  211. <p class="cropper-button" @click="upImgButton">保存查看</p>
  212. <el-upload
  213. class="position-button"
  214. :action="uploadImgUrl"
  215. :show-file-list="false"
  216. :auto-upload="false"
  217. :on-change="signatureChange"
  218. accept="image/jpeg,image/gif,image/png"
  219. :headers="headers"
  220. :before-upload="beforeAvatarUpload">
  221. <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>
  222. </el-upload>
  223. </div>
  224. <p style="color:#999;">请将签名置于选择框内以便提高识别度</p>
  225. <img class="cropper-img" v-if="signatureData" :src="signatureData">
  226. <div slot="footer" class="dialog-footer">
  227. <el-button @click="upImgOpenClick(1)">取 消</el-button>
  228. <el-button type="primary" @click="upSignatureData">确 定</el-button>
  229. </div>
  230. </el-dialog>
  231. <!--上传照片-->
  232. <el-dialog class="up-img-box" title="上传照片" :visible.sync="upFaceOpen" width="600px" append-to-body>
  233. <el-upload
  234. ref="faceUpLoad"
  235. class="position-button"
  236. :action="uploadImgUrl"
  237. :show-file-list="false"
  238. :auto-upload="false"
  239. :on-change="faceChange"
  240. accept="image/jpeg,image/gif,image/png"
  241. :on-success="(res)=>handleAvatarSuccess(res)"
  242. :headers="headers"
  243. :before-upload="beforeAvatarUpload">
  244. <div v-if="!upFaceUrl" style="width:300px;height:300px;border: 1px dashed #E0E0E0;cursor: pointer;margin:20px 130px 0;">
  245. <p style="text-align: center;color:#999;font-weight:500;font-size: 20px;line-height:300px;margin:0;">+</p>
  246. </div>
  247. <div v-if="upFaceUrl" class="scrollbar-box" style="width:560px;margin:0 auto;max-height:700px;overflow-y: scroll">
  248. <img :src="upFaceUrl" style="max-width:560px;border: 1px dashed #E0E0E0;cursor: pointer;margin:0 auto;">
  249. </div>
  250. </el-upload>
  251. <div slot="footer" class="dialog-footer">
  252. <el-button @click="faceButton(1)">取 消</el-button>
  253. <el-button type="primary" @click="faceButton(2)">确 定</el-button>
  254. </div>
  255. </el-dialog>
  256. <!--修改手机号-->
  257. <el-dialog class="revise-phone-box" @close="offPhone" title="修改手机号" :visible.sync="dialogPhoneType"
  258. v-if="dialogPhoneType" width="400px" append-to-body>
  259. <el-form ref="phoneForm" :model="phoneForm" :rules="rules" label-width="0px">
  260. <el-form-item label="" prop="phone">
  261. <div class="phone-box">
  262. <el-input
  263. maxlength="11"
  264. v-model.trim="phoneForm.phone"
  265. :placeholder="phoneState == 1?'请输入旧手机号':'请输入新手机号'"
  266. clearable>
  267. <template slot="prepend">+86</template>
  268. </el-input>
  269. </div>
  270. </el-form-item>
  271. </el-form>
  272. <el-form ref="codeForm" :model="phoneForm" :rules="rules" label-width="0px">
  273. <el-form-item label="" prop="code">
  274. <div class="code-box">
  275. <el-input
  276. maxlength="6"
  277. v-model.trim="phoneForm.code"
  278. placeholder="请输入验证码"
  279. clearable>
  280. </el-input>
  281. <p class="code-button" @click="getCode">{{codeTimeText}}</p>
  282. </div>
  283. </el-form-item>
  284. </el-form>
  285. <div slot="footer" class="dialog-footer">
  286. <el-button style="width:100px;" @click="showPhone(2)">取 消</el-button>
  287. <el-button style="width:100px;" type="primary" @click="revisePhone">{{phoneState==1?'下一步':(phoneState==2?'确定':'')}}</el-button>
  288. </div>
  289. </el-dialog>
  290. </div>
  291. </template>
  292. <script>
  293. import { Navbar } from '@/layout/components'
  294. import userAvatar from "./userAvatar";
  295. import { getUserProfile,updateUserPwd,changePhone,genSign,updateSignature,upDataProfile,
  296. getSendCode, phoneCheckCode, putPhone} from "@/api/system/user";
  297. import { getToken } from "@/utils/auth";
  298. export default {
  299. name: "mine",
  300. components: {
  301. Navbar,
  302. userAvatar
  303. },
  304. data(){
  305. const equalToPassword = (rule, value, callback) => {
  306. if (this.form.confirmPassword !== value) {
  307. callback(new Error("两次输入的密码不一致"));
  308. } else {
  309. callback();
  310. }
  311. };
  312. const equalToPasswordTwo = (rule, value, callback) => {
  313. if (this.form.newPassword !== value) {
  314. callback(new Error("两次输入的密码不一致"));
  315. } else {
  316. callback();
  317. }
  318. };
  319. const validatePass = (rule, value, callback) => {
  320. let reg = /^(?![A-z0-9]+$)(?=.[^%&',;=?$\x22])(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9]).{8,16}$/
  321. console.log("reg.test(value)",reg.test(value))
  322. if(reg.test(value)){
  323. callback()
  324. }else{
  325. return callback(new Error('密码应在8-16位包括数字和字母与特殊字符'));
  326. }
  327. };
  328. return{
  329. buttonType:'1',
  330. uploadImgUrl: window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + "/laboratory/studentinfo/commit/face", // 上传的图片服务器地址
  331. uploadImgUrlTwo: window.location.href.split('://')[0]+'://' + process.env.VUE_APP_BASE_API + "/file/upload", // 上传的图片服务器地址
  332. headers: {
  333. Authorization: "Bearer " + getToken(),
  334. },
  335. pageType:false,
  336. user: {},
  337. roleGroup: {},
  338. postGroup: {},
  339. activeTab: "resetPwd",
  340. form:{
  341. oldPassword:"",
  342. newPassword:"",
  343. confirmPassword:""
  344. },
  345. userform:{},
  346. userformData:{},
  347. open:false,
  348. // 表单校验
  349. rules: {
  350. oldPassword: [
  351. { required: true, message: "旧密码不能为空", trigger: "blur" },
  352. ],
  353. newPassword: [
  354. { required: true, message: "新密码不能为空", trigger: "blur" },
  355. { min: 8, max: 16, message: "长度在 8 到 16 个字符", trigger: "blur" },
  356. { required: true, validator: equalToPassword, trigger: "blur" },
  357. { required: true, message: "请输入8-16位密码,不能输入连续性和重复性的密码,密码中需要包含:大写字母、小写字符、数字和字符", validator: validatePass, trigger: "blur" }
  358. ],
  359. confirmPassword: [
  360. { required: true, message: "确认密码不能为空", trigger: "blur" },
  361. { min: 8, max: 16, message: "长度在 8 到 16 个字符", trigger: "blur" },
  362. { required: true, validator: equalToPasswordTwo, trigger: "blur" },
  363. { required: true, message: "请输入8-16位密码,不能输入连续性和重复性的密码,密码中需要包含:大写字母、小写字符、数字和字符", validator: validatePass, trigger: "blur" }
  364. ],
  365. phone: [
  366. { required: true, message: "请输入手机号码", trigger: "blur" },
  367. { validator: this.checkPhone, trigger: 'blur' },
  368. { min: 11, max: 11, message: "请输入11位手机号码", trigger: "blur" },
  369. { required: true, message: "请输入手机号码", validator: this.spaceJudgment, trigger: "blur" }
  370. ],
  371. // phone: [
  372. // { required: true, message: "请输入手机号码", trigger: "blur" },
  373. // { required: true, message: "请输入手机号码", validator: this.spaceJudgment, trigger: "blur" }
  374. // ],
  375. code: [
  376. { required: true, message: "请输入验证码", trigger: "blur" },
  377. { required: true, message: "请输入验证码", validator: this.spaceJudgment, trigger: "blur" }
  378. ],
  379. // email: [
  380. // { required: true, message: "请输入邮箱地址", trigger: "blur" },
  381. // { required: true, message: "请输入正确的邮箱地址", type: 'email'},
  382. // { required: true, message: "请输入邮箱地址", validator: this.spaceJudgment, trigger: "blur" }
  383. // ],
  384. // dateBirth: [
  385. // { required: true, message: "请选择出生日期", trigger: "blur" }
  386. // ],
  387. },
  388. //上传签名开关
  389. upImgOpen:false,
  390. option:{
  391. img: '', // 裁剪图片的地址
  392. outputSize: 1, //裁剪生成图片的质量(可选0.1 - 1)
  393. outputType: 'png', //裁剪生成图片的格式(jpeg || png || webp)
  394. info: true, //图片大小信息
  395. canScale: true, //图片是否允许滚轮缩放
  396. autoCrop: true, //是否默认生成截图框
  397. autoCropWidth: 240, //默认生成截图框宽度
  398. autoCropHeight: 80, //默认生成截图框高度
  399. fixed: true, //是否开启截图框宽高固定比例
  400. fixedNumber: [3, 1], //截图框的宽高比例
  401. full: false, //false按原比例裁切图片,不失真
  402. fixedBox: true, //固定截图框大小,不允许改变
  403. canMove: false, //上传图片是否可以移动
  404. canMoveBox: true, //截图框能否拖动
  405. original: false, //上传图片按照原始比例渲染
  406. centerBox: false, //截图框是否被限制在图片里面
  407. height: true, //是否按照设备的dpr 输出等比例图片
  408. infoTrue: false, //true为展示真实输出图片宽高,false展示看到的截图框宽高
  409. maxImgSize: 3000, //限制图片最大宽度和高度
  410. enlarge: 1, //图片根据截图框输出比例倍数
  411. mode: '560px 400px' //图片默认渲染方式
  412. },
  413. previews:{},
  414. //上传人脸
  415. upFaceOpen:false,
  416. upFaceUrl:"",
  417. //临时签名数据
  418. signatureData:"",
  419. //修改手机号相关
  420. dialogPhoneType:false,
  421. phoneForm:{
  422. phone:"",
  423. code:"",
  424. },
  425. codeTime:"",
  426. codeTimeText:"获取验证码",
  427. phoneState:1,
  428. newPhoneData:{},
  429. }
  430. },
  431. created() {
  432. this.getUser();
  433. },
  434. methods: {
  435. //下一步/修改手机号码
  436. revisePhone(){
  437. this.$refs["phoneForm"].validate((valid) => {
  438. if (valid) {
  439. this.$refs["codeForm"].validate((valid) => {
  440. if (valid) {
  441. if(this.phoneState == 1){
  442. let obj = JSON.parse(JSON.stringify(this.phoneForm))
  443. phoneCheckCode(obj).then(response => {
  444. if(response.data){
  445. this.$set(this,'newPhoneData',JSON.parse(JSON.stringify(obj)));
  446. clearInterval(this.codeTime);
  447. this.$set(this,'phoneForm',{phone:"",code:""});
  448. this.$set(this,'codeTime',"");
  449. this.$set(this,'codeTimeText',"获取验证码");
  450. this.$set(this,'phoneState',2);
  451. }else{
  452. this.msgError('验证码错误')
  453. }
  454. });
  455. }else{
  456. let newObj = {
  457. code:this.phoneForm.code,
  458. newPhone:this.phoneForm.phone,
  459. oldPhone:this.newPhoneData.phone,
  460. }
  461. putPhone(newObj).then(response => {
  462. console.log('response',response);
  463. if(response.code==200){
  464. this.dialogPhoneType = false;
  465. clearInterval(this.codeTime);
  466. this.$set(this,'phoneForm',{phone:"",code:""});
  467. this.$set(this,'codeTime',"");
  468. this.$set(this,'codeTimeText',"获取验证码");
  469. this.$set(this,'phoneState',1);
  470. this.msgSuccess(response.msg)
  471. this.getUser();
  472. }else{
  473. this.msgError(response.msg)
  474. }
  475. });
  476. }
  477. }
  478. });
  479. }
  480. });
  481. },
  482. //手机号验证
  483. checkPhone(rule, value, callback) {
  484. if (!value) {
  485. return callback(new Error('不能为空'))
  486. } else {
  487. const reg = /^1[3|4|5|7|8|9][0-9]\d{8}$/
  488. if (reg.test(value)) {
  489. callback()
  490. } else {
  491. return callback(new Error('请输入正确的手机号码'))
  492. }
  493. }
  494. },
  495. //开启修改手机号
  496. showPhone(type){
  497. if (type == 1){
  498. this.$set(this,'phoneForm',{phone:"",code:""});
  499. this.$set(this,'codeTimeText',"获取验证码");
  500. this.$set(this,'phoneState',1);
  501. this.dialogPhoneType = true;
  502. } else{
  503. this.dialogPhoneType = false;
  504. }
  505. },
  506. //关闭修改手机号
  507. offPhone(){
  508. clearInterval(this.codeTime);
  509. this.$set(this,'codeTime',"");
  510. },
  511. //获取验证码
  512. getCode(){
  513. this.$refs["phoneForm"].validate((valid) => {
  514. if (valid) {
  515. if(!this.codeTime){
  516. let obj = {
  517. phone:this.phoneForm.phone
  518. }
  519. getSendCode(obj).then(response => {
  520. console.log(response.data)
  521. this.$set(this,'codeTimeText',30);
  522. this.phoneTime();
  523. });
  524. }
  525. }
  526. });
  527. },
  528. //倒计时
  529. phoneTime(){
  530. let self = this;
  531. let num = 30;
  532. this.codeTime = setInterval(refreshCount, 1000);
  533. function refreshCount() {
  534. if(num<=1){
  535. console.log("结束")
  536. clearInterval(self.codeTime);
  537. self.$set(self,'codeTime',"");
  538. self.$set(self,'codeTimeText','获取验证码');
  539. }else{
  540. num--;
  541. self.$set(self,'codeTimeText',num);
  542. console.log("持续启动中",num)
  543. }
  544. }
  545. },
  546. //修改用户信息
  547. upDataProfile(){
  548. let self = this;
  549. this.$refs["userform"].validate(valid => {
  550. if (valid) {
  551. if(!this.userform.email&&!this.userform.dateBirth){
  552. this.msgError('邮箱/出生年月,请至少填写一项进行修改')
  553. return
  554. }
  555. if((this.userform.email == this.userformData.email)&&
  556. (this.userform.dateBirth == this.userformData.dateBirth)){
  557. this.msgError('邮箱/出生年月,请至少修改一项再进行保存操作')
  558. return
  559. }
  560. let obj = {};
  561. if(this.userform.email){
  562. let regex = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
  563. if(!regex.test(this.userform.email)){
  564. this.msgError('请输入正确的邮箱地址')
  565. return
  566. }else{
  567. obj.email = this.userform.email;
  568. }
  569. }else {
  570. obj.email = '';
  571. }
  572. if(this.userform.dateBirth){
  573. obj.dateBirth = this.userform.dateBirth;
  574. }else{
  575. obj.dateBirth = '';
  576. }
  577. obj.userId = this.user.userId;
  578. this.$confirm('确定要修改吗', "警告", {
  579. confirmButtonText: "确定",
  580. cancelButtonText: "取消",
  581. type: "warning"
  582. }).then(function() {
  583. upDataProfile(obj).then(response => {
  584. self.msgSuccess('操作成功');
  585. self.getUser();
  586. });
  587. }).then(() => {
  588. }).catch(() => {});
  589. }
  590. })
  591. },
  592. //修改按钮密码
  593. submit() {
  594. let self = this;
  595. self.$refs["form"].validate(valid => {
  596. if (valid) {
  597. this.$confirm('确定要修改吗', "警告", {
  598. confirmButtonText: "确定",
  599. cancelButtonText: "取消",
  600. type: "warning"
  601. }).then(function() {
  602. self.updateUserPwd();
  603. }).then(() => {
  604. }).catch(() => {});
  605. }
  606. });
  607. },
  608. //修改密码接口
  609. updateUserPwd(){
  610. updateUserPwd(this.form.oldPassword, this.form.newPassword).then(
  611. response => {
  612. this.form.oldPassword = "";
  613. this.form.newPassword = "";
  614. this.form.confirmPassword = "";
  615. this.msgSuccess("修改成功");
  616. }
  617. );
  618. },
  619. //返回按钮
  620. outButton(){
  621. this.$router.back()
  622. },
  623. //页面按钮点击
  624. buttonTypeClick(type){
  625. if(this.buttonType != type){
  626. this.buttonType = type;
  627. }
  628. },
  629. //获取信息
  630. getUser() {
  631. getUserProfile().then(response => {
  632. this.user = response.data;
  633. this.roleGroup = response.roleGroup;
  634. this.postGroup = response.postGroup;
  635. let obj = {
  636. phonenumber:response.data.phonenumber,
  637. email:response.data.email,
  638. dateBirth:response.data.dateBirth,
  639. }
  640. this.$set(this,'userform',JSON.parse(JSON.stringify(obj)));
  641. this.$set(this,'userformData',JSON.parse(JSON.stringify(obj)));
  642. this.pageType = true;
  643. });
  644. },
  645. //上传签名
  646. upSignatureData(){
  647. if(!this.signatureData){
  648. this.msgError('请先选择签名上传并保存查看')
  649. }
  650. var blob = this.dataURLtoBlob(this.signatureData);
  651. var file = this.blobToFile(blob, 'dx.jpg');
  652. let formData = new FormData();
  653. formData.append('file',file,"DX.jpg")
  654. console.log("formData",formData);
  655. updateSignature(formData).then(response => {
  656. if(response.code == 200){
  657. this.msgSuccess("操作成功");
  658. this.upImgOpen = false;
  659. this.getUser();
  660. }
  661. });
  662. },
  663. //照片页面开关
  664. upFaceOpenClick(type){
  665. if(type == 1){
  666. this.upFaceOpen = false;
  667. }else if (type == 2){
  668. this.upFaceUrl = this.user.faceImg;
  669. this.upFaceOpen = true;
  670. }
  671. },
  672. //签名页面开关
  673. upImgOpenClick(type){
  674. if(type == 1){
  675. this.upImgOpen = false;
  676. }else if (type == 2){
  677. this.option.img = this.user.signature;
  678. this.signatureData = this.user.signature;
  679. this.upImgOpen = true;
  680. }
  681. },
  682. //确定签名
  683. upImgButton(){
  684. let self = this;
  685. this.$refs.cropper.getCropBlob(async (data) => {
  686. let formData = new FormData();
  687. formData.append('file',data,"DX.jpg")
  688. genSign(formData).then(response => {
  689. if(response.code == 200){
  690. this.signatureData = 'data:image/png;base64,'+response.data;
  691. } else {
  692. this.msgError(response.msg)
  693. }
  694. });
  695. })
  696. },
  697. //照片选择
  698. faceChange(val){
  699. const windowURL = window.URL || window.webkitURL;
  700. this.upFaceUrl = windowURL.createObjectURL(val.raw)
  701. },
  702. //签名选择
  703. signatureChange(val){
  704. const windowURL = window.URL || window.webkitURL;
  705. this.option.img = windowURL.createObjectURL(val.raw)
  706. this.signatureData = "";
  707. this.upImgOpen = true;
  708. },
  709. // 照片上传按钮
  710. faceButton(type){
  711. if(type==1){
  712. this.upFaceOpen = false;
  713. }else if(type == 2){
  714. this.$refs.faceUpLoad.submit();
  715. }
  716. },
  717. //上传
  718. handleAvatarSuccess(res, type) {
  719. if(res.code == 200){
  720. this.user.faceImg = res.data.cardUrl;
  721. this.upFaceOpen = false;
  722. this.getUser();
  723. this.msgSuccess(res.msg)
  724. this.$forceUpdate()
  725. }else{
  726. this.msgError(res.msg)
  727. }
  728. },
  729. beforeAvatarUpload(file) {
  730. let type = false;
  731. if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif') {
  732. type = true;
  733. }else{
  734. this.$message.error('只能上传png/jpeg/gif格式图片');
  735. type = false;
  736. }
  737. return type;
  738. },
  739. // 实时预览函数
  740. realTime(data) {
  741. console.log("实时预览函数",data)
  742. this.previews = data;
  743. },
  744. //图片加载的回调 imgLoad 返回结果success, error
  745. imgLoad (msg) {
  746. console.log("图片加载的回调",msg)
  747. // console.log('imgLoad')
  748. // console.log(msg)
  749. },
  750. //将base64转换为blob
  751. dataURLtoBlob: function(dataurl) {
  752. var arr = dataurl.split(',')
  753. var mime = arr[0].match(/:(.*?);/)[1]
  754. var bstr = atob(arr[1])
  755. var n = bstr.length
  756. var u8arr = new Uint8Array(n)
  757. while (n--) {
  758. u8arr[n] = bstr.charCodeAt(n);
  759. }
  760. return new Blob([u8arr], { type: mime });
  761. },
  762. //将blob转换为file
  763. blobToFile: function(theBlob, fileName){
  764. theBlob.lastModifiedDate = new Date();
  765. theBlob.name = fileName;
  766. return theBlob;
  767. },
  768. },
  769. beforeRouteLeave(to, from, next) {
  770. console.log("to",to);
  771. if(to.name == 'IndexHome'){
  772. this.$router.push({ path: "/redirect"+to.fullPath });
  773. }else{
  774. next();
  775. }
  776. }
  777. }
  778. </script>
  779. <style scoped lang="scss">
  780. .mine{
  781. height:100%;
  782. width:100%;
  783. display: flex;
  784. flex-direction: column;
  785. *{
  786. margin:0;
  787. }
  788. .mine-page{
  789. flex:1;
  790. display: flex;
  791. .left-max-box{
  792. width:300px;
  793. margin:5px 20px 20px 20px;
  794. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  795. border-radius:10px;
  796. .left-title{
  797. font-size:18px;
  798. text-align: center;
  799. line-height: 30px;
  800. margin-top:30px;
  801. color:#0045af;
  802. }
  803. .left-user-img{
  804. width:130px;
  805. height:130px;
  806. overflow: hidden;
  807. border-radius:50%;
  808. margin:30px auto 20px;
  809. }
  810. .left-name{
  811. font-size:20px;
  812. line-height:43px;
  813. text-align: center;
  814. }
  815. .left-num{
  816. font-size:16px;
  817. line-height:38px;
  818. text-align: center;
  819. }
  820. .left-text-max-box{
  821. border-top:1px dashed #dedede;
  822. border-bottom:1px dashed #dedede;
  823. margin:24px 10px 0;
  824. padding:20px 0;
  825. .left-text-big-box{
  826. display: flex;
  827. .left-text-big-box-left{
  828. width:100px;
  829. height:38px;
  830. display: flex;
  831. margin-right:10px;
  832. img{
  833. width:16px;
  834. height:16px;
  835. margin:11px 10px 0;
  836. }
  837. p{
  838. flex:1;
  839. font-size:14px;
  840. line-height:38px;
  841. }
  842. }
  843. .left-text-big-box-right{
  844. height:38px;
  845. flex:1;
  846. display: flex;
  847. .img-one{
  848. width:16px;
  849. height:14px;
  850. margin:12px 10px 0;
  851. }
  852. .img-two{
  853. width:16px;
  854. height:16px;
  855. margin:11px 10px 0;
  856. }
  857. p{
  858. flex:1;
  859. font-size:14px;
  860. line-height:38px;
  861. }
  862. }
  863. }
  864. .left-text-min-box{
  865. display: flex;
  866. height:38px;
  867. img{
  868. width:16px;
  869. height:16px;
  870. margin:11px 10px 0;
  871. }
  872. p{
  873. flex:1;
  874. font-size:14px;
  875. line-height:38px;
  876. }
  877. }
  878. }
  879. .left-type-text-max-box{
  880. padding:20px 0;
  881. div{
  882. display: flex;
  883. p{
  884. flex:1;
  885. font-size:14px;
  886. color:#333;
  887. line-height:40px;
  888. }
  889. p:nth-child(1){
  890. text-align: left;
  891. margin-left:32px;
  892. }
  893. p:nth-child(2){
  894. text-align: right;
  895. margin-right:48px;
  896. }
  897. .p-color-a{
  898. color:#06B924;
  899. }
  900. .p-color-b{
  901. color:#FF9735;
  902. }
  903. }
  904. }
  905. }
  906. .right-max-box{
  907. flex:1;
  908. margin:5px 20px 20px 0;
  909. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  910. border-radius:10px;
  911. display: flex;
  912. flex-direction: column;
  913. .right-title-box{
  914. display: flex;
  915. border-bottom:1px solid #dedede;
  916. .title-button-min-box{
  917. height:90px;
  918. margin:0 20px;
  919. cursor: pointer;
  920. p:nth-child(1){
  921. margin-top:6px;
  922. line-height:78px;
  923. font-size:16px;
  924. }
  925. p:nth-child(2){
  926. height:6px;
  927. border-radius:4px;
  928. }
  929. .bottomColor{
  930. color:#0045AF;
  931. }
  932. .bottomBack{
  933. background:#0045AF ;
  934. }
  935. }
  936. .right-null-p{
  937. flex:1;
  938. }
  939. .right-out-button{
  940. margin:20px;
  941. }
  942. }
  943. .type-one-max-box{
  944. width:100px;
  945. margin:40px auto 0;
  946. }
  947. .up-data-box{
  948. display: inline-block;
  949. width:380px;
  950. line-height:20px;
  951. margin-bottom:30px;
  952. .up-data-min-box{
  953. .up-data-title{
  954. font-size:15px;
  955. color:#333;
  956. }
  957. .up-data-button{
  958. width:120px;
  959. height:120px;
  960. border: 1px dashed #E0E0E0;
  961. cursor: pointer;
  962. p{
  963. text-align: center;
  964. color:#999;
  965. font-weight:500;
  966. }
  967. p:nth-child(1){
  968. font-size: 20px;
  969. line-height:40px;
  970. margin-top:20px;
  971. }
  972. p:nth-child(2){
  973. font-size: 16px;
  974. }
  975. }
  976. .img-one{
  977. width:120px;
  978. height:120px;
  979. }
  980. .img-two{
  981. width: 240px;
  982. height:80px;
  983. }
  984. }
  985. }
  986. .form-item-min{
  987. margin-top:40px;
  988. }
  989. }
  990. }
  991. }
  992. </style>
  993. <style lang="scss">
  994. .up-img-box{
  995. .el-dialog__body{
  996. padding-top:0;
  997. }
  998. .img-one{
  999. width:560px;
  1000. height:150px;
  1001. }
  1002. .cropper-img{
  1003. display: block;
  1004. border:1px solid #e0e0e0;
  1005. width:360px;
  1006. height:120px;
  1007. margin:0 auto;
  1008. }
  1009. .cropper-box{
  1010. width:560px;
  1011. height:270px;
  1012. position: relative;
  1013. .cropper-button{
  1014. position: absolute;
  1015. right:10px;top:10px;
  1016. z-index:1;
  1017. background: #0183FA;
  1018. color:#fff;
  1019. cursor: pointer;
  1020. padding:5px 10px;
  1021. margin:0;
  1022. border-radius:6px;
  1023. }
  1024. }
  1025. }
  1026. .revise-phone-box{
  1027. .phone-box{
  1028. }
  1029. .code-box{
  1030. display: flex;
  1031. .code-button{
  1032. font-size:14px;
  1033. margin:0 0 0 20px;
  1034. width:140px;
  1035. text-align: center;
  1036. color:#0045AF;
  1037. border:1px solid #0045AF;
  1038. line-height:38px;
  1039. border-radius:6px;
  1040. cursor: pointer;
  1041. }
  1042. }
  1043. }
  1044. </style>