userCenterPersonalInformation.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <template>
  2. <div>
  3. <div
  4. style="
  5. height: 600px;
  6. position: relative;
  7. width: 100%;
  8. margin-top: 30px;
  9. min-height: 700px;
  10. "
  11. >
  12. <div
  13. style="
  14. margin-left: 200px;
  15. font-size: 14px;
  16. font-weight: 700;
  17. color: #666;
  18. padding: 4px 10px;
  19. border-left: 2px solid #666;
  20. "
  21. >
  22. {{ $t("common.PersonalInformation") }}
  23. </div>
  24. <el-form
  25. ref="form"
  26. :model="form"
  27. :rules="rules"
  28. label-width="100px"
  29. class="demo-ruleForm"
  30. style="
  31. position: absolute;
  32. left: 56%;
  33. top: 55%;
  34. transform: translate(-55%, -50%);
  35. "
  36. >
  37. <el-form-item :label="$t('common.Nickname')" prop="userNickName">
  38. <el-input
  39. v-model="form.userNickName"
  40. maxlength="20"
  41. show-word-limit
  42. v-bind:disabled="this.isModifyNick"
  43. ></el-input>
  44. <div style="color: #666666">{{ $t("common.notice") }}</div>
  45. </el-form-item>
  46. <el-form-item :label="$t('common.RealName')" prop="name">
  47. <el-input
  48. v-model="form.name"
  49. maxlength="10"
  50. show-word-limit
  51. ></el-input>
  52. </el-form-item>
  53. <!-- <el-form-item :label="$t('common.ID')" prop="idNumber">
  54. <el-input
  55. v-model="form.idNumber"
  56. maxlength="18"
  57. show-word-limit
  58. ></el-input>
  59. </el-form-item> -->
  60. <el-form-item :label="$t('common.Gender')">
  61. <el-radio
  62. v-model="form.genderDict"
  63. v-for="item in genderDicts"
  64. :label="item.value"
  65. >{{ item.label }}</el-radio
  66. >
  67. </el-form-item>
  68. <el-form-item :label="$t('common.DateOfBirth')" prop="birthday">
  69. <el-date-picker
  70. v-model="form.birthday"
  71. type="date"
  72. :placeholder="$t('common.SelectDate')"
  73. >
  74. </el-date-picker>
  75. </el-form-item>
  76. <el-form-item :label="$t('common.Nationality')">
  77. <el-select
  78. :placeholder="$t('common.PleaseSelectNationality')"
  79. v-model="form.nationalityDict"
  80. style="width: 75%"
  81. >
  82. <el-option
  83. v-for="item in nationalityDicts"
  84. :label="item.label"
  85. :value="item.value"
  86. ></el-option>
  87. </el-select>
  88. </el-form-item>
  89. <el-form-item :label="$t('common.Address')">
  90. <el-input
  91. v-model="form.postalAddress"
  92. maxlength="50"
  93. show-word-limit
  94. ></el-input>
  95. </el-form-item>
  96. </el-form>
  97. </div>
  98. <!-- <div style="height: 300px;position: relative;width: 100%;margin-top: 30px;">
  99. <div style="margin-left: 200px;font-size: 14px;font-weight: 700;color: #666;padding: 4px 10px;border-left: 2px solid #666;">社交信息</div>
  100. <el-form ref="form" :model="form" :rules="rules" label-width="100px" class="demo-ruleForm" style="position: absolute;left: 56%;top: 58%;transform: translate(-55%,-50%);">
  101. <el-form-item label="手机号:" prop="mobilePhone">
  102. <el-input v-model="form.mobilePhone" disabled></el-input>
  103. <span style="margin-left: 20px;color: #2c5589;" class="cursor" @click="dialogVisibles">{{isBindPhone}}</span>
  104. </el-form-item>
  105. <el-form-item label="微信号:">
  106. <el-input v-model="form.wechat" ></el-input>
  107. </el-form-item>
  108. <el-form-item label="QQ:">
  109. <el-input v-model="form.qq" ></el-input>
  110. </el-form-item>
  111. <el-form-item label="微博:">
  112. <el-input v-model="form.weibo" ></el-input>
  113. </el-form-item>
  114. </el-form>
  115. </div> -->
  116. <div style="height: 200px">
  117. <div v-if="this.isAuth == false" style="margin-top: 100px">
  118. <el-button type="primary" style="margin-left: 300px" @click="save()">{{
  119. $t("common.Save")
  120. }}</el-button>
  121. <el-button style="margin-left: 30px" @click="reset()">{{
  122. $t("common.Reset")
  123. }}</el-button>
  124. </div>
  125. </div>
  126. <div>
  127. <el-dialog
  128. :title="$t('common.ModifyPhoneNumber')"
  129. :visible.sync="dialogVisible"
  130. width="30%"
  131. height="50%"
  132. >
  133. <div style="height: 100px; position: relative; width: 100%">
  134. <el-form
  135. ref="form"
  136. :model="form"
  137. label-width="80px"
  138. style="
  139. position: absolute;
  140. left: 56%;
  141. top: 55%;
  142. transform: translate(-55%, -50%);
  143. width: 400px;
  144. "
  145. >
  146. <el-form-item :label="$t('common.OriginalPhone')">
  147. <el-input v-model="tel.oldTel"></el-input>
  148. </el-form-item>
  149. <el-form-item :label="$t('common.VerificationCode')">
  150. <el-input v-model="tel.passWord2"></el-input>
  151. <span
  152. v-show="show"
  153. @click="getCode"
  154. style="margin-left: 20px; color: #2c5589"
  155. class="cursor"
  156. >{{ $t("common.GetCaptcha") }}</span
  157. >
  158. <span
  159. v-show="!show"
  160. class="count"
  161. style="margin-left: 20px; color: #999"
  162. >{{ count }}{{ $t("common.SendInSeconds") }}</span
  163. >
  164. </el-form-item>
  165. </el-form>
  166. </div>
  167. <span slot="footer" class="dialog-footer">
  168. <el-button @click="dialogVisible = false">{{
  169. $t("common.Cancel")
  170. }}</el-button>
  171. <el-button type="primary" @click="dialogVisible = false">{{
  172. $t("common.Confirm")
  173. }}</el-button>
  174. </span>
  175. </el-dialog>
  176. </div>
  177. <div v-if="addTag">
  178. <userCenterAddTag
  179. v-bind:systemLabel="systemLabel"
  180. :mergeSelectedLabels="mergeSelectedLabels"
  181. @closeMain="closeMain"
  182. ></userCenterAddTag>
  183. </div>
  184. </div>
  185. </template>
  186. <script>
  187. import { saveUserInfo } from "@/api/user";
  188. import { findUserInfo } from "@/api/user";
  189. import { getDicts } from "@/api/dict";
  190. import Base from "@/views/base/Base";
  191. import { formatDate } from "@/utils/formatUtils";
  192. import userCenterAddTag from "./userCenterAddTag";
  193. import { addIntegral, addGrowth } from "@/utils/toCompleteTask";
  194. import { getUserPointPage } from "@/api/user";
  195. export default {
  196. name: "userCenterPersonalInformation",
  197. extends: Base,
  198. components: {
  199. userCenterAddTag,
  200. },
  201. data() {
  202. return {
  203. isBindPhone: "",
  204. bindPhone: "",
  205. codeFromTel: "",
  206. show: true,
  207. count: "",
  208. timer: null,
  209. informationsClass: "1",
  210. dialogVisible: false,
  211. ifDiaslog: "",
  212. addTag: false,
  213. props: { multiple: true },
  214. isAuth: "",
  215. options: [
  216. {
  217. value: 1,
  218. label: "东南",
  219. },
  220. {
  221. value: 2,
  222. label: "西北",
  223. },
  224. {
  225. value: 3,
  226. label: "上下",
  227. },
  228. {
  229. value: 4,
  230. label: "左右",
  231. },
  232. ],
  233. systemLabel: [
  234. {
  235. label: "标签一",
  236. type: "",
  237. },
  238. {
  239. label: "标签二",
  240. type: "",
  241. },
  242. ],
  243. mergeSelectedLabels: [],
  244. isModifyNick: false,
  245. form: {
  246. userNickName: "",
  247. postalAddress: "",
  248. // idNumber: "",
  249. hobby: "",
  250. name: "",
  251. fullName: "",
  252. IDCode: "",
  253. gender: "",
  254. genderDict: "M",
  255. nationalityDict: "",
  256. birthday: "",
  257. tel: "",
  258. nationality: "",
  259. region: "",
  260. label: [],
  261. tag: "",
  262. interest: [],
  263. wechat: "",
  264. qq: "",
  265. micro_blog: "",
  266. weibo: "",
  267. },
  268. genderDicts: [],
  269. nationalityDicts: [],
  270. tel: {
  271. oldTel: "",
  272. passWord2: "",
  273. },
  274. rules: {},
  275. rulesZh: {
  276. name: [
  277. { required: true, message: "请输入真实姓名", trigger: "blur" },
  278. {
  279. min: 2,
  280. max: 20,
  281. message: "长度在 2 到 20 个字符",
  282. trigger: "blur",
  283. },
  284. ],
  285. nationalityDict: [
  286. { required: true, message: "请选择国籍", trigger: "blur" },
  287. ],
  288. // idNumber: [
  289. // { required: false, message: "请输入身份证号", trigger: "blur" },
  290. // {
  291. // pattern:
  292. // /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/,
  293. // message: this.$t("common.PleaseEnterYourLegalIDNumber"),
  294. // trigger: "blur",
  295. // },
  296. // ],
  297. genderDict: [
  298. { required: true, message: "请选择性别", trigger: "change" },
  299. ],
  300. birthday: [
  301. { required: false, message: "请选择出生日期", trigger: "blur" },
  302. ],
  303. postalAddress: [
  304. { required: false, message: "请输入地区", trigger: "blur" },
  305. ],
  306. },
  307. rulesEn: {
  308. name: [
  309. {
  310. required: true,
  311. message: "Please enter your real name",
  312. trigger: "blur",
  313. },
  314. {
  315. min: 3,
  316. max: 20,
  317. message: "The length is between 3 and 20 characters",
  318. trigger: "blur",
  319. },
  320. ],
  321. nationalityDict: [
  322. {
  323. required: true,
  324. message: "Please select nationality",
  325. trigger: "blur",
  326. },
  327. ],
  328. // idNumber: [
  329. // {
  330. // required: false,
  331. // message: "Please enter ID number",
  332. // trigger: "blur",
  333. // },
  334. // {
  335. // pattern:
  336. // /(^[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}$)/,
  337. // message: this.$t("common.PleaseEnterYourLegalIDNumber"),
  338. // trigger: "blur",
  339. // },
  340. // ],
  341. genderDict: [
  342. {
  343. required: true,
  344. message: "Please select gender",
  345. trigger: "change",
  346. },
  347. ],
  348. birthday: [
  349. {
  350. required: false,
  351. message: "Please select the date of birth",
  352. trigger: "blur",
  353. },
  354. ],
  355. postalAddress: [
  356. { required: false, message: "Please enter region", trigger: "blur" },
  357. ],
  358. },
  359. user: {
  360. umsUser: {},
  361. },
  362. pointStatus: null,
  363. };
  364. },
  365. mounted() {
  366. this.userInfo();
  367. this.isBindOrModify();
  368. },
  369. watch: {
  370. "$i18n.locale"() {
  371. this.userInfo();
  372. this.isBindOrModify();
  373. },
  374. },
  375. computed: {
  376. genderMap: function () {
  377. return this.genderDicts.array2Obj("value", "label");
  378. },
  379. nationalityMap: function () {
  380. return this.nationalityDicts.array2Obj("value", "label");
  381. },
  382. },
  383. methods: {
  384. addTagChange() {
  385. this.addTag = true;
  386. },
  387. closeMain(val) {
  388. this.mergeSelectedLabels = val;
  389. console.log(this.mergeSelectedLabels);
  390. this.addTag = false;
  391. },
  392. userInfo() {
  393. getUserPointPage().then((res) => {
  394. this.pointStatus = res.data.umsUserPoints[0].pointStatus;
  395. });
  396. if (this.$i18n.locale.toUpperCase() == "EN") {
  397. getDicts("GENDER_DICT_EN,UNIT_COUNTRY_DICT_EN").then((result) => {
  398. var data = result.data;
  399. if (data) {
  400. this.genderDicts = result.data["0"] || [];
  401. this.nationalityDicts = result.data["1"] || [];
  402. }
  403. });
  404. } else {
  405. getDicts("GENDER_DICT,UNIT_COUNTRY_DICT").then((result) => {
  406. var data = result.data;
  407. if (data) {
  408. this.genderDicts = result.data["0"] || [];
  409. this.nationalityDicts = result.data["1"] || [];
  410. }
  411. });
  412. }
  413. findUserInfo()
  414. .then((result) => {
  415. if (result.data) {
  416. this.form = result.data;
  417. if (result.data.realnameValidatedStatus == "y") {
  418. //已实名认证 信息不可进行修改
  419. this.isAuth = true;
  420. }
  421. if (result.msg == "false") {
  422. //将昵称输入框置灰
  423. this.isModifyNick = true;
  424. }
  425. console.log("this.form:", this.form);
  426. this.user.umsUser.userNickName = result.data.userNickName;
  427. var params = {
  428. realName: result.data.name,
  429. umsUser: this.user.umsUser,
  430. userId: this.user.userId,
  431. username: this.user.username,
  432. };
  433. window.localStorage.setItem("user", JSON.stringify(params));
  434. }
  435. })
  436. .catch((error) => {
  437. this.$message({
  438. message: error.msg,
  439. type: "error",
  440. });
  441. });
  442. },
  443. getInformation(num) {
  444. this.informationsClass = num;
  445. },
  446. async save() {
  447. this.$refs["form"].validate((valid) => {
  448. if (valid) {
  449. var basePersonnelInfo = new Object();
  450. //如果昵称是置灰状态,就不需要修改昵称了
  451. if (this.isModifyNick == true) {
  452. basePersonnelInfo.userNickName = "";
  453. } else {
  454. basePersonnelInfo.userNickName = this.form.userNickName;
  455. }
  456. basePersonnelInfo.birthday = this.form.birthday
  457. ? formatDate(this.form.birthday, "YYYY-MM-DD HH:mm:ss")
  458. : "";
  459. basePersonnelInfo.id = this.form.id;
  460. basePersonnelInfo.postalAddress = this.form.postalAddress;
  461. basePersonnelInfo.nationalityDict = this.form.nationalityDict;
  462. basePersonnelInfo.genderDict = this.form.genderDict;
  463. // basePersonnelInfo.idNumber = this.form.idNumber;
  464. basePersonnelInfo.name = this.form.name;
  465. basePersonnelInfo.nationality =
  466. this.nationalityMap[this.form.nationalityDict];
  467. basePersonnelInfo.gender = this.genderMap[this.form.genderDict];
  468. saveUserInfo(
  469. basePersonnelInfo.userNickName,
  470. JSON.stringify(basePersonnelInfo)
  471. )
  472. .then((result) => {
  473. if (
  474. this.user.umsUser.userUsertypeDict !== "2" &&
  475. this.pointStatus == "y"
  476. ) {
  477. addIntegral("point_task_complete_info", 20);
  478. addGrowth("point_task_complete_info");
  479. }
  480. if (result.status != 200) {
  481. if (this.$i18n.locale.toUpperCase() == "EN") {
  482. return this.$message.error("Save failed!");
  483. } else {
  484. return this.$message.error("保存失败!");
  485. }
  486. }
  487. if (this.$i18n.locale.toUpperCase() == "EN") {
  488. return this.$message.success("Saved successfully!");
  489. } else {
  490. return this.$message.success("保存成功!");
  491. }
  492. })
  493. .catch((error) => {
  494. this.$message({
  495. message: error.msg,
  496. type: "error",
  497. });
  498. });
  499. }
  500. });
  501. },
  502. //中国标准时间 转 yy-MM-dd hh:mm:ss
  503. YymmddFormat(newDate) {
  504. let Month = newDate.getMonth() + 1;
  505. Month = Month >= 10 ? Month : "0" + Month;
  506. let d = newDate.getDate();
  507. d = d >= 10 ? d : "0" + d;
  508. return [
  509. [newDate.getFullYear(), Month, d].join("-"),
  510. [newDate.getHours(), newDate.getMinutes(), newDate.getSeconds()].join(
  511. ":"
  512. ),
  513. ].join(" ");
  514. },
  515. dialogVisibles() {
  516. //跳转页面
  517. this.$router.push({
  518. name: this.bindPhone,
  519. });
  520. },
  521. isBindOrModify() {
  522. if (this.$i18n.locale.toUpperCase() == "EN") {
  523. this.rules = this.rulesEn;
  524. } else {
  525. this.rules = this.rulesZh;
  526. }
  527. console.log("this.rules");
  528. console.log(this.rules);
  529. var users = localStorage.getItem("user");
  530. var user = JSON.parse(users);
  531. var userPreferredMobile = user.umsUser.userPreferredMobile;
  532. if (!userPreferredMobile) {
  533. this.isBindPhone = "绑定手机";
  534. this.bindPhone = "securitySettingBindPhone";
  535. } else {
  536. this.isBindPhone = "修改手机";
  537. this.bindPhone = "securitySettingChangePhone";
  538. }
  539. },
  540. reset() {
  541. this.form.name = "";
  542. // this.form.idNumber = "";
  543. this.form.nationalityDict = "";
  544. this.form.postalAddress = "";
  545. this.form.birthday = "";
  546. this.form.genderDict = "";
  547. },
  548. },
  549. };
  550. </script>
  551. <style scoped>
  552. .box1:after {
  553. display: block;
  554. clear: both;
  555. content: "";
  556. visibility: hidden;
  557. height: 0;
  558. }
  559. .el-input,
  560. .el-cascader {
  561. width: 75%;
  562. }
  563. .el-form {
  564. width: 500px !important;
  565. }
  566. .el-button {
  567. width: 200px;
  568. height: 45px;
  569. }
  570. </style>