index.vue 31 KB

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