123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421 |
- <template>
- <div class="boxs">
- <div style="width: 500px; margin: auto; margin-top: 30px">
- <div style="height: 100px; position: relative">
- <el-upload
- class="avatar-uploader"
- action="/api/file/upload/img?module=personnel"
- :show-file-list="false"
- :on-success="handleAvatarSuccess"
- :headers="myHeaders"
- :before-upload="beforeAvatarUpload"
- >
- <img
- v-if="form.userPic"
- :src="'api/file/pub/' + form.userPic"
- class="avatar"
- />
- <i v-else class="el-icon-plus avatar-uploader-icon"></i>
- </el-upload>
- <img
- src="@/assets/img/userCenter/setUp.png"
- alt=""
- style="position: absolute; right: 180px; bottom: -10px; width: 40px"
- />
- <!-- <img :src="'api/file/pub/'+ form.photo" alt="" style="width: 100px;position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);"/> -->
- </div>
- </div>
- <div style="height: 400px; position: relative; width: 100%">
- <el-form
- ref="form"
- :model="form"
- label-width="140px"
- style="
- position: absolute;
- left: 53%;
- top: 55%;
- transform: translate(-55%, -50%);
- width: 400px;
- height: 400px;
- "
- >
- <el-form-item :label="$t('common.MobilePhone')">
- <el-input v-model="form.userPreferredMobile" disabled></el-input>
- <!-- <span style="margin-left: 20px;color: #2c5589;" class="cursor" @click="dialogVisibles(1)">修改邮箱</span>-->
- </el-form-item>
- <el-form-item :label="$t('common.Email') + ':'">
- <el-input v-model="form.userEmail" disabled></el-input>
- <!-- <span style="margin-left: 20px;color: #2c5589;" class="cursor" @click="dialogVisibles(1)">修改邮箱</span>-->
- </el-form-item>
- <el-form-item :label="$t('common.DateOfRegistration')">
- <el-input v-model="form.userAccountRegistertime" disabled></el-input>
- </el-form-item>
- <el-form-item :label="$t('common.CustomerType')">
- <el-input v-model="form.region" disabled></el-input>
- </el-form-item>
- <el-form-item :label="$t('common.LogInLast')">
- <el-input v-model="form.lastLoginTime" disabled></el-input>
- </el-form-item>
- <!-- <el-form-item label="修改密码:">
- <el-input v-model="form.date3" disabled></el-input>
- <span style="margin-left: 20px;color: #2c5589;" class="cursor" @click="dialogVisibles(2)">修改密码</span>
- </el-form-item>-->
- </el-form>
- </div>
- <div>
- <el-dialog
- :title="title"
- :visible.sync="dialogVisible"
- width="30%"
- height="50%"
- v-if="ifDiaslog == 2"
- >
- <div style="height: 200px; position: relative; width: 100%">
- <el-form
- ref="form"
- :model="form"
- label-width="80px"
- style="
- position: absolute;
- left: 56%;
- top: 55%;
- transform: translate(-55%, -50%);
- width: 400px;
- "
- >
- <el-form-item :label="$t('common.OriginalPassword')">
- <el-input v-model="passWord.passWord1"></el-input>
- </el-form-item>
- <el-form-item :label="$t('common.NewPassword')">
- <el-input v-model="passWord.passWord2"></el-input>
- </el-form-item>
- <el-form-item :label="$t('common.ConfirmPassword')">
- <el-input v-model="passWord.passWord3"></el-input>
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">{{
- $t("common.Cancel")
- }}</el-button>
- <el-button type="primary" @click="dialogVisible = false">{{
- $t("common.Confirm")
- }}</el-button>
- </span>
- </el-dialog>
- <el-dialog
- :title="title"
- :visible.sync="dialogVisible"
- width="30%"
- height="50%"
- v-if="ifDiaslog == 1"
- >
- <div style="height: 200px; position: relative; width: 100%">
- <el-form
- ref="form"
- :model="form"
- label-width="100px"
- style="
- position: absolute;
- left: 56%;
- top: 55%;
- transform: translate(-55%, -50%);
- width: 400px;
- "
- >
- <el-form-item :label="$t('common.Mailbox')">
- <el-input v-model="passWord.passWord1"></el-input>
- </el-form-item>
- <el-form-item :label="$t('common.VerificationCode')">
- <el-input v-model="passWord.passWord2"></el-input>
- <span
- v-show="show"
- @click="getCode"
- style="margin-left: 20px; color: #2c5589"
- class="cursor"
- >{{ $t("common.GetCaptcha") }}</span
- >
- <span
- v-show="!show"
- class="count"
- style="margin-left: 20px; color: #999"
- >{{ count }}{{ $t("common.SendInSeconds") }}</span
- >
- </el-form-item>
- </el-form>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button @click="dialogVisible = false">{{
- $t("common.Cancel")
- }}</el-button>
- <el-button type="primary" @click="dialogVisible = false">{{
- $t("common.Confirm")
- }}</el-button>
- </span>
- </el-dialog>
- </div>
- </div>
- </template>
- <script>
- import { findBasicInfo, saveUserPic } from "@/api/user";
- import { getDicts } from "@/api/dict";
- import { getToken } from "@/utils/auth";
- import { addIntegral, addGrowth } from "@/utils/toCompleteTask";
- import { getUserPointPage } from "@/api/user";
- export default {
- name: "userCenterEssentialInformation",
- data() {
- return {
- informationsClass: "1",
- dialogVisible: false,
- ifDiaslog: "",
- imageUrl: "",
- title: "",
- form: {
- userPreferredMobile: "",
- userAccountRegistertime: "",
- userEmail: "",
- name: "1233@163.com",
- region: "",
- date1: "2018-05-19",
- date3: "2018-05-19",
- date2: "2020-05-25 11:20:23",
- delivery: false,
- type: [],
- resource: "",
- userPic: "/def/user.png",
- desc: "",
- },
- passWord: {
- passWord1: "",
- passWord2: "",
- passWord3: "",
- },
- Emal: {
- newEmal: "",
- VerificationCode: "",
- },
- userUsertypeDicts: [],
- show: true,
- count: "",
- timer: null,
- myHeaders: { Authorization: "Bearer " + getToken() },
- user: {
- umsUser: {},
- },
- pointStatus: null,
- };
- },
- computed: {
- userUsertypeMap: function () {
- return this.userUsertypeDicts.array2Obj("value", "label");
- },
- },
- watch: {
- "$i18n.locale"() {
- this.initData();
- this.userBasicInfo();
- },
- },
- created() {
- this.initData();
- this.userBasicInfo();
- },
- methods: {
- initData: function () {
- getUserPointPage().then((res) => {
- this.pointStatus = res.data.umsUserPoints[0].pointStatus;
- });
- },
- async userBasicInfo() {
- if (this.$i18n.locale.toUpperCase() == "EN") {
- await getDicts("USERTYPE_DICT_EN").then((result) => {
- if (result.data) {
- this.userUsertypeDicts = result.data["0"] || [];
- }
- });
- } else {
- await getDicts("USERTYPE_DICT").then((result) => {
- if (result.data) {
- this.userUsertypeDicts = result.data["0"] || [];
- }
- });
- }
- await findBasicInfo().then((result) => {
- this.form = result.data;
- console.log("this.form", this.form);
- if (!this.form.userPic) {
- this.form.userPic = "/def/user.png";
- }
- console.log(this.form.userAccountRegistertime);
- const regtime = this.YymmddFormat(
- new Date(this.form.userAccountRegistertime)
- );
- const logintime = this.YymmddFormat(new Date(this.form.lastLoginTime));
- if (this.form.userAccountRegistertime !== undefined)
- this.form.userAccountRegistertime = regtime;
- if (this.form.lastLoginTime !== undefined)
- this.form.lastLoginTime = logintime;
- var userUsertypeMap = this.userUsertypeDicts.array2Obj(
- "value",
- "label"
- );
- if (result.data.userUsertypeDict !== undefined) {
- console.log(userUsertypeMap[result.data.userUsertypeDict]);
- this.form.region = userUsertypeMap[result.data.userUsertypeDict];
- }
- if (this.form.userPreferredMobile) {
- this.form.userPreferredMobile =
- this.form.userPreferredMobile.substr(4, 3) +
- "****" +
- this.form.userPreferredMobile.substr(11);
- }
- });
- },
- getInformation(num) {
- this.informationsClass = num;
- },
- // handleClose(done) {
- // this.$confirm('确认关闭?')
- // .then(_ => {
- // done();
- // })
- // .catch(_ => {});
- // },
- //中国标准时间 转 yy-MM-dd hh:mm:ss
- YymmddFormat(newDate) {
- let Month = newDate.getMonth() + 1;
- Month = Month >= 10 ? Month : "0" + Month;
- let d = newDate.getDate();
- d = d >= 10 ? d : "0" + d;
- return [
- [newDate.getFullYear(), Month, d].join("-"),
- [newDate.getHours(), newDate.getMinutes(), newDate.getSeconds()].join(
- ":"
- ),
- ].join(" ");
- },
- dialogVisibles(num) {
- this.ifDiaslog = num;
- if (num == 1) {
- this.title = "修改邮箱";
- this.$router.push({
- name: "",
- });
- } else if (num == 2) {
- this.title = "修改密码";
- this.$router.push({
- name: "",
- });
- }
- // this.dialogVisible=true
- },
- getCode() {
- const TIME_COUNT = 60;
- if (!this.timer) {
- this.count = TIME_COUNT;
- this.show = false;
- this.timer = setInterval(() => {
- if (this.count > 0 && this.count <= TIME_COUNT) {
- this.count--;
- } else {
- this.show = true;
- clearInterval(this.timer);
- this.timer = null;
- }
- }, 1000);
- }
- },
- handleAvatarSuccess(res, file) {
- this.form.userPic = res.data;
- //保存图像
- saveUserPic(this.form.userPic)
- .then((result) => {
- if (
- this.user.umsUser.userUsertypeDict !== "2" &&
- this.pointStatus == "y"
- ) {
- addIntegral("point_task_upload_head_portrait", 20);
- addGrowth("point_task_upload_head_portrait");
- }
- this.$forceUpdate();
- this.$message({
- message: this.$t("common.uploadSuccess"),
- type: "success",
- });
- //头像路径更新到localstorage
- let user = JSON.parse(window.localStorage.getItem("user"));
- user.umsUser.userPic = this.form.userPic;
- window.localStorage.setItem("user", JSON.stringify(user));
- })
- .catch((error) => {
- this.$message({
- message: error.msg,
- type: "error",
- });
- });
- },
- beforeAvatarUpload(file) {
- const isJPG = file.type === "image/jpeg";
- const isLt2M = file.size / 1024 / 1024 < 2;
- /* if (!isJPG) {
- this.$message.error('上传头像图片只能是 JPG 格式!');
- return;
- }*/
- /*if (!isLt2M) {
- this.$message.error(this.$t('common.uploadInfo'));
- return;
- }*/
- // return isJPG && isLt2M;
- },
- },
- };
- </script>
- <style scoped>
- .box1:after {
- display: block;
- clear: both;
- content: "";
- visibility: hidden;
- height: 0;
- }
- .el-input {
- width: 75%;
- }
- .el-form {
- width: 500px !important;
- }
- .avatar-uploader .el-upload {
- border: 1px dashed #d9d9d9;
- border-radius: 6px;
- cursor: pointer;
- position: relative;
- overflow: hidden;
- }
- .avatar-uploader .el-upload:hover {
- border-color: #409eff;
- }
- .avatar-uploader-icon {
- font-size: 28px;
- color: #8c939d;
- width: 125px;
- height: 110px;
- line-height: 178px;
- text-align: center;
- }
- .avatar {
- width: 105px;
- height: 110px;
- display: block;
- border-radius: 60px;
- overflow: hidden;
- }
- .boxs >>> .el-upload {
- position: absolute;
- left: 50%;
- top: 0;
- transform: translateX(-50%);
- }
- </style>
|