userdetail.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <view class="user-page">
  3. <u-navbar
  4. title="用户详情"
  5. :safeAreaInsetTop="true"
  6. :fixed="true"
  7. :placeholder="true"
  8. height="50px"
  9. bgColor="transparent"
  10. titleStyle="fw600 fs-18"
  11. leftIconColor="#303133"
  12. @leftClick="goBack"
  13. >
  14. <view class="u-nav-slot" slot="left">
  15. <u-icon name="arrow-left" size="20" color="#303133"></u-icon>
  16. </view>
  17. <view class="u-nav-slot" slot="right" @tap="rightClick">
  18. <view class="nav-edit-btn">
  19. <u-icon name="edit-pen" size="14" color="#0065f8"></u-icon>
  20. <text class="nav-edit-text">编辑</text>
  21. </view>
  22. </view>
  23. </u-navbar>
  24. <view class="user-page-content">
  25. <!-- 个人资料 -->
  26. <view class="detail-card">
  27. <view class="detail-row">
  28. <view class="detail-icon-box">
  29. <u-icon name="photo-fill" size="14" color="#ffffff"></u-icon>
  30. </view>
  31. <text class="detail-label">头像</text>
  32. <view class="detail-value-area">
  33. <image
  34. class="detail-avatar"
  35. :src="personalMsg.avatar"
  36. mode="aspectFill"
  37. ></image>
  38. </view>
  39. </view>
  40. <view class="detail-divider"></view>
  41. <view class="detail-row">
  42. <view class="detail-icon-box">
  43. <u-icon name="account-fill" size="14" color="#ffffff"></u-icon>
  44. </view>
  45. <text class="detail-label">姓名</text>
  46. <text class="detail-value">{{ personalMsg.realname }}</text>
  47. </view>
  48. <view class="detail-divider"></view>
  49. <view class="detail-row">
  50. <view class="detail-icon-box">
  51. <u-icon
  52. :name="personalMsg.sex === '女' ? 'woman' : 'man'"
  53. size="14"
  54. color="#ffffff"
  55. ></u-icon>
  56. </view>
  57. <text class="detail-label">性别</text>
  58. <text class="detail-value">{{ personalMsg.sex }}</text>
  59. </view>
  60. <view class="detail-divider"></view>
  61. <view class="detail-row">
  62. <view class="detail-icon-box">
  63. <u-icon name="calendar-fill" size="14" color="#ffffff"></u-icon>
  64. </view>
  65. <text class="detail-label">生日</text>
  66. <text class="detail-value">{{ personalMsg.birthday }}</text>
  67. </view>
  68. </view>
  69. <!-- 对外信息展示 -->
  70. <view class="detail-card">
  71. <view class="detail-row">
  72. <view class="detail-icon-box">
  73. <u-icon name="eye-fill" size="14" color="#ffffff"></u-icon>
  74. </view>
  75. <text class="detail-label">对外信息展示</text>
  76. <text class="detail-value">
  77. {{
  78. getSubStringText(
  79. personalMsg.realname + "@" + personalMsg.orgCode,
  80. 11
  81. )
  82. }}
  83. </text>
  84. </view>
  85. </view>
  86. <!-- 联系方式 -->
  87. <view class="detail-card">
  88. <view class="detail-row">
  89. <view class="detail-icon-box">
  90. <u-icon name="phone-fill" size="14" color="#ffffff"></u-icon>
  91. </view>
  92. <text class="detail-label">手机</text>
  93. <text class="detail-value">{{ personalMsg.phone }}</text>
  94. </view>
  95. <view class="detail-divider"></view>
  96. <view class="detail-row">
  97. <view class="detail-icon-box">
  98. <u-icon name="email-fill" size="14" color="#ffffff"></u-icon>
  99. </view>
  100. <text class="detail-label">邮箱</text>
  101. <text class="detail-value">{{ personalMsg.email }}</text>
  102. </view>
  103. </view>
  104. </view>
  105. </view>
  106. </template>
  107. <script>
  108. import api from "@/api/api.js";
  109. export default {
  110. data() {
  111. return {
  112. personalMsg: {
  113. avatar: "",
  114. realname: "",
  115. username: "",
  116. sex: 1,
  117. birthday: new Date(),
  118. orgCode: "",
  119. workNo: "",
  120. status: 1,
  121. phone: "",
  122. telephone: "",
  123. email: "",
  124. post: "",
  125. departIds: "",
  126. identity: "",
  127. },
  128. userUrl: "/sys/user/queryById",
  129. positionUrl: "/sys/position/list",
  130. departUrl: "/sys/user/userDepartList",
  131. };
  132. },
  133. onLoad() {
  134. this.loadinfo();
  135. },
  136. methods: {
  137. getSubStringText(text, len) {
  138. if (!text || text.length == 0) {
  139. return "";
  140. }
  141. if (text.length < len) {
  142. return text;
  143. }
  144. return text.substr(0, len) + "...";
  145. },
  146. //左上角返回键:返回上一页
  147. goBack() {
  148. uni.navigateBack({
  149. delta: 1,
  150. });
  151. },
  152. rightClick() {
  153. this.$Router.push({ name: "useredit", params: this.personalMsg });
  154. /* uni.navigateTo({
  155. url: '/pages/user/useredit?item='+item
  156. }); */
  157. },
  158. loadinfo() {
  159. this.$http
  160. .get(this.userUrl, { params: { id: this.$store.getters.userid } })
  161. .then((res) => {
  162. console.log("用户", res);
  163. if (res.data.success) {
  164. let result = res.data.result;
  165. if (result.avatar && result.avatar.length > 0)
  166. this.personalMsg.avatar = api.getFileAccessHttpUrl(result.avatar);
  167. this.personalMsg.realname = result.realname;
  168. this.personalMsg.username = result.username;
  169. this.personalMsg.post = result.post;
  170. this.personalMsg.sex = result.sex === 1 ? "男" : "女";
  171. this.personalMsg.birthday =
  172. result.birthday == null ? "无" : result.birthday;
  173. this.personalMsg.departIds = result.departIds;
  174. this.personalMsg.workNo = result.workNo;
  175. this.personalMsg.phone = result.phone;
  176. this.personalMsg.telephone =
  177. result.telephone == null ? "无" : result.telephone;
  178. this.personalMsg.email = result.email;
  179. this.personalMsg.post = result.post;
  180. this.personalMsg.identity =
  181. result.identity === 1 ? "普通成员" : "上级";
  182. this.personalMsg.status = result.status === 1 ? "正常" : "冻结";
  183. this.personalMsg.orgCode = result.orgCode;
  184. }
  185. })
  186. .catch((e) => {
  187. console.log("请求错误", e);
  188. });
  189. this.$http
  190. .get(this.departUrl, { params: { userId: this.$store.getters.userid } })
  191. .then((res) => {
  192. if (res.success) {
  193. for (let item of res.result) {
  194. this.personalMsg.orgCode = item.title;
  195. this.personalMsg.departIds = item.title;
  196. }
  197. }
  198. })
  199. .catch((e) => {
  200. console.log("请求错误", e);
  201. });
  202. this.$http
  203. .get(this.positionUrl)
  204. .then((res) => {
  205. if (res.success) {
  206. let postArr = res.result.records;
  207. for (let item of postArr) {
  208. if (this.personalMsg.post == item.code) {
  209. this.personalMsg.post = item.name;
  210. }
  211. }
  212. }
  213. })
  214. .catch((e) => {
  215. console.log("请求错误", e);
  216. });
  217. },
  218. },
  219. };
  220. </script>
  221. <style lang="scss" scoped>
  222. .user-page {
  223. min-height: 100vh;
  224. background: linear-gradient(180deg, #c8d8f8 0%, #eef4fd 320rpx, #f4f7fd 100%);
  225. }
  226. .user-page-content {
  227. padding-left: 24rpx;
  228. padding-right: 24rpx;
  229. padding-bottom: 40rpx;
  230. box-sizing: border-box;
  231. }
  232. .nav-edit-btn {
  233. display: flex;
  234. flex-direction: row;
  235. align-items: center;
  236. padding: 0 14rpx;
  237. height: 44rpx;
  238. border: 1rpx solid #0065f8;
  239. border-radius: 8rpx;
  240. background: #ffffff;
  241. box-sizing: border-box;
  242. }
  243. .nav-edit-text {
  244. margin-left: 6rpx;
  245. font-size: 24rpx;
  246. color: #0065f8;
  247. line-height: 1;
  248. }
  249. .detail-card {
  250. background: #ffffff;
  251. border: 1rpx solid #e8effc;
  252. border-radius: 16rpx;
  253. padding: 0 24rpx;
  254. margin-bottom: 20rpx;
  255. box-shadow: 0 4rpx 16rpx rgba(43, 124, 255, 0.08);
  256. }
  257. .detail-row {
  258. display: flex;
  259. flex-direction: row;
  260. align-items: center;
  261. min-height: 112rpx;
  262. padding: 20rpx 0;
  263. }
  264. .detail-divider {
  265. height: 1rpx;
  266. background: #eef0f4;
  267. }
  268. .detail-icon-box {
  269. display: flex;
  270. align-items: center;
  271. justify-content: center;
  272. width: 56rpx;
  273. height: 56rpx;
  274. border-radius: 12rpx;
  275. background: linear-gradient(135deg, #80b4ff, #347df3);
  276. box-sizing: border-box;
  277. flex-shrink: 0;
  278. margin-right: 20rpx;
  279. }
  280. .detail-label {
  281. flex-shrink: 0;
  282. width: 170rpx;
  283. font-size: 24rpx;
  284. color: #000;
  285. line-height: 1.4;
  286. }
  287. .detail-value-area {
  288. flex: 1;
  289. min-width: 0;
  290. display: flex;
  291. flex-direction: row;
  292. align-items: center;
  293. justify-content: flex-end;
  294. }
  295. .detail-value {
  296. flex: 1;
  297. min-width: 0;
  298. font-size: 24rpx;
  299. font-weight: 500;
  300. color: #0065f8;
  301. line-height: 1.4;
  302. text-align: right;
  303. word-break: break-all;
  304. }
  305. .detail-avatar {
  306. width: 88rpx;
  307. height: 88rpx;
  308. border-radius: 50%;
  309. border: 1rpx solid #e8effc;
  310. }
  311. </style>