mine.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <template>
  2. <view>
  3. <cu-custom heighten="94" ref="Dustom"
  4. bgImage="https://yostest175549.obs.cn-east-2.myhuaweicloud.com:443/202306151686796745663B52544232.png">
  5. <view slot="head" class="head" :style="{ 'height': headHeight, 'top': posTop }">
  6. <view class="custom-bar" :style="{ 'height': customBar }">
  7. <navigator class="iconfont icon-wode-xuanzhong" url="#" @click.stop="openPopup" />
  8. </view>
  9. <navigator class="user" url="#" @click.stop="openPopup">
  10. <image class="profile-photo" v-if="userMsg.attinfos[0].url" :src="userMsg.attinfos[0].url"
  11. mode="aspectFill" />
  12. <view v-else class="profile-photo">
  13. <view class="substitution">
  14. <text class="iconfont icon-wode-xuanzhong" />
  15. </view>
  16. </view>
  17. <view class="text">
  18. <view class="name u-line-1">
  19. {{ userMsg.name }}
  20. </view>
  21. <view class="replenish">
  22. <text class="iconfont icon-daka" />
  23. {{ userMsg.phonenumber || '未填写' }}
  24. <block v-if="userMsg.hr.userid">
  25. <text style="margin: 0 10px;">
  26. |
  27. </text>
  28. {{ userMsg.hr.position || '未知职位' }}
  29. </block>
  30. </view>
  31. </view>
  32. </navigator>
  33. </view>
  34. </cu-custom>
  35. <view class="nav-box">
  36. <navigator class="nav-item" url="#">
  37. <text class="iconfont icon-wode-xuanzhong" />
  38. <view class="view">
  39. 修改登录密码
  40. </view>
  41. <text class="iconfont icon-wode-xuanzhong" />
  42. </navigator>
  43. <navigator class="nav-item" url="#">
  44. <text class="iconfont icon-wode-xuanzhong" />
  45. <view class="view">
  46. 修改登录手机号
  47. </view>
  48. <text class="iconfont icon-wode-xuanzhong" />
  49. </navigator>
  50. <navigator class="nav-item" url="#">
  51. <text class="iconfont icon-wode-xuanzhong" />
  52. <view class="view">
  53. 绑定微信
  54. </view>
  55. <text class="iconfont icon-wode-xuanzhong" />
  56. </navigator>
  57. </view>
  58. <u-button :customStyle="butStyle" @click="logOut()">退出登录</u-button>
  59. <u-popup :show="showPopup" :customStyle="popupStyle" bgColor="#F7F7F7" :overlay="false" zIndex="9998" mode="left"
  60. @close="showPopup = false">
  61. <view :style="{ 'height': spaceUsage }" />
  62. <view class="head-p">
  63. 账号信息
  64. <text class="cuIcon-close" @click="showPopup = false" />
  65. </view>
  66. <upload maxCount="1" @uploadCallback="uploadCallback">
  67. <navigator class="portrait-p-box" url="#">
  68. <view class="label">
  69. 头像
  70. </view>
  71. <view class="content">
  72. <image class="profile-photo" v-if="userMsg.attinfos[0].url" :src="userMsg.attinfos[0].url"
  73. mode="aspectFill" />
  74. <view v-else class="profile-photo">
  75. <view class="substitution">
  76. <text class="iconfont icon-wode-xuanzhong" />
  77. </view>
  78. </view>
  79. <text class="iconfont icon-a-wodetiaozhuan" />
  80. </view>
  81. </navigator>
  82. </upload>
  83. <view class="rests-p-box">
  84. <view class="row">
  85. <view class="label">
  86. 工号
  87. </view>
  88. <view class="content">
  89. {{ userMsg.accountno }}
  90. </view>
  91. </view>
  92. <navigator url="#" class="row" @click="openModal('name', '姓名', userMsg.name, '请填写姓名')">
  93. <view class="label">
  94. 姓名
  95. </view>
  96. <view class="content">
  97. {{ userMsg.name }}
  98. <text class="iconfont icon-a-wodetiaozhuan" />
  99. </view>
  100. </navigator>
  101. <block v-if="userMsg.hr.userid">
  102. <navigator url="#" class="row" @click="openModal('email', '邮箱', userMsg.hr.email, '请填写邮箱')">
  103. <view class="label">
  104. 邮箱
  105. </view>
  106. <view class="content">
  107. {{ userMsg.hr.email || '--' }}
  108. <text class="iconfont icon-a-wodetiaozhuan" />
  109. </view>
  110. </navigator>
  111. <view class="row">
  112. <view class="label">
  113. 部门
  114. </view>
  115. <view class="content">
  116. {{ userMsg.hr.depname || '--' }}
  117. </view>
  118. </view>
  119. <view class="row">
  120. <view class="label">
  121. 职位
  122. </view>
  123. <view class="content">
  124. {{ userMsg.hr.position || '--' }}
  125. </view>
  126. </view>
  127. </block>
  128. </view>
  129. </u-popup>
  130. <u-overlay :show="showPopup" zIndex="9997" @click="showPopup = false" />
  131. <u-modal :show="changeUser.showModal" @confirm="changeUserMsg" @cancel="changeUser.showModal = false"
  132. showCancelButton ref="uModal" :asyncClose="true">
  133. <view class="modal-content">
  134. <view class="title">
  135. 修改{{ changeUser.title }}
  136. </view>
  137. <input class="input" v-model="changeUser.changeValue" type="text" :placeholder="changeUser.placeholder" />
  138. </view>
  139. </u-modal>
  140. </view>
  141. </template>
  142. <script>
  143. import upload from "../../../components/my-upload.vue";
  144. import {
  145. queryStr,
  146. CheckEmail
  147. } from "../../../utils/basicInspection"
  148. export default {
  149. name: 'Mine',
  150. components: { upload },
  151. data() {
  152. return {
  153. posTop: this.tovw(this.StatusBar),
  154. headHeight: this.tovw(this.CustomBar - this.StatusBar),
  155. customBar: this.tovw(this.CustomBar - this.StatusBar),
  156. butStyle: {
  157. position: "fixed",
  158. bottom: '32vw',
  159. left: "2.667vw",
  160. width: "94.667vw",
  161. height: "12vw",
  162. background: "rgba(255,255,255,0.1)",
  163. borderRadius: "1.067vw",
  164. border: "0.267vw solid rgba(255,255,255,0.5)",
  165. fontSize: "4vw",
  166. color: "#FFFFFF"
  167. },
  168. popupStyle: {
  169. width: "88.000vw",
  170. background: "#F7F7F7",
  171. padding: "2.667vw",
  172. boxSizing: "border-box"
  173. },
  174. userMsg: {},
  175. showPopup: false,
  176. spaceUsage: 0,
  177. changeUser: {
  178. name: "",
  179. showModal: false,
  180. title: "",
  181. changeValue: "",
  182. placeholder: "",
  183. }
  184. };
  185. },
  186. created() {
  187. this.getUserMsg()
  188. },
  189. methods: {
  190. /* 打开modal */
  191. openModal(name, title, value, placeholder) {
  192. this.changeUser = {
  193. name,
  194. showModal: true,
  195. title,
  196. changeValue: "",
  197. placeholder: value || placeholder,
  198. }
  199. },
  200. /* 修改用户信息 */
  201. changeUserMsg() {
  202. let changeUser = this.changeUser,
  203. content = {
  204. name: this.userMsg.name,
  205. email: this.userMsg.hr.email || "",
  206. phonenumber: this.userMsg.phonenumber
  207. };
  208. if (changeUser.changeValue == '') return this.changeUser.showModal = false;
  209. if (changeUser.name == 'name') {
  210. content.name = queryStr(changeUser.changeValue, '已移除非法字符');
  211. } else if (changeUser.name == 'email') {
  212. if (!CheckEmail(changeUser.changeValue.trim())) return this.$refs.uModal.loading = false;
  213. content.email = changeUser.changeValue.trim();
  214. }
  215. this.$Http.basic({
  216. id: 20230608105602,
  217. content
  218. }).then(res => {
  219. console.log("修改用户信息", res)
  220. if (this.cutoff(res.msg, '修改成功')) return;
  221. this.userMsg.name = content.name;
  222. this.userMsg.hr.email && (this.userMsg.hr.email = content.email);
  223. this.changeUser.showModal = false;
  224. this.getUserMsg();
  225. })
  226. },
  227. // 获取用户信息
  228. getUserMsg() {
  229. this.$Http.basic({
  230. id: 20230608105102,
  231. content: {
  232. nocache: true
  233. }
  234. }).then(res => {
  235. console.log("用户信息", res)
  236. if (this.cutoff(res.msg, '修改成功')) return;
  237. this.userMsg = res.data;
  238. })
  239. },
  240. openPopup() {
  241. this.spaceUsage = this.$refs.Dustom.getHeight();
  242. this.showPopup = true;
  243. },
  244. uploadCallback(attachmentids) {
  245. let attinfos = [];
  246. //删除原本头像
  247. if (this.userMsg.attinfos.length) this.$Http.basic({
  248. "classname": "system.attachment.Attachment",
  249. "method": "deleteFileLink",
  250. "content": {
  251. "linksids": this.userMsg.attinfos.map(v => v.linksid)
  252. }
  253. }).then(res => {
  254. console.log("删除原本头像", res)
  255. if (this.cutoff(res.msg)) return;
  256. this.userMsg.attinfos = attinfos;
  257. })
  258. //绑定新头像
  259. if (attachmentids) this.$Http.basic({
  260. "classname": "system.attachment.Attachment",
  261. "method": "createFileLink",
  262. "content": {
  263. "ownertable": "sys_users",
  264. "ownerid": uni.getStorageSync('userMsg').userid,
  265. "usetype": "headportrait",
  266. "attachmentids": attachmentids
  267. }
  268. }).then(res => {
  269. console.log("绑定头像", res)
  270. if (this.cutoff(res.msg)) return;
  271. attinfos = res.data;
  272. this.userMsg.attinfos = attinfos;
  273. })
  274. },
  275. logOut() {
  276. uni.showModal({
  277. title: '提示',
  278. content: '是否确认退出登录',
  279. success: ({ confirm }) => {
  280. if (confirm) uni.reLaunch({
  281. url: "/pages/login/login"
  282. })
  283. },
  284. })
  285. },
  286. },
  287. }
  288. </script>
  289. <style lang="scss">
  290. .head {
  291. position: fixed;
  292. width: 100vw;
  293. z-index: 99991;
  294. .custom-bar {
  295. width: 100vw;
  296. position: relative;
  297. .iconfont {
  298. position: absolute;
  299. bottom: 14px;
  300. font-size: 16px;
  301. color: #FFFFFF;
  302. margin-left: 10px;
  303. }
  304. }
  305. .user {
  306. display: flex;
  307. height: 84px;
  308. width: 100vw;
  309. padding: 10px;
  310. box-sizing: border-box;
  311. .profile-photo {
  312. width: 64px;
  313. height: 64px;
  314. border-radius: 50%;
  315. overflow: hidden;
  316. flex-shrink: 0;
  317. margin-right: 10px;
  318. .substitution {
  319. width: 64px;
  320. line-height: 64px;
  321. text-align: center;
  322. background: #EFF4FA;
  323. .iconfont {
  324. font-size: 32px;
  325. color: #7C98BB;
  326. }
  327. }
  328. }
  329. .text {
  330. flex: 1;
  331. height: 64px;
  332. width: 0;
  333. .name {
  334. height: 24px;
  335. line-height: 24px;
  336. font-size: 17px;
  337. color: #FFFFFF;
  338. margin-top: 5px;
  339. }
  340. .replenish {
  341. margin-top: 10px;
  342. line-height: 20px;
  343. font-size: 14px;
  344. color: #FFFFFF;
  345. .iconfont {
  346. font-size: 14px;
  347. margin-right: 5px;
  348. }
  349. }
  350. }
  351. }
  352. }
  353. .nav-box {
  354. width: 355px;
  355. margin: 10px auto 0;
  356. border-radius: 4px;
  357. overflow: hidden;
  358. background: rgba($color: #fff, $alpha: 0.1);
  359. .nav-item {
  360. display: flex;
  361. align-items: center;
  362. width: 100%;
  363. height: 45px;
  364. padding: 0 10px;
  365. box-sizing: border-box;
  366. color: #fff;
  367. font-size: 14px;
  368. .view {
  369. flex: 1;
  370. margin-left: 10px;
  371. }
  372. .iconfont {
  373. font-size: 14px;
  374. flex-shrink: 0;
  375. }
  376. }
  377. }
  378. .cu-bar .content {
  379. overflow: auto !important;
  380. }
  381. .head-p {
  382. width: 100%;
  383. display: flex;
  384. justify-content: space-between;
  385. height: 21px;
  386. font-size: 15px;
  387. color: #333333;
  388. line-height: 21px;
  389. .cuIcon-close {
  390. padding-left: 10px;
  391. }
  392. }
  393. .portrait-p-box,
  394. .rests-p-box {
  395. width: 310px;
  396. background: #FFFFFF;
  397. box-sizing: border-box;
  398. padding-right: 10px;
  399. border-radius: 4px;
  400. overflow: hidden;
  401. }
  402. .portrait-p-box {
  403. height: 60px;
  404. margin-top: 15px;
  405. display: flex;
  406. align-items: center;
  407. justify-content: space-between;
  408. .label {
  409. font-size: 14px;
  410. font-family: PingFang SC-Regular, PingFang SC;
  411. color: #666666;
  412. margin-left: 15px;
  413. }
  414. .content {
  415. display: flex;
  416. align-items: center;
  417. .icon-a-wodetiaozhuan {
  418. font-size: 18px;
  419. color: #999;
  420. }
  421. .profile-photo {
  422. width: 32px;
  423. height: 32px;
  424. border-radius: 50%;
  425. overflow: hidden;
  426. .substitution {
  427. width: 32px;
  428. line-height: 32px;
  429. text-align: center;
  430. background: #EFF4FA;
  431. .iconfont {
  432. font-size: 16px;
  433. color: #7C98BB;
  434. }
  435. }
  436. }
  437. }
  438. }
  439. .rests-p-box {
  440. margin-top: 10px;
  441. .row {
  442. display: flex;
  443. width: 310px;
  444. box-sizing: border-box;
  445. padding: 13px 10px 12px 15px;
  446. .label {
  447. min-width: 28px;
  448. flex: 1;
  449. font-size: 14px;
  450. line-height: 20px;
  451. }
  452. .content {
  453. line-height: 20px;
  454. font-size: 14px;
  455. color: #333333;
  456. .icon-a-wodetiaozhuan {
  457. font-size: 14px;
  458. }
  459. }
  460. }
  461. }
  462. .modal-content {
  463. width: 100%;
  464. .title {
  465. width: 100%;
  466. text-align: center;
  467. font-size: 18px;
  468. color: #333;
  469. }
  470. .input {
  471. width: 100%;
  472. margin-top: 22px;
  473. border: 1px solid #888;
  474. height: 30px;
  475. line-height: 30px;
  476. padding-left: 6px;
  477. font-size: 14px;
  478. border-radius: 4px;
  479. }
  480. }
  481. </style>