userdetail.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <view>
  3. <scroll-view scroll-y class="page">
  4. <cu-custom bgColor="bg-luohu" :isBack="true">
  5. <block slot="backText">返回</block>
  6. <block slot="content">用户详情</block>
  7. </cu-custom>
  8. <view class="example-body " style="display: flex;justify-content: center; margin-top: 80rpx;">
  9. <u-avatar :src="photo" size="160" @click="getImage">
  10. </u-avatar>
  11. </view>
  12. <uni-card>
  13. <view class="cu-list menu">
  14. <u-form :model="user" ref="uForm" label-width="160">
  15. <u-form-item label="单位名称">
  16. <u-input v-model="user.qq" input-align="right" disabled />
  17. </u-form-item>
  18. <u-form-item label="客户姓名">
  19. <u-input v-model="user.name" input-align="right" />
  20. </u-form-item>
  21. <u-form-item label="手机号">
  22. <u-input v-model="user.mobile" input-align="right" />
  23. </u-form-item>
  24. <u-form-item label="邮箱">
  25. <u-input v-model="user.email" input-align="right" />
  26. </u-form-item>
  27. <u-form-item label="地址">
  28. <u-input v-model="user.address" input-align="right" />
  29. </u-form-item>
  30. </u-form>
  31. <u-button class="u-m-t-40 btn-back-color" type="error" @click="sumbit">提交</u-button>
  32. </view>
  33. </uni-card>
  34. </scroll-view>
  35. </view>
  36. </template>
  37. <script>
  38. import {
  39. ACCESS_TOKEN,
  40. USER_NAME,
  41. USER_INFO
  42. } from "@/common/util/constants"
  43. import api from '@/api/api.js'
  44. import http from '@/common/service/http.js'
  45. export default {
  46. data() {
  47. return {
  48. id: '',
  49. user: {
  50. companyname: '',
  51. number: '',
  52. username: '',
  53. },
  54. photo: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/b7c7f970-517d-11eb-97b7-0dc4655d6e68.jpg'
  55. };
  56. },
  57. onLoad() {
  58. let user = uni.getStorageSync(USER_INFO).employee;
  59. this.id = user.id
  60. this.loadinfo()
  61. },
  62. methods: {
  63. loadinfo() {
  64. let token = uni.getStorageSync(ACCESS_TOKEN)
  65. this.$http.get('ibps/platform/v3/employee/load', {
  66. params: {
  67. employeeId: this.id
  68. }
  69. }).then(res => {
  70. if (res.data.state == '200') {
  71. let result = res.data.data
  72. this.user = result
  73. if (result.photo != '') {
  74. this.photo = http.apiHosp + 'ibps/platform/v3' + this.user.photo +
  75. '&access_token=' +
  76. token + '&tenantId='
  77. }
  78. }
  79. }).catch(e => {})
  80. },
  81. //手机号码判断
  82. checkPhone(value) {
  83. const reg = /^((13[0-9])|(14[5,7])|(15[0-3,5-9])|(17[0,3,5-8])|(18[0-9])|166|198|199|(147))\d{8}$/
  84. if (!reg.test(value)) {
  85. return false
  86. }
  87. return true
  88. },
  89. sumbit() {
  90. uni.showLoading({
  91. mask: true,
  92. title: "加载中"
  93. })
  94. if (this.user.name == '') {
  95. uni.showToast({
  96. title: '请填写姓名',
  97. icon: 'none',
  98. duration: 2000
  99. })
  100. uni.hideLoading()
  101. return
  102. }
  103. if (!this.checkPhone(this.user.mobile)) {
  104. uni.showToast({
  105. title: '请填写正确的手机号码',
  106. icon: 'none',
  107. duration: 2000
  108. })
  109. uni.hideLoading()
  110. return
  111. }
  112. this.$http.post('ibps/platform/v3/employee/update', {
  113. partyEmployeePo: this.user,
  114. user: this.user,
  115. attrValueVoList: [],
  116. positionVoList: [],
  117. roleVoList: [],
  118. userGroupPoList: []
  119. }).then(res => {
  120. if (res.data.state == '200') {
  121. let datas = res.data
  122. uni.showToast({
  123. title: datas.message,
  124. icon: 'none',
  125. duration: 2000
  126. })
  127. let info = uni.getStorageSync(USER_INFO);
  128. info.user = this.user
  129. uni.setStorage({
  130. key: 'login_user_info',
  131. data: info
  132. })
  133. } else {
  134. let datas = res.data
  135. uni.showToast({
  136. title: datas.cause,
  137. icon: 'none',
  138. duration: 2000
  139. })
  140. }
  141. uni.hideLoading()
  142. }).catch(res => {
  143. let datas = res.data
  144. uni.showToast({
  145. title: datas.cause,
  146. icon: 'none',
  147. duration: 2000
  148. })
  149. uni.hideLoading()
  150. })
  151. },
  152. getImage() {
  153. let token = uni.getStorageSync(ACCESS_TOKEN)
  154. uni.chooseImage({
  155. success: (res) => {
  156. const tempFilePaths = res.tempFilePaths;
  157. // this.select(tempFilePaths[0])
  158. uni.uploadFile({
  159. // url: http.apiHosp + 'ibps/platform/v3/file/upload/mobile', //仅为示例,非真实的接口地址
  160. url: http.apiHosp + '/ibps/platform/v3/file/upload', //仅为示例,非真实的接口地址
  161. filePath: tempFilePaths[0],
  162. name: 'file',
  163. formData: {
  164. 'ext': '.jpg'
  165. },
  166. header: {
  167. 'X-Authorization-access_token': token,
  168. 'X-Authorization-systemid': ''
  169. },
  170. success: (res) => {
  171. let data = JSON.parse(res.data)
  172. if (data.state == 200) {
  173. let datas = data.data
  174. this.user.photo = '/file/getImage?attachmentId=' + datas.id
  175. let phto = '/file/getImage?attachmentId=' + datas.id +
  176. '&access_token=' + token + '&tenantId='
  177. this.photo = http.apiHosp + 'ibps/platform/v3' + phto
  178. }
  179. }
  180. });
  181. }
  182. });
  183. },
  184. }
  185. }
  186. </script>
  187. <style>
  188. .page {
  189. height: 100Vh;
  190. width: 100vw;
  191. }
  192. .page.show {
  193. overflow: hidden;
  194. }
  195. .switch-sex::after {
  196. content: "\e716";
  197. }
  198. .switch-sex::before {
  199. content: "\e7a9";
  200. }
  201. .switch-music::after {
  202. content: "\e66a";
  203. }
  204. .switch-music::before {
  205. content: "\e6db";
  206. }
  207. .example-body {
  208. padding: 10px;
  209. padding-top: 0;
  210. }
  211. .custom-image-box {
  212. /* #ifndef APP-NVUE */
  213. display: flex;
  214. /* #endif */
  215. flex-direction: row;
  216. justify-content: space-between;
  217. align-items: center;
  218. }
  219. .text {
  220. font-size: 14px;
  221. color: #333;
  222. }
  223. </style>
  224. <style lang="scss" scoped>
  225. /deep/ .uni-input-input {
  226. color: #8799a3;
  227. }
  228. /deep/ .u-form-item--left__content__label {
  229. color: #8799a3;
  230. }
  231. </style>