profile.vue 5.3 KB

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