123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438 |
- <template>
- <view class="user-center">
- <u-popup :show="show" :customStyle="popupStyle" bgColor="#F7F7F7" :overlay="false" zIndex="9998" mode="left"
- @close="onClose">
- <view :style="{ 'height': spaceUsage }" />
- <view class="head-p">
- 账号信息
- <text class="cuIcon-close" @click="onClose" />
- </view>
- <upload maxCount="1" @uploadCallback="uploadCallback">
- <navigator class="portrait-p-box" url="#">
- <view class="label">
- 头像
- </view>
- <view class="content">
- <image class="profile-photo" v-if="userMsg.attinfos.length" :src="userMsg.attinfos[0].url"
- mode="aspectFill" />
- <view v-else class="profile-photo">
- <view class="substitution">
- <text class="iconfont icon-wode-xuanzhong" />
- </view>
- </view>
- <text class="iconfont icon-a-wodetiaozhuan" />
- </view>
- </navigator>
- </upload>
- <view class="rests-p-box">
- <view class="row">
- <view class="label">
- 工号
- </view>
- <view class="content">
- {{ userMsg.accountno }}
- </view>
- </view>
- <navigator url="#" class="row" @click="openModal('name', '姓名', userMsg.name, '请填写姓名')">
- <view class="label">
- 姓名
- </view>
- <view class="content">
- {{ userMsg.name || '--' }}
- <text class="iconfont icon-a-wodetiaozhuan" />
- </view>
- </navigator>
- <navigator url="#" class="row" @click="openModal('phonenumber', '手机号', userMsg.phonenumber, '请填写手机号码')">
- <view class="label">
- 手机号
- </view>
- <view class="content">
- {{ userMsg.phonenumber || '--' }}
- <text class="iconfont icon-a-wodetiaozhuan" />
- </view>
- </navigator>
- <block v-if="userMsg.hr.userid">
- <navigator url="#" class="row" @click="openModal('email', '邮箱', userMsg.hr.email, '请填写邮箱')">
- <view class="label">
- 邮箱
- </view>
- <view class="content">
- {{ userMsg.hr.email || '--' }}
- <text class="iconfont icon-a-wodetiaozhuan" />
- </view>
- </navigator>
- <view class="row">
- <view class="label">
- 部门
- </view>
- <view class="content">
- {{ userMsg.hr.depname || '--' }}
- </view>
- </view>
- <view class="row">
- <view class="label">
- 职位
- </view>
- <view class="content">
- {{ userMsg.hr.position || '--' }}
- </view>
- </view>
- </block>
- </view>
- </u-popup>
- <u-overlay :show="show" zIndex="9997" @click="onClose" />
- <u-modal :show="changeUser.showModal" @confirm="changeUserMsg" @cancel="onCancel" showCancelButton ref="uModal"
- :asyncClose="true">
- <view class="modal-content">
- <view class="title">
- 修改{{ changeUser.title }}
- </view>
- <view style="margin-top: 20px;" />
- <u-input :focus="inputFocus" :placeholder="changeUser.placeholder" border="surround"
- v-model="changeUser.changeValue" :type="changeUser.name == 'phonenumber' ? 'number' : 'text'" />
- <block v-if="changeUser.name == 'phonenumber'">
- <view style="margin-top: 10px;" />
- <u-input :focus="passwordFocus" placeholder="短信验证码" border="surround" v-model="password" type="number">
- <template slot="suffix">
- <u-button @tap="getCode" type="success" size="mini">{{ tips }} </u-button>
- </template>
- </u-input>
- </block>
- </view>
- </u-modal>
- </view>
- </template>
- <script>
- import {
- queryStr,
- CheckEmail,
- CheckPhoneNumber
- } from "../../../utils/basicInspection";
- import upload from "../../../components/my-upload.vue";
- import { hexMD5 } from "../../login/modules/md5";
- let count = 30,
- countDown = null;
- export default {
- props: {
- userMsg: {
- type: Object
- },
- getMsg: {
- type: Function
- }
- },
- components: { upload },
- data() {
- return {
- show: false,
- inputFocus: false,
- passwordFocus: false,
- spaceUsage: 0,
- popupStyle: {
- width: "88.000vw",
- background: "#F7F7F7",
- padding: "2.667vw",
- boxSizing: "border-box"
- },
- changeUser: {
- name: "",
- showModal: false,
- title: "",
- changeValue: "",
- placeholder: "",
- },
- password: "",
- tips: "获取验证码"
- }
- },
- methods: {
- /* 关闭用户中心 */
- onClose() {
- this.show = false;
- },
- /* 开始修改 */
- openModal(name, title, value, placeholder) {
- this.changeUser = {
- name,
- showModal: true,
- title,
- changeValue: "",
- placeholder: value || placeholder,
- }
- console.log(this.changeUser)
- setTimeout(() => {
- this.inputFocus = true
- }, 100)
- },
- /* 取消修改 */
- onCancel() {
- this.changeUser.showModal = false
- this.inputFocus = false
- },
- /* 修改用户信息 */
- changeUserMsg() {
- let changeUser = this.changeUser,
- content = {
- name: this.userMsg.name,
- email: this.userMsg.hr.email || "",
- phonenumber: this.userMsg.phonenumber
- };
- if (["name", 'phonenumber'].some(v => v == changeUser.name) && changeUser.changeValue == '') {
- uni.showToast({
- title: changeUser.title + '不可为空', icon: "none"
- })
- return this.$refs.uModal.loading = false;
- }
- if (changeUser.name == 'name') {
- content.name = queryStr(changeUser.changeValue, '已移除非法字符');
- } else if (changeUser.name == 'email') {
- if (!CheckEmail(changeUser.changeValue.trim())) return this.$refs.uModal.loading = false;
- content.email = changeUser.changeValue.trim();
- } else if (changeUser.name == 'phonenumber') {
- if (!CheckPhoneNumber(changeUser.changeValue.trim())) {
- uni.showToast({
- title: "请检查手机号",
- icon: "none"
- })
- return this.$refs.uModal.loading = false;
- }
- if (this.password == "") {
- uni.showToast({
- title: "还未输入验证码",
- icon: "none"
- })
- return this.$refs.uModal.loading = false;
- }
- content.phonenumber = changeUser.changeValue.trim();
- content.password = hexMD5(this.password);
- }
- this.$Http.basic({
- id: 20230608105602,
- content
- }).then(res => {
- console.log("修改用户信息", res)
- if (this.cutoff(res.msg, changeUser.title + '修改成功')) return this.$refs.uModal.loading = false;
- this.password = ""
- clearInterval(countDown);
- this.tips = '获取验证码';
- count = 30;
- this.userMsg.name = content.name;
- this.userMsg.hr.email && (this.userMsg.hr.email = content.email);
- this.onCancel();
- this.$emit("getMsg")
- })
- },
- /* 更新用户头像 */
- uploadCallback(attachmentids) {
- let attinfos = [];
- // uni.get
- //删除原本头像
- if (this.userMsg.attinfos.length) this.$Http.basic({
- "classname": "system.attachment.Attachment",
- "method": "deleteFileLink",
- "content": {
- "linksids": this.userMsg.attinfos.map(v => v.linksid)
- }
- }).then(res => {
- console.log("删除原本头像", res)
- if (this.cutoff(res.msg)) return;
- this.userMsg.attinfos = attinfos;
- })
- //绑定新头像
- if (attachmentids) this.$Http.basic({
- "classname": "system.attachment.Attachment",
- "method": "createFileLink",
- "content": {
- "ownertable": "sys_users",
- "ownerid": uni.getStorageSync('userMsg').userid,
- "usetype": "headportrait",
- "attachmentids": attachmentids
- }
- }).then(res => {
- console.log("绑定头像", res)
- if (this.cutoff(res.msg)) return;
- this.$emit("getMsg");
- uni.showToast({
- title: "头像修改成功",
- icon: "none"
- })
- })
- },
- async getCode() {
- let phonenumber = this.changeUser.changeValue,
- title = "";
- if (phonenumber == "") {
- title = '手机号码不可为空'
- } else if (!CheckPhoneNumber(phonenumber.trim())) {
- title = '请检查手机号码'
- } else {
- if (this.tips == '获取验证码' || this.tips == '重新获取') {
- let res = await this.$Http.basic({
- id: 20230608105502,
- "content": {
- phonenumber
- }
- });
- console.log("获取短信验证码", res)
- uni.showToast({
- title: res.msg,
- icon: "none"
- })
- if (res.data == '失败') return;
- count -= 1;
- this.tips = count + 's后可重新获取';
- countDown = setInterval(() => {
- if (count == 0) {
- clearInterval(countDown);
- this.tips = '重新获取';
- count = 30;
- } else {
- count -= 1;
- this.tips = count + 's后可重新获取';
- }
- }, 1000)
- } else {
- title = `${count}秒后可重新获取`
- }
- };
- if (title) uni.showToast({
- title,
- icon: "none"
- })
- }
- },
- }
- </script>
- <style lang="scss" scoped>
- .user-center {
- .head-p {
- width: 100%;
- display: flex;
- justify-content: space-between;
- height: 21px;
- font-size: 15px;
- color: #333333;
- line-height: 21px;
- .cuIcon-close {
- padding-left: 10px;
- }
- }
- .portrait-p-box,
- .rests-p-box {
- width: 310px;
- background: #FFFFFF;
- box-sizing: border-box;
- padding-right: 10px;
- border-radius: 4px;
- overflow: hidden;
- }
- .portrait-p-box {
- height: 60px;
- margin-top: 15px;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .label {
- font-size: 14px;
- font-family: PingFang SC-Regular, PingFang SC;
- color: #666666;
- margin-left: 15px;
- }
- .content {
- display: flex;
- align-items: center;
- .icon-a-wodetiaozhuan {
- font-size: 18px;
- color: #999;
- }
- .profile-photo {
- width: 32px;
- height: 32px;
- border-radius: 50%;
- overflow: hidden;
- .substitution {
- width: 32px;
- line-height: 32px;
- text-align: center;
- background: #EFF4FA;
- .iconfont {
- font-size: 16px;
- color: #7C98BB;
- }
- }
- }
- }
- }
- .rests-p-box {
- margin-top: 10px;
- .row {
- display: flex;
- width: 310px;
- box-sizing: border-box;
- padding: 13px 10px 12px 15px;
- .label {
- min-width: 28px;
- flex: 1;
- font-size: 14px;
- line-height: 20px;
- }
- .content {
- line-height: 20px;
- font-size: 14px;
- color: #333333;
- .icon-a-wodetiaozhuan {
- font-size: 14px;
- }
- }
- }
- }
- .modal-content {
- width: 100%;
- .title {
- width: 100%;
- text-align: center;
- font-size: 18px;
- color: #333;
- }
- .input {
- width: 100%;
- margin-top: 22px;
- border: 1px solid #888;
- height: 30px;
- line-height: 30px;
- padding-left: 6px;
- font-size: 14px;
- border-radius: 4px;
- }
- }
- /deep/ .uni-input-placeholder,
- /deep/.uni-input-wrapper {
- font-size: 12px;
- }
- /deep/ .u-button__text {
- font-size: 10px !important;
- }
- }
- </style>
|