profile.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  1. <template>
  2. <view class="container">
  3. <!-- <u-navbar :is-fixed="false" :border-bottom="false" :is-back="true" back-icon-name="arrow-leftward" title="个人资料"
  4. back-icon-size="35" :background="{ background: '#fff' }" title-color="#000">
  5. <view class="complie" slot="right" @click="submit">完成</view>
  6. </u-navbar> -->
  7. <uNavBar dark :fixed="true" backgroundColor="#3F9EFF" statusBar="false" left-icon="left" left-text="返回"
  8. :title="title" rightText="完成" @clickLeft="toBack" @clickRight="submit">
  9. </uNavBar>
  10. <view class="content">
  11. <view class="avatar">
  12. <image :src="userInfo.avatar" class="avatar-image" mode=""></image>
  13. <view class="a" @click="handleChooseImg">更换头像</view>
  14. </view>
  15. <view class="form">
  16. <view class="cell">
  17. <view class="name">姓名</view>
  18. <input type="text" placeholder="请输入姓名" v-model="userInfo.nick_name" class="ipt"
  19. placeholder-class="hold" />
  20. </view>
  21. <view class="cell">
  22. <view class="name">角色</view>
  23. <input type="text" placeholder="" disabled="true" v-model="deptName" class="ipt"
  24. placeholder-class="hold" style="color: #82848A;" />
  25. </view>
  26. <view class="cell">
  27. <view class="name">单位</view>
  28. <input type="text" placeholder="" disabled="true" v-model="roleName" class="ipt"
  29. placeholder-class="hold" style="color: #82848A;" />
  30. </view>
  31. <!-- <view class="cell">
  32. <view class="name">生日</view>
  33. <picker mode="date" class="ipt" :class="{ hold: !detail.birthday }"
  34. @change="changeDefaultPicker('birthday', $event)">
  35. <view>{{ detail.birthday || '请选择生日' }}</view>
  36. </picker>
  37. </view> -->
  38. <!-- <view class="cell">
  39. <view class="name">性别</view>
  40. <picker mode="selector" :range="sexPicker" range-key="name" class="ipt"
  41. :class="{ hold: !detail.sex }" @change="changePicker('sex', $event)">
  42. <view>{{ detail.sex === 1?'男':'女' || '请选择性别' }}</view>
  43. </picker>
  44. </view> -->
  45. <view class="cell">
  46. <view class="name">手机号</view>
  47. <input type="number" placeholder="请填写手机号" v-model="detail.phone" class="ipt"
  48. placeholder-class="hold" />
  49. </view>
  50. <view class="cell">
  51. <view class="name">邮箱</view>
  52. <input v-model="detail.email" class="ipt" placeholder-class="hold" />
  53. </view>
  54. <!--<view class="cell">
  55. <view class="name">国家/地区</view>
  56. <pickRegions :defaultRegion="detail.region" v-model="detail.region"
  57. :class="{ hold: !detail.region, ipt: true }">
  58. <view>{{ detail.region || '请选择国家/地区' }}</view>
  59. </pickRegions>
  60. </view>-->
  61. </view>
  62. </view>
  63. <!-- -->
  64. <!-- <view class="back" @click="logout">退出登录</view> -->
  65. </view>
  66. </template>
  67. <script>
  68. import http from '@/http/api.js'
  69. import pickRegions from '@/components/pick-regions/pick-regions.vue';
  70. import uNavBar from '@/uni_modules/uni-nav-bar/components/uni-nav-bar/uni-nav-bar.vue'
  71. export default {
  72. components: {
  73. pickRegions,
  74. uNavBar
  75. },
  76. data() {
  77. return {
  78. sexPicker: [{
  79. name: '男'
  80. },
  81. {
  82. name: '女'
  83. }
  84. ],
  85. detail: {},
  86. deptName: '',
  87. roleName: '',
  88. title: '个人资料'
  89. };
  90. },
  91. onLoad() {
  92. const that = this;
  93. this.$u.api.userInfo().then(data => {
  94. console.log(data);
  95. if (data.success) {
  96. this.detail = data.data;
  97. http.request({
  98. url: '/galaxy-system/dept/detail?id=' + this.userInfo.dept_id,
  99. method: 'GET'
  100. }).then(res => {
  101. console.log(JSON.stringify(res.data))
  102. that.deptName = res.data.deptName;
  103. }).catch(err => {
  104. console.log(err)
  105. })
  106. http.request({
  107. url: '/galaxy-system/role/select?roleId=' + this.userInfo.role_id,
  108. method: 'GET'
  109. }).then(res => {
  110. console.log(JSON.stringify(res.data))
  111. var name = "";
  112. res.data.forEach(info => {
  113. name += name.length > 0 ? ":" : "";
  114. name += info.roleName;
  115. })
  116. that.roleName = name;
  117. }).catch(err => {
  118. console.log(err)
  119. })
  120. }
  121. }).catch(err => {
  122. console.log(err)
  123. this.$u.func.showToast({
  124. title: err,
  125. })
  126. })
  127. },
  128. methods: {
  129. toBack() {
  130. uni.navigateBack({
  131. delta: 1
  132. })
  133. },
  134. logout() {
  135. this.$u.func.logout();
  136. },
  137. submit() {
  138. // let detail = this.detail
  139. // if (!detail.phone && !/^1\d{10}$/.test(detail.phone)) {
  140. // return uni.showToast({
  141. // title: '请输入正确的手机号',
  142. // duration: 2000,
  143. // icon: 'none'
  144. // });
  145. // }
  146. // console.log(JSON.stringify(detail));
  147. },
  148. changeDefaultPicker(name, e) {
  149. this.detail[name] = e.detail.value;
  150. },
  151. changePicker(name, e) {
  152. this.detail[name] = this[`${name}Picker`][e.detail.value].name;
  153. },
  154. handleChooseImg() {
  155. let that = this;
  156. uni.chooseImage({
  157. count: 1,
  158. success(e) {
  159. that.detail.avatar = e.tempFilePaths[0];
  160. }
  161. });
  162. }
  163. }
  164. };
  165. </script>
  166. <style lang="scss">
  167. .container {
  168. background-color: #f7f7f7;
  169. min-height: 100vh;
  170. padding: 0 0 200rpx;
  171. overflow: hidden;
  172. }
  173. .complie {
  174. vertical-align: middle;
  175. padding: 10rpx 20rpx;
  176. font-size: 32rpx;
  177. font-family: Source Han Sans CN;
  178. font-weight: 400;
  179. color: #14b9c8;
  180. }
  181. .content {
  182. background-color: #ffffff;
  183. overflow: hidden;
  184. }
  185. .avatar {
  186. margin-top: 30rpx;
  187. display: flex;
  188. justify-content: center;
  189. align-items: center;
  190. flex-direction: column;
  191. font-size: 30rpx;
  192. font-family: Source Han Sans CN;
  193. font-weight: 400;
  194. color: #14b9c8;
  195. .avatar-image {
  196. width: 162rpx;
  197. height: 162rpx;
  198. background: #ffffff;
  199. border-radius: 50%;
  200. background-color: #82848a;
  201. margin-bottom: 15rpx;
  202. }
  203. }
  204. .form {
  205. padding: 0 36rpx;
  206. .cell {
  207. display: flex;
  208. justify-content: space-between;
  209. align-items: center;
  210. padding: 40rpx 0;
  211. font-size: 30rpx;
  212. font-family: Source Han Sans CN;
  213. font-weight: bold;
  214. color: #666666;
  215. &:not(:last-of-type) {
  216. border-bottom: 2rpx solid #efefef;
  217. }
  218. .ipt {
  219. flex: 1;
  220. margin-left: 40rpx;
  221. text-align: right;
  222. font-size: 23rpx;
  223. font-family: Source Han Sans CN;
  224. font-weight: bold;
  225. color: #333333;
  226. }
  227. .hold {
  228. font-size: 27rpx;
  229. font-family: Source Han Sans CN;
  230. font-weight: bold;
  231. color: #c8c8ce;
  232. }
  233. }
  234. }
  235. .back {
  236. margin-top: 40rpx;
  237. text-align: center;
  238. height: 109rpx;
  239. background: #ffffff;
  240. font-size: 34rpx;
  241. font-family: Source Han Sans CN;
  242. font-weight: bold;
  243. color: #141414;
  244. line-height: 109rpx;
  245. }
  246. </style>