mine.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528
  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.length" :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.length" :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 :focus="changeUser.showModal" class="input" v-model="changeUser.changeValue" type="text"
  138. :placeholder="changeUser.placeholder" />
  139. </view>
  140. </u-modal>
  141. </view>
  142. </template>
  143. <script>
  144. import upload from "../../../components/my-upload.vue";
  145. import {
  146. queryStr,
  147. CheckEmail
  148. } from "../../../utils/basicInspection"
  149. export default {
  150. name: 'Mine',
  151. components: { upload },
  152. data() {
  153. return {
  154. uninitialized: true,
  155. posTop: this.tovw(this.StatusBar),
  156. headHeight: this.tovw(this.CustomBar - this.StatusBar),
  157. customBar: this.tovw(this.CustomBar - this.StatusBar),
  158. butStyle: {
  159. position: "fixed",
  160. bottom: '32vw',
  161. left: "2.667vw",
  162. width: "94.667vw",
  163. height: "12vw",
  164. background: "rgba(255,255,255,0.1)",
  165. borderRadius: "1.067vw",
  166. border: "0.267vw solid rgba(255,255,255,0.5)",
  167. fontSize: "4vw",
  168. color: "#FFFFFF"
  169. },
  170. popupStyle: {
  171. width: "88.000vw",
  172. background: "#F7F7F7",
  173. padding: "2.667vw",
  174. boxSizing: "border-box"
  175. },
  176. userMsg: {},
  177. showPopup: false,
  178. spaceUsage: 0,
  179. changeUser: {
  180. name: "",
  181. showModal: false,
  182. title: "",
  183. changeValue: "",
  184. placeholder: "",
  185. }
  186. };
  187. },
  188. methods: {
  189. init(forcedUpdating = true) {
  190. this.uninitialized = false;
  191. this.getUserMsg()
  192. console.log("加载我的")
  193. },
  194. /* 打开modal */
  195. openModal(name, title, value, placeholder) {
  196. this.changeUser = {
  197. name,
  198. showModal: true,
  199. title,
  200. changeValue: "",
  201. placeholder: value || placeholder,
  202. }
  203. },
  204. /* 修改用户信息 */
  205. changeUserMsg() {
  206. let changeUser = this.changeUser,
  207. content = {
  208. name: this.userMsg.name,
  209. email: this.userMsg.hr.email || "",
  210. phonenumber: this.userMsg.phonenumber
  211. };
  212. if (changeUser.changeValue == '') return this.changeUser.showModal = false;
  213. if (changeUser.name == 'name') {
  214. content.name = queryStr(changeUser.changeValue, '已移除非法字符');
  215. } else if (changeUser.name == 'email') {
  216. if (!CheckEmail(changeUser.changeValue.trim())) return this.$refs.uModal.loading = false;
  217. content.email = changeUser.changeValue.trim();
  218. }
  219. this.$Http.basic({
  220. id: 20230608105602,
  221. content
  222. }).then(res => {
  223. console.log("修改用户信息", res)
  224. if (this.cutoff(res.msg, '修改成功')) return;
  225. this.userMsg.name = content.name;
  226. this.userMsg.hr.email && (this.userMsg.hr.email = content.email);
  227. this.changeUser.showModal = false;
  228. this.getUserMsg();
  229. })
  230. },
  231. // 获取用户信息
  232. getUserMsg() {
  233. this.$Http.basic({
  234. id: 20230608105102,
  235. content: {
  236. nocache: true
  237. }
  238. }).then(res => {
  239. console.log("用户信息", res)
  240. if (this.cutoff(res.msg)) return;
  241. this.userMsg = res.data;
  242. })
  243. },
  244. openPopup() {
  245. this.spaceUsage = this.$refs.Dustom.getHeight();
  246. this.showPopup = true;
  247. },
  248. uploadCallback(attachmentids) {
  249. let attinfos = [];
  250. //删除原本头像
  251. if (this.userMsg.attinfos.length) this.$Http.basic({
  252. "classname": "system.attachment.Attachment",
  253. "method": "deleteFileLink",
  254. "content": {
  255. "linksids": this.userMsg.attinfos.map(v => v.linksid)
  256. }
  257. }).then(res => {
  258. console.log("删除原本头像", res)
  259. if (this.cutoff(res.msg)) return;
  260. this.userMsg.attinfos = attinfos;
  261. })
  262. //绑定新头像
  263. if (attachmentids) this.$Http.basic({
  264. "classname": "system.attachment.Attachment",
  265. "method": "createFileLink",
  266. "content": {
  267. "ownertable": "sys_users",
  268. "ownerid": uni.getStorageSync('userMsg').userid,
  269. "usetype": "headportrait",
  270. "attachmentids": attachmentids
  271. }
  272. }).then(res => {
  273. console.log("绑定头像", res)
  274. if (this.cutoff(res.msg)) return;
  275. attinfos = res.data;
  276. this.userMsg.attinfos = attinfos;
  277. })
  278. },
  279. logOut() {
  280. uni.showModal({
  281. title: '提示',
  282. content: '是否确认退出登录',
  283. success: ({ confirm }) => {
  284. if (confirm) uni.reLaunch({
  285. url: "/pages/login/login"
  286. })
  287. },
  288. })
  289. },
  290. }
  291. }
  292. </script>
  293. <style lang="scss">
  294. .head {
  295. position: fixed;
  296. width: 100vw;
  297. z-index: 99991;
  298. .custom-bar {
  299. width: 100vw;
  300. position: relative;
  301. .iconfont {
  302. position: absolute;
  303. bottom: 14px;
  304. font-size: 16px;
  305. color: #FFFFFF;
  306. margin-left: 10px;
  307. }
  308. }
  309. .user {
  310. display: flex;
  311. height: 84px;
  312. width: 100vw;
  313. padding: 10px;
  314. box-sizing: border-box;
  315. .profile-photo {
  316. width: 64px;
  317. height: 64px;
  318. border-radius: 50%;
  319. overflow: hidden;
  320. flex-shrink: 0;
  321. margin-right: 10px;
  322. .substitution {
  323. width: 64px;
  324. line-height: 64px;
  325. text-align: center;
  326. background: #EFF4FA;
  327. .iconfont {
  328. font-size: 32px;
  329. color: #7C98BB;
  330. }
  331. }
  332. }
  333. .text {
  334. flex: 1;
  335. height: 64px;
  336. width: 0;
  337. .name {
  338. height: 24px;
  339. line-height: 24px;
  340. font-size: 17px;
  341. color: #FFFFFF;
  342. margin-top: 5px;
  343. }
  344. .replenish {
  345. margin-top: 10px;
  346. line-height: 20px;
  347. font-size: 14px;
  348. color: #FFFFFF;
  349. .iconfont {
  350. font-size: 14px;
  351. margin-right: 5px;
  352. }
  353. }
  354. }
  355. }
  356. }
  357. .nav-box {
  358. width: 355px;
  359. margin: 10px auto 0;
  360. border-radius: 4px;
  361. overflow: hidden;
  362. background: rgba($color: #fff, $alpha: 0.1);
  363. .nav-item {
  364. display: flex;
  365. align-items: center;
  366. width: 100%;
  367. height: 45px;
  368. padding: 0 10px;
  369. box-sizing: border-box;
  370. color: #fff;
  371. font-size: 14px;
  372. .view {
  373. flex: 1;
  374. margin-left: 10px;
  375. }
  376. .iconfont {
  377. font-size: 14px;
  378. flex-shrink: 0;
  379. }
  380. }
  381. }
  382. .cu-bar .content {
  383. overflow: auto !important;
  384. }
  385. .head-p {
  386. width: 100%;
  387. display: flex;
  388. justify-content: space-between;
  389. height: 21px;
  390. font-size: 15px;
  391. color: #333333;
  392. line-height: 21px;
  393. .cuIcon-close {
  394. padding-left: 10px;
  395. }
  396. }
  397. .portrait-p-box,
  398. .rests-p-box {
  399. width: 310px;
  400. background: #FFFFFF;
  401. box-sizing: border-box;
  402. padding-right: 10px;
  403. border-radius: 4px;
  404. overflow: hidden;
  405. }
  406. .portrait-p-box {
  407. height: 60px;
  408. margin-top: 15px;
  409. display: flex;
  410. align-items: center;
  411. justify-content: space-between;
  412. .label {
  413. font-size: 14px;
  414. font-family: PingFang SC-Regular, PingFang SC;
  415. color: #666666;
  416. margin-left: 15px;
  417. }
  418. .content {
  419. display: flex;
  420. align-items: center;
  421. .icon-a-wodetiaozhuan {
  422. font-size: 18px;
  423. color: #999;
  424. }
  425. .profile-photo {
  426. width: 32px;
  427. height: 32px;
  428. border-radius: 50%;
  429. overflow: hidden;
  430. .substitution {
  431. width: 32px;
  432. line-height: 32px;
  433. text-align: center;
  434. background: #EFF4FA;
  435. .iconfont {
  436. font-size: 16px;
  437. color: #7C98BB;
  438. }
  439. }
  440. }
  441. }
  442. }
  443. .rests-p-box {
  444. margin-top: 10px;
  445. .row {
  446. display: flex;
  447. width: 310px;
  448. box-sizing: border-box;
  449. padding: 13px 10px 12px 15px;
  450. .label {
  451. min-width: 28px;
  452. flex: 1;
  453. font-size: 14px;
  454. line-height: 20px;
  455. }
  456. .content {
  457. line-height: 20px;
  458. font-size: 14px;
  459. color: #333333;
  460. .icon-a-wodetiaozhuan {
  461. font-size: 14px;
  462. }
  463. }
  464. }
  465. }
  466. .modal-content {
  467. width: 100%;
  468. .title {
  469. width: 100%;
  470. text-align: center;
  471. font-size: 18px;
  472. color: #333;
  473. }
  474. .input {
  475. width: 100%;
  476. margin-top: 22px;
  477. border: 1px solid #888;
  478. height: 30px;
  479. line-height: 30px;
  480. padding-left: 6px;
  481. font-size: 14px;
  482. border-radius: 4px;
  483. }
  484. }
  485. </style>