personal.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <template>
  2. <!-- 个人资料 -->
  3. <view>
  4. <u-navbar title="个人资料" autoBack placeholder></u-navbar>
  5. <view class="card_form">
  6. <x-form ref="personage" :userType="userType" :list="list" :model="model" :rules="rules" @confirm="confirm"
  7. @clientele="clientele"></x-form>
  8. </view>
  9. </view>
  10. </template>
  11. <script>
  12. export default {
  13. data() {
  14. return {
  15. list: [{
  16. field: 'name',
  17. label: '姓名',
  18. placeholder: '请输入姓名',
  19. type: 'input',
  20. required: true,
  21. }, {
  22. field: 'principalPhone',
  23. label: '手机号码',
  24. placeholder: '请输入手机号码',
  25. type: 'input',
  26. required: true,
  27. }, {
  28. field: 'type',
  29. label: '类型',
  30. placeholder: '请选择类型',
  31. type: 'radio',
  32. required: true,
  33. options: [{
  34. label: '商户',
  35. value: 0,
  36. },
  37. {
  38. label: '私人',
  39. value: 1,
  40. }
  41. ],
  42. }, {
  43. field: 'region',
  44. label: '所在城市/地区',
  45. placeholder: '请选择所在城市/地区',
  46. type: 'cascader',
  47. required: true,
  48. }, {
  49. field: 'address',
  50. label: '地址',
  51. placeholder: '请输入详细地址',
  52. type: 'input',
  53. required: true,
  54. }, {
  55. field: 'addressImg',
  56. label: '现场图片',
  57. placeholder: '请上传现场图片',
  58. type: 'upload',
  59. required: true,
  60. }, {
  61. field: 'remark',
  62. label: '备注',
  63. placeholder: '请输入备注',
  64. type: 'textarea',
  65. }],
  66. model: {
  67. name: '',
  68. principalPhone: '',
  69. type: '',
  70. region: '',
  71. address: '',
  72. addressImg: '',
  73. remark: '',
  74. },
  75. rules: {
  76. 'name': {
  77. type: 'string',
  78. required: true,
  79. message: '请输入姓名',
  80. trigger: ['blur', 'change']
  81. },
  82. 'principalPhone': {
  83. type: 'string',
  84. required: true,
  85. message: '请输入手机号码',
  86. trigger: ['blur', 'change']
  87. },
  88. 'type': {
  89. type: 'number',
  90. required: true,
  91. message: '请选择客户类型',
  92. trigger: ['blur', 'change']
  93. },
  94. 'region': {
  95. type: 'string',
  96. required: true,
  97. message: '请选择所在城市/地区',
  98. trigger: ['blur', 'change']
  99. },
  100. 'address': {
  101. type: 'string',
  102. required: true,
  103. message: '请输入详细地址',
  104. trigger: ['blur', 'change']
  105. },
  106. 'addressImg': {
  107. required: true,
  108. message: '请上传现场图片',
  109. trigger: ['blur', 'change']
  110. },
  111. },
  112. userInfo: {},
  113. userType: 5,
  114. }
  115. },
  116. mounted() {
  117. this.getUser()
  118. },
  119. methods: {
  120. getUser() {
  121. this.$api.get('/api/user/profile').then(res => {
  122. if (res.code == 200) {
  123. const param = res.data.user
  124. this.userInfo = param
  125. this.$nextTick(() => {
  126. this.userType = param.provUser.userType
  127. this.model.name = param.provUser.name
  128. this.model.idCard = param.provUser.idCard
  129. this.model.phone = param.provUser.phone
  130. this.model.description = param.provUser.description
  131. let arrImg = []
  132. let arrImg1 = []
  133. if (param.provStoreUserBindCertificate.imgUrl && this.userType == 3) {
  134. arrImg = param.provStoreUserBindCertificate.imgUrl.split(',')
  135. } else if (param.provTruckUserBindCertificate.imgUrl && this.userType == 4) {
  136. arrImg = param.provTruckUserBindCertificate.imgUrl.split(',')
  137. }
  138. arrImg.forEach(item => {
  139. let arr = {
  140. thumb: this.$baseUrl + item,
  141. url: item,
  142. }
  143. arrImg1.push(arr)
  144. })
  145. this.$refs.personage.fileList1 = arrImg1
  146. })
  147. // console.log(this.model, 26)
  148. }
  149. })
  150. },
  151. // 修改个人信息
  152. clientele() {
  153. let param = {
  154. id: this.userInfo.id,
  155. roleId: this.userInfo.roleId,
  156. provUser: {
  157. name: this.model.name,
  158. cmpCode: this.model.cmpCode,
  159. phone: this.model.phone,
  160. description: this.model.description,
  161. },
  162. provStoreUserBindCertificate: {
  163. certificateNo: this.model.certificateNo,
  164. issueAuthority: this.model.issueAuthority,
  165. imgUrl: this.model.imgUrl,
  166. remarks: this.model.remarks,
  167. },
  168. provTruckUserBindCertificate: {
  169. certificateNo: this.model.certificateNo,
  170. issueAuthority: this.model.issueAuthority,
  171. imgUrl: this.model.imgUrls,
  172. remarks: this.model.remarks,
  173. }
  174. }
  175. if (this.userType == 3) {
  176. delete param.provTruckUserBindCertificate
  177. } else if (this.userType == 4) {
  178. delete param.provStoreUserBindCertificate
  179. }
  180. this.$api.put('/api/sys-user', param).then(res => {
  181. if (res.code == 200) {
  182. this.getUser()
  183. uni.$u.toast(res.msg)
  184. }
  185. })
  186. }
  187. }
  188. }
  189. </script>
  190. <style lang="scss">
  191. .card_form {
  192. margin: 10rpx 40rpx;
  193. }
  194. </style>