indexOne.vue 36 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052
  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" :close-on-click-modal="false" 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" :close-on-click-modal="false" 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="修改手机号" :close-on-click-modal="false" :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]+'://' + this.judgmentNetworkReturnAddress() + "/laboratory/studentinfo/commit/face", // 上传的图片服务器地址
  331. uploadImgUrlTwo: window.location.href.split('://')[0]+'://' + this.judgmentNetworkReturnAddress() + "/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. const file = new File([data], 'userImg.jpg', { type: 'image/jpeg', lastModified: Date.now() });
  687. let formData = new FormData();
  688. formData.append('file',file,"DX.jpg")
  689. genSign(formData).then(response => {
  690. if(response.code == 200){
  691. this.signatureData = 'data:image/png;base64,'+response.data;
  692. } else {
  693. this.msgError(response.msg)
  694. }
  695. });
  696. })
  697. },
  698. //照片选择
  699. faceChange(val){
  700. const windowURL = window.URL || window.webkitURL;
  701. this.upFaceUrl = windowURL.createObjectURL(val.raw)
  702. },
  703. //签名选择
  704. signatureChange(val){
  705. const windowURL = window.URL || window.webkitURL;
  706. this.option.img = windowURL.createObjectURL(val.raw)
  707. this.signatureData = "";
  708. this.upImgOpen = true;
  709. },
  710. // 照片上传按钮
  711. faceButton(type){
  712. if(type==1){
  713. this.upFaceOpen = false;
  714. }else if(type == 2){
  715. this.$refs.faceUpLoad.submit();
  716. }
  717. },
  718. //上传
  719. handleAvatarSuccess(res, type) {
  720. if(res.code == 200){
  721. this.user.faceImg = res.data.cardUrl;
  722. this.upFaceOpen = false;
  723. this.getUser();
  724. this.msgSuccess('上传成功!')
  725. this.$forceUpdate()
  726. }else{
  727. this.msgError(res.msg)
  728. }
  729. },
  730. beforeAvatarUpload(file) {
  731. let type = false;
  732. if (file.type == 'image/png' || file.type == 'image/jpeg' || file.type == 'image/gif') {
  733. type = true;
  734. }else{
  735. this.$message.error('只能上传png/jpeg/gif格式图片');
  736. type = false;
  737. }
  738. return type;
  739. },
  740. // 实时预览函数
  741. realTime(data) {
  742. console.log("实时预览函数",data)
  743. this.previews = data;
  744. },
  745. //图片加载的回调 imgLoad 返回结果success, error
  746. imgLoad (msg) {
  747. console.log("图片加载的回调",msg)
  748. // console.log('imgLoad')
  749. // console.log(msg)
  750. },
  751. //将base64转换为blob
  752. dataURLtoBlob: function(dataurl) {
  753. var arr = dataurl.split(',')
  754. var mime = arr[0].match(/:(.*?);/)[1]
  755. var bstr = atob(arr[1])
  756. var n = bstr.length
  757. var u8arr = new Uint8Array(n)
  758. while (n--) {
  759. u8arr[n] = bstr.charCodeAt(n);
  760. }
  761. return new Blob([u8arr], { type: mime });
  762. },
  763. //将blob转换为file
  764. blobToFile: function(theBlob, fileName){
  765. theBlob.lastModifiedDate = new Date();
  766. theBlob.name = fileName;
  767. return theBlob;
  768. },
  769. },
  770. beforeRouteLeave(to, from, next) {
  771. console.log("to",to);
  772. if(to.name == 'IndexHome'){
  773. this.$router.push({ path: "/redirect"+to.fullPath });
  774. }else{
  775. next();
  776. }
  777. }
  778. }
  779. </script>
  780. <style scoped lang="scss">
  781. .mine{
  782. height:100%;
  783. width:100%;
  784. display: flex;
  785. flex-direction: column;
  786. *{
  787. margin:0;
  788. }
  789. .mine-page{
  790. flex:1;
  791. display: flex;
  792. .left-max-box{
  793. width:300px;
  794. margin:5px 20px 20px 20px;
  795. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  796. border-radius:10px;
  797. .left-title{
  798. font-size:18px;
  799. text-align: center;
  800. line-height: 30px;
  801. margin-top:30px;
  802. color:#0045af;
  803. }
  804. .left-user-img{
  805. width:130px;
  806. height:130px;
  807. overflow: hidden;
  808. border-radius:50%;
  809. margin:30px auto 20px;
  810. }
  811. .left-name{
  812. font-size:20px;
  813. line-height:43px;
  814. text-align: center;
  815. }
  816. .left-num{
  817. font-size:16px;
  818. line-height:38px;
  819. text-align: center;
  820. }
  821. .left-text-max-box{
  822. border-top:1px dashed #dedede;
  823. border-bottom:1px dashed #dedede;
  824. margin:24px 10px 0;
  825. padding:20px 0;
  826. .left-text-big-box{
  827. display: flex;
  828. .left-text-big-box-left{
  829. width:100px;
  830. height:38px;
  831. display: flex;
  832. margin-right:10px;
  833. img{
  834. width:16px;
  835. height:16px;
  836. margin:11px 10px 0;
  837. }
  838. p{
  839. flex:1;
  840. font-size:14px;
  841. line-height:38px;
  842. }
  843. }
  844. .left-text-big-box-right{
  845. height:38px;
  846. flex:1;
  847. display: flex;
  848. .img-one{
  849. width:16px;
  850. height:14px;
  851. margin:12px 10px 0;
  852. }
  853. .img-two{
  854. width:16px;
  855. height:16px;
  856. margin:11px 10px 0;
  857. }
  858. p{
  859. flex:1;
  860. font-size:14px;
  861. line-height:38px;
  862. }
  863. }
  864. }
  865. .left-text-min-box{
  866. display: flex;
  867. height:38px;
  868. img{
  869. width:16px;
  870. height:16px;
  871. margin:11px 10px 0;
  872. }
  873. p{
  874. flex:1;
  875. font-size:14px;
  876. line-height:38px;
  877. }
  878. }
  879. }
  880. .left-type-text-max-box{
  881. padding:20px 0;
  882. div{
  883. display: flex;
  884. p{
  885. flex:1;
  886. font-size:14px;
  887. color:#333;
  888. line-height:40px;
  889. }
  890. p:nth-child(1){
  891. text-align: left;
  892. margin-left:32px;
  893. }
  894. p:nth-child(2){
  895. text-align: right;
  896. margin-right:48px;
  897. }
  898. .p-color-a{
  899. color:#06B924;
  900. }
  901. .p-color-b{
  902. color:#FF9735;
  903. }
  904. }
  905. }
  906. }
  907. .right-max-box{
  908. flex:1;
  909. margin:5px 20px 20px 0;
  910. box-shadow: 0 0 8px 2px rgba(0, 0, 0, 0.1);
  911. border-radius:10px;
  912. display: flex;
  913. flex-direction: column;
  914. .right-title-box{
  915. display: flex;
  916. border-bottom:1px solid #dedede;
  917. .title-button-min-box{
  918. height:90px;
  919. margin:0 20px;
  920. cursor: pointer;
  921. p:nth-child(1){
  922. margin-top:6px;
  923. line-height:78px;
  924. font-size:16px;
  925. }
  926. p:nth-child(2){
  927. height:6px;
  928. border-radius:4px;
  929. }
  930. .bottomColor{
  931. color:#0045AF;
  932. }
  933. .bottomBack{
  934. background:#0045AF ;
  935. }
  936. }
  937. .right-null-p{
  938. flex:1;
  939. }
  940. .right-out-button{
  941. margin:20px;
  942. }
  943. }
  944. .type-one-max-box{
  945. width:100px;
  946. margin:40px auto 0;
  947. }
  948. .up-data-box{
  949. display: inline-block;
  950. width:380px;
  951. line-height:20px;
  952. margin-bottom:30px;
  953. .up-data-min-box{
  954. .up-data-title{
  955. font-size:15px;
  956. color:#333;
  957. }
  958. .up-data-button{
  959. width:120px;
  960. height:120px;
  961. border: 1px dashed #E0E0E0;
  962. cursor: pointer;
  963. p{
  964. text-align: center;
  965. color:#999;
  966. font-weight:500;
  967. }
  968. p:nth-child(1){
  969. font-size: 20px;
  970. line-height:40px;
  971. margin-top:20px;
  972. }
  973. p:nth-child(2){
  974. font-size: 16px;
  975. }
  976. }
  977. .img-one{
  978. width:120px;
  979. height:120px;
  980. }
  981. .img-two{
  982. width: 240px;
  983. height:80px;
  984. }
  985. }
  986. }
  987. .form-item-min{
  988. margin-top:40px;
  989. }
  990. }
  991. }
  992. }
  993. </style>
  994. <style lang="scss">
  995. .up-img-box{
  996. .el-dialog__body{
  997. padding-top:0;
  998. }
  999. .img-one{
  1000. width:560px;
  1001. height:150px;
  1002. }
  1003. .cropper-img{
  1004. display: block;
  1005. border:1px solid #e0e0e0;
  1006. width:360px;
  1007. height:120px;
  1008. margin:0 auto;
  1009. }
  1010. .cropper-box{
  1011. width:560px;
  1012. height:270px;
  1013. position: relative;
  1014. .cropper-button{
  1015. position: absolute;
  1016. right:10px;top:10px;
  1017. z-index:1;
  1018. background: #0183FA;
  1019. color:#fff;
  1020. cursor: pointer;
  1021. padding:5px 10px;
  1022. margin:0;
  1023. border-radius:6px;
  1024. }
  1025. }
  1026. }
  1027. .revise-phone-box{
  1028. .phone-box{
  1029. }
  1030. .code-box{
  1031. display: flex;
  1032. .code-button{
  1033. font-size:14px;
  1034. margin:0 0 0 20px;
  1035. width:140px;
  1036. text-align: center;
  1037. color:#0045AF;
  1038. border:1px solid #0045AF;
  1039. line-height:38px;
  1040. border-radius:6px;
  1041. cursor: pointer;
  1042. }
  1043. }
  1044. }
  1045. </style>