personal.vue 5.3 KB

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